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@1465
|
16 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Member list" }
|
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@1465
|
34 ui.sectionHead( function()
|
bsw@1465
|
35 ui.heading { level = 1, content = newsletter and (newsletter.subject) or _"New newsletter" }
|
bsw@1465
|
36 end )
|
bsw@1465
|
37
|
bsw@1465
|
38 ui.sectionRow( function()
|
bsw@1465
|
39 local units = {
|
bsw@1465
|
40 { id = 0, name = _"All members" },
|
bsw@1465
|
41 { id = "_", name = _"" },
|
bsw@1465
|
42 }
|
bsw@1465
|
43 for i, unit in ipairs(Unit:get_flattened_tree()) do
|
bsw@1465
|
44 units[#units+1] = unit
|
bsw@1465
|
45 end
|
bsw@1465
|
46 ui.field.text{ label = _"Date", name = "published" }
|
bsw@1465
|
47 ui.field.select{
|
bsw@1465
|
48 label = "Recipient",
|
bsw@1465
|
49 name = "unit_id",
|
bsw@1465
|
50 foreign_records = units,
|
bsw@1465
|
51 foreign_id = "id",
|
bsw@1465
|
52 foreign_name = "name",
|
bsw@1465
|
53 disabled_records = { ["_"] = true },
|
bsw@1465
|
54 value = newsletter.unit_id
|
bsw@1465
|
55 }
|
bsw@1465
|
56 ui.field.boolean{ label = _"Override disable notifications?", name = "include_all_members" }
|
bsw@1465
|
57 slot.put("<br />")
|
bsw@1465
|
58 ui.field.text{ label = _"Subject", name = "subject" }
|
bsw@1465
|
59 ui.field.text{ label = _"Content", name = "content", multiline = true, attr = { rows = "20" } }
|
bsw@1248
|
60
|
bsw@1465
|
61 ui.submit{ text = _"create newsletter" }
|
bsw@1465
|
62 slot.put(" ")
|
bsw@1465
|
63 ui.link { module = "admin", view = "index", content = _"cancel" }
|
bsw@1465
|
64 end )
|
bsw@1465
|
65 end
|
bsw@1465
|
66 }
|
bsw@1465
|
67 end }
|
bsw@1465
|
68 end }
|
bsw@1465
|
69 end }
|
bsw@1465
|
70 end }
|