liquid_feedback_frontend

annotate app/main/initiative/_list.lua @ 24:81586ea68d57

Minor bugfixes

app/main/initiative/_list.lua:
Replaced single by optional object mode

locale/translations.de.lua:
Consistent translation

app/main/initiative/_show.lua:
Added missing case "not approved" in voting info box

app/main/initiative/_show_voting.lua:
Added link to initiative

app/main/initiative/_show_voting.lua:
Added missing argument for link

app/main/member/show_tab.lua:
Added outgoing argument to show outgoing delegations correctly
author bsw
date Sun Feb 21 14:09:11 2010 +0100 (2010-02-21)
parents 00d1004545f1
children 0849be391140
rev   line source
bsw/jbe@19 1 ui.script{ script = "lf_initiative_expanded = {};" }
bsw@11 2
bsw/jbe@0 3 local issue = param.get("issue", "table")
bsw/jbe@0 4
bsw/jbe@19 5 local initiatives_selector = param.get("initiatives_selector", "table")
bsw@11 6 initiatives_selector
bsw/jbe@19 7 :join("issue", nil, "issue.id = initiative.issue_id")
bsw@11 8 :left_join("initiator", "_initiator", { "_initiator.initiative_id = initiative.id AND _initiator.member_id = ?", app.session.member.id} )
bsw@11 9 :left_join("supporter", "_supporter", { "_supporter.initiative_id = initiative.id AND _supporter.member_id = ?", app.session.member.id} )
bsw@11 10
bsw@11 11 :add_field("(_initiator.member_id NOTNULL)", "is_initiator")
bsw@11 12 :add_field({"(_supporter.member_id NOTNULL) AND NOT EXISTS(SELECT 1 FROM opinion WHERE opinion.initiative_id = initiative.id AND opinion.member_id = ? AND ((opinion.degree = 2 AND NOT fulfilled) OR (opinion.degree = -2 AND fulfilled)))", app.session.member.id }, "is_supporter")
bsw@11 13 :add_field({"EXISTS(SELECT 1 FROM opinion WHERE opinion.initiative_id = initiative.id AND opinion.member_id = ? AND ((opinion.degree = 2 AND NOT fulfilled) OR (opinion.degree = -2 AND fulfilled)))", app.session.member.id }, "is_potential_supporter")
bsw@11 14
bsw/jbe@19 15 local initiatives_count = initiatives_selector:count()
bsw@11 16
bsw/jbe@19 17 local limit = param.get("limit", atom.number)
bsw/jbe@19 18 local no_sort = param.get("no_sort", atom.boolean)
bsw/jbe@19 19
bsw/jbe@19 20 local show_for_issue = param.get("show_for_issue", atom.boolean)
bsw/jbe@19 21
bsw/jbe@19 22 local show_for_initiative
bsw/jbe@19 23
bsw/jbe@19 24 local show_for_initiative_id = param.get("for_initiative_id", atom.number)
bsw/jbe@19 25
bsw/jbe@19 26 if show_for_initiative_id then
bsw/jbe@19 27 show_for_initiative = Initiative:by_id(show_for_initiative_id)
bsw/jbe@19 28
bsw/jbe@19 29 elseif not show_for_initiative_id and show_for_issue and issue and issue.ranks_available then
bsw/jbe@19 30 winning_initiative = Initiative:new_selector()
bsw/jbe@19 31 :add_where{ "issue_id = ?", issue.id }
bsw/jbe@19 32 :add_where("rank = 1")
bsw@24 33 :optional_object_mode()
bsw/jbe@19 34 :exec()
bsw/jbe@19 35 if winning_initiative then
bsw/jbe@19 36 show_for_initiative = winning_initiative
bsw/jbe@19 37 ui.container{
bsw/jbe@19 38 attr = { class = "admitted_info" },
bsw/jbe@19 39 content = _"This issue has been finished with the following winning initiative:"
bsw/jbe@19 40 }
bsw/jbe@19 41 else
bsw/jbe@19 42 ui.container{
bsw/jbe@19 43 attr = { class = "not_admitted_info" },
bsw/jbe@19 44 content = _"This issue has been finished without any winning initiative."
bsw/jbe@19 45 }
bsw/jbe@19 46 end
bsw/jbe@19 47 end
bsw/jbe@19 48
bsw/jbe@19 49
bsw/jbe@19 50 if show_for_initiative then
bsw/jbe@19 51 ui.script{ script = "lf_initiative_expanded['initiative_content_" .. tostring(show_for_initiative.id) .. "'] = true;" }
bsw/jbe@19 52 initiatives_selector:add_where{ "initiative.id != ?", show_for_initiative.id }
bsw/jbe@19 53
bsw/jbe@19 54 execute.view{
bsw/jbe@19 55 module = "initiative",
bsw/jbe@19 56 view = "_list_element",
bsw/jbe@19 57 params = {
bsw/jbe@19 58 initiative = show_for_initiative,
bsw/jbe@19 59 expanded = true,
bsw/jbe@19 60 expandable = true
bsw/jbe@19 61 }
bsw/jbe@19 62 }
bsw/jbe@19 63 if show_for_issue then
bsw/jbe@19 64 slot.put("<br />")
bsw/jbe@19 65 ui.container{
bsw/jbe@19 66 attr = { style = "font-weight: bold;" },
bsw/jbe@0 67 content = function()
bsw/jbe@19 68 slot.put(_"Alternative initiatives")
bsw/jbe@0 69 end
bsw/jbe@0 70 }
bsw/jbe@0 71 end
bsw/jbe@19 72 elseif show_for_issue then
bsw/jbe@19 73 ui.container{
bsw/jbe@19 74 attr = { style = "font-weight: bold;" },
bsw/jbe@19 75 content = function()
bsw/jbe@19 76 slot.put(_"Alternative initiatives")
bsw/jbe@19 77 end
bsw@11 78 }
bsw@11 79 end
bsw/jbe@19 80
bsw/jbe@19 81 if not show_for_initiative or initiatives_count > 1 then
bsw/jbe@19 82
bsw/jbe@19 83
bsw/jbe@19 84 local more_initiatives_count
bsw/jbe@19 85 if limit then
bsw/jbe@19 86 limit = limit - (show_for_initiative and 1 or 0)
bsw/jbe@19 87 if initiatives_count > limit then
bsw/jbe@19 88 more_initiatives_count = initiatives_count - limit
bsw/jbe@19 89 end
bsw/jbe@19 90 initiatives_selector:limit(limit)
bsw/jbe@19 91 end
bsw/jbe@19 92
bsw/jbe@19 93 local expandable = param.get("expandable", atom.boolean)
bsw/jbe@19 94
bsw/jbe@19 95 local issue = param.get("issue", "table")
bsw/jbe@19 96
bsw/jbe@19 97 local name = "initiative_list"
bsw/jbe@19 98 if issue then
bsw/jbe@19 99 name = "issue_" .. tostring(issue.id) .. "_initiative_list"
bsw/jbe@19 100 end
bsw/jbe@19 101
bsw/jbe@19 102 ui.add_partial_param_names{ name }
bsw/jbe@19 103
bsw/jbe@19 104 local order_filter = {
bsw/jbe@19 105 name = name,
bsw/jbe@19 106 label = _"Order by"
bsw/jbe@19 107 }
bsw/jbe@19 108
bsw/jbe@19 109 if issue and issue.ranks_available then
bsw/jbe@19 110 order_filter[#order_filter+1] = {
bsw/jbe@19 111 name = "rank",
bsw/jbe@19 112 label = _"Rank",
bsw/jbe@19 113 selector_modifier = function(selector) selector:add_order_by("initiative.rank, initiative.admitted DESC, vote_ratio(initiative.positive_votes, initiative.negative_votes) DESC, initiative.id") end
bsw/jbe@19 114 }
bsw/jbe@19 115 end
bsw/jbe@19 116
bsw/jbe@19 117 order_filter[#order_filter+1] = {
bsw/jbe@19 118 name = "potential_support",
bsw/jbe@19 119 label = _"Potential support",
bsw/jbe@19 120 selector_modifier = function(selector) selector:add_order_by("initiative.supporter_count::float / issue.population::float DESC, initiative.id") end
bsw/jbe@19 121 }
bsw/jbe@19 122
bsw/jbe@19 123 order_filter[#order_filter+1] = {
bsw/jbe@19 124 name = "support",
bsw/jbe@19 125 label = _"Support",
bsw/jbe@19 126 selector_modifier = function(selector) selector:add_order_by("initiative.satisfied_supporter_count::float / issue.population::float DESC, initiative.id") end
bsw/jbe@19 127 }
bsw/jbe@19 128
bsw/jbe@19 129 order_filter[#order_filter+1] = {
bsw/jbe@19 130 name = "newest",
bsw/jbe@19 131 label = _"Newest",
bsw/jbe@19 132 selector_modifier = function(selector) selector:add_order_by("initiative.created DESC, initiative.id") end
bsw/jbe@19 133 }
bsw/jbe@19 134
bsw/jbe@19 135 order_filter[#order_filter+1] = {
bsw/jbe@19 136 name = "oldest",
bsw/jbe@19 137 label = _"Oldest",
bsw/jbe@19 138 selector_modifier = function(selector) selector:add_order_by("initiative.created, initiative.id") end
bsw/jbe@19 139 }
bsw/jbe@19 140
bsw/jbe@19 141 ui_filters = ui.filters
bsw/jbe@19 142
bsw/jbe@19 143 if no_sort then
bsw/jbe@19 144 ui_filters = function(args) args.content() end
bsw/jbe@19 145 if issue.ranks_available then
bsw/jbe@19 146 initiatives_selector:add_order_by("initiative.rank, initiative.admitted DESC, vote_ratio(initiative.positive_votes, initiative.negative_votes) DESC, initiative.id")
bsw/jbe@19 147 else
bsw/jbe@19 148 initiatives_selector:add_order_by("initiative.supporter_count::float / issue.population::float DESC, initiative.id")
bsw/jbe@19 149 end
bsw/jbe@19 150 end
bsw/jbe@19 151
bsw/jbe@19 152 ui_filters{
bsw/jbe@19 153 label = _"Change order",
bsw/jbe@19 154 order_filter,
bsw/jbe@19 155 selector = initiatives_selector,
bsw/jbe@19 156 content = function()
bsw/jbe@19 157 ui.paginate{
bsw/jbe@19 158 name = issue and "issue_" .. tostring(issue.id) .. "_page" or nil,
bsw/jbe@19 159 selector = initiatives_selector,
bsw/jbe@19 160 per_page = param.get("per_page", atom.number),
bsw/jbe@19 161 content = function()
bsw/jbe@19 162 local initiatives = initiatives_selector:exec()
bsw/jbe@19 163 for i, initiative in ipairs(initiatives) do
bsw/jbe@19 164 local expanded = config.user_tab_mode == "accordeon_all_expanded" and expandable or
bsw/jbe@19 165 show_for_initiative and initiative.id == show_for_initiative.id
bsw/jbe@19 166 if expanded then
bsw/jbe@19 167 ui.script{ script = "lf_initiative_expanded['initiative_content_" .. tostring(initiative.id) .. "'] = true;" }
bsw/jbe@19 168 end
bsw/jbe@19 169 execute.view{
bsw/jbe@19 170 module = "initiative",
bsw/jbe@19 171 view = "_list_element",
bsw/jbe@19 172 params = {
bsw/jbe@19 173 initiative = initiative,
bsw/jbe@19 174 expanded = expanded,
bsw/jbe@19 175 expandable = expandable
bsw/jbe@19 176 }
bsw/jbe@19 177 }
bsw/jbe@19 178 end
bsw/jbe@19 179 end
bsw/jbe@19 180 }
bsw/jbe@19 181 end
bsw/jbe@19 182 }
bsw/jbe@19 183
bsw/jbe@19 184 if more_initiatives_count then
bsw/jbe@19 185 ui.link{
bsw/jbe@19 186 attr = { style = "font-size: 75%; font-style: italic;" },
bsw/jbe@19 187 content = _("and #{count} more initiatives", { count = more_initiatives_count }),
bsw/jbe@19 188 module = "issue",
bsw/jbe@19 189 view = "show",
bsw/jbe@19 190 id = issue.id,
bsw/jbe@19 191 }
bsw/jbe@19 192 end
bsw/jbe@19 193
bsw/jbe@19 194 end
bsw/jbe@19 195
bsw/jbe@19 196 if show_for_issue then
bsw/jbe@19 197 slot.put("<br />")
bsw/jbe@19 198
bsw/jbe@19 199 if issue and initiatives_count == 1 then
bsw/jbe@19 200 ui.container{
bsw/jbe@19 201 content = function()
bsw/jbe@19 202 if issue.fully_frozen or issue.closed then
bsw/jbe@19 203 slot.put(_"There were no more alternative initiatives.")
bsw/jbe@19 204 else
bsw/jbe@19 205 slot.put(_"There are no more alternative initiatives currently.")
bsw/jbe@19 206 end
bsw/jbe@19 207 end
bsw/jbe@19 208 }
bsw/jbe@19 209 end
bsw/jbe@19 210
bsw/jbe@19 211 if not (issue.fully_frozen or issue.closed) then
bsw/jbe@19 212 slot.put(" ")
bsw/jbe@19 213 ui.link{
bsw/jbe@19 214 content = function()
bsw/jbe@19 215 ui.image{ static = "icons/16/script_add.png" }
bsw/jbe@19 216 slot.put(" ")
bsw/jbe@19 217 slot.put(_"Create alternative initiative")
bsw/jbe@19 218 end,
bsw/jbe@19 219 module = "initiative",
bsw/jbe@19 220 view = "new",
bsw/jbe@19 221 params = { issue_id = issue.id }
bsw/jbe@19 222 }
bsw/jbe@19 223 end
bsw/jbe@19 224 end

Impressum / About Us