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/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: execute.view{
bsw/jbe@0: module = "supporter",
bsw/jbe@0: view = "_show_box",
bsw/jbe@0: params = { initiative = initiative }
bsw/jbe@0: }
bsw/jbe@0:
bsw/jbe@4: slot.put_into("sub_title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
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/jbe@4:
bsw/jbe@4: util.help("initiative.show")
bsw/jbe@4:
bsw/jbe@4:
bsw/jbe@4: ui.container{
bsw/jbe@4: attr = { class = "vertical" },
bsw/jbe@4: content = function()
bsw/jbe@4: ui.container{
bsw/jbe@4: attr = { class = "ui_field_label" },
bsw/jbe@4: content = _"Discussion URL"
bsw/jbe@4: }
bsw/jbe@4: ui.tag{
bsw/jbe@4: tag = "span",
bsw@3: content = function()
bsw/jbe@4: if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw/jbe@4: ui.link{
bsw/jbe@4: attr = {
bsw/jbe@4: class = "actions",
bsw/jbe@5: target = "_blank",
bsw/jbe@4: title = initiative.discussion_url
bsw/jbe@4: },
bsw/jbe@4: content = function()
bsw/jbe@4: slot.put(encode.html(initiative.discussion_url))
bsw/jbe@4: end,
bsw/jbe@4: external = initiative.discussion_url
bsw/jbe@4: }
bsw/jbe@4: end
bsw/jbe@4: slot.put(" ")
bsw/jbe@4: if initiator then
bsw/jbe@4: ui.link{
bsw/jbe@4: attr = { class = "actions" },
bsw/jbe@4: content = _"(change URL)",
bsw/jbe@4: module = "initiative",
bsw/jbe@4: view = "edit",
bsw/jbe@4: id = initiative.id
bsw/jbe@4: }
bsw/jbe@4: end
bsw/jbe@4: end
bsw@3: }
bsw@3: end
bsw/jbe@4: }
bsw/jbe@4:
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/jbe@4: if initiator 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/jbe@6: tabs[#tabs+1] = {
bsw/jbe@6: name = "suggestion",
bsw/jbe@6: label = _"Suggestions",
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/jbe@6: if not initiative.issue.fully_frozen and not initiative.issue.closed 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/jbe@6: tabs[#tabs+1] = {
bsw/jbe@6: name = "satisfied_supporter",
bsw/jbe@6: label = _"Supporter",
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/jbe@6: members_selector = initiative:get_reference_selector("supporting_members_snapshot")
bsw/jbe@6: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
bsw/jbe@6: :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/jbe@6: :add_field("direct_interest_snapshot.weight")
bsw/jbe@6: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
bsw/jbe@6: :add_where("direct_supporter_snapshot.satisfied")
bsw/jbe@6: }
bsw/jbe@6: }
bsw/jbe@6: end
bsw/jbe@6: }
bsw/jbe@6:
bsw/jbe@6: tabs[#tabs+1] = {
bsw/jbe@6: name = "supporter",
bsw/jbe@6: label = _"Potential supporter",
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/jbe@6: members_selector = initiative:get_reference_selector("supporting_members_snapshot")
bsw/jbe@6: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
bsw/jbe@6: :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/jbe@6: :add_field("direct_interest_snapshot.weight")
bsw/jbe@6: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
bsw/jbe@6: :add_where("NOT direct_supporter_snapshot.satisfied")
bsw/jbe@6: }
bsw/jbe@6: }
bsw/jbe@6: end
bsw/jbe@6: }
bsw/jbe@6:
bsw/jbe@6: tabs[#tabs+1] = {
bsw/jbe@6: name = "initiators",
bsw/jbe@6: label = _"Initiators",
bsw/jbe@6: content = function()
bsw/jbe@6: execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
bsw/jbe@6: end
bsw/jbe@6: }
bsw/jbe@6:
bsw/jbe@6: tabs[#tabs+1] = {
bsw/jbe@6: name = "drafts",
bsw/jbe@6: label = _"Old drafts",
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/jbe@6: 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: