annotate app/main/admin/unit_edit.lua @ 1463:16868516595f
New layout for admin policy edit view
author |
bsw |
date |
Thu Oct 18 17:34:24 2018 +0200 (2018-10-18) |
parents |
32cc544d5a5b |
children |
9a01089a6703 |
rev |
line source |
bsw@525
|
1 local id = param.get_id()
|
bsw@525
|
2
|
bsw/jbe@1309
|
3 local hint = not id
|
bsw/jbe@1309
|
4
|
bsw@525
|
5 local unit = Unit:by_id(id)
|
bsw@525
|
6
|
bsw@1184
|
7 ui.titleAdmin(_"Organizational unit")
|
bsw@525
|
8
|
bsw@595
|
9 local units = {
|
bsw@595
|
10 { id = nil, name = "" }
|
bsw@595
|
11 }
|
bsw@595
|
12
|
bsw@595
|
13 for i, unit in ipairs(Unit:get_flattened_tree()) do
|
bsw@595
|
14 units[#units+1] = { id = unit.id, name = unit.name }
|
bsw@525
|
15 end
|
bsw@525
|
16
|
bsw@525
|
17 ui.form{
|
bsw@1045
|
18 attr = { class = "vertical section" },
|
bsw@525
|
19 module = "admin",
|
bsw@595
|
20 action = "unit_update",
|
bsw@595
|
21 id = unit and unit.id,
|
bsw@595
|
22 record = unit,
|
bsw@525
|
23 routing = {
|
bsw@525
|
24 default = {
|
bsw@525
|
25 mode = "redirect",
|
bsw@525
|
26 modules = "admin",
|
bsw@1045
|
27 view = "index"
|
bsw@525
|
28 }
|
bsw@525
|
29 },
|
bsw@525
|
30 content = function()
|
bsw@1045
|
31 ui.sectionHead( function()
|
bsw@1045
|
32 ui.heading { level = 1, content = unit and unit.name or _"New organizational unit" }
|
bsw@1045
|
33 end )
|
bsw@1045
|
34 ui.sectionRow( function()
|
bsw@1045
|
35 ui.field.select{
|
bsw@1045
|
36 label = _"Parent unit",
|
bsw@1045
|
37 name = "parent_id",
|
bsw@1045
|
38 foreign_records = units,
|
bsw@1045
|
39 foreign_id = "id",
|
bsw@1045
|
40 foreign_name = "name"
|
bsw@1045
|
41 }
|
bsw@1045
|
42 ui.field.text{ label = _"Name", name = "name" }
|
bsw@1045
|
43 ui.field.text{ label = _"Description", name = "description", multiline = true }
|
bsw@1209
|
44 ui.field.text{ label = _"External reference", name = "external_reference" }
|
bsw/jbe@1309
|
45 ui.field.boolean{ label = _"Active?", name = "active", value = hint and true or nil }
|
bsw@525
|
46
|
bsw@1045
|
47 slot.put("<br />")
|
bsw@1045
|
48 ui.submit{ text = _"update unit" }
|
bsw@1045
|
49 slot.put(" ")
|
bsw@1045
|
50 ui.link{ module = "admin", view = "index", content = _"cancel" }
|
bsw@1045
|
51 end )
|
bsw@525
|
52 end
|
bsw@525
|
53 }
|