liquid_feedback_frontend
view app/main/delegation/new.lua @ 159:5d797c6706d5
implement quorum display
show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Sat Oct 09 03:42:48 2010 +0200 (2010-10-09) | 
| parents | bf885faf3452 | 
| children | 02aacb3dffe0 | 
 line source
     1 local area = Area:by_id(param.get("area_id", atom.integer))
     2 if area then
     3   slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name)))
     4   util.help("delegation.new.area")
     5 end
     7 local issue = Issue:by_id(param.get("issue_id", atom.integer))
     8 if issue then
     9   slot.put_into("title", encode.html(_"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name)))
    10   util.help("delegation.new.issue")
    11 end
    13 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
    15 if not area and not issue then
    16   slot.put_into("title", encode.html(_"Set global delegation"))
    17   util.help("delegation.new.global")
    18 end
    20 slot.select("actions", function()
    21   if issue then
    22     ui.link{
    23       module = "issue",
    24       view = "show",
    25       id = issue.id,
    26       content = function()
    27           ui.image{ static = "icons/16/cancel.png" }
    28           slot.put(_"Cancel")
    29       end,
    30     }
    31   elseif area then
    32     ui.link{
    33       module = "area",
    34       view = "show",
    35       id = area.id,
    36       content = function()
    37           ui.image{ static = "icons/16/cancel.png" }
    38           slot.put(_"Cancel")
    39       end,
    40     }
    41   else
    42     ui.link{
    43       module = "index",
    44       view = "index",
    45       content = function()
    46           ui.image{ static = "icons/16/cancel.png" }
    47           slot.put(_"Cancel")
    48       end,
    49     }
    50   end
    51 end)
    55 local contact_members = Member:new_selector()
    56   :add_where{ "contact.member_id = ?", app.session.member.id }
    57   :join("contact", nil, "member.id = contact.other_member_id")
    58   :add_order_by("member.name")
    59   :exec()
    62 ui.form{
    63   attr = { class = "vertical" },
    64   module = "delegation",
    65   action = "update",
    66   params = {
    67     area_id = area and area.id or nil,
    68     issue_id = issue and issue.id or nil,
    69   },
    70   routing = {
    71     default = {
    72       mode = "redirect",
    73       module = area and "area" or issue and "issue" or "index",
    74       view = (area or issue) and "show" or "index",
    75       id = area and area.id or issue and issue.id or nil,
    76     }
    77   },
    78   content = function()
    79     local records = {
    80       {
    81         id = "-1",
    82         name = _"No delegation"
    83       }
    84     }
    86     for i, record in ipairs(contact_members) do
    87       records[#records+1] = record
    88     end
    89     disabled_records = {}
    90     -- add initiative authors
    91     if initiative then
    92       records[#records+1] = {id="_", name=_"--- Initiators ---"}
    93       disabled_records["_"] = true
    94       for i,record in ipairs(initiative.initiators) do
    95         trace.debug(record)
    96         trace.debug(record.member.name)
    97         records[#records+1] = record.member
    98       end
    99     end
   101     ui.field.select{
   102       label = _"Trustee",
   103       name = "trustee_id",
   104       foreign_records = records,
   105       foreign_id = "id",
   106       foreign_name = "name",
   107       disabled_records = disabled_records
   108     }
   110     ui.submit{ text = _"Save" }
   111   end
   112 }
