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@1466
|
38 for i, unit in ipairs(Unit:get_flattened_tree()) 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@1466
|
56 ui.submit{ text = _"create newsletter" }
|
bsw@1466
|
57 slot.put(" ")
|
bsw@1466
|
58 ui.link { module = "admin", view = "index", content = _"cancel" }
|
bsw@1466
|
59
|
bsw@1465
|
60 end
|
bsw@1465
|
61 }
|
bsw@1465
|
62 end }
|
bsw@1465
|
63 end }
|
bsw@1465
|
64 end }
|
bsw@1465
|
65 end }
|