bsw@1598: local unit_id = config.single_unit_id or request.get_param{ name = "unit" } bsw@1598: local area_id = config.single_area_id or request.get_param{ name = "area" } bsw@1602: bsw@1602: local initiative = param.get("initiative", "table") bsw@1602: local issue = param.get("issue", "table") bsw@1602: if issue then bsw@1602: area_id = issue.area_id bsw@1602: unit_id = issue.area.unit_id bsw@1602: end bsw@1602: bsw/jbe@1309: if unit_id == "all" then bsw/jbe@1309: unit_id = nil bsw@1598: area_id = nil bsw/jbe@1309: end bsw/jbe@1309: local unit bsw/jbe@1309: if unit_id then bsw/jbe@1309: unit = Unit:by_id(unit_id) bsw/jbe@1309: end bsw/jbe@1309: if area_id == "all" then bsw/jbe@1309: area_id = nil bsw/jbe@1309: end bsw/jbe@1309: local area bsw/jbe@1309: if area_id then bsw/jbe@1309: area = Area:by_id(area_id) bsw/jbe@1309: end bsw@1598: bsw@1598: if unit then bsw@1598: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw@1598: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw@1598: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name } bsw@1598: if unit.description and #(unit.description) > 0 then bsw@1598: ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description } bsw@1598: end bsw@1598: if config.render_external_reference_unit then bsw@1598: config.render_external_reference_unit(unit) bsw@1598: end bsw@1598: end } bsw@1598: bsw@1598: bsw@1623: if not (config.voting_only and config.disable_delegations) and app.session.member_id and ( bsw@1623: app.session.member:has_voting_right_for_unit_id(unit.id) bsw@1623: or app.session.member:has_initiative_right_for_unit_id(unit.id) bsw@1623: ) then bsw@1598: ui.container{ attr = { class = "mdl-card__actions" }, content = function() bsw@1598: bsw@1598: unit:load_delegation_info_once_for_member_id(app.session.member_id) bsw@1598: bsw@1598: local text bsw@1598: if unit.delegation_info.own_delegation_scope == "unit" then bsw@1598: local member = Member:by_id(unit.delegation_info.first_trustee_id) bsw@1598: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" } bsw@1598: execute.view{ bsw@1598: module = "member", bsw@1598: view = "_show_thumb", bsw@1598: params = { bsw@1598: member = member bsw@1598: } bsw@1598: } bsw@1598: text = _"change delegation..." bsw@1598: else bsw@1598: text = _"delegate..." bsw@1598: end bsw@1598: bsw@1598: ui.link { bsw@1598: attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, bsw@1598: module = "delegation", view = "show", params = { bsw@1598: unit_id = unit.id, bsw@1598: }, bsw@1598: content = text bsw@1598: } bsw@1598: bsw@1598: end } bsw@1598: end bsw@1598: end } bsw@1598: end bsw@1598: bsw@1596: if area then bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw/jbe@1309: if unit then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw@1598: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name } bsw@1598: if area.description and #(area.description) > 0 then bsw@1598: ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: end bsw@1623: if not (config.voting_only and config.disable_delegations) and app.session.member_id and ( bsw@1623: app.session.member:has_voting_right_for_unit_id(area.unit_id) bsw@1623: or app.session.member:has_initiative_right_for_unit_id(area.unit_id) bsw@1623: ) then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__actions" }, content = function() bsw/jbe@1309: bsw@1598: area:load_delegation_info_once_for_member_id(app.session.member_id) bsw@1596: bsw@1598: local text bsw@1598: if area.delegation_info.own_delegation_scope == "area" then bsw@1598: local member = Member:by_id(area.delegation_info.first_trustee_id) bsw@1623: if member then bsw@1623: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" } bsw@1623: execute.view{ bsw@1623: module = "member", bsw@1623: view = "_show_thumb", bsw@1623: params = { bsw@1623: member = member bsw@1623: } bsw@1598: } bsw@1623: else bsw@1623: ui.tag{ content = _"Delegation abandoned" } bsw@1623: end bsw@1598: text = _"change delegation..." bsw@1598: else bsw@1598: text = _"delegate..." bsw/jbe@1309: end bsw@1598: bsw@1598: ui.link { bsw@1598: attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, bsw@1598: module = "delegation", view = "show", params = { bsw@1598: area_id = area.id, bsw@1598: }, bsw@1598: content = text bsw@1598: } bsw@1598: bsw/jbe@1309: if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then bsw/jbe@1309: ui.link { bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, bsw@1496: module = "draft", view = "new", bsw/jbe@1309: params = { area_id = area.id }, bsw/jbe@1309: content = function() bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" } bsw/jbe@1309: ui.tag{ content = _"new issue" } bsw/jbe@1309: end bsw/jbe@1309: } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: end bsw@1598: bsw@1598: