# HG changeset patch # User Daniel Poelzleithner # Date 1286381723 -7200 # Node ID 7c3e8a1678fc61734d908853512d40675230a041 # Parent a33abf457d29e4a91d4b5ec4a8ab44b304e5e468 fix timeline saved filters add Members:set_setting_map code check for empty name update settings when saved under same name fixes bug #305 diff -r a33abf457d29 -r 7c3e8a1678fc app/main/timeline/_action/save.lua --- a/app/main/timeline/_action/save.lua Wed Oct 06 16:35:33 2010 +0200 +++ b/app/main/timeline/_action/save.lua Wed Oct 06 18:15:23 2010 +0200 @@ -8,12 +8,16 @@ local subkey = param.get("name") -setting_map = SettingMap:new() -setting_map.member_id = app.session.member.id -setting_map.key = "timeline_filters" -setting_map.subkey = subkey -setting_map.value = options_string -setting_map:save() +if not subkey or subkey == "" then + slot.put_into("error", _"This name is really too short!") + request.redirect{ + module = "timeline", + view = "save_filter", + } + return +end + +app.session.member:set_setting_map("timeline_filters", subkey, options_string) local timeline_params = {} if options_string then diff -r a33abf457d29 -r 7c3e8a1678fc app/main/timeline/_action/update.lua --- a/app/main/timeline/_action/update.lua Wed Oct 06 16:35:33 2010 +0200 +++ b/app/main/timeline/_action/update.lua Wed Oct 06 18:15:23 2010 +0200 @@ -48,7 +48,6 @@ end local date = param.get("date") -trace.debug(param.get("search_from")) if param.get("search_from") == "last_24h" then date = "last_24h" @@ -95,7 +94,10 @@ if param.get("save", atom.boolean) then request.redirect{ module = "timeline", - view = "save_filter" + view = "save_filter", + params = { + current_name = param.get("current_name") + } } else request.redirect{ diff -r a33abf457d29 -r 7c3e8a1678fc app/main/timeline/index.lua --- a/app/main/timeline/index.lua Wed Oct 06 16:35:33 2010 +0200 +++ b/app/main/timeline/index.lua Wed Oct 06 18:15:23 2010 +0200 @@ -3,6 +3,7 @@ view = "_constants" } +local active_name = "" local options_box_count = param.get("options_box_count", atom.number) or 1 if options_box_count > 10 then options_box_count = 10 @@ -36,6 +37,7 @@ local name = setting_map.subkey if options_string == current_options then active = true + active_name = name end ui.link{ image = { static = "icons/16/time.png" }, @@ -65,6 +67,9 @@ end, module = "timeline", view = "save_filter", + params = { + current_name = active_name + }, attr = { onclick = "el=document.getElementById('timeline_save');el.checked=true;el.form.submit();return(false);" } @@ -77,7 +82,6 @@ module = "timeline", action = "update", content = function() - ui.container{ content = function() @@ -164,7 +168,7 @@ name = "show_options", value = param.get("show_options", atom.boolean) } - + ui.hidden_field{ name = "current_name", value = active_name } ui.field.boolean{ attr = { id = "timeline_save", style = "display: none;", onchange="this.form.submit();" }, name = "save", diff -r a33abf457d29 -r 7c3e8a1678fc app/main/timeline/save_filter.lua --- a/app/main/timeline/save_filter.lua Wed Oct 06 16:35:33 2010 +0200 +++ b/app/main/timeline/save_filter.lua Wed Oct 06 18:15:23 2010 +0200 @@ -19,6 +19,7 @@ ui.field.text{ label = _"Name", name = "name", + value = param.get("current_name") } ui.submit{ text = _"Save" diff -r a33abf457d29 -r 7c3e8a1678fc model/member.lua --- a/model/member.lua Wed Oct 06 16:35:33 2010 +0200 +++ b/model/member.lua Wed Oct 06 18:15:23 2010 +0200 @@ -357,7 +357,15 @@ end function Member.object:set_setting_map(key, subkey, value) - + setting_map = self:get_setting_map_by_key_and_subkey(key, subkey) + if not setting_map then + setting_map = SettingMap:new() + setting_map.member_id = self.id + setting_map.key = key + setting_map.subkey = subkey + end + setting_map.value = value + setting_map:save() end function Member.object_get:notify_email_locked()