liquid_feedback_frontend

annotate app/main/member/settings_notification.lua @ 1290:7f81a32c3e86

Another case for random notification hour
author bsw
date Mon Apr 18 10:38:58 2016 +0200 (2016-04-18)
parents 0722ce4a403a
children 32cc544d5a5b
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@1045 32 ui.sectionRow( function()
bsw@1045 33
bsw@1045 34 ui.container{ content = function()
bsw@1045 35 ui.tag{
bsw@1045 36 tag = "input",
bsw@1045 37 attr = {
bsw@1045 38 id = "notify_level_all",
bsw@1248 39 type = "radio", name = "disable_notifications", value = "false",
bsw@1282 40 checked = not app.session.member.disable_notifications and "checked" or nil,
bsw@1281 41 onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "show" : "hide"](400) ]]
bsw@1045 42 }
bsw@1045 43 }
bsw@1045 44 ui.tag{
bsw@1045 45 tag = "label", attr = { ['for'] = "notify_level_all" },
bsw@1045 46 content = _"I like to receive notifications"
bsw@1045 47 }
bsw@1045 48 end }
bsw@1045 49
bsw@1255 50
bsw@1281 51 ui.container{ attr = { class = "view_on_notify_level_all_false", style = "margin-left: 3em;" }, content = function()
bsw@1283 52 slot.put("<br />")
bsw@1277 53
bsw@1277 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." }
bsw@1279 55 slot.put("<br />")
bsw@1261 56 ui.container{ content = function()
bsw@1261 57 ui.tag{
bsw@1261 58 tag = "input",
bsw@1261 59 attr = {
bsw@1261 60 id = "digest_on",
bsw@1261 61 type = "radio", name = "digest", value = "true",
bsw@1287 62 checked = (app.session.member.disable_notifications or app.session.member.notification_hour ~= nil) and "checked" or nil,
bsw@1281 63 onchange = [[ $(".view_on_digest_true")[this.checked ? "show" : "hide"](400) ]]
bsw@1261 64 }
bsw@1261 65 }
bsw@1261 66 ui.tag{
bsw@1261 67 tag = "label", attr = { ['for'] = "digest_on" },
bsw@1285 68 content = _"I want to receive a regular digest"
bsw@1261 69 }
bsw@1262 70 end }
bsw@1261 71
bsw@1281 72 ui.container{ attr = { class = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
bsw@1284 73
bsw@1285 74 ui.tag{ content = _"every" }
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@1285 81 { id = "daily", name = _"day" },
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@1284 97 ui.tag{ content = _"between" }
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@1289 106 local random_hour
bsw@1290 107 if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
bsw@1289 108 random_hour = multirand.integer(0,23)
bsw@1289 109 end
bsw@1261 110 ui.field.select{
bsw@1273 111 container_attr = { style = "display: inline-block; vertical-align: middle;" },
bsw@1280 112 attr = { style = "width: 10em;" },
bsw@1261 113 name = "notification_hour",
bsw@1261 114 foreign_records = foreign_records,
bsw@1261 115 foreign_id = "id",
bsw@1268 116 foreign_name = "name",
bsw@1289 117 value = random_hour or app.session.member.notification_hour
bsw@1261 118 }
bsw@1261 119 end }
bsw@1261 120
bsw@1261 121 ui.container{ content = function()
bsw@1261 122 ui.tag{
bsw@1261 123 tag = "input",
bsw@1261 124 attr = {
bsw@1261 125 id = "digest_off",
bsw@1261 126 type = "radio", name = "digest", value = "false",
bsw@1286 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,
bsw@1281 128 onchange = [[ $(".view_on_digest_true")[this.checked ? "hide" : "show"](400) ]]
bsw@1261 129 }
bsw@1261 130 }
bsw@1261 131 ui.tag{
bsw@1261 132 tag = "label", attr = { ['for'] = "digest_off" },
bsw@1285 133 content = _"don't send me a digest"
bsw@1261 134 }
bsw@1261 135 end }
bsw@1255 136 end }
bsw@1255 137
bsw@1263 138 slot.put("<br />")
bsw@1255 139
bsw@1045 140 ui.container{ content = function()
bsw@1045 141 ui.tag{
bsw@1045 142 tag = "input",
bsw@1045 143 attr = {
bsw@1045 144 id = "notify_level_none",
bsw@1248 145 type = "radio", name = "disable_notifications", value = "true",
bsw@1281 146 checked = app.session.member.disable_notifications and "checked" or nil,
bsw@1281 147 onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "hide" : "show"](400) ]]
bsw@1045 148 }
bsw@1045 149 }
bsw@1045 150 ui.tag{
bsw@1045 151 tag = "label", attr = { ['for'] = "notify_level_none" },
bsw@1285 152 content = _"don't send me notifications by email"
bsw@1045 153 }
bsw@1045 154 end }
bsw@1045 155
bsw@1282 156 if app.session.member.disable_notifications then
bsw@1282 157 ui.script{ script = [[ $(".view_on_notify_level_all_false").hide() ]] }
bsw@1282 158 end
bsw@1282 159
bsw@1288 160 if not app.session.member.disable_notifications and app.session.member.notification_hour == nil then
bsw@1282 161 ui.script{ script = [[ $(".view_on_digest_true").hide() ]] }
bsw@1282 162 end
bsw@1282 163
bsw@1045 164 slot.put("<br />")
bsw@1045 165
bsw@1045 166 ui.tag{
bsw@1045 167 tag = "input",
bsw@1045 168 attr = {
bsw@1045 169 type = "submit",
bsw@1045 170 class = "btn btn-default",
bsw@1045 171 value = _"Save"
bsw@1045 172 },
bsw@1045 173 content = ""
bsw@348 174 }
bsw@1045 175 slot.put("<br /><br /><br />")
bsw@1045 176
bsw@1045 177 slot.put(" ")
bsw@1045 178 if return_to == "home" then
bsw@1045 179 ui.link {
bsw@1045 180 module = "index", view = "index",
bsw@1045 181 content = _"cancel"
bsw@1045 182 }
bsw@1045 183 else
bsw@1045 184 ui.link {
bsw@1045 185 module = "member", view = "show", id = app.session.member_id,
bsw@1045 186 content = _"cancel"
bsw@1045 187 }
bsw@1045 188 end
bsw@1045 189 end )
bsw@1045 190 end )
bsw@474 191
bsw@286 192 end
bsw@286 193 }
bsw@287 194

Impressum / About Us