liquid_feedback_frontend

diff app/main/policy/_list.lua @ 1045:701a5cf6b067

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents
children 41f55e4cb905
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/policy/_list.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -0,0 +1,90 @@
     1.4 +local for_area = param.get("for_area", "table")
     1.5 +
     1.6 +local selector = Policy:new_selector()
     1.7 +  :add_where("policy.active")
     1.8 +  :add_order_by("policy.index")
     1.9 +
    1.10 +if for_area then
    1.11 +  selector:join("allowed_policy", nil,
    1.12 +    { "allowed_policy.policy_id = policy.id AND allowed_policy.area_id = ?", for_area.id }
    1.13 +  )
    1.14 +end
    1.15 +
    1.16 +local policies = selector:exec()
    1.17 +
    1.18 +
    1.19 +for i, policy in ipairs(policies) do
    1.20 +  ui.container { 
    1.21 +    attr = { class = "sidebarRow", id = "policy" .. policy.id },
    1.22 +    content = function ()
    1.23 +
    1.24 +      ui.heading { level = 3, content = policy.name }
    1.25 +      
    1.26 +      ui.tag{
    1.27 +        content = policy.description
    1.28 +      }
    1.29 +
    1.30 +      slot.put ( "<br />" )
    1.31 +      
    1.32 +      ui.link {
    1.33 +        attr = {
    1.34 +          class = "policy-show-details",
    1.35 +          onclick = "$('#policy" .. policy.id .. " .policy-details').show(); $('#policy" .. policy.id .. " .policy-show-details').hide(); $('#policy" .. policy.id .. " .policy-hide-details').show(); return false;"
    1.36 +        },
    1.37 +        content = _"show details"
    1.38 +      }
    1.39 +      
    1.40 +      ui.link {
    1.41 +        attr = {
    1.42 +          class = "policy-hide-details",
    1.43 +          onclick = "$('#policy" .. policy.id .. " .policy-details').hide(); $('#policy" .. policy.id .. " .policy-show-details').show(); $('#policy" .. policy.id .. " .policy-hide-details').hide(); return false;",
    1.44 +          style = "display: none;"
    1.45 +        },
    1.46 +        content = _"hide details"
    1.47 +      }
    1.48 +      
    1.49 +      ui.container {
    1.50 +        attr = {
    1.51 +          class = "policy-details",
    1.52 +          style = "display: none;"
    1.53 +        },
    1.54 +        content = function ()
    1.55 +
    1.56 +          ui.heading { level = 4, content = _"Phase durations" }
    1.57 +
    1.58 +          if policy.polling then
    1.59 +            ui.field.text{ label = _"New" .. ":", value = _"without" }
    1.60 +          else
    1.61 +            ui.field.text{ label = _"New" .. ":", value = "≤ " .. policy.admission_time }
    1.62 +          end
    1.63 +          ui.field.text{ label = _"Discussion" .. ":", value = policy.discussion_time or _"variable" }
    1.64 +          ui.field.text{ label = _"Frozen" .. ":", value = policy.verification_time or _"variable" }
    1.65 +          ui.field.text{ label = _"Voting" .. ":", value = policy.voting_time or _"variable" }
    1.66 +
    1.67 +          ui.heading { level = 4, content = _"Quorums" }
    1.68 +          
    1.69 +          if policy.polling then
    1.70 +            ui.field.text{ label = _"Issue quorum" .. ":", value = _"without" }
    1.71 +          else
    1.72 +            ui.field.text{
    1.73 +              label = _"Issue quorum" .. ":", 
    1.74 +              value = "≥ " .. tostring(policy.issue_quorum_num) .. "/" .. tostring(policy.issue_quorum_den)
    1.75 +            }
    1.76 +          end
    1.77 +          ui.field.text{
    1.78 +            label = _"Initiative quorum" .. ":", 
    1.79 +            value = "≥ " .. tostring(policy.initiative_quorum_num) .. "/" .. tostring(policy.initiative_quorum_den)
    1.80 +          }
    1.81 +          ui.field.text{
    1.82 +            label = _"Direct majority" .. ":", 
    1.83 +            value = (policy.direct_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.direct_majority_num) .. "/" .. tostring(policy.direct_majority_den)
    1.84 +          }
    1.85 +          ui.field.text{
    1.86 +            label = _"Indirect majority" .. ":", 
    1.87 +            value = (policy.indirect_majority_strict and ">" or "≥" ) .. " " .. tostring(policy.indirect_majority_num) .. "/" .. tostring(policy.indirect_majority_den)
    1.88 +          }
    1.89 +        end
    1.90 +      }
    1.91 +    end
    1.92 +  }
    1.93 +end
    1.94 \ No newline at end of file

Impressum / About Us