liquid_feedback_frontend
view app/main/admin/unit_edit.lua @ 830:9c714f697e4e
Do not show inactive units on member home page
| author | bsw | 
|---|---|
| date | Tue Jul 10 23:38:16 2012 +0200 (2012-07-10) | 
| parents | b5684668ac4b | 
| children | 701a5cf6b067 | 
 line source
     1 local id = param.get_id()
     3 local unit = Unit:by_id(id)
     5 if unit then
     6   ui.title(_("Unit: '#{name}'", { name = unit.name }))
     7 else
     8   ui.title(_"Add new unit")
     9 end
    11 local units = {
    12   { id = nil, name = "" }
    13 }
    15 for i, unit in ipairs(Unit:get_flattened_tree()) do
    16   units[#units+1] = { id = unit.id, name = unit.name }
    17 end
    19 ui.form{
    20   attr = { class = "vertical" },
    21   module = "admin",
    22   action = "unit_update",
    23   id = unit and unit.id,
    24   record = unit,
    25   routing = {
    26     default = {
    27       mode = "redirect",
    28       modules = "admin",
    29       view = "unit_list"
    30     }
    31   },
    32   content = function()
    33     ui.field.select{
    34       label = _"Parent unit",
    35       name = "parent_id",
    36       foreign_records = units,
    37       foreign_id      = "id",
    38       foreign_name    = "name"
    39     }
    40     ui.field.text{     label = _"Name",         name = "name" }
    41     ui.field.text{     label = _"Description",  name = "description", multiline = true }
    42     ui.field.boolean{  label = _"Active?",      name = "active" }
    44     slot.put("<br />")
    45     ui.submit{         text  = _"Save" }
    46   end
    47 }
