liquid_feedback_frontend

annotate app/main/admin/area_show.lua @ 263:f42d16567c5d

Added admin section for units, added unit support to areas in admin section
author bsw
date Tue Feb 07 18:13:00 2012 +0100 (2012-02-07)
parents 46351752814f
children b5684668ac4b
rev   line source
bsw/jbe@0 1 local id = param.get_id()
bsw/jbe@0 2
bsw@193 3 local area = Area:by_id(id) or Area:new()
bsw@193 4
bsw@263 5 if not area.unit_id then
bsw@263 6 area.unit_id = param.get("unit_id", atom.integer)
bsw@263 7 end
bsw@263 8
bsw@193 9 slot.put_into("title", _"Create / edit area")
bsw/jbe@0 10
bsw@193 11 slot.select("actions", function()
bsw@193 12 ui.link{
bsw@193 13 attr = { class = { "admin_only" } },
bsw@193 14 text = _"Cancel",
bsw@193 15 module = "admin",
bsw@263 16 view = "area_list",
bsw@263 17 params = { unit_id = area.unit_id }
bsw@193 18 }
bsw@193 19 end)
bsw/jbe@0 20
bsw/jbe@0 21 ui.form{
bsw/jbe@0 22 attr = { class = "vertical" },
bsw/jbe@0 23 record = area,
bsw/jbe@5 24 module = "admin",
bsw/jbe@5 25 action = "area_update",
bsw/jbe@0 26 routing = {
bsw/jbe@0 27 default = {
bsw/jbe@0 28 mode = "redirect",
bsw/jbe@0 29 module = "admin",
bsw@263 30 view = "area_list",
bsw@263 31 params = { unit_id = area.unit_id }
bsw/jbe@0 32 }
bsw/jbe@0 33 },
bsw@193 34 id = id,
bsw/jbe@0 35 content = function()
bsw@193 36 policies = Policy:build_selector{ active = true }:exec()
poelzi@126 37 local def_policy = {
poelzi@126 38 {
poelzi@126 39 id = "-1",
poelzi@126 40 name = _"No default"
poelzi@126 41 }
poelzi@126 42 }
poelzi@126 43 for i, record in ipairs(policies) do
poelzi@126 44 def_policy[#def_policy+1] = record
poelzi@126 45 end
poelzi@126 46
bsw@263 47 ui.field.hidden{ name = "unit_id", value = area.unit_id }
bsw@263 48 ui.field.text{ label = _"Unit", value = area.unit.name, readonly = true }
bsw/jbe@0 49 ui.field.text{ label = _"Name", name = "name" }
bsw/jbe@0 50 ui.field.text{ label = _"Description", name = "description", multiline = true }
bsw@193 51 ui.field.select{ label = _"Default Policy", name = "default_policy",
poelzi@126 52 value=area.default_policy and area.default_policy.id or "-1",
poelzi@126 53 foreign_records = def_policy,
poelzi@126 54 foreign_id = "id",
poelzi@126 55 foreign_name = "name"
poelzi@126 56 }
poelzi@119 57 ui.multiselect{ label = _"Policies", name = "allowed_policies[]",
poelzi@126 58 foreign_records = policies,
poelzi@119 59 foreign_id = "id",
poelzi@119 60 foreign_name = "name",
bsw@193 61 connecting_records = area.allowed_policies or {},
bsw@193 62 foreign_reference = "id",
bsw@193 63 }
bsw@263 64 slot.put("<br /><br />")
bsw@263 65 ui.field.boolean{ label = _"Active?", name = "active" }
bsw/jbe@0 66 ui.submit{ text = _"Save" }
bsw/jbe@0 67 end
bsw/jbe@0 68 }

Impressum / About Us