liquid_feedback_frontend
view app/main/admin/unit_edit.lua @ 548:8af806af86a0
Added issue related preloading to issue show and initiative view
| author | bsw | 
|---|---|
| date | Tue May 29 20:45:58 2012 +0200 (2012-05-29) | 
| parents | 63d6549cc00b | 
| children | bc6934411019 | 
 line source
     1 local id = param.get_id()
     3 local unit = Unit:by_id(id)
     5 if member then
     6   slot.put_into("title", encode.html(_("Unit: '#{name}'", { name = unit.name })))
     7 else
     8   slot.put_into("title", encode.html(_"Add new unit"))
     9 end
    11 local units_selector = Unit:new_selector()
    13 if member then
    14   units_selector
    15     :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id })
    16     :add_field("privilege.voting_right", "voting_right")
    17 end
    19 local units = units_selector:exec()
    21 ui.form{
    22   attr = { class = "vertical" },
    23   module = "admin",
    24   action = "member_update",
    25   id = member and member.id,
    26   record = member,
    27   readonly = not app.session.member.admin,
    28   routing = {
    29     default = {
    30       mode = "redirect",
    31       modules = "admin",
    32       view = "member_list"
    33     }
    34   },
    35   content = function()
    36     ui.field.text{     label = _"Identification", name = "identification" }
    37     ui.field.text{     label = _"Notification email", name = "notify_email" }
    38     ui.field.boolean{  label = _"Admin?",       name = "admin" }
    40     slot.put("<br />")
    42     for i, unit in ipairs(units) do
    43       ui.field.boolean{
    44         name = "unit_" .. unit.id,
    45         label = unit.name,
    46         value = unit.voting_right
    47       }
    48     end
    49     slot.put("<br /><br />")
    51     ui.field.boolean{  label = _"Send invite?",       name = "invite_member" }
    52     ui.submit{         text  = _"Save" }
    53   end
    54 }
