liquid_feedback_frontend

diff app/main/lf2/_issue.lua @ 217:73dbc9e2bfd4

Cummulative patch for enhancements at next generation frontend
author bsw
date Sat Mar 12 19:22:50 2011 +0100 (2011-03-12)
parents
children 7ea52c710503
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/lf2/_issue.lua	Sat Mar 12 19:22:50 2011 +0100
     1.3 @@ -0,0 +1,178 @@
     1.4 +local issue = param.get("issue", "table")
     1.5 +local for_list = param.get("for_list", atom.boolean)
     1.6 +
     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(?, null, null, " .. tostring(issue.id or "NULL") .. ")", app.session.member.id }, "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 +local current_delegating_interest = false
    1.37 +
    1.38 +for i, trustee in ipairs(trustees) do
    1.39 +  if i > 1 and trustee.participation then
    1.40 +    delegating_interest = true
    1.41 +  end
    1.42 +end
    1.43 +--]]
    1.44 +local row_count = #initiatives + 3
    1.45 +if #trustees > 1 then
    1.46 +  row_count = row_count + 1
    1.47 +end
    1.48 +
    1.49 +ui.box{ class = "issue", content = function()
    1.50 +  ui.box_row{ class = "head", content = function()
    1.51 +
    1.52 +    ui.box_col{ class = "issue_id left head", content = function()
    1.53 +      if interest then
    1.54 +        local text
    1.55 +        if issue.close then
    1.56 +          text = _"You were interested in this issue"
    1.57 +        else
    1.58 +          text = _"You are interested in this issue"
    1.59 +        end
    1.60 +        ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_star.png" }
    1.61 +      elseif delegating_interest then
    1.62 +        local text
    1.63 +        if issue.closed then
    1.64 +          text = _"Someone in your delegation chain was interested"
    1.65 +        else
    1.66 +          text = _"Someone in your delegation chain is interested"
    1.67 +        end
    1.68 +        ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_delegated_star.png" }
    1.69 +      end
    1.70 +      slot.put(" ")
    1.71 +      ui.link{
    1.72 +        module = "lf2", view = "issue", id = issue.id,
    1.73 +        content = _("Issue ##{id}", { id = issue.id })
    1.74 +      }
    1.75 +    end }
    1.76 +
    1.77 +  end }
    1.78 +
    1.79 +  if #trustees > 1 then
    1.80 +    ui.box_row{ class = "head2", content = function()
    1.81 +      ui.box_col{ class = "head left", content = function()
    1.82 +        execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
    1.83 +      end }
    1.84 +    end }
    1.85 +  end
    1.86 +    
    1.87 +  if not issue.closed and not issue.fully_frozen then
    1.88 +    ui.box_row{ content = function()
    1.89 +      ui.box_col{ class = "head", content = function()
    1.90 +        if interest then
    1.91 +          ui.link{
    1.92 +            text = _"Remove interest",
    1.93 +            module  = "interest", action  = "update", params  = { issue_id = issue.id, delete = true },
    1.94 +            routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
    1.95 +          }
    1.96 +        elseif not issue.closed and not issue.fully_frozen then
    1.97 +          ui.link{
    1.98 +            text = _"Add my interest",
    1.99 +            module  = "interest", action  = "update", params  = { issue_id = issue.id },
   1.100 +            routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
   1.101 +          }
   1.102 +        end
   1.103 +        if #trustees == 1 then
   1.104 +          ui.link{
   1.105 +            text = _"Set issue delegation",
   1.106 +            module = "lf2", view = "delegation", params = { issue_id = issue.id }
   1.107 +          }    
   1.108 +        end
   1.109 +        slot.put(" · ")
   1.110 +        if not issue.closed and not issue.fully_frozen then
   1.111 +          if trustees[1].scope_out == "issue" then
   1.112 +            text = _"Change or revoke issue delegation"
   1.113 +          else
   1.114 +            text = _"Set issue delegation"
   1.115 +          end  
   1.116 +          ui.link{
   1.117 +            text = text,
   1.118 +            module = "lf2", view = "delegation", params = { issue_id = issue.id }
   1.119 +          }    
   1.120 +        end
   1.121 +      end }
   1.122 +
   1.123 +    end }
   1.124 +  end
   1.125 +  
   1.126 +  ui.box_row{ content = function()
   1.127 +    ui.box_col{ class = "unit_name left", content = function()
   1.128 +      ui.link{
   1.129 +        module = "lf2", view = "index", id = issue.area.unit_id,
   1.130 +        params = { phase = issue.phase },
   1.131 +        text = issue.area.unit.name
   1.132 +      }
   1.133 +    end }
   1.134 +    ui.box_col{ class = "policy_name right", content = function()
   1.135 +      ui.link{
   1.136 +        module = "lf2", view = "policy", id = issue.policy_id,
   1.137 +        content = issue.policy.name
   1.138 +      }
   1.139 +    end }
   1.140 +  end }
   1.141 +
   1.142 +  ui.box_row{ content = function()
   1.143 +    ui.box_col{ class = "area_name left", content = function()
   1.144 +      ui.link{
   1.145 +        module = "lf2", view = "area", id = issue.area_id,
   1.146 +        params = { phase = issue.phase },
   1.147 +        text = issue.area.name
   1.148 +      }
   1.149 +    end }
   1.150 +    ui.box_col{ class = "state_time_left right", content = function()
   1.151 +      ui.tag{ content = issue.state_name }
   1.152 +      slot.put(" · ")
   1.153 +      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.154 +    end }
   1.155 +  end }
   1.156 +
   1.157 +
   1.158 +  ui.box_row{ class = "subhead", content = function()
   1.159 +    ui.box_col{ class = "head", content = _"Initiatives" }
   1.160 +  end }
   1.161 +
   1.162 +  for i, initiative in ipairs(issue.initiatives) do
   1.163 +    ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
   1.164 +      execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
   1.165 +    end } end }
   1.166 +  end
   1.167 +  if not for_list then
   1.168 +    -- TODO bugfix for not working reference loader
   1.169 +    interested_members = issue:get_reference_selector("interested_members_snapshot"):exec()
   1.170 +
   1.171 +    ui.box_row{ class = "subhead", content = function()
   1.172 +      ui.box_col{ class = "head left", content = _"Members, interested in this issue" }
   1.173 +      ui.box_col{ class = "right", content = _("#{count} members", { count = #interested_members }) }
   1.174 +    end }
   1.175 +    ui.box_row{ class = "interested", content = function()
   1.176 +      ui.box_col{ class = "", content = function()
   1.177 +        execute.view{ module = "lf2", view = "_avatars", params = { members = interested_members, issue_id = issue.id } }
   1.178 +      end }
   1.179 +    end }
   1.180 +  end
   1.181 +end }
   1.182 \ No newline at end of file

Impressum / About Us