# HG changeset patch # User bsw # Date 1612127070 -3600 # Node ID 6b203b43bef3ea1df98c648138a3236a606165f3 # Parent 631f6311a9eb1c352a6155080aafaf602544186d Reworked unit and area head and delegation buttons diff -r 631f6311a9eb -r 6b203b43bef3 app/main/index/_head.lua --- a/app/main/index/_head.lua Sun Jan 31 20:37:22 2021 +0100 +++ b/app/main/index/_head.lua Sun Jan 31 22:04:30 2021 +0100 @@ -1,12 +1,13 @@ -local unit_id = config.single_unit_id or tonumber(request.get_param{ name = "unit" }) +local unit_id = config.single_unit_id or request.get_param{ name = "unit" } +local area_id = config.single_area_id or request.get_param{ name = "area" } if unit_id == "all" then unit_id = nil + area_id = nil end local unit if unit_id then unit = Unit:by_id(unit_id) end -local area_id = config.single_area_id or tonumber(request.get_param{ name = "area" }) if area_id == "all" then area_id = nil end @@ -14,80 +15,96 @@ if area_id then area = Area:by_id(area_id) end + +print(unit_id, area_id, unit, area) + +if unit then + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name } + if unit.description and #(unit.description) > 0 then + ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description } + end + if config.render_external_reference_unit then + config.render_external_reference_unit(unit) + end + end } + + + if not (config.voting_only and config.disable_delegations) and app.session.member_id then + ui.container{ attr = { class = "mdl-card__actions" }, content = function() + + unit:load_delegation_info_once_for_member_id(app.session.member_id) + + local text + if unit.delegation_info.own_delegation_scope == "unit" then + local member = Member:by_id(unit.delegation_info.first_trustee_id) + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" } + execute.view{ + module = "member", + view = "_show_thumb", + params = { + member = member + } + } + text = _"change delegation..." + else + text = _"delegate..." + end + + ui.link { + attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, + module = "delegation", view = "show", params = { + unit_id = unit.id, + }, + content = text + } + + end } + end + end } +end + if area then - if app.session.member_id then - area:load_delegation_info_once_for_member_id(app.session.member_id) - end ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() if unit then ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() - if not config.single_area_id then - ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name .. " ยป " .. area.name } - else - ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name } + ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name } + if area.description and #(area.description) > 0 then + ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description } end end } end - if area.description and #(area.description) > 0 then - if not config.single_area_id then - ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = area.description } - else - ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = unit.description } - end - end if not (config.voting_only and config.disable_delegations) and app.session.member_id then ui.container{ attr = { class = "mdl-card__actions" }, content = function() - if not config.disable_delegations then - - if area.delegation_info.first_trustee_id then - local member = Member:by_id(area.delegation_info.first_trustee_id) - ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" } - execute.view{ - module = "member", - view = "_show_thumb", - params = { - member = member - } - } - end - - local text - if area.delegation_info.own_delegation_scope == nil then - text = _"delegate..." - else - text = _"change delegation..." - end - - - ui.tag{ attr = { id = "change_delegation", class = "mdl-button" }, content = text } - + area:load_delegation_info_once_for_member_id(app.session.member_id) - ui.tag { tag = "ul", attr = { class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect", ["for"] = "change_delegation" }, content = function() - - ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() - ui.link { - attr = { class = "mdl-menu__link" }, - module = "delegation", view = "show", params = { - unit_id = area.unit_id, - }, - content = _("unit: #{name}", { name = area.unit.name }) - } - end } - - ui.tag{ tag = "li", attr = { class = "mdl-menu__item" }, content = function() - ui.link { - attr = { class = "mdl-menu__link" }, - module = "delegation", view = "show", params = { - area_id = area.id - }, - content = _("subject area: #{name}", { name = area.name }) - } - end } - end } + local text + if area.delegation_info.own_delegation_scope == "area" then + local member = Member:by_id(area.delegation_info.first_trustee_id) + ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" } + execute.view{ + module = "member", + view = "_show_thumb", + params = { + member = member + } + } + text = _"change delegation..." + else + text = _"delegate..." end - + + ui.link { + attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, + module = "delegation", view = "show", params = { + area_id = area.id, + }, + content = text + } + if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then ui.link { attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" }, @@ -102,26 +119,6 @@ end } end end } -elseif unit then - ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() - ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() - ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name } - end } - if unit.description and #(unit.description) > 0 then - ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = unit.description } - end - if config.render_external_reference_unit then - config.render_external_reference_unit(unit) - end - --ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function() - --end } - end } -else - ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() - ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() - ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"All issues" } - end } - ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = _"All issues in your units. Use filters above to limit results." } - end } end - + + diff -r 631f6311a9eb -r 6b203b43bef3 app/main/index/index.lua --- a/app/main/index/index.lua Sun Jan 31 20:37:22 2021 +0100 +++ b/app/main/index/index.lua Sun Jan 31 22:04:30 2021 +0100 @@ -8,6 +8,7 @@ if unit_id == "all" then unit_id = nil + area_id = nil end if area_id == "all" then @@ -26,6 +27,7 @@ end end + if area_id then area = Area:by_id(area_id) if not area or area.unit_id ~= unit.id then