liquid_feedback_frontend
view app/main/timeline/_list.lua @ 145:90520c9fca44
implement area filter in timeline
allows the user to ignore any area in the timeline filter.
better display in javascript off
allows the user to ignore any area in the timeline filter.
better display in javascript off
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Thu Oct 07 00:35:48 2010 +0200 (2010-10-07) |
parents | 166fd10c7e81 |
children | d37dce888225 |
line source
1 local timeline_selector = param.get("timeline_selector", "table")
2 local event_names = param.get("event_names", "table")
3 local initiatives_per_page = param.get("initiatives_per_page", atom.number) or 3
6 -- test if selector is valid
7 local test_selector = timeline_selector:get_db_conn():new_selector()
8 test_selector:add_field('count(1)')
9 test_selector:add_from(timeline_selector)
10 test_selector:single_object_mode()
12 err, x = test_selector:try_exec()
14 if err then
15 slot.put_into("error", _"Invalid query")
16 else
17 ui.paginate{
18 per_page = param.get("per_page", atom.number) or 25,
19 selector = timeline_selector,
20 container_attr = { class = "ui_paginate timeline_results" },
21 content = function()
22 local timelines = timeline_selector:exec()
23 timelines:load("issue")
24 timelines:load("initiative")
25 timelines:load("member")
26 ui.list{
27 attr = { class = "nohover" },
28 records = timelines,
29 columns = {
30 {
31 field_attr = { style = "width: 10em;" },
32 content = function(timeline)
33 ui.field.text{
34 attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"},
35 value = format.time(timeline.occurrence)
36 }
38 ui.field.text{
39 attr = { style = "font-size: 75%; font-weight: bold;"},
40 value = event_names[timeline.event] or timeline.event
41 }
42 if timeline.event == "draft_created" and timeline.count > 1 then
43 ui.field.text{
44 attr = { style = "font-size: 75%;"},
45 value = _("(#{more_count} duplicates removed)", { more_count = timeline.count - 1 })
46 }
47 end
48 end
49 },
50 {
51 content = function(timeline)
52 local issue
53 local initiative
54 if timeline.issue then
55 issue = timeline.issue
56 elseif timeline.initiative then
57 initiative = timeline.initiative
58 issue = initiative.issue
59 elseif timeline.draft then
60 initiative = timeline.draft.initiative
61 issue = initiative.issue
62 elseif timeline.suggestion then
63 initiative = timeline.suggestion.initiative
64 issue = initiative.issue
65 end
66 if issue then
67 if timeline.is_interested then
68 local label = _"You are interested in this issue",
69 ui.image{
70 attr = { alt = label, title = label, style = "float: left; margin-right: 0.5em;" },
71 static = "icons/16/eye.png"
72 }
73 end
74 slot.put(" ")
75 ui.tag{
76 tag = "span",
77 attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"},
78 content = issue.area.name .. ", " .. _("Issue ##{id}", { id = issue.id })
79 }
80 else
81 ui.tag{
82 tag = "span",
83 attr = { style = "font-size: 75%; background-color: #ccc; display: block; margin-bottom: 1ex;"},
84 content = function() slot.put(" ") end
85 }
86 end
88 if timeline.member then
89 execute.view{
90 module = "member_image",
91 view = "_show",
92 params = {
93 member = timeline.member,
94 image_type = "avatar",
95 show_dummy = true
96 }
97 }
98 ui.link{
99 content = timeline.member.name,
100 module = "member",
101 view = "show",
102 id = timeline.member.id
103 }
104 end
105 if timeline.issue then
106 local initiatives_selector = timeline.issue
107 :get_reference_selector("initiatives")
108 execute.view{
109 module = "initiative",
110 view = "_list",
111 params = {
112 issue = timeline.issue,
113 initiatives_selector = initiatives_selector,
114 per_page = initiatives_per_page,
115 no_sort = true,
116 limit = initiatives_per_page
117 }
118 }
119 elseif initiative then
120 execute.view{
121 module = "initiative",
122 view = "_list",
123 params = {
124 issue = initiative.issue,
125 initiatives_selector = Initiative:new_selector():add_where{ "initiative.id = ?", initiative.id },
126 per_page = initiatives_per_page,
127 no_sort = true
128 }
129 }
130 end
131 if timeline.suggestion then
132 ui.link{
133 module = "suggestion",
134 view = "show",
135 id = timeline.suggestion.id,
136 content = timeline.suggestion.name
137 }
138 end
139 end
140 },
141 }
142 }
143 end
144 }
145 end