bsw/jbe@1309: local unit_id = config.single_unit_id or tonumber(request.get_param{ name = "unit" }) bsw/jbe@1309: if unit_id == "all" then bsw/jbe@1309: unit_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: local area_id = config.single_area_id or tonumber(request.get_param{ name = "area" }) 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@1596: if area then bsw/jbe@1309: if app.session.member_id then bsw/jbe@1309: area:load_delegation_info_once_for_member_id(app.session.member_id) bsw/jbe@1309: end 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/jbe@1309: if not config.single_area_id then bsw@1596: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name .. " ยป " .. area.name } bsw/jbe@1309: else bsw/jbe@1309: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: if area.description and #(area.description) > 0 then bsw/jbe@1309: if not config.single_area_id then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = area.description } bsw/jbe@1309: else bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = unit.description } bsw/jbe@1309: end bsw/jbe@1309: end bsw/jbe@1309: if not (config.voting_only and config.disable_delegations) and app.session.member_id then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__actions" }, content = function() bsw/jbe@1309: bsw@1596: if not config.disable_delegations then bsw@1596: bsw/jbe@1309: if area.delegation_info.first_trustee_id then bsw@1596: local member = Member:by_id(area.delegation_info.first_trustee_id) bsw@1596: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" } bsw@1596: execute.view{ bsw@1596: module = "member", bsw@1596: view = "_show_thumb", bsw@1596: params = { bsw@1596: member = member bsw/jbe@1309: } bsw@1596: } bsw/jbe@1309: end bsw@1596: bsw@1596: local text bsw@1596: if area.delegation_info.own_delegation_scope == nil then bsw@1596: text = _"delegate..." bsw@1596: else bsw@1596: text = _"change delegation..." bsw@1596: end bsw@1596: bsw@1596: bsw@1596: ui.tag{ attr = { id = "change_delegation", class = "mdl-button" }, content = text } bsw/jbe@1309: bsw@1596: bsw@1596: ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = "change_delegation" }, content = function() bsw@1596: bsw@1596: ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() bsw/jbe@1309: ui.link { bsw@1596: attr = { class = "mdl-menu__link" }, bsw/jbe@1309: module = "delegation", view = "show", params = { bsw/jbe@1309: unit_id = area.unit_id, bsw/jbe@1309: }, bsw@1596: content = _("unit: #{name}", { name = area.unit.name }) bsw/jbe@1309: } bsw@1596: end } bsw@1596: bsw@1596: ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() bsw/jbe@1309: ui.link { bsw@1596: attr = { class = "mdl-menu__link" }, bsw/jbe@1309: module = "delegation", view = "show", params = { bsw/jbe@1309: area_id = area.id bsw/jbe@1309: }, bsw@1596: content = _("subject area: #{name}", { name = area.name }) bsw/jbe@1309: } bsw@1596: end } bsw@1596: end } bsw/jbe@1309: end bsw@1596: 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: elseif unit then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw/jbe@1309: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name } bsw/jbe@1309: end } bsw/jbe@1309: if unit.description and #(unit.description) > 0 then bsw/jbe@1309: ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = unit.description } bsw/jbe@1309: end bsw@1532: if config.render_external_reference_unit then bsw@1532: config.render_external_reference_unit(unit) bsw@1532: end bsw/jbe@1309: --ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function() bsw/jbe@1309: --end } bsw/jbe@1309: end } bsw@1489: else bsw@1489: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() bsw@1489: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw@1489: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"All issues" } bsw@1489: end } bsw@1489: ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = _"All issues in your units. Use filters above to limit results." } bsw@1489: end } bsw/jbe@1309: end bsw/jbe@1309: