liquid_feedback_frontend
view app/main/policy/_list.lua @ 1481:4f4a42bb84ec
Show quora correctly
| author | bsw | 
|---|---|
| date | Wed Oct 24 14:41:00 2018 +0200 (2018-10-24) | 
| parents | 32cc544d5a5b | 
| children | 
 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       if policy.description and #(policy.description) > 0 then
    24         ui.tag{
    25           content = policy.description
    26         }
    27         slot.put ( "<br />" )
    28       end
    30       ui.link {
    31         attr = {
    32           class = "policy-show-details",
    33           onclick = "$('#policy" .. policy.id .. " .policy-details').show(); $('#policy" .. policy.id .. " .policy-show-details').hide(); $('#policy" .. policy.id .. " .policy-hide-details').show(); return false;"
    34         },
    35         content = _"show details"
    36       }
    38       ui.link {
    39         attr = {
    40           class = "policy-hide-details",
    41           onclick = "$('#policy" .. policy.id .. " .policy-details').hide(); $('#policy" .. policy.id .. " .policy-show-details').show(); $('#policy" .. policy.id .. " .policy-hide-details').hide(); return false;",
    42           style = "display: none;"
    43         },
    44         content = _"hide details"
    45       }
    47       ui.container {
    48         attr = {
    49           class = "policy-details",
    50           style = "display: none;"
    51         },
    52         content = function ()
    54           ui.heading { level = 4, content = _"Phase durations" }
    56           if policy.polling then
    57             ui.field.text{ label = _"New" .. ":", value = _"without" }
    58           else
    59             ui.field.text{ label = _"New" .. ":", value = "≥ " .. format.interval_text(policy.min_admission_time) }
    60             ui.field.text{ label = _"New" .. ":", value = "≤ " .. format.interval_text(policy.max_admission_time) }
    61           end
    62           ui.field.text{ label = _"Discussion" .. ":", value = format.interval_text(policy.discussion_time) or _"variable" }
    63           ui.field.text{ label = _"Frozen" .. ":", value = format.interval_text(policy.verification_time) or _"variable" }
    64           ui.field.text{ label = _"Voting" .. ":", value = format.interval_text(policy.voting_time) or _"variable" }
    66           ui.heading { level = 4, content = _"Quorums" }
    68           if policy.polling then
    69             ui.field.text{ label = _"Issue quorum" .. ":", value = _"without" }
    70           else
    71             ui.field.text{
    72               label = _"Issue quorum" .. ":", 
    73               value = "≥ " .. tostring(policy.issue_quorum)
    74             }
    75           end
    76           ui.field.text{
    77             label = _"Initiative quorum" .. ":", 
    78             value = "≥ " .. tostring(policy.initiative_quorum_num) .. "/" .. tostring(policy.initiative_quorum_den)
    79           }
    80           ui.field.text{
    81             label = _"Direct majority" .. ":", 
    82             value = (policy.direct_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.direct_majority_num) .. "/" .. tostring(policy.direct_majority_den)
    83           }
    84           ui.field.text{
    85             label = _"Indirect majority" .. ":", 
    86             value = (policy.indirect_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.indirect_majority_num) .. "/" .. tostring(policy.indirect_majority_den)
    87           }
    88         end
    89       }
    90     end
    91   }
    92 end
