annotate app/main/admin/unit_edit.lua @ 1248:c0fd12b97d65
Changes on notifications system, newsletter support added
 | author | 
 bsw | 
 | date | 
 Tue Apr 05 20:40:37 2016 +0200 (2016-04-05) | 
 | parents | 
 fede09736f2b  | 
 | children | 
 32cc544d5a5b  | 
 
 | 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@1184
 | 
     5 ui.titleAdmin(_"Organizational unit")
 | 
| 
bsw@525
 | 
     6 
 | 
| 
bsw@595
 | 
     7 local units = {
 | 
| 
bsw@595
 | 
     8   { id = nil, name = "" }
 | 
| 
bsw@595
 | 
     9 }
 | 
| 
bsw@595
 | 
    10 
 | 
| 
bsw@595
 | 
    11 for i, unit in ipairs(Unit:get_flattened_tree()) do
 | 
| 
bsw@595
 | 
    12   units[#units+1] = { id = unit.id, name = unit.name }
 | 
| 
bsw@525
 | 
    13 end
 | 
| 
bsw@525
 | 
    14 
 | 
| 
bsw@525
 | 
    15 ui.form{
 | 
| 
bsw@1045
 | 
    16   attr = { class = "vertical section" },
 | 
| 
bsw@525
 | 
    17   module = "admin",
 | 
| 
bsw@595
 | 
    18   action = "unit_update",
 | 
| 
bsw@595
 | 
    19   id = unit and unit.id,
 | 
| 
bsw@595
 | 
    20   record = unit,
 | 
| 
bsw@525
 | 
    21   routing = {
 | 
| 
bsw@525
 | 
    22     default = {
 | 
| 
bsw@525
 | 
    23       mode = "redirect",
 | 
| 
bsw@525
 | 
    24       modules = "admin",
 | 
| 
bsw@1045
 | 
    25       view = "index"
 | 
| 
bsw@525
 | 
    26     }
 | 
| 
bsw@525
 | 
    27   },
 | 
| 
bsw@525
 | 
    28   content = function()
 | 
| 
bsw@1045
 | 
    29     ui.sectionHead( function()
 | 
| 
bsw@1045
 | 
    30       ui.heading { level = 1, content = unit and unit.name or _"New organizational unit" }
 | 
| 
bsw@1045
 | 
    31     end )
 | 
| 
bsw@1045
 | 
    32     ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
    33       ui.field.select{
 | 
| 
bsw@1045
 | 
    34         label = _"Parent unit",
 | 
| 
bsw@1045
 | 
    35         name = "parent_id",
 | 
| 
bsw@1045
 | 
    36         foreign_records = units,
 | 
| 
bsw@1045
 | 
    37         foreign_id      = "id",
 | 
| 
bsw@1045
 | 
    38         foreign_name    = "name"
 | 
| 
bsw@1045
 | 
    39       }
 | 
| 
bsw@1045
 | 
    40       ui.field.text{     label = _"Name",         name = "name" }
 | 
| 
bsw@1045
 | 
    41       ui.field.text{     label = _"Description",  name = "description", multiline = true }
 | 
| 
bsw@1209
 | 
    42       ui.field.text{     label = _"External reference",  name = "external_reference" }
 | 
| 
bsw@1045
 | 
    43       ui.field.boolean{  label = _"Active?",      name = "active" }
 | 
| 
bsw@525
 | 
    44 
 | 
| 
bsw@1045
 | 
    45       slot.put("<br />")
 | 
| 
bsw@1045
 | 
    46       ui.submit{         text  = _"update unit" }
 | 
| 
bsw@1045
 | 
    47       slot.put(" ")
 | 
| 
bsw@1045
 | 
    48       ui.link{ module = "admin", view = "index", content = _"cancel" }
 | 
| 
bsw@1045
 | 
    49     end )
 | 
| 
bsw@525
 | 
    50   end
 | 
| 
bsw@525
 | 
    51 }
 |