liquid_feedback_frontend
diff app/main/admin/unit_edit.lua @ 595:bc6934411019
Added unit editor, small fixes at admin section
author | bsw |
---|---|
date | Sun Jun 24 20:41:50 2012 +0200 (2012-06-24) |
parents | 63d6549cc00b |
children | b5684668ac4b |
line diff
1.1 --- a/app/main/admin/unit_edit.lua Sat Jun 23 20:56:52 2012 +0200 1.2 +++ b/app/main/admin/unit_edit.lua Sun Jun 24 20:41:50 2012 +0200 1.3 @@ -2,53 +2,46 @@ 1.4 1.5 local unit = Unit:by_id(id) 1.6 1.7 -if member then 1.8 +if unit then 1.9 slot.put_into("title", encode.html(_("Unit: '#{name}'", { name = unit.name }))) 1.10 else 1.11 slot.put_into("title", encode.html(_"Add new unit")) 1.12 end 1.13 1.14 -local units_selector = Unit:new_selector() 1.15 - 1.16 -if member then 1.17 - units_selector 1.18 - :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id }) 1.19 - :add_field("privilege.voting_right", "voting_right") 1.20 +local units = { 1.21 + { id = nil, name = "" } 1.22 +} 1.23 + 1.24 +for i, unit in ipairs(Unit:get_flattened_tree()) do 1.25 + units[#units+1] = { id = unit.id, name = unit.name } 1.26 end 1.27 1.28 -local units = units_selector:exec() 1.29 - 1.30 ui.form{ 1.31 attr = { class = "vertical" }, 1.32 module = "admin", 1.33 - action = "member_update", 1.34 - id = member and member.id, 1.35 - record = member, 1.36 - readonly = not app.session.member.admin, 1.37 + action = "unit_update", 1.38 + id = unit and unit.id, 1.39 + record = unit, 1.40 routing = { 1.41 default = { 1.42 mode = "redirect", 1.43 modules = "admin", 1.44 - view = "member_list" 1.45 + view = "unit_list" 1.46 } 1.47 }, 1.48 content = function() 1.49 - ui.field.text{ label = _"Identification", name = "identification" } 1.50 - ui.field.text{ label = _"Notification email", name = "notify_email" } 1.51 - ui.field.boolean{ label = _"Admin?", name = "admin" } 1.52 + ui.field.select{ 1.53 + label = _"Parent unit", 1.54 + name = "parent_id", 1.55 + foreign_records = units, 1.56 + foreign_id = "id", 1.57 + foreign_name = "name" 1.58 + } 1.59 + ui.field.text{ label = _"Name", name = "name" } 1.60 + ui.field.text{ label = _"Description", name = "description", multiline = true } 1.61 + ui.field.boolean{ label = _"Active?", name = "active" } 1.62 1.63 slot.put("<br />") 1.64 - 1.65 - for i, unit in ipairs(units) do 1.66 - ui.field.boolean{ 1.67 - name = "unit_" .. unit.id, 1.68 - label = unit.name, 1.69 - value = unit.voting_right 1.70 - } 1.71 - end 1.72 - slot.put("<br /><br />") 1.73 - 1.74 - ui.field.boolean{ label = _"Send invite?", name = "invite_member" } 1.75 ui.submit{ text = _"Save" } 1.76 end 1.77 }