liquid_feedback_frontend
view app/main/index/_head.lua @ 1496:ed3c40911ae1
Completed image attachments feature
author | bsw |
---|---|
date | Tue Feb 11 15:24:36 2020 +0100 (2020-02-11) |
parents | 3ab878ba277e |
children | 3c15fea3f1c0 |
line source
1 local unit_id = config.single_unit_id or tonumber(request.get_param{ name = "unit" })
2 if unit_id == "all" then
3 unit_id = nil
4 end
5 local unit
6 if unit_id then
7 unit = Unit:by_id(unit_id)
8 end
9 local area_id = config.single_area_id or tonumber(request.get_param{ name = "area" })
10 if area_id == "all" then
11 area_id = nil
12 end
13 local area
14 if area_id then
15 area = Area:by_id(area_id)
16 end
17 if area and unit and area.unit_id ~= unit.id then
18 area_id = nil
19 end
20 if area and area.unit_id == unit_id then
21 if app.session.member_id then
22 area:load_delegation_info_once_for_member_id(app.session.member_id)
23 end
25 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
26 if unit then
27 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
28 if not config.single_area_id then
29 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name .. " / " .. area.name }
30 else
31 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
32 end
33 end }
34 end
35 if area.description and #(area.description) > 0 then
36 if not config.single_area_id then
37 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = area.description }
38 else
39 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = unit.description }
40 end
41 end
42 if not (config.voting_only and config.disable_delegations) and app.session.member_id then
43 ui.container{ attr = { class = "mdl-card__actions" }, content = function()
45 if app.session.member_id then
46 if area.delegation_info.first_trustee_id then
47 local member = Member:by_id(area.delegation_info.first_trustee_id)
48 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
49 execute.view{
50 module = "member_image",
51 view = "_show",
52 params = {
53 member = member,
54 image_type = "avatar",
55 show_dummy = true
56 }
57 }
58 end
60 if not config.disable_delegations then
61 if area.delegation_info.own_delegation_scope == "unit" then
62 ui.link {
63 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
64 module = "delegation", view = "show", params = {
65 unit_id = area.unit_id,
66 },
67 content = _("change/revoke delegation of organizational unit")
68 }
69 slot.put(" ")
70 end
71 if area.delegation_info.own_delegation_scope == nil then
72 local text
73 if config.single_area_id then
74 text = _"choose delegatee"
75 else
76 text = _"choose subject area delegatee"
77 end
78 ui.link {
79 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
80 module = "delegation", view = "show", params = {
81 area_id = area.id
82 },
83 content = function()
84 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "forward" }
85 ui.tag{ content = text }
86 end
87 }
88 slot.put(" ")
89 elseif area.delegation_info.own_delegation_scope == "area" then
90 local text
91 if config.single_area_id then
92 text = _"change/revoke delegation"
93 else
94 text = _"change/revoke area delegation"
95 end
96 ui.link {
97 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
98 module = "delegation", view = "show", params = {
99 area_id = area.id
100 },
101 content = text
102 }
103 slot.put(" ")
104 else
105 ui.link {
106 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
107 module = "delegation", view = "show", params = {
108 area_id = area.id
109 },
110 content = _"change/revoke delegation only for this subject area"
111 }
112 slot.put(" ")
113 end
114 end
115 end
116 if not config.voting_only and app.session.member_id and app.session.member:has_initiative_right_for_unit_id ( area.unit_id ) then
117 ui.link {
118 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
119 module = "draft", view = "new",
120 params = { area_id = area.id },
121 content = function()
122 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "add" }
123 ui.tag{ content = _"new issue" }
124 end
125 }
126 end
127 end }
128 end
129 end }
130 elseif unit then
131 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
132 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
133 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
134 end }
135 if unit.description and #(unit.description) > 0 then
136 ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = unit.description }
137 end
138 --ui.container{ attr = { class = "mdl-card__actions mdl-card--border" }, content = function()
139 --end }
140 end }
141 else
142 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
143 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
144 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"All issues" }
145 end }
146 ui.container{ attr = { class = "mdl-card__supporting-text mdl-card--border" }, content = _"All issues in your units. Use filters above to limit results." }
147 end }
148 end