liquid_feedback_frontend

annotate app/main/issue/_show.lua @ 525:63d6549cc00b

Delegation chain preview improved, better visualisation of current context, code cleanup
author bsw
date Fri May 18 19:07:07 2012 +0200 (2012-05-18)
parents
children 4cee33ad5e16
rev   line source
bsw@525 1 local issue = param.get("issue", "table")
bsw@525 2 local initiative_limit = param.get("initiative_limit", atom.integer)
bsw@525 3 local for_listing = param.get("for_listing", atom.boolean)
bsw@525 4
bsw@525 5 local direct_voter
bsw@525 6 if app.session.member_id then
bsw@525 7 direct_voter = DirectVoter:by_pk(issue.id, app.session.member.id)
bsw@525 8 end
bsw@525 9
bsw@525 10 local voteable = app.session.member_id and issue.state == 'voting' and
bsw@525 11 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
bsw@525 12
bsw@525 13 local vote_link_text = direct_voter and _"Change vote" or "Vote now"
bsw@525 14
bsw@525 15
bsw@525 16 local class = "issue"
bsw@525 17 if issue.is_interested then
bsw@525 18 class = class .. " interested"
bsw@525 19 elseif issue.is_interested_by_delegation_to_member_id then
bsw@525 20 class = class .. " interested_by_delegation"
bsw@525 21 end
bsw@525 22
bsw@525 23 ui.container{ attr = { class = class }, content = function()
bsw@525 24
bsw@525 25 execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
bsw@525 26
bsw@525 27 if for_listing then
bsw@525 28 ui.container{ attr = { class = "context" }, content = function()
bsw@525 29 ui.tag{ content = issue.area.unit.name }
bsw@525 30 slot.put(" · ")
bsw@525 31 ui.tag{ content = issue.area.name }
bsw@525 32 end }
bsw@525 33 end
bsw@525 34 ui.container{ attr = { class = "title" }, content = function()
bsw@525 35
bsw@525 36 ui.link{
bsw@525 37 attr = { class = "issue_id" },
bsw@525 38 text = _("#{policy_name} ##{issue_id}", {
bsw@525 39 policy_name = issue.policy.name,
bsw@525 40 issue_id = issue.id
bsw@525 41 }),
bsw@525 42 module = "issue",
bsw@525 43 view = "show",
bsw@525 44 id = issue.id
bsw@525 45 }
bsw@525 46 end }
bsw@525 47
bsw@525 48 ui.tag{
bsw@525 49 attr = { class = "content issue_policy_info" },
bsw@525 50 tag = "div",
bsw@525 51 content = function()
bsw@525 52
bsw@525 53 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
bsw@525 54
bsw@525 55 if issue.state_time_left then
bsw@525 56 slot.put(" · ")
bsw@525 57 if issue.state_time_left:sub(1,1) == "-" then
bsw@525 58 if issue.state == "new" then
bsw@525 59 ui.tag{ content = _("Discussion starts soon") }
bsw@525 60 elseif issue.state == "discussion" then
bsw@525 61 ui.tag{ content = _("Verification starts soon") }
bsw@525 62 elseif issue.state == "frozen" then
bsw@525 63 ui.tag{ content = _("Voting starts soon") }
bsw@525 64 elseif issue.state == "voting" then
bsw@525 65 ui.tag{ content = _("Counting starts soon") }
bsw@525 66 end
bsw@525 67 else
bsw@525 68 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
bsw@525 69 end
bsw@525 70 end
bsw@525 71
bsw@525 72 end
bsw@525 73 }
bsw@525 74
bsw@525 75 ui.container{
bsw@525 76 attr = { class = "content actions" }, content = function()
bsw@525 77
bsw@525 78 if voteable then
bsw@525 79 ui.link{
bsw@525 80 content = vote_link_text,
bsw@525 81 module = "vote",
bsw@525 82 view = "list",
bsw@525 83 params = { issue_id = issue.id }
bsw@525 84 }
bsw@525 85 slot.put(" · ")
bsw@525 86 end
bsw@525 87
bsw@525 88 if app.session.member_id then
bsw@525 89 execute.view{
bsw@525 90 module = "interest",
bsw@525 91 view = "_show_box",
bsw@525 92 params = { issue = issue, initiative = initiative }
bsw@525 93 }
bsw@525 94 slot.put(" · ")
bsw@525 95 end
bsw@525 96
bsw@525 97 if config.issue_discussion_url_func then
bsw@525 98 local url = config.issue_discussion_url_func(issue)
bsw@525 99 ui.link{
bsw@525 100 attr = { target = "_blank" },
bsw@525 101 external = url,
bsw@525 102 content = _"Discussion on issue"
bsw@525 103 }
bsw@525 104 slot.put(" · ")
bsw@525 105 end
bsw@525 106
bsw@525 107 if config.etherpad and app.session.member then
bsw@525 108 ui.link{
bsw@525 109 attr = { target = "_blank" },
bsw@525 110 external = issue.etherpad_url,
bsw@525 111 content = _"Issue pad"
bsw@525 112 }
bsw@525 113 slot.put(" · ")
bsw@525 114 end
bsw@525 115
bsw@525 116
bsw@525 117 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
bsw@525 118 if not issue.fully_frozen and not issue.closed then
bsw@525 119 ui.link{
bsw@525 120 attr = { class = "action" },
bsw@525 121 text = _"Create alternative initiative",
bsw@525 122 module = "initiative",
bsw@525 123 view = "new",
bsw@525 124 params = { issue_id = issue.id }
bsw@525 125 }
bsw@525 126 end
bsw@525 127 end
bsw@525 128
bsw@525 129 end }
bsw@525 130
bsw@525 131 if not for_listing then
bsw@525 132
bsw@525 133 if voteable then
bsw@525 134 ui.container{
bsw@525 135 attr = { class = "voting_active_info" },
bsw@525 136 content = function()
bsw@525 137 slot.put(_"Voting for this issue is currently running!")
bsw@525 138 slot.put(" ")
bsw@525 139 if app.session.member_id then
bsw@525 140 ui.link{
bsw@525 141 content = vote_link_text,
bsw@525 142 module = "vote",
bsw@525 143 view = "list",
bsw@525 144 params = { issue_id = issue.id }
bsw@525 145 }
bsw@525 146 end
bsw@525 147 end
bsw@525 148 }
bsw@525 149 end
bsw@525 150
bsw@525 151 end
bsw@525 152
bsw@525 153 ui.container{ attr = { class = "initiative_list" }, content = function()
bsw@525 154
bsw@525 155 local initiatives_selector = issue:get_reference_selector("initiatives")
bsw@525 156 local highlight_string = param.get("highlight_string")
bsw@525 157 if highlight_string then
bsw@525 158 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
bsw@525 159 end
bsw@525 160 execute.view{
bsw@525 161 module = "initiative",
bsw@525 162 view = "_list",
bsw@525 163 params = {
bsw@525 164 issue = issue,
bsw@525 165 initiatives_selector = initiatives_selector,
bsw@525 166 highlight_string = highlight_string,
bsw@525 167 per_page = initiative_limit,
bsw@525 168 no_sort = true,
bsw@525 169 limit = initiative_limit,
bsw@525 170 for_member = for_member
bsw@525 171 }
bsw@525 172 }
bsw@525 173 end }
bsw@525 174 end }
bsw@525 175

Impressum / About Us