liquid_feedback_frontend

diff app/main/lf2/_issues.lua @ 211:4993b71b383f

First checkin of lf2 (frontend second generation) prototype
author bsw
date Wed Mar 02 20:06:26 2011 +0100 (2011-03-02)
parents
children 3e4ad069847a
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/lf2/_issues.lua	Wed Mar 02 20:06:26 2011 +0100
     1.3 @@ -0,0 +1,114 @@
     1.4 +local issues = param.get("issues", "table")
     1.5 +
     1.6 +for i, issue in ipairs(issues) do
     1.7 +  local initiatives = issue.initiatives
     1.8 +
     1.9 +  local interested_members = issue.interested_members
    1.10 +
    1.11 +  -- prepare interest of current user
    1.12 +  local interest = issue.interest
    1.13 +
    1.14 +  -- prepare trustees
    1.15 +  local trustees = Member:new_selector()
    1.16 +    :add_field("delegation_chain.*")
    1.17 +    :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
    1.18 +    :add_order_by("index")
    1.19 +    :exec()
    1.20 +    
    1.21 +  local global_delegation
    1.22 +  local area_delegation
    1.23 +  local issue_delegation
    1.24 +
    1.25 +  for i, delegation in ipairs(issue.outgoing_delegations) do
    1.26 +    if delegation.scope == "global" then global_delegation = delegation
    1.27 +    elseif delegation.scope == "area" then area_delegation = delegation
    1.28 +    elseif delegation.scope == "issue" then issue_delegation = delegation
    1.29 +    end
    1.30 +  end
    1.31 +
    1.32 +  local delegation = issue_delegation or area_delegation or global_delegation
    1.33 +
    1.34 +  local delegating_interest = issue.delegating_interest
    1.35 +
    1.36 +  ui.box{ class = "issue", content = function()
    1.37 +
    1.38 +    ui.box_row{ class = "head", content = function()
    1.39 +
    1.40 +      ui.box_col{ class = "issue_id left", content = function()
    1.41 +        ui.link{
    1.42 +          module = "lf2", view = "issue", id = issue.id,
    1.43 +          content = _("Issue ##{id}", { id = issue.id })
    1.44 +        }
    1.45 +      end }
    1.46 +    
    1.47 +      ui.box_col{ class = "unit_name right", content = function()
    1.48 +        ui.link{ 
    1.49 +          module = "lf2", view = "unit", id = 1,
    1.50 +          content = "Dummy unit name" 
    1.51 +        }
    1.52 +      end }
    1.53 +      ui.box_col{ class = "area_name right clearright", content = function()
    1.54 +        ui.link{
    1.55 +          module = "lf2", view = "area_name", id = issue.area_id,
    1.56 +          content = issue.area.name
    1.57 +        }
    1.58 +      end }
    1.59 +      ui.box_col{ class = "policy_name left clearleft first", content = function()
    1.60 +        ui.link{
    1.61 +          module = "lf2", view = "policy", id = issue.policy_id,
    1.62 +          content = issue.policy.name
    1.63 +        }
    1.64 +      end }
    1.65 +
    1.66 +    end }
    1.67 +
    1.68 +    ui.box_row{ class = "head2", content = function()
    1.69 +
    1.70 +      ui.box_col{ class = "state_name left", content = function()
    1.71 +        ui.tag{ content = issue.state_name }
    1.72 +        slot.put(" · ")
    1.73 +        ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left =  issue.state_time_left }) }
    1.74 +      end }
    1.75 +    end }
    1.76 +    
    1.77 +    if interest or delegation then
    1.78 +      ui.box_row{ class = "head2", content = function()
    1.79 +        ui.box_col{ class = "interest left", content = function()
    1.80 +          if interest then
    1.81 +            ui.image{ static = "lf2/icon_star.png" }
    1.82 +            if issue.closed then
    1.83 +              slot.put(" ", _"You were interested in this issue")
    1.84 +            else
    1.85 +              slot.put(" ", _"You are interested in this issue")
    1.86 +            end
    1.87 +          elseif delegating_interest then
    1.88 +            ui.image{ static = "lf2/icon_delegated_star.png" }
    1.89 +            if issue.closed then
    1.90 +              slot.put(" ", _"You were interested in this issue by delegation")
    1.91 +            else
    1.92 +              slot.put(" ", _"You are interested in this issue by delegation")
    1.93 +            end
    1.94 +          elseif trustees then
    1.95 +            slot.put(_"You have delegated this issue")
    1.96 +          else
    1.97 +            slot.put(_"You are not interested in this issue")
    1.98 +          end
    1.99 +        end } 
   1.100 +        -- TODO if delegation ist falsch
   1.101 +        if delegation then
   1.102 +          slot.put(tostring(delegation.id))
   1.103 +          ui.box_col{ class = "delegation right", content = function()
   1.104 +            execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
   1.105 +          end }
   1.106 +        end
   1.107 +      end }
   1.108 +    end
   1.109 +    
   1.110 +    for i, initiative in ipairs(issue.initiatives) do
   1.111 +      ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
   1.112 +        execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
   1.113 +      end } end }
   1.114 +    end
   1.115 +    
   1.116 +  end }
   1.117 +end
   1.118 \ No newline at end of file

Impressum / About Us