liquid_feedback_frontend

view app/main/member/settings_notification.lua @ 1859:02c34183b6df

Fixed wrong filename in INSTALL file
author bsw
date Tue Nov 28 18:54:51 2023 +0100 (5 months ago)
parents 678c7146f27b
children
line source
1 local return_to = param.get("return_to")
2 local return_to_area_id = param.get("return_to_area_id", atom.integer)
3 local return_to_area = Area:by_id(return_to_area_id)
5 ui.titleMember(_"notification settings")
7 ui.grid{ content = function()
8 ui.cell_main{ content = function()
10 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
11 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
12 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"notification settings" }
13 end }
14 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
16 ui.form{
17 attr = { class = "vertical" },
18 module = "member",
19 action = "update_notify_level",
20 routing = {
21 ok = {
22 mode = "redirect",
23 module = return_to == "area" and "index" or return_to == "home" and "index" or "member",
24 view = return_to == "area" and "index" or return_to == "home" and "index" or "settings",
25 params = return_to_area and { unit = return_to_area.unit_id, area = return_to_area.id } or nil
26 }
27 },
28 content = function()
30 ui.container{ content = function()
31 ui.tag{ tag = "label", attr = {
32 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
33 ["for"] = "notify_level_all"
34 },
35 content = function()
36 ui.tag{
37 tag = "input",
38 attr = {
39 id = "notify_level_all",
40 class = "mdl-checkbox__input",
41 type = "checkbox", name = "enable_notifications", value = "true",
42 checked = not app.session.member.disable_notifications and "checked" or nil,
43 onchange = [[ display = document.getElementById("view_on_notify_level_all_false").style.display = this.checked ? "block" : "none"; ]]
44 }
45 }
46 ui.tag{
47 attr = { class = "mdl-checkbox__label", ['for'] = "notify_level_all" },
48 content = _"I like to receive notifications"
49 }
50 end
51 }
52 end }
55 ui.container{ attr = { id = "view_on_notify_level_all_false" }, content = function()
56 slot.put("<br />")
58 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." }
59 slot.put("<br />")
60 ui.container{ content = function()
61 ui.tag{ tag = "label", attr = {
62 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
63 ["for"] = "digest_on"
64 },
65 content = function()
66 ui.tag{
67 tag = "input",
68 attr = {
69 id = "digest_on",
70 class = "mdl-checkbox__input",
71 type = "checkbox", name = "digest", value = "true",
72 checked = app.session.member.notification_hour ~= nil and "checked" or nil,
73 onchange = [[ display = document.getElementById("view_on_digest_true").style.display = this.checked ? "block" : "none"; ]]
74 }
75 }
76 ui.tag{
77 attr = { class = "mdl-checkbox__label", ['for'] = "digest_on" },
78 content = _"I want to receive a regular digest"
79 }
80 end
81 }
82 end }
84 ui.container{ attr = { id = "view_on_digest_true", style = "margin-left: 4em;" }, content = function()
86 ui.tag{ content = _"every" }
87 slot.put(" ")
88 ui.field.select{
89 container_attr = { style = "display: inline-block; vertical-align: middle;" },
90 attr = { style = "width: 10em;" },
91 name = "notification_dow",
92 foreign_records = {
93 { id = "daily", name = _"day" },
94 { id = 0, name = _"Sunday" },
95 { id = 1, name = _"Monday" },
96 { id = 2, name = _"Tuesday" },
97 { id = 3, name = _"Wednesday" },
98 { id = 4, name = _"Thursday" },
99 { id = 5, name = _"Friday" },
100 { id = 6, name = _"Saturday" }
101 },
102 foreign_id = "id",
103 foreign_name = "name",
104 value = app.session.member.notification_dow
105 }
107 slot.put(" ")
109 ui.tag{ content = _"between" }
110 slot.put(" ")
111 local foreign_records = {}
112 for i = 0, 23 do
113 foreign_records[#foreign_records+1] = {
114 id = i,
115 name = string.format("%02d:00 - %02d:59", i, i),
116 }
117 end
118 local random_hour
119 if app.session.member.disable_notifications or app.session.member.notification_hour == nil then
120 random_hour = multirand.integer(0,23)
121 end
122 ui.field.select{
123 container_attr = { style = "display: inline-block; vertical-align: middle;" },
124 attr = { style = "width: 10em;" },
125 name = "notification_hour",
126 foreign_records = foreign_records,
127 foreign_id = "id",
128 foreign_name = "name",
129 value = random_hour or app.session.member.notification_hour
130 }
131 end }
133 end }
135 slot.put("<br />")
137 if app.session.member.disable_notifications then
138 ui.script{ script = [[ document.getElementById("view_on_notify_level_all_false").style.display = "none"; ]] }
139 end
141 if app.session.member.notification_hour == nil then
142 ui.script{ script = [[ document.getElementById("view_on_digest_true").style.display = "none"; ]] }
143 end
145 slot.put("<br />")
147 ui.tag{
148 tag = "input",
149 attr = {
150 type = "submit",
151 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
152 value = _"Save"
153 },
154 content = ""
155 }
156 slot.put(" &nbsp; ")
158 slot.put(" ")
159 if return_to == "home" then
160 ui.link {
161 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
162 module = "index", view = "index",
163 content = _"cancel"
164 }
165 else
166 ui.link {
167 attr = { class = "mdl-button mdl-js-button" },
168 module = "member", view = "show", id = app.session.member_id,
169 content = _"Cancel"
170 }
171 end
173 end
174 }
176 end }
177 end }
178 end }
180 ui.cell_sidebar{ content = function()
181 execute.view {
182 module = "member", view = "_sidebar_whatcanido", params = {
183 member = app.session.member
184 }
185 }
186 end }
188 end }

Impressum / About Us