| rev | 
   line source | 
| 
bsw@1045
 | 
     1 local return_to = param.get("return_to")
 | 
| 
bsw@1250
 | 
     2 local return_to_area_id param.get("return_to_area_id", atom.integer)
 | 
| 
bsw@1045
 | 
     3 
 | 
| 
bsw@1126
 | 
     4 ui.titleMember(_"notification settings")
 | 
| 
bsw@286
 | 
     5 
 | 
| 
bsw@1045
 | 
     6 execute.view {
 | 
| 
bsw@1045
 | 
     7   module = "member", view = "_sidebar_whatcanido", params = {
 | 
| 
bsw@1045
 | 
     8     member = app.session.member
 | 
| 
bsw@1045
 | 
     9   }
 | 
| 
bsw@1045
 | 
    10 }
 | 
| 
bsw@286
 | 
    11 
 | 
| 
bsw@286
 | 
    12 ui.form{
 | 
| 
bsw@286
 | 
    13   attr = { class = "vertical" },
 | 
| 
bsw@286
 | 
    14   module = "member",
 | 
| 
bsw@348
 | 
    15   action = "update_notify_level",
 | 
| 
bsw@286
 | 
    16   routing = {
 | 
| 
bsw@286
 | 
    17     ok = {
 | 
| 
bsw@286
 | 
    18       mode = "redirect",
 | 
| 
bsw@1250
 | 
    19       module = return_to == "area" and "area" or return_to == "home" and "index" or "member",
 | 
| 
bsw@1250
 | 
    20       view = return_to == "area" and "show" or return_to == "home" and "index" or "show",
 | 
| 
bsw@1250
 | 
    21       id = return_to == "area" and return_to_area_id or return_to ~= "home" and app.session.member_id or nil
 | 
| 
bsw@286
 | 
    22     }
 | 
| 
bsw@286
 | 
    23   },
 | 
| 
bsw@286
 | 
    24   content = function()
 | 
| 
bsw@1045
 | 
    25 
 | 
| 
bsw@1045
 | 
    26     ui.section( function()
 | 
| 
bsw@1045
 | 
    27 
 | 
| 
bsw@1045
 | 
    28       ui.sectionHead( function()
 | 
| 
bsw@1250
 | 
    29         ui.heading { level = 1, content = _"Do you like to receive updates by email?" }
 | 
| 
bsw@1045
 | 
    30       end )
 | 
| 
bsw@1045
 | 
    31 
 | 
| 
bsw@474
 | 
    32     
 | 
| 
bsw@1045
 | 
    33       ui.sectionRow( function()
 | 
| 
bsw@1045
 | 
    34       
 | 
| 
bsw@1045
 | 
    35         ui.container{ content = function()
 | 
| 
bsw@1045
 | 
    36           ui.tag{
 | 
| 
bsw@1045
 | 
    37             tag = "input", 
 | 
| 
bsw@1045
 | 
    38             attr = {
 | 
| 
bsw@1045
 | 
    39               id = "notify_level_all",
 | 
| 
bsw@1248
 | 
    40               type = "radio", name = "disable_notifications", value = "false",
 | 
| 
bsw@1248
 | 
    41               checked = not app.session.member.disable_notifications and "checked" or nil
 | 
| 
bsw@1281
 | 
    42               onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "show" : "hide"](400) ]]
 | 
| 
bsw@1045
 | 
    43             }
 | 
| 
bsw@1045
 | 
    44           }
 | 
| 
bsw@1045
 | 
    45           ui.tag{
 | 
| 
bsw@1045
 | 
    46             tag = "label", attr = { ['for'] = "notify_level_all" },
 | 
| 
bsw@1045
 | 
    47             content = _"I like to receive notifications"
 | 
| 
bsw@1045
 | 
    48           }
 | 
| 
bsw@1045
 | 
    49         end }
 | 
| 
bsw@1045
 | 
    50         
 | 
| 
bsw@1045
 | 
    51         slot.put("<br />")
 | 
| 
bsw@1255
 | 
    52         
 | 
