liquid_feedback_frontend

diff app/main/member/settings_notification.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents 7f81a32c3e86
children 2626155efb83
line diff
     1.1 --- a/app/main/member/settings_notification.lua	Thu Jun 23 03:30:57 2016 +0200
     1.2 +++ b/app/main/member/settings_notification.lua	Sun Jul 15 14:07:29 2018 +0200
     1.3 @@ -1,194 +1,224 @@
     1.4  local return_to = param.get("return_to")
     1.5 -local return_to_area_id param.get("return_to_area_id", atom.integer)
     1.6 +local return_to_area_id = param.get("return_to_area_id", atom.integer)
     1.7 +local return_to_area = Area:by_id(return_to_area_id)
     1.8  
     1.9  ui.titleMember(_"notification settings")
    1.10  
    1.11 -execute.view {
    1.12 -  module = "member", view = "_sidebar_whatcanido", params = {
    1.13 -    member = app.session.member
    1.14 -  }
    1.15 -}
    1.16 +ui.grid{ content = function()
    1.17 +  ui.cell_main{ content = function()
    1.18 +
    1.19 +    ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    1.20 +      ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    1.21 +        ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"notification settings" }
    1.22 +      end }
    1.23 +      ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    1.24  
    1.25 -ui.form{
    1.26 -  attr = { class = "vertical" },
    1.27 -  module = "member",
    1.28 -  action = "update_notify_level",
    1.29 -  routing = {
    1.30 -    ok = {
    1.31 -      mode = "redirect",
    1.32 -      module = return_to == "area" and "area" or return_to == "home" and "index" or "member",
    1.33 -      view = return_to == "area" and "show" or return_to == "home" and "index" or "show",
    1.34 -      id = return_to == "area" and return_to_area_id or return_to ~= "home" and app.session.member_id or nil
    1.35 -    }
    1.36 -  },
    1.37 -  content = function()
    1.38 -
    1.39 -    ui.section( function()
    1.40 -
    1.41 -      ui.sectionHead( function()
    1.42 -        ui.heading { level = 1, content = _"Do you like to receive updates by email?" }
    1.43 -      end )
    1.44 -
    1.45 -      ui.sectionRow( function()
    1.46 -      
    1.47 -        ui.container{ content = function()
    1.48 -          ui.tag{
    1.49 -            tag = "input", 
    1.50 -            attr = {
    1.51 -              id = "notify_level_all",
    1.52 -              type = "radio", name = "disable_notifications", value = "false",
    1.53 -              checked = not app.session.member.disable_notifications and "checked" or nil,
    1.54 -              onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "show" : "hide"](400) ]]
    1.55 +        ui.form{
    1.56 +          attr = { class = "vertical" },
    1.57 +          module = "member",
    1.58 +          action = "update_notify_level",
    1.59 +          routing = {
    1.60 +            ok = {
    1.61 +              mode = "redirect",
    1.62 +              module = return_to == "area" and "index" or return_to == "home" and "index" or "member",
    1.63 +              view = return_to == "area" and "index" or return_to == "home" and "index" or "settings",
    1.64 +              params = return_to_area and { unit = return_to_area.unit_id, area = return_to_area.id } or nil
    1.65              }
    1.66 -          }
    1.67 -          ui.tag{
    1.68 -            tag = "label", attr = { ['for'] = "notify_level_all" },
    1.69 -            content = _"I like to receive notifications"
    1.70 -          }
    1.71 -        end }
    1.72 -        
    1.73 -        
    1.74 -        ui.container{ attr = { class = "view_on_notify_level_all_false", style = "margin-left: 3em;" }, content = function()
    1.75 -          slot.put("<br />")
    1.76 -        
    1.77 -          ui.container{ content = _"You will receive status update notification on issue phase changes. Additionally you can subscribe for a regular digest including updates on initiative drafts and new suggestions." }
    1.78 -          slot.put("<br />")
    1.79 -          ui.container{ content = function()
    1.80 -            ui.tag{
    1.81 -              tag = "input", 
    1.82 -              attr = {
    1.83 -                id = "digest_on",
    1.84 -                type = "radio", name = "digest", value = "true",
    1.85 -                checked = (app.session.member.disable_notifications or app.session.member.notification_hour ~= nil) and "checked" or nil,
    1.86 -                onchange = [[ $(".view_on_digest_true")[this.checked ? "show" : "hide"](400) ]]
    1.87 +          },
    1.88 +          content = function()
    1.89 +
    1.90 +          
    1.91 +            ui.container{ content = function()
    1.92 +              ui.tag{ tag = "label", attr = {
    1.93 +                  class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
    1.94 +                  ["for"] = "notify_level_all"
    1.95 +                },
    1.96 +                content = function()
    1.97 +                  ui.tag{
    1.98 +                    tag = "input",
    1.99 +                    attr = {
   1.100 +                      id = "notify_level_all",
   1.101 +                      class = "mdl-radio__button",
   1.102 +                      type = "radio", name = "disable_notifications", value = "false",
   1.103 +                      checked = not app.session.member.disable_notifications and "checked" or nil,
   1.104 +                    }
   1.105 +                  }
   1.106 +                  ui.tag{
   1.107 +                    attr = { class = "mdl-radio__label", ['for'] = "notify_level_all" },
   1.108 +                    content = _"I like to receive notifications"
   1.109 +                  }
   1.110 +                end
   1.111                }
   1.112 -            }
   1.113 +            end }
   1.114 +            
   1.115 +            
   1.116 +            ui.container{ attr = { class = "view_on_notify_level_all_false", style = "margin-left: 3em;" }, content = function()
   1.117 +              slot.put("<br />")
   1.118 +            
   1.119 +              ui.container{ content = _"You will receive status update notification on issue phase changes. Additionally you can subscribe for a regular digest including updates on initiative drafts and new suggestions." }
   1.120 +              slot.put("<br />")
   1.121 +              ui.container{ content = function()
   1.122 +                ui.tag{ tag = "label", attr = {
   1.123 +                    class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
   1.124 +                    ["for"] = "digest_on"
   1.125 +                  },
   1.126 +                  content = function()
   1.127 +                    ui.tag{
   1.128 +                      tag = "input", 
   1.129 +                      attr = {
   1.130 +                        id = "digest_on",
   1.131 +                        class = "mdl-radio__button",
   1.132 +                        type = "radio", name = "digest", value = "true",
   1.133 +                        checked = (app.session.member.disable_notifications or app.session.member.notification_hour ~= nil) and "checked" or nil,
   1.134 +                      }
   1.135 +                    }
   1.136 +                    ui.tag{
   1.137 +                      attr = { class = "mdl-radio__label", ['for'] = "digest_on" },
   1.138 +                      content = _"I want to receive a regular digest"
   1.139 +                    }
   1.140 +                  end
   1.141 +                }
   1.142 +              end }
   1.143 +          
   1.144 +              ui.container{ attr = { class = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
   1.145 +
   1.146 +                ui.tag{ content = _"every" }
   1.147 +                slot.put(" ")
   1.148 +                ui.field.select{
   1.149 +                  container_attr = { style = "display: inline-block; vertical-align: middle;" },
   1.150 +                  attr = { style = "width: 10em;" },
   1.151 +                  name = "notification_dow",
   1.152 +                  foreign_records = {
   1.153 +                    { id = "daily", name = _"day" },
   1.154 +                    { id = 0, name = _"Sunday" },
   1.155 +                    { id = 1, name = _"Monday" },
   1.156 +                    { id = 2, name = _"Tuesday" },
   1.157 +                    { id = 3, name = _"Wednesday" },
   1.158 +                    { id = 4, name = _"Thursday" },
   1.159 +                    { id = 5, name = _"Friday" },
   1.160 +                    { id = 6, name = _"Saturday" }
   1.161 +                  },
   1.162 +                  foreign_id = "id",
   1.163 +                  foreign_name = "name",
   1.164 +                  value = app.session.member.notification_dow
   1.165 +                }
   1.166 +                
   1.167 +                slot.put(" ")
   1.168 +
   1.169 +                ui.tag{ content = _"between" }
   1.170 +                slot.put(" ")
   1.171 +                local foreign_records = {}
   1.172 +                for i = 0, 23 do
   1.173 +                  foreign_records[#foreign_records+1] = {
   1.174 +                    id = i,
   1.175 +                    name = string.format("%02d:00 - %02d:59", i, i),
   1.176 +                  }
   1.177 +                end
   1.178 +                local random_hour
   1.179 +                if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
   1.180 +                  random_hour = multirand.integer(0,23)
   1.181 +                end
   1.182 +                ui.field.select{
   1.183 +                  container_attr = { style = "display: inline-block; vertical-align: middle;" },
   1.184 +                  attr = { style = "width: 10em;" },
   1.185 +                  name = "notification_hour",
   1.186 +                  foreign_records = foreign_records,
   1.187 +                  foreign_id = "id",
   1.188 +                  foreign_name = "name",
   1.189 +                  value = random_hour or app.session.member.notification_hour
   1.190 +                }
   1.191 +              end }
   1.192 +              
   1.193 +              ui.container{ content = function()
   1.194 +                ui.tag{ tag = "label", attr = {
   1.195 +                    class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
   1.196 +                    ["for"] = "digest_off"
   1.197 +                  },
   1.198 +                  content = function()
   1.199 +                    ui.tag{
   1.200 +                      tag = "input", 
   1.201 +                      attr = {
   1.202 +                        id = "digest_off",
   1.203 +                        class = "mdl-radio__button",
   1.204 +                        type = "radio", name = "digest", value = "false",
   1.205 +                        checked = not app.session.member.disable_notifications and app.session.member.notification_dow == nil and app.session.member.notification_hour == nil and "checked" or nil,
   1.206 +                      }
   1.207 +                    }
   1.208 +                    ui.tag{
   1.209 +                      tag = "label", attr = { class = "mdl-radio__label", ['for'] = "digest_off" },
   1.210 +                      content = _"don't send me a digest"
   1.211 +                    }
   1.212 +                  end
   1.213 +                }
   1.214 +              end }
   1.215 +            end }
   1.216 +            
   1.217 +            slot.put("<br />")
   1.218 +            
   1.219 +            ui.container{ content = function()
   1.220 +              ui.tag{ tag = "label", attr = {
   1.221 +                  class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
   1.222 +                  ["for"] = "notify_level_none"
   1.223 +                },
   1.224 +                content = function()
   1.225 +                  ui.tag{
   1.226 +                    tag = "input", 
   1.227 +                    attr = {
   1.228 +                      id = "notify_level_none",
   1.229 +                      class = "mdl-radio__button",
   1.230 +                      type = "radio", name = "disable_notifications", value = "true",
   1.231 +                      checked = app.session.member.disable_notifications and "checked" or nil
   1.232 +                    }
   1.233 +                  }
   1.234 +                  ui.tag{
   1.235 +                    attr = { class = "mdl-radio__label", ['for'] = "notify_level_none" },
   1.236 +                    content = _"don't send me notifications by email"
   1.237 +                  }
   1.238 +                end
   1.239 +              }
   1.240 +            end }
   1.241 +            
   1.242 +            slot.put("<br />")
   1.243 +          
   1.244              ui.tag{
   1.245 -              tag = "label", attr = { ['for'] = "digest_on" },
   1.246 -              content = _"I want to receive a regular digest"
   1.247 +              tag = "input",
   1.248 +              attr = {
   1.249 +                type = "submit",
   1.250 +                class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
   1.251 +                value = _"Save"
   1.252 +              },
   1.253 +              content = ""
   1.254              }
   1.255 -          end }
   1.256 -            
   1.257 -          ui.container{ attr = { class = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
   1.258 - 
   1.259 -            ui.tag{ content = _"every" }
   1.260 -            slot.put(" ")
   1.261 -            ui.field.select{
   1.262 -              container_attr = { style = "display: inline-block; vertical-align: middle;" },
   1.263 -              attr = { style = "width: 10em;" },
   1.264 -              name = "notification_dow",
   1.265 -              foreign_records = {
   1.266 -                { id = "daily", name = _"day" },
   1.267 -                { id = 0, name = _"Sunday" },
   1.268 -                { id = 1, name = _"Monday" },
   1.269 -                { id = 2, name = _"Tuesday" },
   1.270 -                { id = 3, name = _"Wednesday" },
   1.271 -                { id = 4, name = _"Thursday" },
   1.272 -                { id = 5, name = _"Friday" },
   1.273 -                { id = 6, name = _"Saturday" }
   1.274 -              },
   1.275 -              foreign_id = "id",
   1.276 -              foreign_name = "name",
   1.277 -              value = app.session.member.notification_dow
   1.278 -            }
   1.279 +            slot.put(" &nbsp; ")
   1.280              
   1.281              slot.put(" ")
   1.282 -
   1.283 -            ui.tag{ content = _"between" }
   1.284 -            slot.put(" ")
   1.285 -            local foreign_records = {}
   1.286 -            for i = 0, 23 do
   1.287 -              foreign_records[#foreign_records+1] = {
   1.288 -                id = i,
   1.289 -                name = string.format("%02d:00 - %02d:59", i, i),
   1.290 +            if return_to == "home" then
   1.291 +              ui.link {
   1.292 +                attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
   1.293 +                module = "index", view = "index",
   1.294 +                content = _"cancel"
   1.295 +              }
   1.296 +            else
   1.297 +              ui.link {
   1.298 +                attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
   1.299 +                module = "member", view = "settings", 
   1.300 +                content = _"cancel"
   1.301                }
   1.302              end
   1.303 -            local random_hour
   1.304 -            if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
   1.305 -              random_hour = multirand.integer(0,23)
   1.306 -            end
   1.307 -            ui.field.select{
   1.308 -              container_attr = { style = "display: inline-block; vertical-align: middle;" },
   1.309 -              attr = { style = "width: 10em;" },
   1.310 -              name = "notification_hour",
   1.311 -              foreign_records = foreign_records,
   1.312 -              foreign_id = "id",
   1.313 -              foreign_name = "name",
   1.314 -              value = random_hour or app.session.member.notification_hour
   1.315 -            }
   1.316 -          end }
   1.317 -          
   1.318 -          ui.container{ content = function()
   1.319 -            ui.tag{
   1.320 -              tag = "input", 
   1.321 -              attr = {
   1.322 -                id = "digest_off",
   1.323 -                type = "radio", name = "digest", value = "false",
   1.324 -                checked = not app.session.member.disable_notifications and app.session.member.notification_dow == nil and app.session.member.notification_hour == nil and "checked" or nil,
   1.325 -                onchange = [[ $(".view_on_digest_true")[this.checked ? "hide" : "show"](400) ]]
   1.326 -              }
   1.327 -            }
   1.328 -            ui.tag{
   1.329 -              tag = "label", attr = { ['for'] = "digest_off" },
   1.330 -              content = _"don't send me a digest"
   1.331 -            }
   1.332 -          end }
   1.333 -        end }
   1.334 -        
   1.335 -        slot.put("<br />")
   1.336 +            
   1.337 +          end
   1.338 +        }
   1.339          
   1.340 -        ui.container{ content = function()
   1.341 -          ui.tag{
   1.342 -            tag = "input", 
   1.343 -            attr = {
   1.344 -              id = "notify_level_none",
   1.345 -              type = "radio", name = "disable_notifications", value = "true",
   1.346 -              checked = app.session.member.disable_notifications and "checked" or nil,
   1.347 -              onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "hide" : "show"](400) ]]
   1.348 -            }
   1.349 -          }
   1.350 -          ui.tag{
   1.351 -            tag = "label", attr = { ['for'] = "notify_level_none" },
   1.352 -            content = _"don't send me notifications by email"
   1.353 -          }
   1.354 -        end }
   1.355 -        
   1.356 -        if app.session.member.disable_notifications then
   1.357 -          ui.script{ script = [[ $(".view_on_notify_level_all_false").hide() ]] }
   1.358 -        end
   1.359 -        
   1.360 -        if not app.session.member.disable_notifications and app.session.member.notification_hour == nil  then
   1.361 -          ui.script{ script = [[ $(".view_on_digest_true").hide() ]] }
   1.362 -        end
   1.363 +      end }
   1.364 +    end }
   1.365 +  end }
   1.366  
   1.367 -        slot.put("<br />")
   1.368 -      
   1.369 -        ui.tag{
   1.370 -          tag = "input",
   1.371 -          attr = {
   1.372 -            type = "submit",
   1.373 -            class = "btn btn-default",
   1.374 -            value = _"Save"
   1.375 -          },
   1.376 -          content = ""
   1.377 -        }
   1.378 -        slot.put("<br /><br /><br />")
   1.379 -        
   1.380 -        slot.put(" ")
   1.381 -        if return_to == "home" then
   1.382 -          ui.link {
   1.383 -            module = "index", view = "index",
   1.384 -            content = _"cancel"
   1.385 -          }
   1.386 -        else
   1.387 -          ui.link {
   1.388 -            module = "member", view = "show", id = app.session.member_id, 
   1.389 -            content = _"cancel"
   1.390 -          }
   1.391 -        end
   1.392 -      end ) 
   1.393 -    end )
   1.394 -    
   1.395 -  end
   1.396 -}
   1.397 - 
   1.398 +  ui.cell_sidebar{ content = function()
   1.399 +    execute.view {
   1.400 +      module = "member", view = "_sidebar_whatcanido", params = {
   1.401 +        member = app.session.member
   1.402 +      }
   1.403 +    }
   1.404 +  end }
   1.405 +
   1.406 +end }

Impressum / About Us