liquid_feedback_frontend
view app/main/member/settings_notification.lua @ 1335:4aca9d024d00
Show registration images in backoffice
| author | bsw | 
|---|---|
| date | Fri Aug 03 17:30:21 2018 +0200 (2018-08-03) | 
| parents | 32cc544d5a5b | 
| children | 2626155efb83 | 
 line source
     1 local return_to = param.get("return_to")
     2 local return_to_area_id = param.get("return_to_area_id", atom.integer)
     3 local return_to_area = Area:by_id(return_to_area_id)
     5 ui.titleMember(_"notification settings")
     7 ui.grid{ content = function()
     8   ui.cell_main{ content = function()
    10     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    11       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    12         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"notification settings" }
    13       end }
    14       ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    16         ui.form{
    17           attr = { class = "vertical" },
    18           module = "member",
    19           action = "update_notify_level",
    20           routing = {
    21             ok = {
    22               mode = "redirect",
    23               module = return_to == "area" and "index" or return_to == "home" and "index" or "member",
    24               view = return_to == "area" and "index" or return_to == "home" and "index" or "settings",
    25               params = return_to_area and { unit = return_to_area.unit_id, area = return_to_area.id } or nil
    26             }
    27           },
    28           content = function()
    31             ui.container{ content = function()
    32               ui.tag{ tag = "label", attr = {
    33                   class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
    34                   ["for"] = "notify_level_all"
    35                 },
    36                 content = function()
    37                   ui.tag{
    38                     tag = "input",
    39                     attr = {
    40                       id = "notify_level_all",
    41                       class = "mdl-radio__button",
    42                       type = "radio", name = "disable_notifications", value = "false",
    43                       checked = not app.session.member.disable_notifications and "checked" or nil,
    44                     }
    45                   }
    46                   ui.tag{
    47                     attr = { class = "mdl-radio__label", ['for'] = "notify_level_all" },
    48                     content = _"I like to receive notifications"
    49                   }
    50                 end
    51               }
    52             end }
    55             ui.container{ attr = { class = "view_on_notify_level_all_false", style = "margin-left: 3em;" }, content = function()
    56               slot.put("<br />")
    58               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." }
    59               slot.put("<br />")
    60               ui.container{ content = function()
    61                 ui.tag{ tag = "label", attr = {
    62                     class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
    63                     ["for"] = "digest_on"
    64                   },
    65                   content = function()
    66                     ui.tag{
    67                       tag = "input", 
    68                       attr = {
    69                         id = "digest_on",
    70                         class = "mdl-radio__button",
    71                         type = "radio", name = "digest", value = "true",
    72                         checked = (app.session.member.disable_notifications or app.session.member.notification_hour ~= nil) and "checked" or nil,
    73                       }
    74                     }
    75                     ui.tag{
    76                       attr = { class = "mdl-radio__label", ['for'] = "digest_on" },
    77                       content = _"I want to receive a regular digest"
    78                     }
    79                   end
    80                 }
    81               end }
    83               ui.container{ attr = { class = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
    85                 ui.tag{ content = _"every" }
    86                 slot.put(" ")
    87                 ui.field.select{
    88                   container_attr = { style = "display: inline-block; vertical-align: middle;" },
    89                   attr = { style = "width: 10em;" },
    90                   name = "notification_dow",
    91                   foreign_records = {
    92                     { id = "daily", name = _"day" },
    93                     { id = 0, name = _"Sunday" },
    94                     { id = 1, name = _"Monday" },
    95                     { id = 2, name = _"Tuesday" },
    96                     { id = 3, name = _"Wednesday" },
    97                     { id = 4, name = _"Thursday" },
    98                     { id = 5, name = _"Friday" },
    99                     { id = 6, name = _"Saturday" }
   100                   },
   101                   foreign_id = "id",
   102                   foreign_name = "name",
   103                   value = app.session.member.notification_dow
   104                 }
   106                 slot.put(" ")
   108                 ui.tag{ content = _"between" }
   109                 slot.put(" ")
   110                 local foreign_records = {}
   111                 for i = 0, 23 do
   112                   foreign_records[#foreign_records+1] = {
   113                     id = i,
   114                     name = string.format("%02d:00 - %02d:59", i, i),
   115                   }
   116                 end
   117                 local random_hour
   118                 if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
   119                   random_hour = multirand.integer(0,23)
   120                 end
   121                 ui.field.select{
   122                   container_attr = { style = "display: inline-block; vertical-align: middle;" },
   123                   attr = { style = "width: 10em;" },
   124                   name = "notification_hour",
   125                   foreign_records = foreign_records,
   126                   foreign_id = "id",
   127                   foreign_name = "name",
   128                   value = random_hour or app.session.member.notification_hour
   129                 }
   130               end }
   132               ui.container{ content = function()
   133                 ui.tag{ tag = "label", attr = {
   134                     class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
   135                     ["for"] = "digest_off"
   136                   },
   137                   content = function()
   138                     ui.tag{
   139                       tag = "input", 
   140                       attr = {
   141                         id = "digest_off",
   142                         class = "mdl-radio__button",
   143                         type = "radio", name = "digest", value = "false",
   144                         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,
   145                       }
   146                     }
   147                     ui.tag{
   148                       tag = "label", attr = { class = "mdl-radio__label", ['for'] = "digest_off" },
   149                       content = _"don't send me a digest"
   150                     }
   151                   end
   152                 }
   153               end }
   154             end }
   156             slot.put("<br />")
   158             ui.container{ content = function()
   159               ui.tag{ tag = "label", attr = {
   160                   class = "mdl-radio mdl-js-radio mdl-js-ripple-effect",
   161                   ["for"] = "notify_level_none"
   162                 },
   163                 content = function()
   164                   ui.tag{
   165                     tag = "input", 
   166                     attr = {
   167                       id = "notify_level_none",
   168                       class = "mdl-radio__button",
   169                       type = "radio", name = "disable_notifications", value = "true",
   170                       checked = app.session.member.disable_notifications and "checked" or nil
   171                     }
   172                   }
   173                   ui.tag{
   174                     attr = { class = "mdl-radio__label", ['for'] = "notify_level_none" },
   175                     content = _"don't send me notifications by email"
   176                   }
   177                 end
   178               }
   179             end }
   181             slot.put("<br />")
   183             ui.tag{
   184               tag = "input",
   185               attr = {
   186                 type = "submit",
   187                 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
   188                 value = _"Save"
   189               },
   190               content = ""
   191             }
   192             slot.put("   ")
   194             slot.put(" ")
   195             if return_to == "home" then
   196               ui.link {
   197                 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
   198                 module = "index", view = "index",
   199                 content = _"cancel"
   200               }
   201             else
   202               ui.link {
   203                 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
   204                 module = "member", view = "settings", 
   205                 content = _"cancel"
   206               }
   207             end
   209           end
   210         }
   212       end }
   213     end }
   214   end }
   216   ui.cell_sidebar{ content = function()
   217     execute.view {
   218       module = "member", view = "_sidebar_whatcanido", params = {
   219         member = app.session.member
   220       }
   221     }
   222   end }
   224 end }
