liquid_feedback_frontend

changeset 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
author Daniel Poelzleithner <poelzi@poelzi.org>
date Sat Oct 09 03:42:48 2010 +0200 (2010-10-09)
parents 39d49cf933d8
children cc7650c7053f
files app/main/draft/diff.lua app/main/initiative/_details.lua app/main/initiative/_list_element.lua app/main/issue/_details.lua env/ui/bargraph.lua
line diff
     1.1 --- a/app/main/draft/diff.lua	Fri Oct 08 20:36:56 2010 +0200
     1.2 +++ b/app/main/draft/diff.lua	Sat Oct 09 03:42:48 2010 +0200
     1.3 @@ -1,5 +1,3 @@
     1.4 -slot.put_into("title", _"Diff")
     1.5 -
     1.6  local old_draft_id = param.get("old_draft_id", atom.integer)
     1.7  local new_draft_id = param.get("new_draft_id", atom.integer)
     1.8  
     1.9 @@ -22,6 +20,62 @@
    1.10  local old_draft = Draft:by_id(old_draft_id)
    1.11  local new_draft = Draft:by_id(new_draft_id)
    1.12  
    1.13 +local initiative = new_draft.initiative
    1.14 +local issue = initiative.issue
    1.15 +
    1.16 +slot.select("title", function()
    1.17 +  ui.link{
    1.18 +    content = issue.area.name,
    1.19 +    module = "area",
    1.20 +    view = "show",
    1.21 +    id = issue.area.id
    1.22 +  }
    1.23 +  slot.put(" &middot; ")
    1.24 +  ui.link{
    1.25 +    content = _("Issue ##{id}", { id = issue.id }),
    1.26 +    module = "issue",
    1.27 +    view = "show",
    1.28 +    id = issue.id
    1.29 +  }
    1.30 +  slot.put(" &middot; ")
    1.31 +  ui.link{
    1.32 +    content = _("Initiative: ")..initiative.name,
    1.33 +    module = "initiative",
    1.34 +    view = "show",
    1.35 +    id = initiative.id
    1.36 +  }
    1.37 +  slot.put(" &middot; ")
    1.38 +  slot.put_into("title", _"Diff")
    1.39 +
    1.40 +end)
    1.41 +
    1.42 +if app.session.member_id and not new_draft.initiative.revoked then
    1.43 +  local supporter = Supporter:new_selector():add_where{"member_id = ?", app.session.member_id}:count()
    1.44 +  if supporter then
    1.45 +    ui.container{
    1.46 +      attr = { class = "draft_updated_info" },
    1.47 +      content = function()
    1.48 +        slot.put(_"The draft of this initiative has been updated!")
    1.49 +        slot.put(" ")
    1.50 +        ui.link{
    1.51 +          text   = _"Refresh support to current draft",
    1.52 +          module = "initiative",
    1.53 +          action = "add_support",
    1.54 +          id     = new_draft.initiative.id,
    1.55 +          routing = {
    1.56 +            default = {
    1.57 +              mode = "redirect",
    1.58 +              module = "initiative",
    1.59 +              view = "show",
    1.60 +              id = new_draft.initiative.id
    1.61 +            }
    1.62 +          }
    1.63 +        }
    1.64 +      end
    1.65 +    }
    1.66 +  end
    1.67 +end
    1.68 +
    1.69  local old_draft_content = string.gsub(string.gsub(old_draft.content, "\n", " ###ENTER###\n"), " ", "\n")
    1.70  local new_draft_content = string.gsub(string.gsub(new_draft.content, "\n", " ###ENTER###\n"), " ", "\n")
    1.71  
     2.1 --- a/app/main/initiative/_details.lua	Fri Oct 08 20:36:56 2010 +0200
     2.2 +++ b/app/main/initiative/_details.lua	Sat Oct 09 03:42:48 2010 +0200
     2.3 @@ -5,14 +5,25 @@
     2.4    record = initiative,
     2.5    readonly = true,
     2.6    content = function()
     2.7 +    local policy = initiative.issue.policy
     2.8      ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name }
     2.9      ui.field.text{
    2.10        label = _"Created at",
    2.11        value = tostring(initiative.created)
    2.12      }
    2.13 +    if initiative.revoked then
    2.14 +      ui.field.text{
    2.15 +         label = _"Revoked at",
    2.16 +         value = format.timestamp(initiative.revoked)
    2.17 +       }
    2.18 +    end
    2.19      ui.field.text{
    2.20 -      label = _"Created at",
    2.21 -      value = format.timestamp(initiative.created)
    2.22 +      label   = _"Initiative quorum",
    2.23 +      value = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den)
    2.24 +    }
    2.25 +    ui.field.text{
    2.26 +      label   = _"Currently required",
    2.27 +      value = math.ceil(initiative.issue.population * (policy.initiative_quorum_num / policy.initiative_quorum_den)),
    2.28      }
    2.29    -- ui.field.date{ label = _"Revoked at", name = "revoked" }
    2.30      ui.field.boolean{ label = _"Admitted", name = "admitted" }
     3.1 --- a/app/main/initiative/_list_element.lua	Fri Oct 08 20:36:56 2010 +0200
     3.2 +++ b/app/main/initiative/_list_element.lua	Sat Oct 09 03:42:48 2010 +0200
     3.3 @@ -112,6 +112,8 @@
     3.4                    ui.bargraph{
     3.5                      max_value = max_value,
     3.6                      width = 100,
     3.7 +                    quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
     3.8 +                    quorum_color = "#00F",
     3.9                      bars = {
    3.10                        { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    3.11                        { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
     4.1 --- a/app/main/issue/_details.lua	Fri Oct 08 20:36:56 2010 +0200
     4.2 +++ b/app/main/issue/_details.lua	Sat Oct 09 03:42:48 2010 +0200
     4.3 @@ -14,6 +14,10 @@
     4.4        label = _"Issue quorum",
     4.5        value = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den)
     4.6      }
     4.7 +    ui.field.text{
     4.8 +      label = _"Currently required",
     4.9 +      value = math.ceil(issue.population * policy.issue_quorum_num / policy.issue_quorum_den)
    4.10 +    }
    4.11      ui.field.timestamp{  label = _"Accepted at",           name = "accepted" }
    4.12      ui.field.text{       label = _"Discussion time",       value = issue.discussion_time }
    4.13      ui.field.vote_now{   label = _"Vote now",              name = "vote_now" }
    4.14 @@ -24,6 +28,10 @@
    4.15        label   = _"Initiative quorum",
    4.16        value = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den)
    4.17      }
    4.18 +    ui.field.text{
    4.19 +      label   = _"Currently required",
    4.20 +      value = math.ceil(issue.population * (issue.policy.initiative_quorum_num / issue.policy.initiative_quorum_den)),
    4.21 +    }
    4.22      ui.field.timestamp{  label = _"Fully frozen at",       name = "fully_frozen" }
    4.23      ui.field.text{       label = _"Voting time",           value = issue.voting_time }
    4.24      ui.field.timestamp{  label = _"Closed",                name = "closed" }
     5.1 --- a/env/ui/bargraph.lua	Fri Oct 08 20:36:56 2010 +0200
     5.2 +++ b/env/ui/bargraph.lua	Sat Oct 09 03:42:48 2010 +0200
     5.3 @@ -13,10 +13,33 @@
     5.4      },
     5.5      content = function()
     5.6        local at_least_one_bar = false
     5.7 +      local quorum = args.quorum and args.quorum * args.width / args.max_value or nil
     5.8 +      local length = 0
     5.9        for i, bar in ipairs(args.bars) do
    5.10          if bar.value > 0 then
    5.11            at_least_one_bar = true
    5.12            local value = bar.value * args.width / args.max_value
    5.13 +          if quorum and quorum < length + value then
    5.14 +            local dlength = math.max(quorum - length - 1, 0)
    5.15 +            if dlength > 0 then
    5.16 +              ui.container{
    5.17 +                attr = {
    5.18 +                  style = "width: " .. tostring(dlength) .. "px; background-color: " .. bar.color .. ";",
    5.19 +                },
    5.20 +                content = function() slot.put("&nbsp;") end
    5.21 +              }
    5.22 +            end
    5.23 +            ui.container{
    5.24 +              attr = {
    5.25 +                style = "width: 1px; background-color: " .. (args.quorum_color or "blue") ..";",
    5.26 +              },
    5.27 +              content = function() slot.put("&nbsp;") end
    5.28 +            }
    5.29 +            length = dlength + 1
    5.30 +            value = value - dlength
    5.31 +            quorum = nil
    5.32 +          end
    5.33 +          length = length + value
    5.34            ui.container{
    5.35              attr = {
    5.36                style = "width: " .. tostring(value) .. "px; background-color: " .. bar.color .. ";",

Impressum / About Us