liquid_feedback_frontend
diff app/main/admin/unit_edit.lua @ 525:63d6549cc00b
Delegation chain preview improved, better visualisation of current context, code cleanup
author | bsw |
---|---|
date | Fri May 18 19:07:07 2012 +0200 (2012-05-18) |
parents | |
children | bc6934411019 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/admin/unit_edit.lua Fri May 18 19:07:07 2012 +0200 1.3 @@ -0,0 +1,54 @@ 1.4 +local id = param.get_id() 1.5 + 1.6 +local unit = Unit:by_id(id) 1.7 + 1.8 +if member 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 +end 1.21 + 1.22 +local units = units_selector:exec() 1.23 + 1.24 +ui.form{ 1.25 + attr = { class = "vertical" }, 1.26 + module = "admin", 1.27 + action = "member_update", 1.28 + id = member and member.id, 1.29 + record = member, 1.30 + readonly = not app.session.member.admin, 1.31 + routing = { 1.32 + default = { 1.33 + mode = "redirect", 1.34 + modules = "admin", 1.35 + view = "member_list" 1.36 + } 1.37 + }, 1.38 + content = function() 1.39 + ui.field.text{ label = _"Identification", name = "identification" } 1.40 + ui.field.text{ label = _"Notification email", name = "notify_email" } 1.41 + ui.field.boolean{ label = _"Admin?", name = "admin" } 1.42 + 1.43 + slot.put("<br />") 1.44 + 1.45 + for i, unit in ipairs(units) do 1.46 + ui.field.boolean{ 1.47 + name = "unit_" .. unit.id, 1.48 + label = unit.name, 1.49 + value = unit.voting_right 1.50 + } 1.51 + end 1.52 + slot.put("<br /><br />") 1.53 + 1.54 + ui.field.boolean{ label = _"Send invite?", name = "invite_member" } 1.55 + ui.submit{ text = _"Save" } 1.56 + end 1.57 +}