bsw@1045: local initiative = Initiative:by_id ( param.get_id() )
bsw@1045: local member = app.session.member
bsw@1045:
bsw@1045: if not initiative then
bsw@1045: execute.view { module = "index", view = "404" }
bsw@1045: request.set_status("404 Not Found")
bsw@1045: return
bsw@1045: end
bsw@1045:
bsw/jbe@1309: app.current_initiative = initiative
bsw/jbe@1309:
bsw@1045: local issue_info
bsw@1045:
bsw@1045: if member then
bsw@1045: initiative:load_everything_for_member_id(member.id)
bsw@1045: initiative.issue:load_everything_for_member_id(member.id)
bsw@1045: issue_info = initiative.issue.member_info
bsw@1045: end
bsw@1045:
bsw@1145: local direct_supporter
bsw@1145:
bsw@1045: if app.session.member_id then
bsw@1045: direct_supporter = initiative.issue.member_info.own_participation and initiative.member_info.supported
bsw@1045: end
bsw@718:
bsw/jbe@1309: slot.put_into("header", initiative.display_name)
bsw@1045:
bsw/jbe@1309: execute.view{ module = "issue", view = "_head", params = { issue = initiative.issue, link_issue = true } }
bsw@1045:
bsw/jbe@1309: ui.grid{ content = function()
bsw@1045:
bsw/jbe@1309: ui.cell_main{ content = function()
bsw/jbe@1309: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw/jbe@1309: execute.view{
bsw/jbe@1309: module = "initiative", view = "_head", params = {
bsw/jbe@1309: initiative = initiative
bsw@1045: }
bsw/jbe@1309: }
bsw@1045:
bsw@1519: if initiative.location and initiative.location.marker_link then
bsw@1519: ui.container {
bsw@1519: attr = { class = "mdl-card__content mdl-card--no-bottom-pad" },
bsw@1519: content = function()
bsw@1519: ui.tag{ content = _"This initiative references a FirstLife object." }
bsw@1519: slot.put(" ")
bsw@1519: ui.link{ external = initiative.location.marker_link, content = _"Open in FirstLife" }
bsw@1519: end
bsw@1519: }
bsw@1519: end
bsw@1519:
bsw/jbe@1309: if direct_supporter and not initiative.issue.closed then
bsw/jbe@1309: local supporter = app.session.member:get_reference_selector("supporters")
bsw/jbe@1309: :add_where{ "initiative_id = ?", initiative.id }
bsw/jbe@1309: :optional_object_mode()
bsw/jbe@1309: :exec()
bsw/jbe@1309:
bsw/jbe@1309: if supporter then
bsw@1045:
bsw/jbe@1309: local old_draft_id = supporter.draft_id
bsw/jbe@1309: local new_draft_id = initiative.current_draft.id
bsw/jbe@1309:
bsw/jbe@1309: if old_draft_id ~= new_draft_id then
bsw/jbe@1309: ui.container {
bsw/jbe@1309: attr = { class = "mdl-card__content mdl-card--no-bottom-pad mdl-card--notice" },
bsw/jbe@1309: content = _"The draft of this initiative has been updated!"
bsw/jbe@1309: }
bsw/jbe@1309: ui.container {
bsw/jbe@1309: attr = { class = "mdl-card__actions mdl-card--action-border mdl-card--notice" },
bsw/jbe@1309: content = function ()
bsw/jbe@1309: if not initiative.revoked then
bsw/jbe@1309: ui.link{
bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw/jbe@1309: text = _"refresh my support",
bsw/jbe@1309: module = "initiative",
bsw/jbe@1309: action = "add_support",
bsw/jbe@1309: id = initiative.id,
bsw/jbe@1309: params = { draft_id = initiative.current_draft.id },
bsw/jbe@1309: routing = {
bsw/jbe@1309: default = {
bsw/jbe@1309: mode = "redirect",
bsw/jbe@1309: module = "initiative",
bsw/jbe@1309: view = "show",
bsw/jbe@1309: id = initiative.id
bsw/jbe@1309: }
bsw/jbe@1309: }
bsw/jbe@1309: }
bsw/jbe@1309: slot.put(" ")
bsw/jbe@1309: ui.link{
bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw/jbe@1309: content = _"show differences",
bsw/jbe@1309: module = "draft",
bsw/jbe@1309: view = "diff",
bsw/jbe@1309: params = {
bsw/jbe@1309: old_draft_id = old_draft_id,
bsw/jbe@1309: new_draft_id = new_draft_id
bsw/jbe@1309: }
bsw/jbe@1309: }
bsw/jbe@1309: slot.put(" ")
bsw@1045: end
bsw/jbe@1309: ui.link{
bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
bsw/jbe@1309: text = _"remove my support",
bsw/jbe@1309: module = "initiative",
bsw/jbe@1309: action = "remove_support",
bsw/jbe@1309: id = initiative.id,
bsw/jbe@1309: routing = {
bsw/jbe@1309: default = {
bsw/jbe@1309: mode = "redirect",
bsw/jbe@1309: module = "initiative",
bsw/jbe@1309: view = "show",
bsw/jbe@1309: id = initiative.id
bsw@1045: }
bsw@1045: }
bsw@1061: }
bsw@1061:
bsw/jbe@1309: end
bsw/jbe@1309: }
bsw/jbe@1309: end
bsw/jbe@1309: end
bsw/jbe@1309: end
bsw/jbe@1309:
bsw/jbe@1309: if config.render_external_reference and config.render_external_reference.initiative then
bsw/jbe@1309: config.render_external_reference.initiative(initiative, function (callback)
bsw/jbe@1309: ui.sectionRow(callback)
bsw/jbe@1309: end)
bsw/jbe@1309: end
bsw/jbe@1309: local draft_content = initiative.current_draft.content
bsw/jbe@1309: if config.initiative_abstract then
bsw/jbe@1309: local abstract = string.match(draft_content, "(.+)")
bsw/jbe@1309: if abstract then
bsw/jbe@1309: draft_content = string.match(draft_content, "(.*)")
bsw/jbe@1309: end
bsw/jbe@1309: end
bsw/jbe@1309: ui.container {
bsw/jbe@1309: attr = { class = "draft mdl-card__content mdl-card--border" },
bsw/jbe@1309: content = function ()
bsw/jbe@1309: if initiative.current_draft.formatting_engine == "html" or not initiative.current_draft.formatting_engine then
bsw/jbe@1309: if config.draft_filter then
bsw/jbe@1309: slot.put(config.draft_filter(draft_content))
bsw/jbe@1309: else
bsw/jbe@1309: slot.put(draft_content)
bsw@1045: end
bsw/jbe@1309: else
bsw/jbe@1309: slot.put ( initiative.current_draft:get_content ( "html" ) )
bsw/jbe@1309: end
bsw/jbe@1309: end
bsw/jbe@1309: }
bsw@1045:
bsw@1495: if config.attachments then
bsw@1495:
bsw@1495: local files = File:new_selector()
bsw@1495: :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
bsw@1495: :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
bsw@1495: :reset_fields()
bsw@1495: :add_field("file.id")
bsw@1495: :add_field("draft_attachment.title")
bsw@1495: :add_field("draft_attachment.description")
bsw@1495: :add_order_by("draft_attachment.id")
bsw@1495: :exec()
bsw@1495:
bsw@1495: if #files > 0 then
bsw@1495: ui.container {
bsw@1495: attr = { class = "mdl-card__content mdl-card--border" },
bsw@1495: content = function()
bsw@1495: for i, file in ipairs(files) do
bsw@1495: ui.link{ module = "file", view = "show.jpg", id = file.id, content = function()
bsw@1495: ui.image{ module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
bsw@1495: end }
bsw@1496: ui.container{ content = function()
bsw@1496: ui.tag{ tag = "strong", content = file.title or "" }
bsw@1496: end }
bsw@1495: ui.container{ content = file.description or "" }
bsw@1495: slot.put("
")
bsw@1495: end
bsw@1495: end
bsw@1495: }
bsw@1495: end
bsw@1495: end
bsw@1495:
bsw/jbe@1309: local drafts_count = initiative:get_reference_selector("drafts"):count()
bsw@1045:
bsw/jbe@1309: if not config.voting_only then
bsw/jbe@1309: ui.container {
bsw/jbe@1309: attr = { class = "mdl-card__actions" },
bsw/jbe@1309: content = function()
bsw/jbe@1309: ui.link{
bsw/jbe@1309: attr = { class = "mdl-button mdl-js-button" },
bsw/jbe@1309: module = "initiative", view = "history", id = initiative.id,
bsw/jbe@1309: content = _("draft history (#{count})", { count = drafts_count })
bsw/jbe@1309: }
bsw/jbe@1309: end
bsw/jbe@1309: }
bsw@1045: end
bsw/jbe@1309:
bsw/jbe@1309: end }
bsw/jbe@1309:
bsw/jbe@1309: execute.view{ module = "initiative", view = "_suggestions", params = { initiative = initiative } }
bsw@1045:
bsw/jbe@1309: end }
bsw/jbe@1309:
bsw/jbe@1309: ui.cell_sidebar{ content = function()
bsw/jbe@1309: if config.logo then
bsw/jbe@1309: config.logo()
bsw/jbe@1309: end
bsw@1620:
bsw/jbe@1309: execute.view {
bsw/jbe@1309: module = "issue", view = "_sidebar",
bsw/jbe@1309: params = {
bsw/jbe@1309: issue = initiative.issue,
bsw/jbe@1309: initiative = initiative,
bsw/jbe@1309: member = app.session.member
bsw/jbe@1309: }
bsw/jbe@1309: }
bsw/jbe@1309:
bsw/jbe@1309: execute.view {
bsw/jbe@1309: module = "issue", view = "_sidebar_whatcanido",
bsw/jbe@1309: params = {
bsw/jbe@1309: issue = initiative.issue,
bsw/jbe@1309: initiative = initiative,
bsw/jbe@1309: member = app.session.member
bsw/jbe@1309: }
bsw/jbe@1309: }
bsw/jbe@1309:
bsw/jbe@1309: execute.view {
bsw/jbe@1309: module = "issue", view = "_sidebar_members", params = {
bsw/jbe@1309: issue = initiative.issue, initiative = initiative
bsw/jbe@1309: }
bsw/jbe@1309: }
bsw/jbe@1309:
bsw/jbe@1309: end }
bsw/jbe@1309:
bsw/jbe@1309: end }