bsw/jbe@0: local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
bsw/jbe@0:
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@0: execute.view{
bsw/jbe@0: module = "delegation",
bsw/jbe@0: view = "_show_box",
bsw/jbe@0: params = { issue_id = initiative.issue_id }
bsw/jbe@0: }
bsw/jbe@0:
bsw@2: execute.view{
bsw@2: module = "issue",
bsw@2: view = "_show_box",
bsw@2: params = { issue = initiative.issue }
bsw@2: }
bsw/jbe@0:
bsw/jbe@0: slot.select("path", function()
bsw/jbe@0: ui.link{
bsw/jbe@0: content = _"Area '#{name}'":gsub("#{name}", initiative.issue.area.name),
bsw/jbe@0: module = "area",
bsw/jbe@0: view = "show",
bsw/jbe@0: id = initiative.issue.area.id
bsw/jbe@0: }
bsw/jbe@0: ui.container{ content = "::" }
bsw/jbe@0: ui.link{
bsw@2: content = _"Issue ##{id}":gsub("#{id}", initiative.issue.id),
bsw/jbe@0: module = "issue",
bsw/jbe@0: view = "show",
bsw/jbe@0: id = initiative.issue.id
bsw/jbe@0: }
bsw/jbe@0: end)
bsw/jbe@0:
bsw/jbe@0: slot.put_into("title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
bsw/jbe@0:
bsw/jbe@0: slot.select("actions", function()
bsw/jbe@0:
bsw@3: local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
bsw@3:
bsw@3: if initiator then
bsw@2: ui.link{
bsw@2: content = function()
bsw@2: ui.image{ static = "icons/16/script_add.png" }
bsw@2: slot.put(_"Edit draft")
bsw@2: end,
bsw@2: module = "draft",
bsw@2: view = "new",
bsw@2: params = { initiative_id = initiative.id }
bsw@2: }
bsw@2: end
bsw@2:
bsw@3: if not initiative.issue.fully_frozen and not initiative.issue.closed then
bsw@3: ui.link{
bsw@3: attr = { class = "action" },
bsw@3: content = function()
bsw@3: ui.image{ static = "icons/16/script_add.png" }
bsw@3: 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@3: -- ui.twitter("http://example.com/i" .. tostring(initiative.id) .. " " .. initiative.name)
bsw/jbe@0:
bsw@3: if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw@3: ui.link{
bsw@3: attr = {
bsw@3: target = _"blank",
bsw@3: title = initiative.discussion_url
bsw@3: },
bsw@3: content = function()
bsw@3: ui.image{ static = "icons/16/comments.png" }
bsw@3: slot.put(_"External discussion")
bsw@3: end,
bsw@3: external = initiative.discussion_url
bsw@3: }
bsw@3: end
bsw@3: if initiator then
bsw@3: ui.link{
bsw@3: content = _"(change)",
bsw@3: module = "initiative",
bsw@3: view = "edit",
bsw@3: id = initiative.id
bsw@3: }
bsw@3: end
bsw/jbe@0: 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@0: ui.field.text{ label = _"Name", 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@0: ui.tabs{
bsw/jbe@0: {
bsw/jbe@0: name = "current_draft",
bsw/jbe@0: label = _"Current draft",
bsw/jbe@0: content = function()
bsw/jbe@0: execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } }
bsw/jbe@0: end
bsw/jbe@0: },
bsw/jbe@0: {
bsw/jbe@0: name = "suggestion",
bsw/jbe@0: label = _"Suggestions",
bsw/jbe@0: content = function()
bsw/jbe@0: execute.view{ module = "suggestion", view = "_list", params = { suggestions_selector = initiative:get_reference_selector("suggestions") } }
bsw/jbe@0: slot.put("
")
bsw/jbe@0: if not initiative.issue.frozen and not initiative.issue.closed then
bsw/jbe@0: ui.link{
bsw/jbe@0: content = function()
bsw/jbe@0: ui.image{ static = "icons/16/comment_add.png" }
bsw/jbe@0: slot.put(_"Add new suggestion")
bsw/jbe@0: end,
bsw/jbe@0: attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" },
bsw/jbe@0: static = "#"
bsw/jbe@0: }
bsw/jbe@0: end
bsw/jbe@0: end
bsw/jbe@0: },
bsw/jbe@0: {
bsw/jbe@0: name = "supporter",
bsw/jbe@0: label = _"Supporter",
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@3: members_selector = initiative:get_reference_selector("supporting_members_snapshot")
bsw@3: :join("issue", nil, "issue.id = direct_supporter_snapshot.issue_id")
bsw@3: :join("direct_population_snapshot", nil, "direct_population_snapshot.event = issue.latest_snapshot_event AND direct_population_snapshot.issue_id = issue.id AND direct_population_snapshot.member_id = member.id")
bsw@3: :add_field("direct_population_snapshot.weight")
bsw@3: :add_where("direct_supporter_snapshot.event = issue.latest_snapshot_event")
bsw@3: }
bsw@3: }
bsw/jbe@0: end
bsw/jbe@0: },
bsw/jbe@0: {
bsw/jbe@0: name = "initiators",
bsw/jbe@0: label = _"Initiators",
bsw/jbe@0: content = function()
bsw/jbe@0: execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
bsw/jbe@0: end
bsw/jbe@0: },
bsw/jbe@0: {
bsw/jbe@0: name = "drafts",
bsw/jbe@0: label = _"Old drafts",
bsw/jbe@0: content = function()
bsw/jbe@0: execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } }
bsw/jbe@0: end
bsw/jbe@0: },
bsw@2: {
bsw@2: name = "details",
bsw@2: label = _"Details",
bsw@2: content = function()
bsw@2: ui.form{
bsw@2: attr = { class = "vertical" },
bsw@2: record = initiative,
bsw@2: readonly = true,
bsw@2: content = function()
bsw@2: ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
bsw@2: ui.field.text{
bsw@2: label = _"Created at",
bsw@2: value = tostring(initiative.created)
bsw@2: }
bsw@2: ui.field.text{
bsw@2: label = _"Created at",
bsw@2: value = format.timestamp(initiative.created)
bsw@2: }
bsw@2: ui.field.date{ label = _"Revoked at", name = "revoked" }
bsw@2: ui.field.boolean{ label = _"Admitted", name = "admitted" }
bsw@2: end
bsw@2: }
bsw@2: end
bsw@2: },
bsw/jbe@0: }
bsw/jbe@0:
bsw/jbe@0: