liquid_feedback_frontend

changeset 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
author Daniel Poelzleithner <poelzi@poelzi.org>
date Wed Oct 06 18:15:23 2010 +0200 (2010-10-06)
parents a33abf457d29
children 90520c9fca44
files app/main/timeline/_action/save.lua app/main/timeline/_action/update.lua app/main/timeline/index.lua app/main/timeline/save_filter.lua model/member.lua
line diff
     1.1 --- a/app/main/timeline/_action/save.lua	Wed Oct 06 16:35:33 2010 +0200
     1.2 +++ b/app/main/timeline/_action/save.lua	Wed Oct 06 18:15:23 2010 +0200
     1.3 @@ -8,12 +8,16 @@
     1.4  
     1.5  local subkey = param.get("name")
     1.6  
     1.7 -setting_map = SettingMap:new()
     1.8 -setting_map.member_id = app.session.member.id
     1.9 -setting_map.key = "timeline_filters"
    1.10 -setting_map.subkey = subkey
    1.11 -setting_map.value = options_string
    1.12 -setting_map:save()
    1.13 +if not subkey or subkey == "" then
    1.14 +  slot.put_into("error", _"This name is really too short!")
    1.15 +  request.redirect{
    1.16 +    module = "timeline",
    1.17 +    view = "save_filter",
    1.18 +  }
    1.19 +  return
    1.20 +end
    1.21 +
    1.22 +app.session.member:set_setting_map("timeline_filters", subkey, options_string)
    1.23  
    1.24  local timeline_params = {}
    1.25  if options_string then
     2.1 --- a/app/main/timeline/_action/update.lua	Wed Oct 06 16:35:33 2010 +0200
     2.2 +++ b/app/main/timeline/_action/update.lua	Wed Oct 06 18:15:23 2010 +0200
     2.3 @@ -48,7 +48,6 @@
     2.4  end
     2.5  
     2.6  local date = param.get("date")
     2.7 -trace.debug(param.get("search_from"))
     2.8  
     2.9  if param.get("search_from") == "last_24h" then
    2.10    date = "last_24h"
    2.11 @@ -95,7 +94,10 @@
    2.12  if param.get("save", atom.boolean) then
    2.13    request.redirect{
    2.14      module = "timeline",
    2.15 -    view = "save_filter"
    2.16 +    view = "save_filter",
    2.17 +    params = {
    2.18 +      current_name = param.get("current_name")
    2.19 +    }
    2.20    }
    2.21  else
    2.22    request.redirect{
     3.1 --- a/app/main/timeline/index.lua	Wed Oct 06 16:35:33 2010 +0200
     3.2 +++ b/app/main/timeline/index.lua	Wed Oct 06 18:15:23 2010 +0200
     3.3 @@ -3,6 +3,7 @@
     3.4    view = "_constants"
     3.5  }
     3.6  
     3.7 +local active_name = ""
     3.8  local options_box_count = param.get("options_box_count", atom.number) or 1
     3.9  if options_box_count > 10 then
    3.10    options_box_count = 10
    3.11 @@ -36,6 +37,7 @@
    3.12      local name = setting_map.subkey
    3.13      if options_string == current_options then
    3.14        active = true
    3.15 +      active_name = name
    3.16      end
    3.17      ui.link{
    3.18        image  = { static = "icons/16/time.png" },
    3.19 @@ -65,6 +67,9 @@
    3.20      end,
    3.21      module = "timeline",
    3.22      view = "save_filter",
    3.23 +    params = {
    3.24 +      current_name = active_name
    3.25 +    },
    3.26      attr = { 
    3.27        onclick = "el=document.getElementById('timeline_save');el.checked=true;el.form.submit();return(false);"
    3.28      }
    3.29 @@ -77,7 +82,6 @@
    3.30    module = "timeline",
    3.31    action = "update",
    3.32    content = function()
    3.33 -
    3.34      ui.container{
    3.35  
    3.36        content = function()
    3.37 @@ -164,7 +168,7 @@
    3.38            name = "show_options",
    3.39            value = param.get("show_options", atom.boolean)
    3.40          }
    3.41 -
    3.42 +        ui.hidden_field{ name = "current_name", value = active_name }
    3.43          ui.field.boolean{
    3.44            attr = { id = "timeline_save", style = "display: none;", onchange="this.form.submit();" },
    3.45            name = "save",
     4.1 --- a/app/main/timeline/save_filter.lua	Wed Oct 06 16:35:33 2010 +0200
     4.2 +++ b/app/main/timeline/save_filter.lua	Wed Oct 06 18:15:23 2010 +0200
     4.3 @@ -19,6 +19,7 @@
     4.4      ui.field.text{
     4.5        label = _"Name",
     4.6        name = "name",
     4.7 +      value = param.get("current_name")
     4.8      }
     4.9      ui.submit{
    4.10        text = _"Save"
     5.1 --- a/model/member.lua	Wed Oct 06 16:35:33 2010 +0200
     5.2 +++ b/model/member.lua	Wed Oct 06 18:15:23 2010 +0200
     5.3 @@ -357,7 +357,15 @@
     5.4  end
     5.5  
     5.6  function Member.object:set_setting_map(key, subkey, value)
     5.7 -  
     5.8 +  setting_map = self:get_setting_map_by_key_and_subkey(key, subkey)
     5.9 +  if not setting_map then
    5.10 +    setting_map = SettingMap:new()
    5.11 +    setting_map.member_id = self.id
    5.12 +    setting_map.key = key
    5.13 +    setting_map.subkey = subkey
    5.14 +  end
    5.15 +  setting_map.value = value
    5.16 +  setting_map:save()
    5.17  end
    5.18  
    5.19  function Member.object_get:notify_email_locked()

Impressum / About Us