bsw@525: local id = param.get_id() bsw@525: bsw@525: local unit = Unit:by_id(id) bsw@525: bsw@525: if member then bsw@525: slot.put_into("title", encode.html(_("Unit: '#{name}'", { name = unit.name }))) bsw@525: else bsw@525: slot.put_into("title", encode.html(_"Add new unit")) bsw@525: end bsw@525: bsw@525: local units_selector = Unit:new_selector() bsw@525: bsw@525: if member then bsw@525: units_selector bsw@525: :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id }) bsw@525: :add_field("privilege.voting_right", "voting_right") bsw@525: end bsw@525: bsw@525: local units = units_selector:exec() bsw@525: bsw@525: ui.form{ bsw@525: attr = { class = "vertical" }, bsw@525: module = "admin", bsw@525: action = "member_update", bsw@525: id = member and member.id, bsw@525: record = member, bsw@525: readonly = not app.session.member.admin, bsw@525: routing = { bsw@525: default = { bsw@525: mode = "redirect", bsw@525: modules = "admin", bsw@525: view = "member_list" bsw@525: } bsw@525: }, bsw@525: content = function() bsw@525: ui.field.text{ label = _"Identification", name = "identification" } bsw@525: ui.field.text{ label = _"Notification email", name = "notify_email" } bsw@525: ui.field.boolean{ label = _"Admin?", name = "admin" } bsw@525: bsw@525: slot.put("
") bsw@525: bsw@525: for i, unit in ipairs(units) do bsw@525: ui.field.boolean{ bsw@525: name = "unit_" .. unit.id, bsw@525: label = unit.name, bsw@525: value = unit.voting_right bsw@525: } bsw@525: end bsw@525: slot.put("

") bsw@525: bsw@525: ui.field.boolean{ label = _"Send invite?", name = "invite_member" } bsw@525: ui.submit{ text = _"Save" } bsw@525: end bsw@525: }