# HG changeset patch # User Daniel Poelzleithner # Date 1286588568 -7200 # Node ID 5d797c6706d5d2d9c5672f26524c5efed90cd5af # Parent 39d49cf933d88f418bd08d58aa0854c0481afb08 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 diff -r 39d49cf933d8 -r 5d797c6706d5 app/main/draft/diff.lua --- a/app/main/draft/diff.lua Fri Oct 08 20:36:56 2010 +0200 +++ b/app/main/draft/diff.lua Sat Oct 09 03:42:48 2010 +0200 @@ -1,5 +1,3 @@ -slot.put_into("title", _"Diff") - local old_draft_id = param.get("old_draft_id", atom.integer) local new_draft_id = param.get("new_draft_id", atom.integer) @@ -22,6 +20,62 @@ local old_draft = Draft:by_id(old_draft_id) local new_draft = Draft:by_id(new_draft_id) +local initiative = new_draft.initiative +local issue = initiative.issue + +slot.select("title", function() + ui.link{ + content = issue.area.name, + module = "area", + view = "show", + id = issue.area.id + } + slot.put(" · ") + ui.link{ + content = _("Issue ##{id}", { id = issue.id }), + module = "issue", + view = "show", + id = issue.id + } + slot.put(" · ") + ui.link{ + content = _("Initiative: ")..initiative.name, + module = "initiative", + view = "show", + id = initiative.id + } + slot.put(" · ") + slot.put_into("title", _"Diff") + +end) + +if app.session.member_id and not new_draft.initiative.revoked then + local supporter = Supporter:new_selector():add_where{"member_id = ?", app.session.member_id}:count() + if supporter then + ui.container{ + attr = { class = "draft_updated_info" }, + content = function() + slot.put(_"The draft of this initiative has been updated!") + slot.put(" ") + ui.link{ + text = _"Refresh support to current draft", + module = "initiative", + action = "add_support", + id = new_draft.initiative.id, + routing = { + default = { + mode = "redirect", + module = "initiative", + view = "show", + id = new_draft.initiative.id + } + } + } + end + } + end +end + local old_draft_content = string.gsub(string.gsub(old_draft.content, "\n", " ###ENTER###\n"), " ", "\n") local new_draft_content = string.gsub(string.gsub(new_draft.content, "\n", " ###ENTER###\n"), " ", "\n") diff -r 39d49cf933d8 -r 5d797c6706d5 app/main/initiative/_details.lua --- a/app/main/initiative/_details.lua Fri Oct 08 20:36:56 2010 +0200 +++ b/app/main/initiative/_details.lua Sat Oct 09 03:42:48 2010 +0200 @@ -5,14 +5,25 @@ record = initiative, readonly = true, content = function() + local policy = initiative.issue.policy ui.field.text{ label = _"Issue policy", value = initiative.issue.policy.name } ui.field.text{ label = _"Created at", value = tostring(initiative.created) } + if initiative.revoked then + ui.field.text{ + label = _"Revoked at", + value = format.timestamp(initiative.revoked) + } + end ui.field.text{ - label = _"Created at", - value = format.timestamp(initiative.created) + label = _"Initiative quorum", + value = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) + } + ui.field.text{ + label = _"Currently required", + value = math.ceil(initiative.issue.population * (policy.initiative_quorum_num / policy.initiative_quorum_den)), } -- ui.field.date{ label = _"Revoked at", name = "revoked" } ui.field.boolean{ label = _"Admitted", name = "admitted" } diff -r 39d49cf933d8 -r 5d797c6706d5 app/main/initiative/_list_element.lua --- a/app/main/initiative/_list_element.lua Fri Oct 08 20:36:56 2010 +0200 +++ b/app/main/initiative/_list_element.lua Sat Oct 09 03:42:48 2010 +0200 @@ -112,6 +112,8 @@ ui.bargraph{ max_value = max_value, width = 100, + quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), + quorum_color = "#00F", bars = { { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, diff -r 39d49cf933d8 -r 5d797c6706d5 app/main/issue/_details.lua --- a/app/main/issue/_details.lua Fri Oct 08 20:36:56 2010 +0200 +++ b/app/main/issue/_details.lua Sat Oct 09 03:42:48 2010 +0200 @@ -14,6 +14,10 @@ label = _"Issue quorum", value = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) } + ui.field.text{ + label = _"Currently required", + value = math.ceil(issue.population * policy.issue_quorum_num / policy.issue_quorum_den) + } ui.field.timestamp{ label = _"Accepted at", name = "accepted" } ui.field.text{ label = _"Discussion time", value = issue.discussion_time } ui.field.vote_now{ label = _"Vote now", name = "vote_now" } @@ -24,6 +28,10 @@ label = _"Initiative quorum", value = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) } + ui.field.text{ + label = _"Currently required", + value = math.ceil(issue.population * (issue.policy.initiative_quorum_num / issue.policy.initiative_quorum_den)), + } ui.field.timestamp{ label = _"Fully frozen at", name = "fully_frozen" } ui.field.text{ label = _"Voting time", value = issue.voting_time } ui.field.timestamp{ label = _"Closed", name = "closed" } diff -r 39d49cf933d8 -r 5d797c6706d5 env/ui/bargraph.lua --- a/env/ui/bargraph.lua Fri Oct 08 20:36:56 2010 +0200 +++ b/env/ui/bargraph.lua Sat Oct 09 03:42:48 2010 +0200 @@ -13,10 +13,33 @@ }, content = function() local at_least_one_bar = false + local quorum = args.quorum and args.quorum * args.width / args.max_value or nil + local length = 0 for i, bar in ipairs(args.bars) do if bar.value > 0 then at_least_one_bar = true local value = bar.value * args.width / args.max_value + if quorum and quorum < length + value then + local dlength = math.max(quorum - length - 1, 0) + if dlength > 0 then + ui.container{ + attr = { + style = "width: " .. tostring(dlength) .. "px; background-color: " .. bar.color .. ";", + }, + content = function() slot.put(" ") end + } + end + ui.container{ + attr = { + style = "width: 1px; background-color: " .. (args.quorum_color or "blue") ..";", + }, + content = function() slot.put(" ") end + } + length = dlength + 1 + value = value - dlength + quorum = nil + end + length = length + value ui.container{ attr = { style = "width: " .. tostring(value) .. "px; background-color: " .. bar.color .. ";",