liquid_feedback_frontend
view app/main/initiative/show.lua @ 1488:ce812dccaac2
Work without configured profile fields
author | bsw |
---|---|
date | Mon Jan 07 19:16:30 2019 +0100 (2019-01-07) |
parents | 32cc544d5a5b |
children | 17e7082c377a |
line source
1 local initiative = Initiative:by_id ( param.get_id() )
2 local member = app.session.member
4 if not initiative then
5 execute.view { module = "index", view = "404" }
6 request.set_status("404 Not Found")
7 return
8 end
10 app.current_initiative = initiative
12 local issue_info
14 if member then
15 initiative:load_everything_for_member_id(member.id)
16 initiative.issue:load_everything_for_member_id(member.id)
17 issue_info = initiative.issue.member_info
18 end
20 local direct_supporter
22 if app.session.member_id then
23 direct_supporter = initiative.issue.member_info.own_participation and initiative.member_info.supported
24 end
26 slot.put_into("header", initiative.display_name)
28 execute.view{ module = "issue", view = "_head", params = { issue = initiative.issue, link_issue = true } }
30 ui.grid{ content = function()
32 ui.cell_main{ content = function()
33 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
34 execute.view{
35 module = "initiative", view = "_head", params = {
36 initiative = initiative
37 }
38 }
40 if direct_supporter and not initiative.issue.closed then
41 local supporter = app.session.member:get_reference_selector("supporters")
42 :add_where{ "initiative_id = ?", initiative.id }
43 :optional_object_mode()
44 :exec()
46 if supporter then
48 local old_draft_id = supporter.draft_id
49 local new_draft_id = initiative.current_draft.id
51 if old_draft_id ~= new_draft_id then
52 ui.container {
53 attr = { class = "mdl-card__content mdl-card--no-bottom-pad mdl-card--notice" },
54 content = _"The draft of this initiative has been updated!"
55 }
56 ui.container {
57 attr = { class = "mdl-card__actions mdl-card--action-border mdl-card--notice" },
58 content = function ()
59 if not initiative.revoked then
60 ui.link{
61 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
62 text = _"refresh my support",
63 module = "initiative",
64 action = "add_support",
65 id = initiative.id,
66 params = { draft_id = initiative.current_draft.id },
67 routing = {
68 default = {
69 mode = "redirect",
70 module = "initiative",
71 view = "show",
72 id = initiative.id
73 }
74 }
75 }
76 slot.put(" ")
77 ui.link{
78 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
79 content = _"show differences",
80 module = "draft",
81 view = "diff",
82 params = {
83 old_draft_id = old_draft_id,
84 new_draft_id = new_draft_id
85 }
86 }
87 slot.put(" ")
88 end
89 ui.link{
90 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
91 text = _"remove my support",
92 module = "initiative",
93 action = "remove_support",
94 id = initiative.id,
95 routing = {
96 default = {
97 mode = "redirect",
98 module = "initiative",
99 view = "show",
100 id = initiative.id
101 }
102 }
103 }
105 end
106 }
107 end
108 end
109 end
111 if config.render_external_reference and config.render_external_reference.initiative then
112 config.render_external_reference.initiative(initiative, function (callback)
113 ui.sectionRow(callback)
114 end)
115 end
116 local draft_content = initiative.current_draft.content
117 if config.initiative_abstract then
118 local abstract = string.match(draft_content, "(.+)<!%--END_OF_ABSTRACT%-->")
119 if abstract then
120 draft_content = string.match(draft_content, "<!%--END_OF_ABSTRACT%-->(.*)")
121 end
122 end
123 ui.container {
124 attr = { class = "draft mdl-card__content mdl-card--border" },
125 content = function ()
126 if initiative.current_draft.formatting_engine == "html" or not initiative.current_draft.formatting_engine then
127 if config.draft_filter then
128 slot.put(config.draft_filter(draft_content))
129 else
130 slot.put(draft_content)
131 end
132 else
133 slot.put ( initiative.current_draft:get_content ( "html" ) )
134 end
135 end
136 }
138 local drafts_count = initiative:get_reference_selector("drafts"):count()
140 if not config.voting_only then
141 ui.container {
142 attr = { class = "mdl-card__actions" },
143 content = function()
144 ui.link{
145 attr = { class = "mdl-button mdl-js-button" },
146 module = "initiative", view = "history", id = initiative.id,
147 content = _("draft history (#{count})", { count = drafts_count })
148 }
149 end
150 }
151 end
153 end }
155 execute.view{ module = "initiative", view = "_suggestions", params = { initiative = initiative } }
157 end }
159 ui.cell_sidebar{ content = function()
160 if config.logo then
161 config.logo()
162 end
163 execute.view {
164 module = "issue", view = "_sidebar",
165 params = {
166 issue = initiative.issue,
167 initiative = initiative,
168 member = app.session.member
169 }
170 }
172 execute.view {
173 module = "issue", view = "_sidebar_whatcanido",
174 params = {
175 issue = initiative.issue,
176 initiative = initiative,
177 member = app.session.member
178 }
179 }
181 execute.view {
182 module = "issue", view = "_sidebar_members", params = {
183 issue = initiative.issue, initiative = initiative
184 }
185 }
187 end }
189 end }