| rev | 
   line source | 
| 
bsw/jbe@19
 | 
     1 local initiative = param.get("initiative", "table")
 | 
| 
bsw@274
 | 
     2 local selected = param.get("selected", atom.boolean)
 | 
| 
bsw/jbe@19
 | 
     3 
 | 
| 
bsw@373
 | 
     4 
 | 
| 
bsw@373
 | 
     5 ui.container{ attr = { class = "initiative" }, content = function()
 | 
| 
bsw/jbe@19
 | 
     6 
 | 
| 
bsw@373
 | 
     7   ui.container{ attr = { class = "rank" }, content = function()
 | 
| 
bsw@373
 | 
     8     if initiative.issue.accepted and initiative.issue.closed
 | 
| 
bsw@373
 | 
     9       and initiative.issue.ranks_available or initiative.admitted == false
 | 
| 
bsw@373
 | 
    10     then 
 | 
| 
bsw@373
 | 
    11       ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
 | 
| 
bsw@414
 | 
    12     elseif not initiative.issue.closed then
 | 
| 
bsw@414
 | 
    13       ui.image{ static = "icons/16/script.png" }
 | 
| 
bsw@373
 | 
    14     else
 | 
| 
bsw@414
 | 
    15       ui.image{ static = "icons/16/cross.png" }
 | 
| 
bsw@373
 | 
    16     end
 | 
| 
bsw@373
 | 
    17   end }
 | 
| 
bsw@373
 | 
    18 
 | 
| 
bsw@373
 | 
    19   ui.container{ attr = { class = "bar" }, content = function()
 | 
| 
bsw@373
 | 
    20     if initiative.issue.fully_frozen and initiative.issue.closed then
 | 
| 
bsw@373
 | 
    21       if initiative.issue.ranks_available then 
 | 
| 
bsw@373
 | 
    22         if initiative.negative_votes and initiative.positive_votes then
 | 
| 
bsw@373
 | 
    23           local max_value = initiative.issue.voter_count
 | 
| 
bsw@345
 | 
    24           ui.bargraph{
 | 
| 
bsw@345
 | 
    25             max_value = max_value,
 | 
| 
bsw@345
 | 
    26             width = 100,
 | 
| 
bsw@345
 | 
    27             bars = {
 | 
| 
bsw@373
 | 
    28               { color = "#0a0", value = initiative.positive_votes },
 | 
| 
bsw@373
 | 
    29               { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
 | 
| 
bsw@373
 | 
    30               { color = "#a00", value = initiative.negative_votes },
 | 
| 
bsw/jbe@19
 | 
    31             }
 | 
| 
bsw/jbe@19
 | 
    32           }
 | 
| 
bsw@373
 | 
    33         else
 | 
| 
bsw@345
 | 
    34           slot.put(" ")
 | 
| 
bsw@345
 | 
    35         end
 | 
| 
bsw@373
 | 
    36       else
 | 
| 
bsw@373
 | 
    37         slot.put(_"Counting of votes")
 | 
| 
bsw@345
 | 
    38       end
 | 
| 
bsw@373
 | 
    39     else
 | 
| 
bsw@373
 | 
    40       local max_value = initiative.issue.population or 0
 | 
| 
bsw@373
 | 
    41       ui.bargraph{
 | 
| 
bsw@373
 | 
    42         max_value = max_value,
 | 
| 
bsw@373
 | 
    43         width = 100,
 | 
| 
bsw@373
 | 
    44         quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
 | 
| 
bsw@373
 | 
    45         quorum_color = "#00F",
 | 
| 
bsw@373
 | 
    46         bars = {
 | 
| 
bsw@373
 | 
    47           { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
 | 
| 
bsw@373
 | 
    48           { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
 | 
| 
bsw@373
 | 
    49           { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
 | 
| 
bsw@373
 | 
    50         }
 | 
| 
bsw@373
 | 
    51       }
 | 
| 
bsw@373
 | 
    52     end
 | 
| 
bsw@373
 | 
    53   end }
 | 
| 
bsw@373
 | 
    54 
 | 
| 
bsw@373
 | 
    55   ui.container{ attr = { class = "interest" }, content = function()
 | 
| 
bsw@373
 | 
    56     if initiative.is_initiator then
 | 
| 
bsw@373
 | 
    57       local label = _"You are initiator of this initiative"
 | 
| 
bsw@373
 | 
    58       ui.image{
 | 
| 
bsw@373
 | 
    59         attr = { alt = label, title = label },
 | 
| 
bsw@373
 | 
    60         static = "icons/16/user_edit.png"
 | 
| 
bsw@373
 | 
    61       }
 | 
| 
bsw@373
 | 
    62     elseif initiative.is_supporter then
 | 
| 
bsw@373
 | 
    63       local label = _"You are supporter of this initiative"
 | 
| 
bsw@373
 | 
    64       ui.image{
 | 
| 
bsw@373
 | 
    65         attr = { alt = label, title = label },
 | 
| 
bsw@373
 | 
    66         static = "icons/16/thumb_up_green.png"
 | 
| 
bsw@373
 | 
    67       }
 | 
| 
bsw@373
 | 
    68     elseif initiative.is_potential_supporter then
 | 
| 
bsw@373
 | 
    69       local label = _"You are potentially supporter of this initiative"
 | 
| 
bsw@373
 | 
    70       ui.image{
 | 
| 
bsw@373
 | 
    71         attr = { alt = label, title = label },
 | 
| 
bsw@373
 | 
    72         static = "icons/16/thumb_up.png"
 | 
| 
bsw@373
 | 
    73       }
 | 
| 
bsw@373
 | 
    74     elseif initiative.is_supporter_via_delegation then
 | 
| 
bsw@373
 | 
    75       local label = _"You are supporter of this initiative via delegation"
 | 
| 
bsw@373
 | 
    76       ui.image{
 | 
| 
bsw@373
 | 
    77         attr = { alt = label, title = label },
 | 
| 
bsw@373
 | 
    78         static = "icons/16/thumb_up_green.png"
 | 
| 
bsw@373
 | 
    79       }
 | 
| 
bsw@373
 | 
    80     end
 | 
| 
bsw@373
 | 
    81   end }
 | 
| 
bsw@373
 | 
    82 
 | 
| 
bsw@373
 | 
    83   ui.container{ attr = { class = "name" }, content = function()
 | 
| 
bsw@373
 | 
    84     local link_class = "initiative_link"
 | 
| 
bsw@373
 | 
    85     if initiative.revoked then
 | 
| 
bsw@373
 | 
    86       link_class = "revoked"
 | 
| 
bsw@373
 | 
    87     end
 | 
| 
bsw@373
 | 
    88     if selected then
 | 
| 
bsw@373
 | 
    89       link_class = link_class .. " selected"
 | 
| 
bsw@373
 | 
    90     end
 | 
| 
bsw@373
 | 
    91     if initiative.is_supporter then
 | 
| 
bsw@373
 | 
    92       link_class = link_class .. " supported"
 | 
| 
bsw@373
 | 
    93     end
 | 
| 
bsw@373
 | 
    94     if initiative.is_potential_supporter then
 | 
| 
bsw@373
 | 
    95       link_class = link_class .. " potentially_supported"
 | 
| 
bsw@373
 | 
    96     end
 | 
| 
bsw@373
 | 
    97     if initiative.is_supporter_via_delegation then
 | 
| 
bsw@373
 | 
    98       link_class = link_class .. " supported"
 | 
| 
bsw@373
 | 
    99     end
 | 
| 
bsw@373
 | 
   100     ui.link{
 | 
| 
bsw@373
 | 
   101       attr = { class = link_class },
 | 
| 
bsw@345
 | 
   102       content = function()
 | 
| 
bsw@373
 | 
   103         local name
 | 
| 
bsw@373
 | 
   104         if initiative.name_highlighted then
 | 
| 
bsw@373
 | 
   105           name = encode.highlight(initiative.name_highlighted)
 | 
| 
bsw@373
 | 
   106         else
 | 
| 
bsw@373
 | 
   107           name = encode.html(initiative.shortened_name)
 | 
| 
bsw@345
 | 
   108         end
 | 
| 
bsw@373
 | 
   109         ui.tag{ content = "i" .. initiative.id .. ": " }
 | 
| 
bsw@373
 | 
   110         slot.put(name)
 | 
| 
bsw@373
 | 
   111       end,
 | 
| 
bsw@373
 | 
   112       module  = "initiative",
 | 
| 
bsw@373
 | 
   113       view    = "show",
 | 
| 
bsw@373
 | 
   114       id      = initiative.id
 | 
| 
bsw@345
 | 
   115     }
 | 
| 
bsw@373
 | 
   116         
 | 
| 
bsw@373
 | 
   117   end }
 | 
| 
bsw@373
 | 
   118 
 | 
| 
bsw@373
 | 
   119 end } |