annotate app/main/admin/unit_edit.lua @ 1175:d70610e37245
Force update of member images when editing them
 | author | bsw | 
 | date | Thu Mar 26 19:32:06 2015 +0100 (2015-03-26) | 
 | parents | 701a5cf6b067 | 
 | children | 8c65f5a029b0 | 
 
 | 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@1045 | 6   ui.titleAdmin(_"Organizational unit") | 
| bsw@525 | 7 end | 
| bsw@525 | 8 | 
| bsw@595 | 9 local units = { | 
| bsw@595 | 10   { id = nil, name = "" } | 
| bsw@595 | 11 } | 
| bsw@595 | 12 | 
| bsw@595 | 13 for i, unit in ipairs(Unit:get_flattened_tree()) do | 
| bsw@595 | 14   units[#units+1] = { id = unit.id, name = unit.name } | 
| bsw@525 | 15 end | 
| bsw@525 | 16 | 
| bsw@525 | 17 ui.form{ | 
| bsw@1045 | 18   attr = { class = "vertical section" }, | 
| bsw@525 | 19   module = "admin", | 
| bsw@595 | 20   action = "unit_update", | 
| bsw@595 | 21   id = unit and unit.id, | 
| bsw@595 | 22   record = unit, | 
| bsw@525 | 23   routing = { | 
| bsw@525 | 24     default = { | 
| bsw@525 | 25       mode = "redirect", | 
| bsw@525 | 26       modules = "admin", | 
| bsw@1045 | 27       view = "index" | 
| bsw@525 | 28     } | 
| bsw@525 | 29   }, | 
| bsw@525 | 30   content = function() | 
| bsw@1045 | 31     ui.sectionHead( function() | 
| bsw@1045 | 32       ui.heading { level = 1, content = unit and unit.name or _"New organizational unit" } | 
| bsw@1045 | 33     end ) | 
| bsw@1045 | 34     ui.sectionRow( function() | 
| bsw@1045 | 35       ui.field.select{ | 
| bsw@1045 | 36         label = _"Parent unit", | 
| bsw@1045 | 37         name = "parent_id", | 
| bsw@1045 | 38         foreign_records = units, | 
| bsw@1045 | 39         foreign_id      = "id", | 
| bsw@1045 | 40         foreign_name    = "name" | 
| bsw@1045 | 41       } | 
| bsw@1045 | 42       ui.field.text{     label = _"Name",         name = "name" } | 
| bsw@1045 | 43       ui.field.text{     label = _"Description",  name = "description", multiline = true } | 
| bsw@1045 | 44       ui.field.boolean{  label = _"Active?",      name = "active" } | 
| bsw@525 | 45 | 
| bsw@1045 | 46       slot.put("<br />") | 
| bsw@1045 | 47       ui.submit{         text  = _"update unit" } | 
| bsw@1045 | 48       slot.put(" ") | 
| bsw@1045 | 49       ui.link{ module = "admin", view = "index", content = _"cancel" } | 
| bsw@1045 | 50     end ) | 
| bsw@525 | 51   end | 
| bsw@525 | 52 } |