bsw/jbe@0: local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec() bsw/jbe@0: bsw/jbe@5: slot.select("actions", function() bsw/jbe@5: ui.link{ bsw/jbe@5: content = function() bsw/jbe@5: ui.image{ static = "icons/16/script.png" } bsw/jbe@5: slot.put(_"Show all initiatives") bsw/jbe@5: end, bsw/jbe@5: module = "issue", bsw/jbe@5: view = "show", bsw/jbe@5: id = initiative.issue.id bsw/jbe@5: } bsw/jbe@5: end) bsw/jbe@4: bsw/jbe@4: execute.view{ bsw/jbe@4: module = "issue", bsw/jbe@4: view = "_show_head", bsw/jbe@4: params = { issue = initiative.issue } bsw/jbe@4: } bsw/jbe@4: bsw@10: if initiative.revoked then bsw@10: ui.container{ bsw@10: attr = { class = "revoked_info" }, bsw@10: content = function() bsw@10: slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) })) bsw@10: local suggested_initiative = initiative.suggested_initiative bsw@10: if suggested_initiative then bsw@10: slot.put("

") bsw@10: slot.put(_("The initiators suggest to support the following initiative:")) bsw@10: slot.put("
") bsw@10: ui.link{ bsw@10: content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name), bsw@10: module = "initiative", bsw@10: view = "show", bsw@10: id = suggested_initiative.id bsw@10: } bsw@10: end bsw@10: end bsw@10: } bsw@10: end bsw@10: bsw/jbe@4: local initiator = Initiator:by_pk(initiative.id, app.session.member.id) bsw/jbe@4: bsw@3: --slot.put_into("html_head", '') bsw/jbe@0: bsw/jbe@0: bsw/jbe@0: slot.select("actions", function() bsw/jbe@4: if not initiative.issue.fully_frozen and not initiative.issue.closed then bsw@2: ui.link{ bsw@3: attr = { class = "action" }, bsw@3: content = function() bsw@3: ui.image{ static = "icons/16/script_add.png" } bsw/jbe@4: slot.put(_"Create alternative initiative") bsw@3: end, bsw@3: module = "initiative", bsw@3: view = "new", bsw@3: params = { issue_id = initiative.issue.id } bsw@3: } bsw@3: end bsw/jbe@4: end) bsw/jbe@4: bsw@10: slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) )) bsw@10: bsw@10: slot.select("support", function() bsw@10: ui.container{ bsw@10: attr = { class = "actions" }, bsw@10: content = function() bsw@10: execute.view{ bsw@10: module = "supporter", bsw@10: view = "_show_box", bsw@10: params = { initiative = initiative } bsw@10: } bsw@10: if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then bsw@10: ui.link{ bsw@10: attr = { class = "action", style = "float: left;" }, bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/script_delete.png" } bsw@10: slot.put(_"Revoke initiative") bsw@10: end, bsw@10: module = "initiative", bsw@10: view = "revoke", bsw@10: id = initiative.id bsw@10: } bsw@10: end bsw@10: end bsw@10: } bsw@10: end) bsw/jbe@4: bsw/jbe@4: util.help("initiative.show") bsw/jbe@4: bsw@10: if initiator and initiator.accepted == nil then bsw@10: ui.container{ bsw@10: attr = { class = "initiator_invite_info" }, bsw@10: content = function() bsw@10: slot.put(_"You are invited to become initiator of this initiative.") bsw@10: slot.put(" ") bsw@10: ui.link{ bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/tick.png" } bsw@10: slot.put(_"Accept invitation") bsw@10: end, bsw@10: module = "initiative", bsw@10: action = "accept_invitation", bsw@10: id = initiative.id, bsw@10: routing = { bsw@10: default = { bsw@10: mode = "redirect", bsw@10: module = request.get_module(), bsw@10: view = request.get_view(), bsw@10: id = param.get_id_cgi(), bsw@10: params = param.get_all_cgi() bsw@10: } bsw@10: } bsw@10: } bsw@10: slot.put(" ") bsw@10: ui.link{ bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/cross.png" } bsw@10: slot.put(_"Refuse invitation") bsw@10: end, bsw@10: module = "initiative", bsw@10: action = "reject_initiator_invitation", bsw@10: params = { bsw@10: initiative_id = initiative.id, bsw@10: member_id = app.session.member.id bsw@10: }, bsw@10: routing = { bsw@10: default = { bsw@10: mode = "redirect", bsw@10: module = request.get_module(), bsw@10: view = request.get_view(), bsw@10: id = param.get_id_cgi(), bsw@10: params = param.get_all_cgi() bsw@10: } bsw@10: } bsw@10: } bsw@10: end bsw@10: } bsw@10: slot.put("
") bsw@10: end bsw/jbe@4: bsw@10: if (initiative.discussion_url and #initiative.discussion_url > 0) bsw@10: or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then bsw@10: ui.container{ bsw@10: attr = { class = "vertical" }, bsw@10: content = function() bsw@10: ui.container{ bsw@10: attr = { class = "ui_field_label" }, bsw@10: content = _"Discussion with initiators" bsw@10: } bsw@10: ui.tag{ bsw@10: tag = "span", bsw@10: content = function() bsw@10: if initiative.discussion_url and #initiative.discussion_url > 0 then bsw@10: ui.link{ bsw@10: attr = { bsw@10: class = "actions", bsw@10: target = "_blank", bsw@10: title = initiative.discussion_url bsw@10: }, bsw@10: content = function() bsw@10: slot.put(encode.html(initiative.discussion_url)) bsw@10: end, bsw@10: external = initiative.discussion_url bsw@10: } bsw@10: end bsw@10: slot.put(" ") bsw@10: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@10: ui.link{ bsw@10: attr = { class = "actions" }, bsw@10: content = _"(change URL)", bsw@10: module = "initiative", bsw@10: view = "edit", bsw@10: id = initiative.id bsw@10: } bsw@10: end bsw/jbe@4: end bsw@10: } bsw@10: end bsw@10: } bsw@10: end bsw/jbe@0: bsw/jbe@0: bsw/jbe@0: ui.container{ bsw/jbe@0: attr = { id = "add_suggestion_form", class = "hidden_inline_form" }, bsw/jbe@0: content = function() bsw/jbe@0: bsw/jbe@0: ui.link{ bsw/jbe@0: content = _"Close", bsw/jbe@0: attr = { bsw/jbe@0: onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)", bsw/jbe@0: style = "float: right;" bsw/jbe@0: } bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" } bsw/jbe@0: bsw/jbe@0: bsw/jbe@0: ui.form{ bsw/jbe@0: module = "suggestion", bsw/jbe@0: action = "add", bsw/jbe@0: params = { initiative_id = initiative.id }, bsw/jbe@0: routing = { bsw/jbe@0: default = { bsw/jbe@0: mode = "redirect", bsw/jbe@0: module = "initiative", bsw/jbe@0: view = "show", bsw/jbe@0: id = initiative.id, bsw/jbe@0: params = { tab = "suggestion" } bsw/jbe@0: } bsw/jbe@0: }, bsw/jbe@0: attr = { class = "vertical" }, bsw/jbe@0: content = function() bsw/jbe@4: local supported = Supporter:by_pk(initiative.id, app.session.member.id) and true or false bsw/jbe@4: if not supported then bsw/jbe@4: ui.field.text{ bsw/jbe@4: attr = { class = "warning" }, bsw/jbe@4: value = _"You are currently not supporting this initiative. By adding suggestions to this initiative you will automatically become a potential supporter." bsw/jbe@4: } bsw/jbe@4: end bsw/jbe@4: ui.field.text{ label = _"Title (80 chars max)", name = "name" } bsw/jbe@0: ui.field.text{ label = _"Description", name = "description", multiline = true } bsw/jbe@0: ui.field.select{ bsw/jbe@0: label = _"Degree", bsw/jbe@0: name = "degree", bsw/jbe@0: foreign_records = { bsw/jbe@0: { id = 1, name = _"should"}, bsw/jbe@0: { id = 2, name = _"must"}, bsw/jbe@0: }, bsw/jbe@0: foreign_id = "id", bsw/jbe@0: foreign_name = "name" bsw/jbe@0: } bsw/jbe@0: ui.submit{ text = _"Commit suggestion" } bsw/jbe@0: end bsw/jbe@0: } bsw/jbe@0: end bsw/jbe@0: } bsw/jbe@0: bsw@2: local supporter = app.session.member:get_reference_selector("supporters") bsw@2: :add_where{ "initiative_id = ?", initiative.id } bsw@2: :optional_object_mode() bsw@2: :exec() bsw@2: bsw@2: if supporter then bsw@2: local old_draft_id = supporter.draft_id bsw@2: local new_draft_id = initiative.current_draft.id bsw@2: if old_draft_id ~= new_draft_id then bsw@2: ui.container{ bsw@2: attr = { class = "draft_updated_info" }, bsw@2: content = function() bsw@2: slot.put("The draft of this initiative has been updated!") bsw@2: slot.put(" ") bsw@2: ui.link{ bsw@2: content = _"Show diff", bsw@2: module = "draft", bsw@2: view = "diff", bsw@2: params = { bsw@2: old_draft_id = old_draft_id, bsw@2: new_draft_id = new_draft_id bsw@2: } bsw@2: } bsw@2: slot.put(" ") bsw@2: ui.link{ bsw@2: content = _"Refresh support to current draft", bsw@2: module = "initiative", bsw@2: action = "add_support", bsw@2: id = initiative.id, bsw@2: routing = { bsw@2: default = { bsw@2: mode = "redirect", bsw@2: module = "initiative", bsw@2: view = "show", bsw@2: id = initiative.id bsw@2: } bsw@2: } bsw@2: } bsw@2: end bsw@2: } bsw@2: end bsw@2: end bsw/jbe@0: bsw/jbe@4: bsw/jbe@6: local current_draft_name = _"Current draft" bsw/jbe@6: if initiative.issue.half_frozen then bsw/jbe@6: current_draft_name = _"Voting proposal" bsw/jbe@6: end bsw/jbe@6: bsw/jbe@6: if initiative.issue.state == "finished" then bsw/jbe@6: current_draft_name = _"Voted proposal" bsw/jbe@6: end bsw/jbe@6: bsw/jbe@6: local tabs = { bsw/jbe@0: { bsw/jbe@0: name = "current_draft", bsw/jbe@6: label = current_draft_name, bsw/jbe@0: content = function() bsw@10: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw/jbe@4: ui.link{ bsw/jbe@4: content = function() bsw/jbe@4: ui.image{ static = "icons/16/script_add.png" } bsw/jbe@4: slot.put(_"Edit draft") bsw/jbe@4: end, bsw/jbe@4: module = "draft", bsw/jbe@4: view = "new", bsw/jbe@4: params = { initiative_id = initiative.id } bsw/jbe@4: } bsw/jbe@4: end bsw/jbe@0: execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } } bsw/jbe@0: end bsw/jbe@6: } bsw/jbe@6: } bsw/jbe@6: bsw/jbe@6: if initiative.issue.ranks_available then bsw/jbe@6: tabs[#tabs+1] = { bsw/jbe@6: name = "voter", bsw/jbe@6: label = _"Voter", bsw/jbe@0: content = function() bsw@3: execute.view{ bsw@3: module = "member", bsw@3: view = "_list", bsw@3: params = { bsw@3: initiative = initiative, bsw/jbe@6: members_selector = initiative.issue:get_reference_selector("direct_voters") bsw/jbe@6: :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id }) bsw/jbe@6: :add_field("direct_voter.weight as voter_weight") bsw/jbe@6: :add_field("coalesce(vote.grade, 0) as grade") bsw@3: } bsw@3: } bsw/jbe@0: end bsw/jbe@6: } bsw/jbe@6: end bsw/jbe@6: bsw@10: local suggestion_count = initiative:get_reference_selector("suggestions"):count() bsw@10: bsw/jbe@6: tabs[#tabs+1] = { bsw/jbe@6: name = "suggestion", bsw@10: label = _"Suggestions" .. " (" .. tostring(suggestion_count) .. ")", bsw/jbe@6: content = function() bsw/jbe@6: execute.view{ bsw/jbe@6: module = "suggestion", bsw/jbe@6: view = "_list", bsw/jbe@6: params = { bsw/jbe@6: initiative = initiative, bsw/jbe@6: suggestions_selector = initiative:get_reference_selector("suggestions") bsw/jbe@6: } bsw/jbe@6: } bsw/jbe@6: slot.put("
") bsw@10: if not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then bsw/jbe@6: ui.link{ bsw@2: content = function() bsw/jbe@6: ui.image{ static = "icons/16/comment_add.png" } bsw/jbe@6: slot.put(_"Add new suggestion") bsw/jbe@6: end, bsw/jbe@6: attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" }, bsw/jbe@6: static = "#" bsw@2: } bsw@2: end bsw/jbe@6: end bsw/jbe@6: } bsw/jbe@6: bsw@10: local members_selector = initiative:get_reference_selector("supporting_members_snapshot") bsw@10: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") bsw@10: :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") bsw@10: :add_field("direct_interest_snapshot.weight") bsw@10: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") bsw@10: :add_where("direct_supporter_snapshot.satisfied") bsw@10: bsw@10: local satisfied_supporter_count = members_selector:count() bsw@10: bsw/jbe@6: tabs[#tabs+1] = { bsw/jbe@6: name = "satisfied_supporter", bsw@10: label = _"Supporter" .. " (" .. tostring(satisfied_supporter_count) .. ")", bsw@10: content = function() bsw@10: execute.view{ bsw@10: module = "member", bsw@10: view = "_list", bsw@10: params = { bsw@10: initiative = initiative, bsw@10: members_selector = members_selector bsw@10: } bsw@10: } bsw@10: end bsw@10: } bsw@10: bsw@10: local members_selector = initiative:get_reference_selector("supporting_members_snapshot") bsw@10: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id") bsw@10: :join("direct_interest_snapshot", nil, "direct_interest_snapshot.event = issue.latest_snapshot_event AND direct_interest_snapshot.issue_id = issue.id AND direct_interest_snapshot.member_id = member.id") bsw@10: :add_field("direct_interest_snapshot.weight") bsw@10: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event") bsw@10: :add_where("NOT direct_supporter_snapshot.satisfied") bsw@10: bsw@10: local potential_supporter_count = members_selector:count() bsw@10: bsw@10: tabs[#tabs+1] = { bsw@10: name = "supporter", bsw@10: label = _"Potential supporter" .. " (" .. tostring(potential_supporter_count) .. ")", bsw/jbe@6: content = function() bsw/jbe@6: execute.view{ bsw/jbe@6: module = "member", bsw/jbe@6: view = "_list", bsw/jbe@6: params = { bsw/jbe@6: initiative = initiative, bsw@10: members_selector = members_selector bsw/jbe@6: } bsw/jbe@6: } bsw/jbe@6: end bsw/jbe@6: } bsw/jbe@6: bsw@10: local initiator_count = initiative:get_reference_selector("initiators"):add_where("accepted"):count() bsw@10: bsw/jbe@6: tabs[#tabs+1] = { bsw@10: name = "initiators", bsw@10: label = _"Initiators" .. " (" .. tostring(initiator_count) .. ")", bsw/jbe@6: content = function() bsw@10: if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then bsw@10: ui.link{ bsw@10: attr = { class = "action" }, bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/user_add.png" } bsw@10: slot.put(_"Invite initiator") bsw@10: end, bsw@10: module = "initiative", bsw@10: view = "add_initiator", bsw@10: params = { initiative_id = initiative.id } bsw@10: } bsw@10: if initiator_count > 1 then bsw@10: ui.link{ bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/user_delete.png" } bsw@10: slot.put(_"Remove initiator") bsw@10: end, bsw@10: module = "initiative", bsw@10: view = "remove_initiator", bsw@10: params = { initiative_id = initiative.id } bsw@10: } bsw@10: end bsw@10: end bsw@10: if initiator and initiator.accepted == false then bsw@10: ui.link{ bsw@10: content = function() bsw@10: ui.image{ static = "icons/16/user_delete.png" } bsw@10: slot.put(_"Cancel refuse of invitation") bsw@10: end, bsw@10: module = "initiative", bsw@10: action = "remove_initiator", bsw@10: params = { bsw@10: initiative_id = initiative.id, bsw@10: member_id = app.session.member.id bsw@10: }, bsw@10: routing = { bsw@10: ok = { bsw@10: mode = "redirect", bsw@10: module = "initiative", bsw@10: view = "show", bsw@10: id = initiative.id bsw@10: } bsw@10: } bsw@10: } bsw@10: end bsw@10: local members_selector = initiative:get_reference_selector("initiating_members") bsw@10: :add_field("initiator.accepted", "accepted") bsw@10: if not (initiator and initiator.accepted) then bsw@10: members_selector:add_where("accepted") bsw@10: end bsw/jbe@6: execute.view{ bsw/jbe@6: module = "member", bsw/jbe@6: view = "_list", bsw/jbe@6: params = { bsw@10: members_selector = members_selector, bsw@10: initiator = initiator bsw/jbe@6: } bsw/jbe@6: } bsw/jbe@6: end bsw/jbe@6: } bsw/jbe@6: bsw@10: local drafts_count = initiative:get_reference_selector("drafts"):count() bsw/jbe@6: bsw/jbe@6: tabs[#tabs+1] = { bsw/jbe@6: name = "drafts", bsw@10: label = _"Draft history" .. " (" .. tostring(drafts_count) .. ")", bsw/jbe@6: content = function() bsw/jbe@6: execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } } bsw/jbe@6: end bsw/jbe@6: } bsw/jbe@6: bsw/jbe@6: tabs[#tabs+1] = { bsw/jbe@6: name = "details", bsw/jbe@6: label = _"Details", bsw/jbe@6: content = function() bsw/jbe@6: ui.form{ bsw/jbe@6: attr = { class = "vertical" }, bsw/jbe@6: record = initiative, bsw/jbe@6: readonly = true, bsw/jbe@6: content = function() bsw/jbe@6: ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name } bsw/jbe@6: ui.field.text{ bsw/jbe@6: label = _"Created at", bsw/jbe@6: value = tostring(initiative.created) bsw/jbe@6: } bsw/jbe@6: ui.field.text{ bsw/jbe@6: label = _"Created at", bsw/jbe@6: value = format.timestamp(initiative.created) bsw/jbe@6: } bsw@10: -- ui.field.date{ label = _"Revoked at", name = "revoked" } bsw/jbe@6: ui.field.boolean{ label = _"Admitted", name = "admitted" } bsw/jbe@6: end bsw/jbe@6: } bsw/jbe@6: end bsw/jbe@0: } bsw/jbe@0: bsw/jbe@0: bsw/jbe@6: ui.tabs(tabs) bsw/jbe@6: