| 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@1045
 | 
    23       ui.tag{
 | 
| 
bsw@1045
 | 
    24         content = policy.description
 | 
| 
bsw@1045
 | 
    25       }
 | 
| 
bsw@1045
 | 
    26 
 | 
| 
bsw@1045
 | 
    27       slot.put ( "<br />" )
 | 
| 
bsw@1045
 | 
    28       
 | 
| 
bsw@1045
 | 
    29       ui.link {
 | 
| 
bsw@1045
 | 
    30         attr = {
 | 
| 
bsw@1045
 | 
    31           class = "policy-show-details",
 | 
| 
bsw@1045
 | 
    32           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
 | 
    33         },
 | 
| 
bsw@1045
 | 
    34         content = _"show details"
 | 
| 
bsw@1045
 | 
    35       }
 | 
| 
bsw@1045
 | 
    36       
 | 
| 
bsw@1045
 | 
    37       ui.link {
 | 
| 
bsw@1045
 | 
    38         attr = {
 | 
| 
bsw@1045
 | 
    39           class = "policy-hide-details",
 | 
| 
bsw@1045
 | 
    40           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
 | 
    41           style = "display: none;"
 | 
| 
bsw@1045
 | 
    42         },
 | 
| 
bsw@1045
 | 
    43         content = _"hide details"
 | 
| 
bsw@1045
 | 
    44       }
 | 
| 
bsw@1045
 | 
    45       
 | 
| 
bsw@1045
 | 
    46       ui.container {
 | 
| 
bsw@1045
 | 
    47         attr = {
 | 
| 
bsw@1045
 | 
    48           class = "policy-details",
 | 
| 
bsw@1045
 | 
    49           style = "display: none;"
 | 
| 
bsw@1045
 | 
    50         },
 | 
| 
bsw@1045
 | 
    51         content = function ()
 | 
| 
bsw@1045
 | 
    52 
 | 
| 
bsw@1045
 | 
    53           ui.heading { level = 4, content = _"Phase durations" }
 | 
| 
bsw@1045
 | 
    54 
 | 
| 
bsw@1045
 | 
    55           if policy.polling then
 | 
| 
bsw@1045
 | 
    56             ui.field.text{ label = _"New" .. ":", value = _"without" }
 | 
| 
bsw@1045
 | 
    57           else
 | 
| 
bsw@1045
 | 
    58             ui.field.text{ label = _"New" .. ":", value = "≤ " .. policy.admission_time }
 | 
| 
bsw@1045
 | 
    59           end
 | 
| 
bsw@1045
 | 
    60           ui.field.text{ label = _"Discussion" .. ":", value = policy.discussion_time or _"variable" }
 | 
| 
bsw@1045
 | 
    61           ui.field.text{ label = _"Frozen" .. ":", value = policy.verification_time or _"variable" }
 | 
| 
bsw@1045
 | 
    62           ui.field.text{ label = _"Voting" .. ":", value = policy.voting_time or _"variable" }
 | 
| 
bsw@1045
 | 
    63 
 | 
| 
bsw@1045
 | 
    64           ui.heading { level = 4, content = _"Quorums" }
 | 
| 
bsw@1045
 | 
    65           
 | 
| 
bsw@1045
 | 
    66           if policy.polling then
 | 
| 
bsw@1045
 | 
    67             ui.field.text{ label = _"Issue quorum" .. ":", value = _"without" }
 | 
| 
bsw@1045
 | 
    68           else
 | 
| 
bsw@1045
 | 
    69             ui.field.text{
 | 
| 
bsw@1045
 | 
    70               label = _"Issue quorum" .. ":", 
 | 
| 
bsw@1045
 | 
    71               value = "≥ " .. tostring(policy.issue_quorum_num) .. "/" .. tostring(policy.issue_quorum_den)
 | 
| 
bsw@1045
 | 
    72             }
 | 
| 
bsw@1045
 | 
    73           end
 | 
| 
bsw@1045
 | 
    74           ui.field.text{
 | 
| 
bsw@1045
 | 
    75             label = _"Initiative quorum" .. ":", 
 | 
| 
bsw@1045
 | 
    76             value = "≥ " .. tostring(policy.initiative_quorum_num) .. "/" .. tostring(policy.initiative_quorum_den)
 | 
| 
bsw@1045
 | 
    77           }
 | 
| 
bsw@1045
 | 
    78           ui.field.text{
 | 
| 
bsw@1045
 | 
    79             label = _"Direct majority" .. ":", 
 | 
| 
bsw@1045
 | 
    80             value = (policy.direct_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.direct_majority_num) .. "/" .. tostring(policy.direct_majority_den)
 | 
| 
bsw@1045
 | 
    81           }
 | 
| 
bsw@1045
 | 
    82           ui.field.text{
 | 
| 
bsw@1045
 | 
    83             label = _"Indirect majority" .. ":", 
 | 
| 
bsw@1045
 | 
    84             value = (policy.indirect_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.indirect_majority_num) .. "/" .. tostring(policy.indirect_majority_den)
 | 
| 
bsw@1045
 | 
    85           }
 | 
| 
bsw@1045
 | 
    86         end
 | 
| 
bsw@1045
 | 
    87       }
 | 
| 
bsw@1045
 | 
    88     end
 | 
| 
bsw@1045
 | 
    89   }
 | 
| 
bsw@1045
 | 
    90 end |