| 
bsw@1281
 | 
    53         ui.container{ attr = { class = "view_on_notify_level_all_false", style = "margin-left: 3em;" }, content = function()
 | 
| 
bsw@1277
 | 
    54         
 | 
| 
bsw@1277
 | 
    55           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@1279
 | 
    56           slot.put("<br />")
 | 
| 
bsw@1261
 | 
    57           ui.container{ content = function()
 | 
| 
bsw@1261
 | 
    58             ui.tag{
 | 
| 
bsw@1261
 | 
    59               tag = "input", 
 | 
| 
bsw@1261
 | 
    60               attr = {
 | 
| 
bsw@1261
 | 
    61                 id = "digest_on",
 | 
| 
bsw@1261
 | 
    62                 type = "radio", name = "digest", value = "true",
 | 
| 
bsw@1266
 | 
    63                 checked = app.session.member.notification_hour ~= nil and "checked" or nil
 | 
| 
bsw@1281
 | 
    64                 onchange = [[ $(".view_on_digest_true")[this.checked ? "show" : "hide"](400) ]]
 | 
| 
bsw@1261
 | 
    65               }
 | 
| 
bsw@1261
 | 
    66             }
 | 
| 
bsw@1261
 | 
    67             ui.tag{
 | 
| 
bsw@1261
 | 
    68               tag = "label", attr = { ['for'] = "digest_on" },
 | 
| 
bsw@1277
 | 
    69               content = _"I want to receive a regular digest. Send the digest at:"
 | 
| 
bsw@1261
 | 
    70             }
 | 
| 
bsw@1262
 | 
    71           end }
 | 
| 
bsw@1261
 | 
    72             
 | 
| 
bsw@1281
 | 
    73           ui.container{ attr = { class = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
 | 
| 
bsw@1261
 | 
    74             ui.tag{ content = _"Day:" }
 | 
| 
bsw@1261
 | 
    75             slot.put(" ")
 | 
| 
bsw@1261
 | 
    76             ui.field.select{
 | 
| 
bsw@1273
 | 
    77               container_attr = { style = "display: inline-block; vertical-align: middle;" },
 | 
| 
bsw@1274
 | 
    78               attr = { style = "width: 10em;" },
 | 
| 
bsw@1261
 | 
    79               name = "notification_dow",
 | 
| 
bsw@1261
 | 
    80               foreign_records = {
 | 
| 
bsw@1261
 | 
    81                 { id = "daily", name = _"daily" },
 | 
| 
bsw@1271
 | 
    82                 { id = 0, name = _"Sunday" },
 | 
| 
bsw@1271
 | 
    83                 { id = 1, name = _"Monday" },
 | 
| 
bsw@1271
 | 
    84                 { id = 2, name = _"Tuesday" },
 | 
| 
bsw@1271
 | 
    85                 { id = 3, name = _"Wednesday" },
 | 
| 
bsw@1271
 | 
    86                 { id = 4, name = _"Thursday" },
 | 
| 
bsw@1271
 | 
    87                 { id = 5, name = _"Friday" },
 | 
| 
bsw@1271
 | 
    88                 { id = 6, name = _"Saturday" }
 | 
| 
bsw@1261
 | 
    89               },
 | 
| 
bsw@1261
 | 
    90               foreign_id = "id",
 | 
| 
bsw@1272
 | 
    91               foreign_name = "name",
 | 
| 
bsw@1272
 | 
    92               value = app.session.member.notification_dow
 | 
| 
bsw@1255
 | 
    93             }
 | 
| 
bsw@1261
 | 
    94             
 | 
| 
bsw@1261
 | 
    95             slot.put(" ")
 | 
| 
bsw@1261
 | 
    96 
 | 
| 
bsw@1261
 | 
    97             ui.tag{ content = _"Hour:" }
 | 
| 
bsw@1261
 | 
    98             slot.put(" ")
 | 
| 
bsw@1261
 | 
    99             local foreign_records = {}
 | 
| 
bsw@1261
 | 
   100             for i = 0, 23 do
 | 
| 
bsw@1261
 | 
   101               foreign_records[#foreign_records+1] = {
 | 
| 
bsw@1261
 | 
   102                 id = i,
 | 
| 
bsw@1277
 | 
   103                 name = string.format("%02d:00 - %02d:59", i, i),
 | 
| 
bsw@1261
 | 
   104               }
 | 
| 
bsw@1261
 | 
   105             end
 | 
| 
bsw@1261
 | 
   106             ui.field.select{
 | 
| 
bsw@1273
 | 
   107               container_attr = { style = "display: inline-block; vertical-align: middle;" },
 | 
| 
bsw@1280
 | 
   108               attr = { style = "width: 10em;" },
 | 
| 
bsw@1261
 | 
   109               name = "notification_hour",
 | 
| 
bsw@1261
 | 
   110               foreign_records = foreign_records,
 | 
| 
bsw@1261
 | 
   111               foreign_id = "id",
 | 
| 
bsw@1268
 | 
   112               foreign_name = "name",
 | 
| 
bsw@1272
 | 
   113               value = app.session.member.notification_hour
 | 
| 
bsw@1261
 | 
   114             }
 | 
| 
bsw@1261
 | 
   115           end }
 | 
| 
bsw@1261
 | 
   116           
 | 
| 
bsw@1261
 | 
   117           ui.container{ content = function()
 | 
| 
bsw@1261
 | 
   118             ui.tag{
 | 
| 
bsw@1261
 | 
   119               tag = "input", 
 | 
| 
bsw@1261
 | 
   120               attr = {
 | 
| 
bsw@1261
 | 
   121                 id = "digest_off",
 | 
| 
bsw@1261
 | 
   122                 type = "radio", name = "digest", value = "false",
 | 
| 
bsw@1276
 | 
   123                 checked = app.session.member.notification_dow == nil and app.session.member.notification_hour == nil and "checked" or nil
 | 
| 
bsw@1281
 | 
   124                 onchange = [[ $(".view_on_digest_true")[this.checked ? "hide" : "show"](400) ]]
 | 
| 
bsw@1261
 | 
   125               }
 | 
| 
bsw@1261
 | 
   126             }
 | 
| 
bsw@1261
 | 
   127             ui.tag{
 | 
| 
bsw@1261
 | 
   128               tag = "label", attr = { ['for'] = "digest_off" },
 | 
| 
bsw@1279
 | 
   129               content = _"Don't send me a digest"
 | 
| 
bsw@1261
 | 
   130             }
 | 
| 
bsw@1261
 | 
   131           end }
 | 
| 
bsw@1255
 | 
   132         end }
 | 
| 
bsw@1255
 | 
   133         
 | 
| 
bsw@1263
 | 
   134         slot.put("<br />")
 | 
| 
bsw@1255
 | 
   135         
 | 
| 
bsw@1045
 | 
   136         ui.container{ content = function()
 | 
| 
bsw@1045
 | 
   137           ui.tag{
 | 
| 
bsw@1045
 | 
   138             tag = "input", 
 | 
| 
bsw@1045
 | 
   139             attr = {
 | 
| 
bsw@1045
 | 
   140               id = "notify_level_none",
 | 
| 
bsw@1248
 | 
   141               type = "radio", name = "disable_notifications", value = "true",
 | 
| 
bsw@1281
 | 
   142               checked = app.session.member.disable_notifications and "checked" or nil,
 | 
| 
bsw@1281
 | 
   143               onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "hide" : "show"](400) ]]
 | 
| 
bsw@1045
 | 
   144             }
 | 
