liquid_feedback_frontend
view app/main/member/settings_notification.lua @ 1303:0160d9a01d0a
Updated German translation
| author | bsw | 
|---|---|
| date | Fri May 06 09:40:25 2016 +0200 (2016-05-06) | 
| parents | 7f81a32c3e86 | 
| children | 32cc544d5a5b | 
 line source
     1 local return_to = param.get("return_to")
     2 local return_to_area_id param.get("return_to_area_id", atom.integer)
     4 ui.titleMember(_"notification settings")
     6 execute.view {
     7   module = "member", view = "_sidebar_whatcanido", params = {
     8     member = app.session.member
     9   }
    10 }
    12 ui.form{
    13   attr = { class = "vertical" },
    14   module = "member",
    15   action = "update_notify_level",
    16   routing = {
    17     ok = {
    18       mode = "redirect",
    19       module = return_to == "area" and "area" or return_to == "home" and "index" or "member",
    20       view = return_to == "area" and "show" or return_to == "home" and "index" or "show",
    21       id = return_to == "area" and return_to_area_id or return_to ~= "home" and app.session.member_id or nil
    22     }
    23   },
    24   content = function()
    26     ui.section( function()
    28       ui.sectionHead( function()
    29         ui.heading { level = 1, content = _"Do you like to receive updates by email?" }
    30       end )
    32       ui.sectionRow( function()
    34         ui.container{ content = function()
    35           ui.tag{
    36             tag = "input", 
    37             attr = {
    38               id = "notify_level_all",
    39               type = "radio", name = "disable_notifications", value = "false",
    40               checked = not app.session.member.disable_notifications and "checked" or nil,
    41               onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "show" : "hide"](400) ]]
    42             }
    43           }
    44           ui.tag{
    45             tag = "label", attr = { ['for'] = "notify_level_all" },
    46             content = _"I like to receive notifications"
    47           }
    48         end }
    51         ui.container{ attr = { class = "view_on_notify_level_all_false", style = "margin-left: 3em;" }, content = function()
    52           slot.put("<br />")
    54           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." }
    55           slot.put("<br />")
    56           ui.container{ content = function()
    57             ui.tag{
    58               tag = "input", 
    59               attr = {
    60                 id = "digest_on",
    61                 type = "radio", name = "digest", value = "true",
    62                 checked = (app.session.member.disable_notifications or app.session.member.notification_hour ~= nil) and "checked" or nil,
    63                 onchange = [[ $(".view_on_digest_true")[this.checked ? "show" : "hide"](400) ]]
    64               }
    65             }
    66             ui.tag{
    67               tag = "label", attr = { ['for'] = "digest_on" },
    68               content = _"I want to receive a regular digest"
    69             }
    70           end }
    72           ui.container{ attr = { class = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
    74             ui.tag{ content = _"every" }
    75             slot.put(" ")
    76             ui.field.select{
    77               container_attr = { style = "display: inline-block; vertical-align: middle;" },
    78               attr = { style = "width: 10em;" },
    79               name = "notification_dow",
    80               foreign_records = {
    81                 { id = "daily", name = _"day" },
    82                 { id = 0, name = _"Sunday" },
    83                 { id = 1, name = _"Monday" },
    84                 { id = 2, name = _"Tuesday" },
    85                 { id = 3, name = _"Wednesday" },
    86                 { id = 4, name = _"Thursday" },
    87                 { id = 5, name = _"Friday" },
    88                 { id = 6, name = _"Saturday" }
    89               },
    90               foreign_id = "id",
    91               foreign_name = "name",
    92               value = app.session.member.notification_dow
    93             }
    95             slot.put(" ")
    97             ui.tag{ content = _"between" }
    98             slot.put(" ")
    99             local foreign_records = {}
   100             for i = 0, 23 do
   101               foreign_records[#foreign_records+1] = {
   102                 id = i,
   103                 name = string.format("%02d:00 - %02d:59", i, i),
   104               }
   105             end
   106             local random_hour
   107             if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
   108               random_hour = multirand.integer(0,23)
   109             end
   110             ui.field.select{
   111               container_attr = { style = "display: inline-block; vertical-align: middle;" },
   112               attr = { style = "width: 10em;" },
   113               name = "notification_hour",
   114               foreign_records = foreign_records,
   115               foreign_id = "id",
   116               foreign_name = "name",
   117               value = random_hour or app.session.member.notification_hour
   118             }
   119           end }
   121           ui.container{ content = function()
   122             ui.tag{
   123               tag = "input", 
   124               attr = {
   125                 id = "digest_off",
   126                 type = "radio", name = "digest", value = "false",
   127                 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,
   128                 onchange = [[ $(".view_on_digest_true")[this.checked ? "hide" : "show"](400) ]]
   129               }
   130             }
   131             ui.tag{
   132               tag = "label", attr = { ['for'] = "digest_off" },
   133               content = _"don't send me a digest"
   134             }
   135           end }
   136         end }
   138         slot.put("<br />")
   140         ui.container{ content = function()
   141           ui.tag{
   142             tag = "input", 
   143             attr = {
   144               id = "notify_level_none",
   145               type = "radio", name = "disable_notifications", value = "true",
   146               checked = app.session.member.disable_notifications and "checked" or nil,
   147               onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "hide" : "show"](400) ]]
   148             }
   149           }
   150           ui.tag{
   151             tag = "label", attr = { ['for'] = "notify_level_none" },
   152             content = _"don't send me notifications by email"
   153           }
   154         end }
   156         if app.session.member.disable_notifications then
   157           ui.script{ script = [[ $(".view_on_notify_level_all_false").hide() ]] }
   158         end
   160         if not app.session.member.disable_notifications and app.session.member.notification_hour == nil  then
   161           ui.script{ script = [[ $(".view_on_digest_true").hide() ]] }
   162         end
   164         slot.put("<br />")
   166         ui.tag{
   167           tag = "input",
   168           attr = {
   169             type = "submit",
   170             class = "btn btn-default",
   171             value = _"Save"
   172           },
   173           content = ""
   174         }
   175         slot.put("<br /><br /><br />")
   177         slot.put(" ")
   178         if return_to == "home" then
   179           ui.link {
   180             module = "index", view = "index",
   181             content = _"cancel"
   182           }
   183         else
   184           ui.link {
   185             module = "member", view = "show", id = app.session.member_id, 
   186             content = _"cancel"
   187           }
   188         end
   189       end ) 
   190     end )
   192   end
   193 }
