rev |
line source |
bsw@1248
|
1 local id = param.get_id()
|
bsw@1248
|
2
|
bsw@1248
|
3 local newsletter = {}
|
bsw@1248
|
4
|
bsw@1248
|
5 if id then
|
bsw@1248
|
6 newsletter = Newsletter:by_id(id)
|
bsw@1248
|
7 end
|
bsw@1248
|
8
|
bsw@1248
|
9 ui.titleAdmin(_"Newsletter")
|
bsw@1248
|
10
|
bsw@1465
|
11 ui.grid{ content = function()
|
bsw@1465
|
12
|
bsw@1465
|
13 ui.cell_main{ content = function()
|
bsw@1465
|
14 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
|
bsw@1465
|
15 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
|
bsw@1466
|
16 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = newsletter and (newsletter.subject) or _"New newsletter" }
|
bsw@1465
|
17 end }
|
bsw@1465
|
18 ui.container{ attr = { class = "mdl-card__content" }, content = function()
|
bsw@1465
|
19 ui.form{
|
bsw@1465
|
20 attr = { class = "vertical section" },
|
bsw@1465
|
21 module = "admin",
|
bsw@1465
|
22 action = "newsletter_update",
|
bsw@1465
|
23 id = newsletter and newsletter.id,
|
bsw@1465
|
24 record = newsletter,
|
bsw@1465
|
25 routing = {
|
bsw@1465
|
26 default = {
|
bsw@1465
|
27 mode = "redirect",
|
bsw@1465
|
28 modules = "admin",
|
bsw@1465
|
29 view = "newsletter_list"
|
bsw@1465
|
30 }
|
bsw@1465
|
31 },
|
bsw@1465
|
32 content = function()
|
bsw@1248
|
33
|
bsw@1466
|
34 local units = {
|
bsw@1466
|
35 { id = 0, name = _"All members" },
|
bsw@1466
|
36 { id = "_", name = _"" },
|
bsw@1466
|
37 }
|
bsw@1505
|
38 for i, unit in ipairs(Unit:get_flattened_tree{include_hidden = true}) do
|
bsw@1466
|
39 units[#units+1] = unit
|
bsw@1466
|
40 end
|
bsw@1466
|
41 ui.field.text{ label = _"Date", name = "published" }
|
bsw@1466
|
42 ui.field.select{
|
bsw@1466
|
43 label = "Recipient",
|
bsw@1466
|
44 name = "unit_id",
|
bsw@1466
|
45 foreign_records = units,
|
bsw@1466
|
46 foreign_id = "id",
|
bsw@1466
|
47 foreign_name = "name",
|
bsw@1466
|
48 disabled_records = { ["_"] = true },
|
bsw@1466
|
49 value = newsletter.unit_id
|
bsw@1466
|
50 }
|
bsw@1466
|
51 ui.field.boolean{ label = _"Override disable notifications?", name = "include_all_members" }
|
bsw@1466
|
52 slot.put("<br />")
|
bsw@1466
|
53 ui.field.text{ label = _"Subject", name = "subject" }
|
bsw@1466
|
54 ui.field.text{ label = _"Content", name = "content", multiline = true, attr = { rows = "20" } }
|
bsw@1248
|
55
|
bsw@1467
|
56 ui.submit{
|
bsw@1467
|
57 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
|
bsw@1467
|
58 text = _"create newsletter"
|
bsw@1467
|
59 }
|
bsw@1466
|
60 slot.put(" ")
|
bsw@1467
|
61 ui.link {
|
bsw@1467
|
62 attr = { class = "mdl-button mdl-js-button" },
|
bsw@1467
|
63 module = "admin", view = "index", content = _"cancel"
|
bsw@1467
|
64 }
|
bsw@1466
|
65
|
bsw@1465
|
66 end
|
bsw@1465
|
67 }
|
bsw@1465
|
68 end }
|
bsw@1465
|
69 end }
|
bsw@1465
|
70 end }
|
bsw@1465
|
71 end }
|