liquid_feedback_frontend
view app/main/policy/_list.lua @ 1238:4204e1185f66
Fixed syntax error in lf4rcs.update_references
| author | bsw | 
|---|---|
| date | Sun Dec 13 17:33:35 2015 +0100 (2015-12-13) | 
| parents | 8288027edb54 | 
| children | 32cc544d5a5b | 
 line source
     1 local for_area = param.get("for_area", "table")
     3 local selector = Policy:new_selector()
     4   :add_where("policy.active")
     5   :add_order_by("policy.index")
     7 if for_area then
     8   selector:join("allowed_policy", nil,
     9     { "allowed_policy.policy_id = policy.id AND allowed_policy.area_id = ?", for_area.id }
    10   )
    11 end
    13 local policies = selector:exec()
    16 for i, policy in ipairs(policies) do
    17   ui.container { 
    18     attr = { class = "sidebarRow", id = "policy" .. policy.id },
    19     content = function ()
    21       ui.heading { level = 3, content = policy.name }
    23       ui.tag{
    24         content = policy.description
    25       }
    27       slot.put ( "<br />" )
    29       ui.link {
    30         attr = {
    31           class = "policy-show-details",
    32           onclick = "$('#policy" .. policy.id .. " .policy-details').show(); $('#policy" .. policy.id .. " .policy-show-details').hide(); $('#policy" .. policy.id .. " .policy-hide-details').show(); return false;"
    33         },
    34         content = _"show details"
    35       }
    37       ui.link {
    38         attr = {
    39           class = "policy-hide-details",
    40           onclick = "$('#policy" .. policy.id .. " .policy-details').hide(); $('#policy" .. policy.id .. " .policy-show-details').show(); $('#policy" .. policy.id .. " .policy-hide-details').hide(); return false;",
    41           style = "display: none;"
    42         },
    43         content = _"hide details"
    44       }
    46       ui.container {
    47         attr = {
    48           class = "policy-details",
    49           style = "display: none;"
    50         },
    51         content = function ()
    53           ui.heading { level = 4, content = _"Phase durations" }
    55           if policy.polling then
    56             ui.field.text{ label = _"New" .. ":", value = _"without" }
    57           else
    58             ui.field.text{ label = _"New" .. ":", value = "≤ min " .. format.interval_text(policy.max_admission_time) }
    59             ui.field.text{ label = _"New" .. ":", value = "≤ max " .. format.interval_text(policy.max_admission_time) }
    60           end
    61           ui.field.text{ label = _"Discussion" .. ":", value = format.interval_text(policy.discussion_time) or _"variable" }
    62           ui.field.text{ label = _"Frozen" .. ":", value = format.interval_text(policy.verification_time) or _"variable" }
    63           ui.field.text{ label = _"Voting" .. ":", value = format.interval_text(policy.voting_time) or _"variable" }
    65           ui.heading { level = 4, content = _"Quorums" }
    67           if policy.polling then
    68             ui.field.text{ label = _"Issue quorum" .. ":", value = _"without" }
    69           else
    70             ui.field.text{
    71               label = _"Issue quorum" .. ":", 
    72               value = "≥ " .. tostring(policy.issue_quorum_num) .. "/" .. tostring(policy.issue_quorum_den)
    73             }
    74           end
    75           ui.field.text{
    76             label = _"Initiative quorum" .. ":", 
    77             value = "≥ " .. tostring(policy.initiative_quorum_num) .. "/" .. tostring(policy.initiative_quorum_den)
    78           }
    79           ui.field.text{
    80             label = _"Direct majority" .. ":", 
    81             value = (policy.direct_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.direct_majority_num) .. "/" .. tostring(policy.direct_majority_den)
    82           }
    83           ui.field.text{
    84             label = _"Indirect majority" .. ":", 
    85             value = (policy.indirect_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.indirect_majority_num) .. "/" .. tostring(policy.indirect_majority_den)
    86           }
    87         end
    88       }
    89     end
    90   }
    91 end
