bsw@1621: local function field(name, label, value, tooltip)
bsw@1621: ui.field.text{
bsw@1621: container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
bsw@1621: attr = { id = "field_" .. name, class = "mdl-textfield__input" },
bsw@1621: label_attr = { class = "mdl-textfield__label", ["for"] = "field_" .. name },
bsw@1621: label = label,
bsw@1621: name = name,
bsw@1621: value = value or nil
bsw@1621: }
bsw@1621: if tooltip then
bsw@1621: ui.container{ attr = { class = "mdl-tooltip", ["for"] = "field_" .. name }, content = tooltip }
bsw@1621: end
bsw@1621: end
bsw@1621:
bsw@1621: local function field_boolean(id, name, checked, label)
bsw@1621: ui.container{ content = function()
bsw@1621: ui.tag{ tag = "label", attr = {
bsw@1621: class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
bsw@1621: ["for"] = id
bsw@1621: },
bsw@1621: content = function()
bsw@1621: ui.tag{
bsw@1621: tag = "input",
bsw@1621: attr = {
bsw@1621: id = id,
bsw@1621: class = "mdl-checkbox__input",
bsw@1621: type = "checkbox", name = name, value = "true",
bsw@1621: checked = checked and "checked" or nil,
bsw@1621: }
bsw@1621: }
bsw@1621: ui.tag{
bsw@1621: attr = { class = "mdl-checkbox__label", ['for'] = id },
bsw@1621: content = label
bsw@1621: }
bsw@1621: end
bsw@1621: }
bsw@1621: end }
bsw@1621: end
bsw@1621:
bsw/jbe@0: local id = param.get_id()
bsw/jbe@0:
bsw@193: local member = Member:by_id(id)
bsw@193:
bsw@1088: local deactivated = member and member.locked and member.login == nil and member.authority_login == nil
bsw@1088:
bsw@1184: ui.titleAdmin(_"Member")
bsw/jbe@0:
bsw@513: local units_selector = Unit:new_selector()
bsw@512:
bsw@513: if member then
bsw@513: units_selector
bsw@513: :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id })
bsw@513: :add_field("privilege.voting_right", "voting_right")
bsw@1438: :add_order_by("unit.name")
bsw@513: end
bsw@513:
bsw@513: local units = units_selector:exec()
bsw@512:
bsw@1455: ui.grid{ content = function()
bsw@310:
bsw@1455: ui.cell_main{ content = function()
bsw@1455: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw@1455: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw@1621: local text = _"Member"
bsw@1621: if member then
bsw@1621: text = text .. " ID " .. member.id
bsw@1621: end
bsw@1621: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = text }
bsw@1455: end }
bsw@1455: ui.container{ attr = { class = "mdl-card__content" }, content = function()
bsw@1455: ui.form{
bsw@1455: attr = { class = "vertical section" },
bsw@1455: module = "admin",
bsw@1455: action = "member_update",
bsw@1455: id = member and member.id,
bsw@1455: record = member,
bsw@1455: readonly = not app.session.member.admin,
bsw@1455: routing = {
bsw@1455: default = {
bsw@1455: mode = "redirect",
bsw@1455: modules = "admin",
bsw@1455: view = "index"
bsw@1455: }
bsw@1455: },
bsw@1455: content = function()
bsw@1455:
bsw@1621: ui.container{ content = function()
bsw@1621: field("identification", _"Identification")
bsw@1621: if member and member.activated then
bsw@1621: slot.put(" ")
bsw@1621: field("name", "Screen name")
bsw@1621: end
bsw@1621: end }
bsw@1621: ui.container{ content = function()
bsw@1621: field("notify_email", _"Notification email (confirmed)")
bsw@1621: slot.put(" ")
bsw@1621: field("notify_email_unconfirmed", _"Notification email (unconfirmed)")
bsw@1621: end }
bsw@1621: -- field("", "")
bsw@1458:
bsw@1456:
bsw@1456: if member and member.activated and not deactivated then
bsw@1621: field("login", "Login name")
bsw@1456: end
bsw@1088:
bsw@1456: for i, unit in ipairs(units) do
bsw@1621: field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name)
bsw@1621:
bsw@1458: end
bsw@1621: slot.put("
")
bsw@1045:
bsw@1455: if member then
bsw@1455: ui.field.text{ label = _"Activated", name = "activated", readonly = true }
bsw@1455: end
bsw@1455:
bsw@1455: if not member or not member.activated then
bsw@1455: ui.field.boolean{ label = _"Send invite?", name = "invite_member" }
bsw@1455: end
bsw@1455:
bsw@1455: if member then
bsw@1455: ui.field.boolean{
bsw@1455: label = _"Member inactive?", name = "deactivate",
bsw@1455: readonly = true,
bsw@1455: value = member and member.active == false
bsw@1455: }
bsw@1455: end
bsw@1455:
bsw@1455: if member then
bsw@1455: ui.field.boolean{
bsw@1455: label = _"Lock member?", name = "locked",
bsw@1455: }
bsw@1455: end
bsw@1455:
bsw@1455: slot.put("
")
bsw@1455: ui.field.boolean{ label = _"Admin?", name = "admin" }
bsw@1455: slot.put("
")
bsw@1461: ui.submit{
bsw@1461: attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
bsw@1461: text = _"update member"
bsw@1461: }
bsw@1621: slot.put(" ")
bsw@1455: if member then
bsw@1461: ui.link {
bsw@1621: attr = { class = "mdl-button mdl-js-button" },
bsw@1461: module = "admin", view = "member_deactivate", content = _"Deactivate member", id = member.id
bsw@1461: }
bsw@1621: slot.put(" ")
bsw@1455: end
bsw@1461: ui.link {
bsw@1461: attr = { class = "mdl-button mdl-js-button" },
bsw@1461: module = "admin", view = "index", content = _"cancel"
bsw@1461: }
bsw@1456:
bsw@1457: end
bsw@1457: }
bsw@1457: end }
bsw@1455: end }
bsw@1455: end }
bsw@1455: end }