| rev | 
   line source | 
| 
bsw@1045
 | 
     1 local return_to = param.get("return_to")
 | 
| 
bsw/jbe@1309
 | 
     2 local return_to_area_id = param.get("return_to_area_id", atom.integer)
 | 
| 
bsw/jbe@1309
 | 
     3 local return_to_area = Area:by_id(return_to_area_id)
 | 
| 
bsw@1045
 | 
     4 
 | 
| 
bsw@1126
 | 
     5 ui.titleMember(_"notification settings")
 | 
| 
bsw@286
 | 
     6 
 | 
| 
bsw/jbe@1309
 | 
     7 ui.grid{ content = function()
 | 
| 
bsw/jbe@1309
 | 
     8   ui.cell_main{ content = function()
 | 
| 
bsw/jbe@1309
 | 
     9 
 | 
| 
bsw/jbe@1309
 | 
    10     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    11       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    12         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"notification settings" }
 | 
| 
bsw/jbe@1309
 | 
    13       end }
 | 
| 
bsw/jbe@1309
 | 
    14       ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
 | 
| 
bsw@286
 | 
    15 
 | 
| 
bsw/jbe@1309
 | 
    16         ui.form{
 | 
| 
bsw/jbe@1309
 | 
    17           attr = { class = "vertical" },
 | 
| 
bsw/jbe@1309
 | 
    18           module = "member",
 | 
| 
bsw/jbe@1309
 | 
    19           action = "update_notify_level",
 | 
| 
bsw/jbe@1309
 | 
    20           routing = {
 | 
| 
bsw/jbe@1309
 | 
    21             ok = {
 | 
| 
bsw/jbe@1309
 | 
    22               mode = "redirect",
 | 
| 
bsw/jbe@1309
 | 
    23               module = return_to == "area" and "index" or return_to == "home" and "index" or "member",
 | 
| 
bsw/jbe@1309
 | 
    24               view = return_to == "area" and "index" or return_to == "home" and "index" or "settings",
 | 
| 
bsw/jbe@1309
 | 
    25               params = return_to_area and { unit = return_to_area.unit_id, area = return_to_area.id } or nil
 | 
| 
bsw@1045
 | 
    26             }
 | 
| 
bsw/jbe@1309
 | 
    27           },
 | 
| 
bsw/jbe@1309
 | 
    28           content = function()
 | 
| 
bsw@1485
 | 
    29             
 | 
| 
bsw/jbe@1309
 | 
    30             ui.container{ content = function()
 | 
| 
bsw/jbe@1309
 | 
    31               ui.tag{ tag = "label", attr = {
 | 
| 
bsw@1485
 | 
    32                   class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
 | 
| 
bsw/jbe@1309
 | 
    33                   ["for"] = "notify_level_all"
 | 
| 
bsw/jbe@1309
 | 
    34                 },
 | 
| 
bsw/jbe@1309
 | 
    35                 content = function()
 | 
| 
bsw/jbe@1309
 | 
    36                   ui.tag{
 | 
| 
bsw/jbe@1309
 | 
    37                     tag = "input",
 | 
| 
bsw/jbe@1309
 | 
    38                     attr = {
 | 
| 
bsw/jbe@1309
 | 
    39                       id = "notify_level_all",
 | 
| 
bsw@1485
 | 
    40                       class = "mdl-checkbox__input",
 | 
| 
bsw@1485
 | 
    41                       type = "checkbox", name = "enable_notifications", value = "true",
 | 
| 
bsw/jbe@1309
 | 
    42                       checked = not app.session.member.disable_notifications and "checked" or nil,
 | 
| 
bsw@1485
 | 
    43                       onchange = [[ display = document.getElementById("view_on_notify_level_all_false").style.display = this.checked ? "block" : "none"; ]]
 | 
| 
bsw/jbe@1309
 | 
    44                     }
 | 
| 
bsw/jbe@1309
 | 
    45                   }
 | 
| 
bsw/jbe@1309
 | 
    46                   ui.tag{
 | 
| 
bsw@1485
 | 
    47                     attr = { class = "mdl-checkbox__label", ['for'] = "notify_level_all" },
 | 
| 
bsw/jbe@1309
 | 
    48                     content = _"I like to receive notifications"
 | 
| 
bsw/jbe@1309
 | 
    49                   }
 | 
| 
bsw/jbe@1309
 | 
    50                 end
 | 
| 
bsw@1261
 | 
    51               }
 | 
| 
bsw/jbe@1309
 | 
    52             end }
 | 
| 
bsw/jbe@1309
 | 
    53             
 | 
| 
bsw/jbe@1309
 | 
    54             
 | 
| 
bsw@1485
 | 
    55             ui.container{ attr = { id = "view_on_notify_level_all_false" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    56               slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
    57             
 | 
| 
bsw/jbe@1309
 | 
    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." }
 | 
| 
bsw/jbe@1309
 | 
    59               slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
    60               ui.container{ content = function()
 | 
| 
bsw/jbe@1309
 | 
    61                 ui.tag{ tag = "label", attr = {
 | 
| 
bsw@1485
 | 
    62                     class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
 | 
| 
bsw/jbe@1309
 | 
    63                     ["for"] = "digest_on"
 | 
| 
bsw/jbe@1309
 | 
    64                   },
 | 
| 
bsw/jbe@1309
 | 
    65                   content = function()
 | 
| 
bsw/jbe@1309
 | 
    66                     ui.tag{
 | 
| 
bsw/jbe@1309
 | 
    67                       tag = "input", 
 | 
| 
bsw/jbe@1309
 | 
    68                       attr = {
 | 
| 
bsw/jbe@1309
 | 
    69                         id = "digest_on",
 | 
| 
bsw@1485
 | 
    70                         class = "mdl-checkbox__input",
 | 
| 
bsw@1485
 | 
    71                         type = "checkbox", name = "digest", value = "true",
 | 
| 
bsw@1485
 | 
    72                         checked = app.session.member.notification_hour ~= nil and "checked" or nil,
 | 
| 
bsw@1485
 | 
    73                         onchange = [[ display = document.getElementById("view_on_digest_true").style.display = this.checked ? "block" : "none"; ]]
 | 
| 
bsw/jbe@1309
 | 
    74                       }
 | 
| 
bsw/jbe@1309
 | 
    75                     }
 | 
| 
bsw/jbe@1309
 | 
    76                     ui.tag{
 | 
| 
bsw@1485
 | 
    77                       attr = { class = "mdl-checkbox__label", ['for'] = "digest_on" },
 | 
| 
bsw/jbe@1309
 | 
    78                       content = _"I want to receive a regular digest"
 | 
| 
bsw/jbe@1309
 | 
    79                     }
 | 
| 
bsw/jbe@1309
 | 
    80                   end
 | 
| 
bsw/jbe@1309
 | 
    81                 }
 | 
| 
bsw/jbe@1309
 | 
    82               end }
 | 
| 
bsw/jbe@1309
 | 
    83           
 | 
| 
bsw@1485
 | 
    84               ui.container{ attr = { id = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    85 
 | 
| 
bsw/jbe@1309
 | 
    86                 ui.tag{ content = _"every" }
 | 
| 
bsw/jbe@1309
 | 
    87                 slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
    88                 ui.field.select{
 | 
| 
bsw/jbe@1309
 | 
    89                   container_attr = { style = "display: inline-block; vertical-align: middle;" },
 | 
| 
bsw/jbe@1309
 | 
    90                   attr = { style = "width: 10em;" },
 | 
| 
bsw/jbe@1309
 | 
    91                   name = "notification_dow",
 | 
| 
bsw/jbe@1309
 | 
    92                   foreign_records = {
 | 
| 
bsw/jbe@1309
 | 
    93                     { id = "daily", name = _"day" },
 | 
| 
bsw/jbe@1309
 | 
    94                     { id = 0, name = _"Sunday" },
 | 
| 
bsw/jbe@1309
 | 
    95                     { id = 1, name = _"Monday" },
 | 
| 
bsw/jbe@1309
 | 
    96                     { id = 2, name = _"Tuesday" },
 | 
| 
bsw/jbe@1309
 | 
    97                     { id = 3, name = _"Wednesday" },
 | 
| 
bsw/jbe@1309
 | 
    98                     { id = 4, name = _"Thursday" },
 | 
| 
bsw/jbe@1309
 | 
    99                     { id = 5, name = _"Friday" },
 | 
| 
bsw/jbe@1309
 | 
   100                     { id = 6, name = _"Saturday" }
 | 
| 
bsw/jbe@1309
 | 
   101                   },
 | 
| 
bsw/jbe@1309
 | 
   102                   foreign_id = "id",
 | 
| 
bsw/jbe@1309
 | 
   103                   foreign_name = "name",
 | 
| 
bsw/jbe@1309
 | 
   104                   value = app.session.member.notification_dow
 | 
| 
bsw/jbe@1309
 | 
   105                 }
 | 
| 
bsw/jbe@1309
 | 
   106                 
 | 
| 
bsw/jbe@1309
 | 
   107                 slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   108 
 | 
| 
bsw/jbe@1309
 | 
   109                 ui.tag{ content = _"between" }
 | 
| 
bsw/jbe@1309
 | 
   110                 slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   111                 local foreign_records = {}
 | 
| 
bsw/jbe@1309
 | 
   112                 for i = 0, 23 do
 | 
| 
bsw/jbe@1309
 | 
   113                   foreign_records[#foreign_records+1] = {
 | 
| 
bsw/jbe@1309
 | 
   114                     id = i,
 | 
| 
bsw/jbe@1309
 | 
   115                     name = string.format("%02d:00 - %02d:59", i, i),
 | 
| 
bsw/jbe@1309
 | 
   116                   }
 | 
| 
bsw/jbe@1309
 | 
   117                 end
 | 
| 
bsw/jbe@1309
 | 
   118                 local random_hour
 | 
| 
bsw/jbe@1309
 | 
   119                 if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
 | 
| 
bsw/jbe@1309
 | 
   120                   random_hour = multirand.integer(0,23)
 | 
| 
bsw/jbe@1309
 | 
   121                 end
 | 
| 
bsw/jbe@1309
 | 
   122                 ui.field.select{
 | 
| 
bsw/jbe@1309
 | 
   123                   container_attr = { style = "display: inline-block; vertical-align: middle;" },
 | 
| 
bsw/jbe@1309
 | 
   124                   attr = { style = "width: 10em;" },
 | 
| 
bsw/jbe@1309
 | 
   125                   name = "notification_hour",
 | 
| 
bsw/jbe@1309
 | 
   126                   foreign_records = foreign_records,
 | 
| 
bsw/jbe@1309
 | 
   127                   foreign_id = "id",
 | 
| 
bsw/jbe@1309
 | 
   128                   foreign_name = "name",
 | 
| 
bsw/jbe@1309
 | 
   129                   value = random_hour or app.session.member.notification_hour
 | 
| 
bsw/jbe@1309
 | 
   130                 }
 | 
| 
bsw/jbe@1309
 | 
   131               end }
 | 
| 
bsw@1485
 | 
   132 
 | 
| 
bsw/jbe@1309
 | 
   133             end }
 | 
| 
bsw/jbe@1309
 | 
   134             
 | 
| 
bsw/jbe@1309
 | 
   135             slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   136             
 | 
| 
bsw@1485
 | 
   137             if app.session.member.disable_notifications then
 | 
| 
bsw@1485
 | 
   138               ui.script{ script = [[ document.getElementById("view_on_notify_level_all_false").style.display = "none"; ]] }
 | 
| 
bsw@1485
 | 
   139             end
 | 
| 
bsw/jbe@1309
 | 
   140             
 | 
| 
bsw@1485
 | 
   141             if app.session.member.notification_hour == nil  then
 | 
| 
bsw@1485
 | 
   142               ui.script{ script = [[ document.getElementById("view_on_digest_true").style.display = "none"; ]] }
 | 
| 
bsw@1485
 | 
   143             end
 | 
| 
bsw@1485
 | 
   144    
 | 
| 
bsw/jbe@1309
 | 
   145             slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
   146           
 | 
| 
bsw@1261
 | 
   147             ui.tag{
 | 
| 
bsw/jbe@1309
 | 
   148               tag = "input",
 | 
| 
bsw/jbe@1309
 | 
   149               attr = {
 | 
| 
bsw/jbe@1309
 | 
   150                 type = "submit",
 | 
| 
bsw/jbe@1309
 | 
   151                 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
 | 
| 
bsw/jbe@1309
 | 
   152                 value = _"Save"
 | 
| 
bsw/jbe@1309
 | 
   153               },
 | 
| 
bsw/jbe@1309
 | 
   154               content = ""
 | 
| 
bsw@1261
 | 
   155             }
 | 
| 
bsw/jbe@1309
 | 
   156             slot.put("   ")
 | 
| 
bsw@1261
 | 
   157             
 | 
| 
bsw@1261
 | 
   158             slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   159             if return_to == "home" then
 | 
| 
bsw/jbe@1309
 | 
   160               ui.link {
 | 
| 
bsw/jbe@1309
 | 
   161                 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
 | 
| 
bsw/jbe@1309
 | 
   162                 module = "index", view = "index",
 | 
| 
bsw/jbe@1309
 | 
   163                 content = _"cancel"
 | 
| 
bsw/jbe@1309
 | 
   164               }
 | 
| 
bsw/jbe@1309
 | 
   165             else
 | 
| 
bsw/jbe@1309
 | 
   166               ui.link {
 | 
| 
bsw/jbe@1309
 | 
   167                 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
 | 
| 
bsw/jbe@1309
 | 
   168                 module = "member", view = "settings", 
 | 
| 
bsw/jbe@1309
 | 
   169                 content = _"cancel"
 | 
| 
bsw@1261
 | 
   170               }
 | 
| 
bsw@1261
 | 
   171             end
 | 
| 
bsw/jbe@1309
 | 
   172             
 | 
| 
bsw/jbe@1309
 | 
   173           end
 | 
| 
bsw/jbe@1309
 | 
   174         }
 | 
| 
bsw@1255
 | 
   175         
 | 
| 
bsw/jbe@1309
 | 
   176       end }
 | 
| 
bsw/jbe@1309
 | 
   177     end }
 | 
| 
bsw/jbe@1309
 | 
   178   end }
 | 
| 
bsw@1282
 | 
   179 
 | 
| 
bsw/jbe@1309
 | 
   180   ui.cell_sidebar{ content = function()
 | 
| 
bsw/jbe@1309
 | 
   181     execute.view {
 | 
| 
bsw/jbe@1309
 | 
   182       module = "member", view = "_sidebar_whatcanido", params = {
 | 
| 
bsw/jbe@1309
 | 
   183         member = app.session.member
 | 
| 
bsw/jbe@1309
 | 
   184       }
 | 
| 
bsw/jbe@1309
 | 
   185     }
 | 
| 
bsw/jbe@1309
 | 
   186   end }
 | 
| 
bsw/jbe@1309
 | 
   187 
 | 
| 
bsw/jbe@1309
 | 
   188 end }
 |