| 
bsw@1045
 | 
   145           }
 | 
| 
bsw@1045
 | 
   146           ui.tag{
 | 
| 
bsw@1045
 | 
   147             tag = "label", attr = { ['for'] = "notify_level_none" },
 | 
| 
bsw@1279
 | 
   148             content = _"Don't send me notifications by email"
 | 
| 
bsw@1045
 | 
   149           }
 | 
| 
bsw@1045
 | 
   150         end }
 | 
| 
bsw@1045
 | 
   151         
 | 
| 
bsw@1045
 | 
   152         slot.put("<br />")
 | 
| 
bsw@1045
 | 
   153       
 | 
| 
bsw@1045
 | 
   154         ui.tag{
 | 
| 
bsw@1045
 | 
   155           tag = "input",
 | 
| 
bsw@1045
 | 
   156           attr = {
 | 
| 
bsw@1045
 | 
   157             type = "submit",
 | 
| 
bsw@1045
 | 
   158             class = "btn btn-default",
 | 
| 
bsw@1045
 | 
   159             value = _"Save"
 | 
| 
bsw@1045
 | 
   160           },
 | 
| 
bsw@1045
 | 
   161           content = ""
 | 
| 
bsw@348
 | 
   162         }
 | 
| 
bsw@1045
 | 
   163         slot.put("<br /><br /><br />")
 | 
| 
bsw@1045
 | 
   164         
 | 
| 
bsw@1045
 | 
   165         slot.put(" ")
 | 
| 
bsw@1045
 | 
   166         if return_to == "home" then
 | 
| 
bsw@1045
 | 
   167           ui.link {
 | 
| 
bsw@1045
 | 
   168             module = "index", view = "index",
 | 
| 
bsw@1045
 | 
   169             content = _"cancel"
 | 
| 
bsw@1045
 | 
   170           }
 | 
| 
bsw@1045
 | 
   171         else
 | 
| 
bsw@1045
 | 
   172           ui.link {
 | 
| 
bsw@1045
 | 
   173             module = "member", view = "show", id = app.session.member_id, 
 | 
| 
bsw@1045
 | 
   174             content = _"cancel"
 | 
| 
bsw@1045
 | 
   175           }
 | 
| 
bsw@1045
 | 
   176         end
 | 
| 
bsw@1045
 | 
   177       end ) 
 | 
| 
bsw@1045
 | 
   178     end )
 | 
| 
bsw@474
 | 
   179     
 | 
| 
bsw@286
 | 
   180   end
 | 
| 
bsw@286
 | 
   181 }
 | 
| 
bsw@287
 | 
   182  
 |