liquid_feedback_frontend

annotate app/main/index/_head.lua @ 1602:a3a7120a67be

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

Impressum / About Us