annotate app/main/admin/unit_edit.lua @ 1202:30b3bf5db1bb
Fixed listening to non-local IPv4 interfaces
 | author | bsw | 
 | date | Sun Jul 12 20:46:57 2015 +0200 (2015-07-12) | 
 | parents | 8c65f5a029b0 | 
 | children | fede09736f2b | 
 
 | 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@1045 | 42       ui.field.boolean{  label = _"Active?",      name = "active" } | 
| bsw@525 | 43 | 
| bsw@1045 | 44       slot.put("<br />") | 
| bsw@1045 | 45       ui.submit{         text  = _"update unit" } | 
| bsw@1045 | 46       slot.put(" ") | 
| bsw@1045 | 47       ui.link{ module = "admin", view = "index", content = _"cancel" } | 
| bsw@1045 | 48     end ) | 
| bsw@525 | 49   end | 
| bsw@525 | 50 } |