bsw/jbe@0: local id = param.get_id()
bsw/jbe@0:
bsw@1045: local hint = not id
bsw@1045:
bsw@193: local area = Area:by_id(id) or Area:new()
bsw@193:
bsw@263: if not area.unit_id then
bsw@263: area.unit_id = param.get("unit_id", atom.integer)
bsw@263: end
bsw@263:
bsw@1045: ui.titleAdmin(_"area")
bsw/jbe@0:
bsw@1468: ui.grid{ content = function()
bsw@1468:
bsw@1468: ui.cell_main{ content = function()
bsw@1468: ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
bsw@1468: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
bsw@1469: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name or _"New area" }
bsw@1468: end }
bsw@1468: ui.container{ attr = { class = "mdl-card__content" }, content = function()
bsw@1468: ui.form{
bsw@1468: attr = { class = "vertical section" },
bsw@1468: record = area,
bsw@1468: module = "admin",
bsw@1468: action = "area_update",
bsw@1468: routing = {
bsw@1468: ok = {
bsw@1468: mode = "redirect",
bsw@1468: module = "admin",
bsw@1468: view = "index",
bsw@1468: params = { unit_id = area.unit_id }
bsw@1468: },
bsw@1468: },
bsw@1468: id = id,
bsw@1468: content = function()
bsw@1468: local policies = Policy:build_selector{ active = true }:exec()
bsw@1468: local def_policy = {
bsw@1468: {
bsw@1468: id = "-1",
bsw@1468: name = _"No default"
bsw@1468: }
bsw@1468: }
bsw@1468: for i, record in ipairs(policies) do
bsw@1468: def_policy[#def_policy+1] = record
bsw@1468: end
poelzi@126:
bsw@1468:
bsw@1468: ui.section( function()
bsw@1468: ui.sectionRow( function()
bsw@1468:
bsw@1468: ui.field.hidden{ name = "unit_id", value = area.unit_id }
bsw@1468: ui.field.text{ label = _"Unit", value = area.unit.name, readonly = true }
bsw@1468: ui.field.text{ label = _"Name", name = "name" }
bsw@1468: ui.field.text{ label = _"Description", name = "description", multiline = true }
bsw@1468: ui.field.text{ label = _"External reference", name = "external_reference" }
bsw@1468: ui.field.select{ label = _"Default Policy", name = "default_policy",
bsw@1468: value=area.default_policy and area.default_policy.id or "-1",
bsw@1468: foreign_records = def_policy,
bsw@1468: foreign_id = "id",
bsw@1468: foreign_name = "name"
bsw@1468: }
bsw@1473: ui.container{ content = _"Allowed policies" }
bsw@1468: ui.multiselect{ name = "allowed_policies[]",
bsw@1468: foreign_records = policies,
bsw@1468: foreign_id = "id",
bsw@1468: foreign_name = "name",
bsw@1468: connecting_records = area.allowed_policies or {},
bsw@1468: foreign_reference = "id",
bsw@1468: }
bsw@1472: slot.put("
")
bsw@1556: ui.field.text{ label = _"Admission quorum standard", name = "quorum_standard", value = hint and 0 or nil }
bsw@1556: ui.field.text{ label = _"Admission quorum issues", name = "quorum_issues", value = hint and 1 or nil }
bsw@1556: ui.field.text{ label = _"Admission quorum time", name = "quorum_time", value = hint and "1 days" or nil }
bsw@1468: ui.field.text{ label = _"Admission quorum exponent", name = "quorum_exponent", value = hint and 0.5 or nil }
bsw@1468: ui.field.text{ label = _"Admission qourum factor", name = "quorum_factor", value = hint and 2 or nil }
bsw@1472: slot.put("
")
bsw@1468: ui.field.boolean{ label = _"Active?", name = "active", value = hint and true or nil }
bsw@1472: slot.put("
")
bsw@1470: ui.submit{
bsw@1470: attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
bsw@1470: text = _"update area"
bsw@1470: }
bsw@1468: slot.put(" ")
bsw@1470: ui.link{
bsw@1470: attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" },
bsw@1470: module = "admin", view = "index", content = _"cancel"
bsw@1470: }
bsw@1468: end )
bsw@1468: end )
bsw@1468: end
bsw@1045: }
bsw@1468: end }
bsw@1468: end }
bsw@1468: end }
bsw@1468: end }