liquid_feedback_frontend

diff app/main/initiative/show.lua @ 0:3bfb2fcf7ab9

Version alpha1
author bsw/jbe
date Wed Nov 18 12:00:00 2009 +0100 (2009-11-18)
parents
children 5c601807d397
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/initiative/show.lua	Wed Nov 18 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,176 @@
     1.4 +local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
     1.5 +
     1.6 +slot.put_into("html_head", '<link rel="alternate" type="application/rss+xml" title="RSS" href="../show/' .. tostring(initiative.id) .. '.rss" />')
     1.7 +
     1.8 +execute.view{
     1.9 +  module = "supporter",
    1.10 +  view = "_show_box",
    1.11 +  params = { initiative = initiative }
    1.12 +}
    1.13 +
    1.14 +execute.view{
    1.15 +  module = "delegation",
    1.16 +  view = "_show_box",
    1.17 +  params = { issue_id = initiative.issue_id }
    1.18 +}
    1.19 +
    1.20 +
    1.21 +slot.select("path", function()
    1.22 +  ui.link{
    1.23 +    content = _"Area '#{name}'":gsub("#{name}", initiative.issue.area.name),
    1.24 +    module = "area",
    1.25 +    view = "show",
    1.26 +    id = initiative.issue.area.id
    1.27 +  }
    1.28 +  ui.container{ content = "::" }
    1.29 +  ui.link{
    1.30 +    content = _"Issue ##{id} (#{policy_name})":gsub("#{id}", initiative.issue.id):gsub("#{policy_name}", initiative.issue.policy.name),
    1.31 +    module = "issue",
    1.32 +    view = "show",
    1.33 +    id = initiative.issue.id
    1.34 +  }
    1.35 +end)
    1.36 +
    1.37 +slot.put_into("title", encode.html(_"Initiative: '#{name}'":gsub("#{name}", initiative.shortened_name) ))
    1.38 +
    1.39 +slot.select("actions", function()
    1.40 +
    1.41 +  ui.twitter("http://example.com/i" .. tostring(initiative.id) .. " " .. initiative.name)
    1.42 +
    1.43 +end)
    1.44 +
    1.45 +
    1.46 +ui.container{
    1.47 +  attr = {  id = "add_suggestion_form", class = "hidden_inline_form" },
    1.48 +  content = function()
    1.49 +
    1.50 +    ui.link{
    1.51 +      content = _"Close",
    1.52 +      attr = {
    1.53 +        onclick = "document.getElementById('add_suggestion_form').style.display='none';return(false)",
    1.54 +        style = "float: right;"
    1.55 +      }
    1.56 +    }
    1.57 +
    1.58 +    ui.field.text{ attr = { class = "head" }, value = _"Add new suggestion" }
    1.59 +
    1.60 +
    1.61 +    ui.form{
    1.62 +      module = "suggestion",
    1.63 +      action = "add",
    1.64 +      params = { initiative_id = initiative.id },
    1.65 +      routing = {
    1.66 +        default = {
    1.67 +          mode = "redirect",
    1.68 +          module = "initiative",
    1.69 +          view = "show",
    1.70 +          id = initiative.id,
    1.71 +          params = { tab = "suggestion" }
    1.72 +        }
    1.73 +      },
    1.74 +      attr = { class = "vertical" },
    1.75 +      content = function()
    1.76 +        ui.field.text{ label = _"Name",        name = "name" }
    1.77 +        ui.field.text{ label = _"Description", name = "description", multiline = true }
    1.78 +        ui.field.select{ 
    1.79 +          label = _"Degree", 
    1.80 +          name = "degree",
    1.81 +          foreign_records = { 
    1.82 +            { id =  1, name = _"should"},
    1.83 +            { id =  2, name = _"must"},
    1.84 +          },
    1.85 +          foreign_id = "id",
    1.86 +          foreign_name = "name"
    1.87 +        }
    1.88 +        ui.submit{ text = _"Commit suggestion" }
    1.89 +      end
    1.90 +    }
    1.91 +  end
    1.92 +}
    1.93 +
    1.94 +
    1.95 +ui.tabs{
    1.96 +  {
    1.97 +    name = "current_draft",
    1.98 +    label = _"Current draft",
    1.99 +    content = function()
   1.100 +      execute.view{ module = "draft", view = "_show", params = { draft = initiative.current_draft } }
   1.101 +      if Initiator:by_pk(initiative.id, app.session.member.id) then
   1.102 +        ui.link{
   1.103 +          content = function()
   1.104 +            ui.image{ static = "icons/16/script_add.png" }
   1.105 +            slot.put(_"Add new draft")
   1.106 +          end,
   1.107 +          module = "draft",
   1.108 +          view = "new",
   1.109 +          params = { initiative_id = initiative.id }
   1.110 +        }
   1.111 +      end
   1.112 +    end
   1.113 +  },
   1.114 +  {
   1.115 +    name = "details",
   1.116 +    label = _"Details",
   1.117 +    content = function()
   1.118 +      ui.form{
   1.119 +        attr = { class = "vertical" },
   1.120 +        record = initiative,
   1.121 +        readonly = true,
   1.122 +        content = function()
   1.123 +          ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
   1.124 +          ui.field.text{
   1.125 +            label = _"Created at",
   1.126 +            value = tostring(initiative.created)
   1.127 +          }
   1.128 +          ui.field.text{
   1.129 +            label = _"Created at",
   1.130 +            value = format.timestamp(initiative.created)
   1.131 +          }
   1.132 +          ui.field.date{ label = _"Revoked at", name = "revoked" }
   1.133 +          ui.field.boolean{ label = _"Admitted", name = "admitted" }
   1.134 +        end
   1.135 +      }
   1.136 +    end
   1.137 +  },
   1.138 +  {
   1.139 +    name = "suggestion",
   1.140 +    label = _"Suggestions",
   1.141 +    content = function()
   1.142 +      execute.view{ module = "suggestion", view = "_list", params = { suggestions_selector = initiative:get_reference_selector("suggestions") } }
   1.143 +      slot.put("<br />")
   1.144 +      if not initiative.issue.frozen and not initiative.issue.closed then
   1.145 +        ui.link{
   1.146 +          content = function()
   1.147 +            ui.image{ static = "icons/16/comment_add.png" }
   1.148 +            slot.put(_"Add new suggestion")
   1.149 +          end,
   1.150 +          attr = { onclick = "document.getElementById('add_suggestion_form').style.display='block';return(false)" },
   1.151 +          static = "#"
   1.152 +        }
   1.153 +      end
   1.154 +    end
   1.155 +  },
   1.156 +  {
   1.157 +    name = "supporter",
   1.158 +    label = _"Supporter",
   1.159 +    content = function()
   1.160 +      execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("supporting_members") } }
   1.161 +    end
   1.162 +  },
   1.163 +  {
   1.164 +    name = "initiators",
   1.165 +    label = _"Initiators",
   1.166 +    content = function()
   1.167 +      execute.view{ module = "member", view = "_list", params = { members_selector = initiative:get_reference_selector("initiating_members") } }
   1.168 +    end
   1.169 +  },
   1.170 +  {
   1.171 +    name = "drafts",
   1.172 +    label = _"Old drafts",
   1.173 +    content = function()
   1.174 +      execute.view{ module = "draft", view = "_list", params = { drafts = initiative.drafts } }
   1.175 +    end
   1.176 +  },
   1.177 +}
   1.178 +
   1.179 +

Impressum / About Us