liquid_feedback_frontend

annotate app/main/initiative/show.lua @ 1309:32cc544d5a5b

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

Impressum / About Us