liquid_feedback_frontend

view 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
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 ui.field.select{
107 container_attr = { style = "display: inline-block; vertical-align: middle;" },
108 attr = { style = "width: 10em;" },
109 name = "notification_hour",
110 foreign_records = foreign_records,
111 foreign_id = "id",
112 foreign_name = "name",
113 value = app.session.member.notification_hour
114 }
115 end }
117 ui.container{ content = function()
118 ui.tag{
119 tag = "input",
120 attr = {
121 id = "digest_off",
122 type = "radio", name = "digest", value = "false",
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,
124 onchange = [[ $(".view_on_digest_true")[this.checked ? "hide" : "show"](400) ]]
125 }
126 }
127 ui.tag{
128 tag = "label", attr = { ['for'] = "digest_off" },
129 content = _"don't send me a digest"
130 }
131 end }
132 end }
134 slot.put("<br />")
136 ui.container{ content = function()
137 ui.tag{
138 tag = "input",
139 attr = {
140 id = "notify_level_none",
141 type = "radio", name = "disable_notifications", value = "true",
142 checked = app.session.member.disable_notifications and "checked" or nil,
143 onchange = [[ $(".view_on_notify_level_all_false")[this.checked ? "hide" : "show"](400) ]]
144 }
145 }
146 ui.tag{
147 tag = "label", attr = { ['for'] = "notify_level_none" },
148 content = _"don't send me notifications by email"
149 }
150 end }
152 if app.session.member.disable_notifications then
153 ui.script{ script = [[ $(".view_on_notify_level_all_false").hide() ]] }
154 end
156 if app.session.member.notification_hour == nil then
157 ui.script{ script = [[ $(".view_on_digest_true").hide() ]] }
158 end
160 slot.put("<br />")
162 ui.tag{
163 tag = "input",
164 attr = {
165 type = "submit",
166 class = "btn btn-default",
167 value = _"Save"
168 },
169 content = ""
170 }
171 slot.put("<br /><br /><br />")
173 slot.put(" ")
174 if return_to == "home" then
175 ui.link {
176 module = "index", view = "index",
177 content = _"cancel"
178 }
179 else
180 ui.link {
181 module = "member", view = "show", id = app.session.member_id,
182 content = _"cancel"
183 }
184 end
185 end )
186 end )
188 end
189 }

Impressum / About Us