liquid_feedback_frontend
view app/main/timeline/_action/update.lua @ 144:7c3e8a1678fc
fix timeline saved filters
add Members:set_setting_map code
check for empty name
update settings when saved under same name
fixes bug #305
add Members:set_setting_map code
check for empty name
update settings when saved under same name
fixes bug #305
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Wed Oct 06 18:15:23 2010 +0200 (2010-10-06) |
parents | 00d1004545f1 |
children | 90520c9fca44 |
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 not options_string then
32 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:* "
33 end
35 local setting_key = "liquidfeedback_frontend_timeline_current_options"
36 local setting = Setting:by_pk(app.session.member.id, setting_key)
38 if not setting or setting.value ~= options_string then
39 if not setting then
40 setting = Setting:new()
41 setting.member_id = app.session.member_id
42 setting.key = setting_key
43 end
44 if options_string then
45 setting.value = options_string
46 setting:save()
47 end
48 end
50 local date = param.get("date")
52 if param.get("search_from") == "last_24h" then
53 date = "last_24h"
54 end
56 if date and #date > 0 then
57 local setting_key = "liquidfeedback_frontend_timeline_current_date"
58 local setting = Setting:by_pk(app.session.member.id, setting_key)
59 if not setting or setting.value ~= date then
60 if not setting then
61 setting = Setting:new()
62 setting.member_id = app.session.member.id
63 setting.key = setting_key
64 end
65 setting.value = date
66 setting:save()
67 end
68 end
70 local setting_key = "liquidfeedback_frontend_timeline_current_options"
71 local setting = Setting:by_pk(app.session.member.id, setting_key)
73 local timeline_params = {}
74 if setting and setting.value then
75 for event_ident, filter_idents in setting.value:gmatch("(%S+):(%S+)") do
76 timeline_params["option_" .. event_ident] = true
77 if filter_idents ~= "*" then
78 for filter_ident in filter_idents:gmatch("([^\|]+)") do
79 timeline_params["option_" .. event_ident .. "_" .. filter_ident] = true
80 end
81 end
82 end
83 end
85 local setting_key = "liquidfeedback_frontend_timeline_current_date"
86 local setting = Setting:by_pk(app.session.member.id, setting_key)
88 if setting then
89 timeline_params.date = setting.value
90 end
92 timeline_params.show_options = param.get("show_options", atom.boolean)
94 if param.get("save", atom.boolean) then
95 request.redirect{
96 module = "timeline",
97 view = "save_filter",
98 params = {
99 current_name = param.get("current_name")
100 }
101 }
102 else
103 request.redirect{
104 module = "timeline",
105 view = "index",
106 params = timeline_params
107 }
108 end