liquid_feedback_frontend
view app/main/timeline/_action/update.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 | 7c3e8a1678fc |
children | 3d0b6f87d8e5 |
line source
1 execute.view{
2 module = "timeline",
3 view = "_constants"
4 }
6 local options_string = param.get("options_string")
8 if not options_string then
9 local active_options = ""
10 for event_ident, event_name in pairs(event_names) do
11 if param.get("option_" .. event_ident, atom.boolean) then
12 active_options = active_options .. event_ident .. ":"
13 local filter_idents = {}
14 for filter_ident, filter_name in pairs(filter_names) do
15 if param.get("option_" .. event_ident .. "_" .. filter_ident, atom.boolean) then
16 filter_idents[#filter_idents+1] = filter_ident
17 end
18 end
19 if #filter_idents > 0 then
20 active_options = active_options .. table.concat(filter_idents, "|") .. " "
21 else
22 active_options = active_options .. "* "
23 end
24 end
25 end
26 if #active_options > 0 then
27 options_string = active_options
28 end
29 end
31 if param.get_list("option_ignore_area", atom.string) then
32 options_string = options_string.." ignore_area:"..table.concat(param.get_list("option_ignore_area", atom.string), "|")
33 end
35 if not options_string then
36 options_string = "issue_created:* issue_finished_after_voting:* issue_accepted:* issue_voting_started:* suggestion_created:* issue_canceled:* initiative_created:* issue_finished_without_voting:* draft_created:* initiative_revoked:* issue_half_frozen:* "
37 end
39 local setting_key = "liquidfeedback_frontend_timeline_current_options"
40 local setting = Setting:by_pk(app.session.member.id, setting_key)
42 if not setting or setting.value ~= options_string then
43 if not setting then
44 setting = Setting:new()
45 setting.member_id = app.session.member_id
46 setting.key = setting_key
47 end
48 if options_string then
49 setting.value = options_string
50 setting:save()
51 end
52 end
54 local date = param.get("date")
56 if param.get("search_from") == "last_24h" then
57 date = "last_24h"
58 end
60 if date and #date > 0 then
61 local setting_key = "liquidfeedback_frontend_timeline_current_date"
62 local setting = Setting:by_pk(app.session.member.id, setting_key)
63 if not setting or setting.value ~= date then
64 if not setting then
65 setting = Setting:new()
66 setting.member_id = app.session.member.id
67 setting.key = setting_key
68 end
69 setting.value = date
70 setting:save()
71 end
72 end
74 local setting_key = "liquidfeedback_frontend_timeline_current_options"
75 local setting = Setting:by_pk(app.session.member.id, setting_key)
77 local timeline_params = {}
78 if setting and setting.value then
79 for event_ident, filter_idents in setting.value:gmatch("(%S+):(%S+)") do
80 timeline_params["option_" .. event_ident] = true
81 if filter_idents ~= "*" then
82 for filter_ident in filter_idents:gmatch("([^\|]+)") do
83 timeline_params["option_" .. event_ident .. "_" .. filter_ident] = true
84 end
85 end
86 end
87 end
89 local setting_key = "liquidfeedback_frontend_timeline_current_date"
90 local setting = Setting:by_pk(app.session.member.id, setting_key)
92 if setting then
93 timeline_params.date = setting.value
94 end
96 timeline_params.show_options = param.get("show_options", atom.boolean)
98 if param.get("save", atom.boolean) then
99 request.redirect{
100 module = "timeline",
101 view = "save_filter",
102 params = {
103 current_name = param.get("current_name")
104 }
105 }
106 else
107 request.redirect{
108 module = "timeline",
109 view = "index",
110 params = timeline_params
111 }
112 end