liquid_feedback_frontend

annotate app/main/index/_head.lua @ 1598:6b203b43bef3

Reworked unit and area head and delegation buttons
author bsw
date Sun Jan 31 22:04:30 2021 +0100 (2021-01-31)
parents 9f55297a1a6a
children d47d2b0cd7c2
rev   line source
bsw@1598 1 local unit_id = config.single_unit_id or request.get_param{ name = "unit" }
bsw@1598 2 local area_id = config.single_area_id or request.get_param{ name = "area" }
bsw/jbe@1309 3 if unit_id == "all" then
bsw/jbe@1309 4 unit_id = nil
bsw@1598 5 area_id = nil
bsw/jbe@1309 6 end
bsw/jbe@1309 7 local unit
bsw/jbe@1309 8 if unit_id then
bsw/jbe@1309 9 unit = Unit:by_id(unit_id)
bsw/jbe@1309 10 end
bsw/jbe@1309 11 if area_id == "all" then
bsw/jbe@1309 12 area_id = nil
bsw/jbe@1309 13 end
bsw/jbe@1309 14 local area
bsw/jbe@1309 15 if area_id then
bsw/jbe@1309 16 area = Area:by_id(area_id)
bsw/jbe@1309 17 end
bsw@1598 18
bsw@1598 19 print(unit_id, area_id, unit, area)
bsw@1598 20
bsw@1598 21 if unit then
bsw@1598 22 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw@1598 23 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw@1598 24 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
bsw@1598 25 if unit.description and #(unit.description) > 0 then
bsw@1598 26 ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description }
bsw@1598 27 end
bsw@1598 28 if config.render_external_reference_unit then
bsw@1598 29 config.render_external_reference_unit(unit)
bsw@1598 30 end
bsw@1598 31 end }
bsw@1598 32
bsw@1598 33
bsw@1598 34 if not (config.voting_only and config.disable_delegations) and app.session.member_id then
bsw@1598 35 ui.container{ attr = { class = "mdl-card__actions" }, content = function()
bsw@1598 36
bsw@1598 37 unit:load_delegation_info_once_for_member_id(app.session.member_id)
bsw@1598 38
bsw@1598 39 local text
bsw@1598 40 if unit.delegation_info.own_delegation_scope == "unit" then
bsw@1598 41 local member = Member:by_id(unit.delegation_info.first_trustee_id)
bsw@1598 42 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
bsw@1598 43 execute.view{
bsw@1598 44 module = "member",
bsw@1598 45 view = "_show_thumb",
bsw@1598 46 params = {
bsw@1598 47 member = member
bsw@1598 48 }
bsw@1598 49 }
bsw@1598 50 text = _"change delegation..."
bsw@1598 51 else
bsw@1598 52 text = _"delegate..."
bsw@1598 53 end
bsw@1598 54
bsw@1598 55 ui.link {
bsw@1598 56 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
bsw@1598 57 module = "delegation", view = "show", params = {
bsw@1598 58 unit_id = unit.id,
bsw@1598 59 },
bsw@1598 60 content = text
bsw@1598 61 }
bsw@1598 62
bsw@1598 63 end }
bsw@1598 64 end
bsw@1598 65 end }
bsw@1598 66 end
bsw@1598 67
bsw@1596 68 if area then
bsw/jbe@1309 69
bsw/jbe@1309 70 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw/jbe@1309 71 if unit then
bsw/jbe@1309 72 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw@1598 73 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
bsw@1598 74 if area.description and #(area.description) > 0 then
bsw@1598 75 ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description }
bsw/jbe@1309 76 end
bsw/jbe@1309 77 end }
bsw/jbe@1309 78 end
bsw/jbe@1309 79 if not (config.voting_only and config.disable_delegations) and app.session.member_id then
bsw/jbe@1309 80 ui.container{ attr = { class = "mdl-card__actions" }, content = function()
bsw/jbe@1309 81
bsw@1598 82 area:load_delegation_info_once_for_member_id(app.session.member_id)
bsw@1596 83
bsw@1598 84 local text
bsw@1598 85 if area.delegation_info.own_delegation_scope == "area" then
bsw@1598 86 local member = Member:by_id(area.delegation_info.first_trustee_id)
bsw@1598 87 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
bsw@1598 88 execute.view{
bsw@1598 89 module = "member",
bsw@1598 90 view = "_show_thumb",
bsw@1598 91 params = {
bsw@1598 92 member = member
bsw@1598 93 }
bsw@1598 94 }
bsw@1598 95 text = _"change delegation..."
bsw@1598 96 else
bsw@1598 97 text = _"delegate..."
bsw/jbe@1309 98 end
bsw@1598 99
bsw@1598 100 ui.link {
bsw@1598 101 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
bsw@1598 102 module = "delegation", view = "show", params = {
bsw@1598 103 area_id = area.id,
bsw@1598 104 },
bsw@1598 105 content = text
bsw@1598 106 }
bsw@1598 107
bsw/jbe@1309 108 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 109 ui.link {
bsw/jbe@1309 110 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
bsw@1496 111 module = "draft", view = "new",
bsw/jbe@1309 112 params = { area_id = area.id },
bsw/jbe@1309 113 content = function()
bsw/jbe@1309 114 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
bsw/jbe@1309 115 ui.tag{ content = _"new issue" }
bsw/jbe@1309 116 end
bsw/jbe@1309 117 }
bsw/jbe@1309 118 end
bsw/jbe@1309 119 end }
bsw/jbe@1309 120 end
bsw/jbe@1309 121 end }
bsw/jbe@1309 122 end
bsw@1598 123
bsw@1598 124

Impressum / About Us