rev |
line source |
bsw@1045
|
1 local for_area = param.get("for_area", "table")
|
bsw@1045
|
2
|
bsw@1045
|
3 local selector = Policy:new_selector()
|
bsw@1045
|
4 :add_where("policy.active")
|
bsw@1045
|
5 :add_order_by("policy.index")
|
bsw@1045
|
6
|
bsw@1045
|
7 if for_area then
|
bsw@1045
|
8 selector:join("allowed_policy", nil,
|
bsw@1045
|
9 { "allowed_policy.policy_id = policy.id AND allowed_policy.area_id = ?", for_area.id }
|
bsw@1045
|
10 )
|
bsw@1045
|
11 end
|
bsw@1045
|
12
|
bsw@1045
|
13 local policies = selector:exec()
|
bsw@1045
|
14
|
bsw@1045
|
15
|
bsw@1045
|
16 for i, policy in ipairs(policies) do
|
bsw@1045
|
17 ui.container {
|
bsw@1045
|
18 attr = { class = "sidebarRow", id = "policy" .. policy.id },
|
bsw@1045
|
19 content = function ()
|
bsw@1045
|
20
|
bsw@1045
|
21 ui.heading { level = 3, content = policy.name }
|
bsw@1045
|
22
|
bsw/jbe@1309
|
23 if policy.description and #(policy.description) > 0 then
|
bsw/jbe@1309
|
24 ui.tag{
|
bsw/jbe@1309
|
25 content = policy.description
|
bsw/jbe@1309
|
26 }
|
bsw/jbe@1309
|
27 slot.put ( "<br />" )
|
bsw/jbe@1309
|
28 end
|
bsw@1045
|
29
|
bsw@1045
|
30 ui.link {
|
bsw@1045
|
31 attr = {
|
bsw@1045
|
32 class = "policy-show-details",
|
bsw@1045
|
33 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
|
34 },
|
bsw@1045
|
35 content = _"show details"
|
bsw@1045
|
36 }
|
bsw@1045
|
37
|
bsw@1045
|
38 ui.link {
|
bsw@1045
|
39 attr = {
|
bsw@1045
|
40 class = "policy-hide-details",
|
bsw@1045
|
41 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
|
42 style = "display: none;"
|
bsw@1045
|
43 },
|
bsw@1045
|
44 content = _"hide details"
|
bsw@1045
|
45 }
|
bsw@1045
|
46
|
bsw@1045
|
47 ui.container {
|
bsw@1045
|
48 attr = {
|
bsw@1045
|
49 class = "policy-details",
|
bsw@1045
|
50 style = "display: none;"
|
bsw@1045
|
51 },
|
bsw@1045
|
52 content = function ()
|
bsw@1045
|
53
|
bsw@1045
|
54 ui.heading { level = 4, content = _"Phase durations" }
|
bsw@1045
|
55
|
bsw@1045
|
56 if policy.polling then
|
bsw@1045
|
57 ui.field.text{ label = _"New" .. ":", value = _"without" }
|
bsw@1045
|
58 else
|
bsw/jbe@1309
|
59 ui.field.text{ label = _"New" .. ":", value = "≥ " .. format.interval_text(policy.min_admission_time) }
|
bsw/jbe@1309
|
60 ui.field.text{ label = _"New" .. ":", value = "≤ " .. format.interval_text(policy.max_admission_time) }
|
bsw@1045
|
61 end
|
bsw@1100
|
62 ui.field.text{ label = _"Discussion" .. ":", value = format.interval_text(policy.discussion_time) or _"variable" }
|
bsw@1100
|
63 ui.field.text{ label = _"Frozen" .. ":", value = format.interval_text(policy.verification_time) or _"variable" }
|
bsw@1100
|
64 ui.field.text{ label = _"Voting" .. ":", value = format.interval_text(policy.voting_time) or _"variable" }
|
bsw@1045
|
65
|
bsw@1045
|
66 ui.heading { level = 4, content = _"Quorums" }
|
bsw@1045
|
67
|
bsw@1045
|
68 if policy.polling then
|
bsw@1045
|
69 ui.field.text{ label = _"Issue quorum" .. ":", value = _"without" }
|
bsw@1045
|
70 else
|
bsw@1045
|
71 ui.field.text{
|
bsw@1045
|
72 label = _"Issue quorum" .. ":",
|
bsw/jbe@1309
|
73 value = "≥ " .. tostring(policy.issue_quorum)
|
bsw@1045
|
74 }
|
bsw@1045
|
75 end
|
bsw@1045
|
76 ui.field.text{
|
bsw@1045
|
77 label = _"Initiative quorum" .. ":",
|
bsw@1045
|
78 value = "≥ " .. tostring(policy.initiative_quorum_num) .. "/" .. tostring(policy.initiative_quorum_den)
|
bsw@1045
|
79 }
|
bsw@1045
|
80 ui.field.text{
|
bsw@1045
|
81 label = _"Direct majority" .. ":",
|
bsw@1045
|
82 value = (policy.direct_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.direct_majority_num) .. "/" .. tostring(policy.direct_majority_den)
|
bsw@1045
|
83 }
|
bsw@1045
|
84 ui.field.text{
|
bsw@1045
|
85 label = _"Indirect majority" .. ":",
|
bsw@1045
|
86 value = (policy.indirect_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.indirect_majority_num) .. "/" .. tostring(policy.indirect_majority_den)
|
bsw@1045
|
87 }
|
bsw@1045
|
88 end
|
bsw@1045
|
89 }
|
bsw@1045
|
90 end
|
bsw@1045
|
91 }
|
bsw/jbe@1309
|
92 end
|