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