liquid_feedback_frontend
annotate app/main/issue/_list.lua @ 127:4fb486bce608
add pageinator to issue view.
this "paginator" shows links to the prev/area/next issues that have the same
state then the current one. This helps a lot when inspecting new issues or voting.
The voting filter works a little bit different, as he also activtes the not_voted subfilter
because it is most likely only not voted issues are interessting to the user
this "paginator" shows links to the prev/area/next issues that have the same
state then the current one. This helps a lot when inspecting new issues or voting.
The voting filter works a little bit different, as he also activtes the not_voted subfilter
because it is most likely only not voted issues are interessting to the user
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Tue Oct 05 04:44:06 2010 +0200 (2010-10-05) |
parents | 733f65c0c0a0 |
children | 7196685f9dd7 |
rev | line source |
---|---|
bsw/jbe@0 | 1 local issues_selector = param.get("issues_selector", "table") |
bsw/jbe@0 | 2 |
bsw@51 | 3 if app.session.member_id then |
bsw@51 | 4 issues_selector |
bsw@51 | 5 :left_join("interest", "_interest", { "_interest.issue_id = issue.id AND _interest.member_id = ?", app.session.member.id} ) |
bsw@51 | 6 :add_field("(_interest.member_id NOTNULL)", "is_interested") |
bsw@51 | 7 end |
bsw@11 | 8 |
bsw/jbe@19 | 9 ui.add_partial_param_names{ |
bsw/jbe@19 | 10 "filter", |
bsw/jbe@19 | 11 "filter_open", |
bsw/jbe@19 | 12 "filter_voting", |
bsw/jbe@19 | 13 "filter_interest", |
bsw/jbe@19 | 14 "issue_list" |
bsw/jbe@19 | 15 } |
bsw/jbe@0 | 16 |
poelzi@127 | 17 local filters = execute.load_chunk{module="issue", chunk="_filters.lua"} |
bsw/jbe@19 | 18 |
bsw/jbe@19 | 19 filters.content = function() |
bsw/jbe@19 | 20 local ui_paginate = ui.paginate |
bsw/jbe@19 | 21 if param.get("per_page") == "all" then |
bsw/jbe@19 | 22 ui_paginate = function(args) args.content() end |
bsw/jbe@19 | 23 end |
bsw/jbe@19 | 24 ui_paginate{ |
bsw/jbe@19 | 25 per_page = tonumber(param.get("per_page")), |
bsw/jbe@19 | 26 selector = issues_selector, |
bsw/jbe@19 | 27 content = function() |
bsw/jbe@19 | 28 local highlight_string = param.get("highlight_string", "string") |
bsw/jbe@19 | 29 local issues = issues or issues_selector:exec() |
bsw/jbe@19 | 30 -- issues:load(initiatives) |
bsw/jbe@19 | 31 ui.list{ |
bsw/jbe@19 | 32 attr = { class = "issues" }, |
bsw/jbe@19 | 33 records = issues, |
bsw/jbe@19 | 34 columns = { |
bsw/jbe@19 | 35 { |
bsw/jbe@19 | 36 label = _"Issue", |
bsw/jbe@19 | 37 content = function(record) |
bsw/jbe@19 | 38 if not param.get("for_area_list", atom.boolean) then |
bsw/jbe@19 | 39 ui.field.text{ |
bsw/jbe@19 | 40 value = record.area.name |
bsw/jbe@19 | 41 } |
bsw/jbe@19 | 42 slot.put("<br />") |
bsw@11 | 43 end |
bsw/jbe@19 | 44 if record.is_interested then |
bsw/jbe@19 | 45 local label = _"You are interested in this issue", |
bsw/jbe@19 | 46 ui.image{ |
bsw/jbe@19 | 47 attr = { alt = label, title = label }, |
bsw/jbe@19 | 48 static = "icons/16/eye.png" |
bsw/jbe@5 | 49 } |
bsw/jbe@19 | 50 slot.put(" ") |
bsw/jbe@19 | 51 end |
bsw/jbe@19 | 52 ui.link{ |
bsw/jbe@19 | 53 text = _("Issue ##{id}", { id = tostring(record.id) }), |
bsw/jbe@19 | 54 module = "issue", |
bsw/jbe@19 | 55 view = "show", |
bsw/jbe@19 | 56 id = record.id |
bsw/jbe@19 | 57 } |
bsw/jbe@19 | 58 if record.state == "new" then |
bsw/jbe@19 | 59 ui.image{ |
bsw/jbe@19 | 60 static = "icons/16/new.png" |
bsw/jbe@5 | 61 } |
bsw/jbe@5 | 62 end |
bsw/jbe@19 | 63 slot.put("<br />") |
bsw/jbe@19 | 64 slot.put("<br />") |
bsw/jbe@19 | 65 if record.old_state then |
bsw/jbe@19 | 66 ui.field.text{ value = format.time(record.sort) } |
bsw/jbe@19 | 67 ui.field.text{ value = Issue:get_state_name_for_state(record.old_state) .. " > " .. Issue:get_state_name_for_state(record.new_state) } |
bsw/jbe@19 | 68 else |
bsw/jbe@19 | 69 end |
bsw/jbe@19 | 70 end |
bsw/jbe@19 | 71 }, |
bsw/jbe@19 | 72 { |
bsw/jbe@19 | 73 label = _"State", |
bsw/jbe@19 | 74 content = function(record) |
bsw/jbe@19 | 75 if record.state == "voting" then |
bsw/jbe@19 | 76 ui.link{ |
bsw/jbe@19 | 77 content = _"Voting", |
bsw/jbe@19 | 78 module = "vote", |
bsw/jbe@19 | 79 view = "list", |
bsw/jbe@19 | 80 params = { issue_id = record.id } |
bsw/jbe@19 | 81 } |
bsw/jbe@19 | 82 else |
bsw/jbe@19 | 83 ui.field.issue_state{ value = record.state } |
bsw/jbe@19 | 84 end |
bsw/jbe@19 | 85 end |
bsw/jbe@19 | 86 }, |
bsw/jbe@19 | 87 { |
bsw/jbe@19 | 88 label = _"Initiatives", |
bsw/jbe@19 | 89 content = function(record) |
bsw/jbe@19 | 90 local initiatives_selector = record:get_reference_selector("initiatives") |
bsw/jbe@19 | 91 local highlight_string = param.get("highlight_string") |
bsw/jbe@19 | 92 if highlight_string then |
bsw/jbe@19 | 93 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted") |
bsw/jbe@19 | 94 end |
bsw/jbe@19 | 95 execute.view{ |
bsw/jbe@19 | 96 module = "initiative", |
bsw/jbe@19 | 97 view = "_list", |
bsw/jbe@19 | 98 params = { |
bsw/jbe@19 | 99 issue = record, |
bsw/jbe@19 | 100 initiatives_selector = initiatives_selector, |
bsw/jbe@19 | 101 highlight_string = highlight_string, |
bsw@51 | 102 per_page = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3, |
bsw/jbe@19 | 103 no_sort = true, |
bsw@51 | 104 limit = app.session.member_id and tonumber(app.session.member:get_setting_value("initiatives_preview_limit") or 3) or 3 |
bsw/jbe@19 | 105 } |
bsw/jbe@19 | 106 } |
bsw/jbe@19 | 107 end |
bsw/jbe@19 | 108 }, |
bsw/jbe@0 | 109 } |
bsw/jbe@19 | 110 } |
bsw/jbe@19 | 111 end |
bsw/jbe@19 | 112 } |
bsw/jbe@19 | 113 end |
bsw/jbe@19 | 114 |
bsw/jbe@19 | 115 filters.selector = issues_selector |
bsw/jbe@19 | 116 filters.label = _"Change filters and order" |
bsw/jbe@19 | 117 |
bsw/jbe@19 | 118 if param.get("no_filter", atom.boolean) then |
bsw/jbe@19 | 119 filters.content() |
bsw/jbe@19 | 120 else |
bsw/jbe@19 | 121 ui.filters(filters) |
bsw/jbe@19 | 122 end |
bsw/jbe@19 | 123 |
bsw/jbe@19 | 124 if param.get("legend", atom.boolean) ~= false then |
bsw/jbe@19 | 125 local filter = param.get_all_cgi().filter |
bsw/jbe@19 | 126 if not filter or filter == "any" or filter ~= "finished" then |
bsw/jbe@19 | 127 ui.bargraph_legend{ |
bsw/jbe@19 | 128 width = 25, |
bsw/jbe@19 | 129 bars = { |
bsw/jbe@19 | 130 { color = "#0a0", label = _"Supporter" }, |
bsw/jbe@19 | 131 { color = "#777", label = _"Potential supporter" }, |
bsw/jbe@19 | 132 { color = "#ddd", label = _"No support at all" }, |
bsw/jbe@19 | 133 } |
bsw/jbe@0 | 134 } |
bsw/jbe@0 | 135 end |
bsw/jbe@19 | 136 if not filter or filter == "any" or filter == "finished" then |
bsw/jbe@19 | 137 ui.bargraph_legend{ |
bsw/jbe@19 | 138 width = 25, |
bsw/jbe@19 | 139 bars = { |
bsw/jbe@19 | 140 { color = "#0a0", label = _"Yes" }, |
bsw/jbe@19 | 141 { color = "#aaa", label = _"Abstention" }, |
bsw/jbe@19 | 142 { color = "#a00", label = _"No" }, |
bsw/jbe@19 | 143 } |
bsw/jbe@19 | 144 } |
bsw/jbe@19 | 145 end |
bsw/jbe@19 | 146 end |
bsw/jbe@19 | 147 |