bsw@1045: local for_area = param.get("for_area", "table") bsw@1045: bsw@1045: local selector = Policy:new_selector() bsw@1045: :add_where("policy.active") bsw@1045: :add_order_by("policy.index") bsw@1045: bsw@1045: if for_area then bsw@1045: selector:join("allowed_policy", nil, bsw@1045: { "allowed_policy.policy_id = policy.id AND allowed_policy.area_id = ?", for_area.id } bsw@1045: ) bsw@1045: end bsw@1045: bsw@1045: local policies = selector:exec() bsw@1045: bsw@1045: bsw@1045: for i, policy in ipairs(policies) do bsw@1045: ui.container { bsw@1045: attr = { class = "sidebarRow", id = "policy" .. policy.id }, bsw@1045: content = function () bsw@1045: bsw@1045: ui.heading { level = 3, content = policy.name } bsw@1045: bsw@1045: ui.tag{ bsw@1045: content = policy.description bsw@1045: } bsw@1045: bsw@1045: slot.put ( "
" ) bsw@1045: bsw@1045: ui.link { bsw@1045: attr = { bsw@1045: class = "policy-show-details", bsw@1045: onclick = "$('#policy" .. policy.id .. " .policy-details').show(); $('#policy" .. policy.id .. " .policy-show-details').hide(); $('#policy" .. policy.id .. " .policy-hide-details').show(); return false;" bsw@1045: }, bsw@1045: content = _"show details" bsw@1045: } bsw@1045: bsw@1045: ui.link { bsw@1045: attr = { bsw@1045: class = "policy-hide-details", bsw@1045: onclick = "$('#policy" .. policy.id .. " .policy-details').hide(); $('#policy" .. policy.id .. " .policy-show-details').show(); $('#policy" .. policy.id .. " .policy-hide-details').hide(); return false;", bsw@1045: style = "display: none;" bsw@1045: }, bsw@1045: content = _"hide details" bsw@1045: } bsw@1045: bsw@1045: ui.container { bsw@1045: attr = { bsw@1045: class = "policy-details", bsw@1045: style = "display: none;" bsw@1045: }, bsw@1045: content = function () bsw@1045: bsw@1045: ui.heading { level = 4, content = _"Phase durations" } bsw@1045: bsw@1045: if policy.polling then bsw@1045: ui.field.text{ label = _"New" .. ":", value = _"without" } bsw@1045: else bsw@1045: ui.field.text{ label = _"New" .. ":", value = "≤ " .. policy.admission_time } bsw@1045: end bsw@1045: ui.field.text{ label = _"Discussion" .. ":", value = policy.discussion_time or _"variable" } bsw@1045: ui.field.text{ label = _"Frozen" .. ":", value = policy.verification_time or _"variable" } bsw@1045: ui.field.text{ label = _"Voting" .. ":", value = policy.voting_time or _"variable" } bsw@1045: bsw@1045: ui.heading { level = 4, content = _"Quorums" } bsw@1045: bsw@1045: if policy.polling then bsw@1045: ui.field.text{ label = _"Issue quorum" .. ":", value = _"without" } bsw@1045: else bsw@1045: ui.field.text{ bsw@1045: label = _"Issue quorum" .. ":", bsw@1045: value = "≥ " .. tostring(policy.issue_quorum_num) .. "/" .. tostring(policy.issue_quorum_den) bsw@1045: } bsw@1045: end bsw@1045: ui.field.text{ bsw@1045: label = _"Initiative quorum" .. ":", bsw@1045: value = "≥ " .. tostring(policy.initiative_quorum_num) .. "/" .. tostring(policy.initiative_quorum_den) bsw@1045: } bsw@1045: ui.field.text{ bsw@1045: label = _"Direct majority" .. ":", bsw@1045: value = (policy.direct_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.direct_majority_num) .. "/" .. tostring(policy.direct_majority_den) bsw@1045: } bsw@1045: ui.field.text{ bsw@1045: label = _"Indirect majority" .. ":", bsw@1045: value = (policy.indirect_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.indirect_majority_num) .. "/" .. tostring(policy.indirect_majority_den) bsw@1045: } bsw@1045: end bsw@1045: } bsw@1045: end bsw@1045: } bsw@1045: end