liquid_feedback_frontend

annotate app/main/member/settings_notification.lua @ 1286:a501cdd10fbb

Changed default option when changing notification level
author bsw
date Mon Apr 18 09:57:49 2016 +0200 (2016-04-18)
parents 48d843cd65f0
children 6154987e3545
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@1286 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@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@1286 123 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 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@1285 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@1285 148 content = _"don't send me notifications by email"
bsw@1045 149 }
bsw@1045 150 end }
bsw@1045 151
bsw@1282 152 if app.session.member.disable_notifications then
bsw@1282 153 ui.script{ script = [[ $(".view_on_notify_level_all_false").hide() ]] }
bsw@1282 154 end
bsw@1282 155
bsw@1282 156 if app.session.member.notification_hour == nil then
bsw@1282 157 ui.script{ script = [[ $(".view_on_digest_true").hide() ]] }
bsw@1282 158 end
bsw@1282 159
bsw@1045 160 slot.put("<br />")
bsw@1045 161
bsw@1045 162 ui.tag{
bsw@1045 163 tag = "input",
bsw@1045 164 attr = {
bsw@1045 165 type = "submit",
bsw@1045 166 class = "btn btn-default",
bsw@1045 167 value = _"Save"
bsw@1045 168 },
bsw@1045 169 content = ""
bsw@348 170 }
bsw@1045 171 slot.put("<br /><br /><br />")
bsw@1045 172
bsw@1045 173 slot.put(" ")
bsw@1045 174 if return_to == "home" then
bsw@1045 175 ui.link {
bsw@1045 176 module = "index", view = "index",
bsw@1045 177 content = _"cancel"
bsw@1045 178 }
bsw@1045 179 else
bsw@1045 180 ui.link {
bsw@1045 181 module = "member", view = "show", id = app.session.member_id,
bsw@1045 182 content = _"cancel"
bsw@1045 183 }
bsw@1045 184 end
bsw@1045 185 end )
bsw@1045 186 end )
bsw@474 187
bsw@286 188 end
bsw@286 189 }
bsw@287 190

Impressum / About Us