| rev | 
   line source | 
| 
bsw@217
 | 
     1 local issue = param.get("issue", "table")
 | 
| 
bsw@217
 | 
     2 local for_list = param.get("for_list", atom.boolean)
 | 
| 
bsw@217
 | 
     3 
 | 
| 
bsw@217
 | 
     4 local initiatives = issue.initiatives
 | 
| 
bsw@217
 | 
     5 
 | 
| 
bsw@217
 | 
     6 local interested_members = issue.interested_members
 | 
| 
bsw@217
 | 
     7 
 | 
| 
bsw@217
 | 
     8 -- prepare interest of current user
 | 
| 
bsw@217
 | 
     9 local interest = issue.interest
 | 
| 
bsw@217
 | 
    10 
 | 
| 
bsw@217
 | 
    11 -- prepare trustees
 | 
| 
bsw@217
 | 
    12 local trustees = Member:new_selector()
 | 
| 
bsw@217
 | 
    13   :add_field("delegation_chain.*")
 | 
| 
bsw@217
 | 
    14   :join({ "delegation_chain(?, null, null, " .. tostring(issue.id or "NULL") .. ")", app.session.member.id }, "delegation_chain", "member.id = delegation_chain.member_id")
 | 
| 
bsw@217
 | 
    15   :add_order_by("index")
 | 
| 
bsw@217
 | 
    16   :exec()
 | 
| 
bsw@217
 | 
    17   
 | 
| 
bsw@217
 | 
    18 local global_delegation
 | 
| 
bsw@217
 | 
    19 local area_delegation
 | 
| 
bsw@217
 | 
    20 local issue_delegation
 | 
| 
bsw@217
 | 
    21 
 | 
| 
bsw@217
 | 
    22 for i, delegation in ipairs(issue.outgoing_delegations) do
 | 
| 
bsw@217
 | 
    23   if delegation.scope == "global" then global_delegation = delegation
 | 
| 
bsw@217
 | 
    24   elseif delegation.scope == "area" then area_delegation = delegation
 | 
| 
bsw@217
 | 
    25   elseif delegation.scope == "issue" then issue_delegation = delegation
 | 
| 
bsw@217
 | 
    26   end
 | 
| 
bsw@217
 | 
    27 end
 | 
| 
bsw@217
 | 
    28 
 | 
| 
bsw@217
 | 
    29 local delegation = issue_delegation or area_delegation or global_delegation
 | 
| 
bsw@217
 | 
    30 
 | 
| 
bsw@217
 | 
    31 local delegating_interest = issue.delegating_interest
 | 
| 
bsw@217
 | 
    32 --[[
 | 
| 
bsw@217
 | 
    33 local current_delegating_interest = false
 | 
| 
bsw@217
 | 
    34 
 | 
| 
bsw@217
 | 
    35 for i, trustee in ipairs(trustees) do
 | 
| 
bsw@217
 | 
    36   if i > 1 and trustee.participation then
 | 
| 
bsw@217
 | 
    37     delegating_interest = true
 | 
| 
bsw@217
 | 
    38   end
 | 
| 
bsw@217
 | 
    39 end
 | 
| 
bsw@217
 | 
    40 --]]
 | 
| 
bsw@217
 | 
    41 local row_count = #initiatives + 3
 | 
| 
bsw@217
 | 
    42 if #trustees > 1 then
 | 
| 
bsw@217
 | 
    43   row_count = row_count + 1
 | 
| 
bsw@217
 | 
    44 end
 | 
| 
bsw@217
 | 
    45 
 | 
| 
bsw@217
 | 
    46 ui.box{ class = "issue", content = function()
 | 
| 
bsw@217
 | 
    47   ui.box_row{ class = "head", content = function()
 | 
| 
bsw@217
 | 
    48 
 | 
| 
bsw@217
 | 
    49     ui.box_col{ class = "issue_id left head", content = function()
 | 
| 
bsw@217
 | 
    50       if interest then
 | 
| 
bsw@217
 | 
    51         local text
 | 
| 
bsw@217
 | 
    52         if issue.close then
 | 
| 
bsw@217
 | 
    53           text = _"You were interested in this issue"
 | 
| 
bsw@217
 | 
    54         else
 | 
| 
bsw@217
 | 
    55           text = _"You are interested in this issue"
 | 
| 
bsw@217
 | 
    56         end
 | 
| 
bsw@217
 | 
    57         ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_star.png" }
 | 
| 
bsw@217
 | 
    58       elseif delegating_interest then
 | 
| 
bsw@217
 | 
    59         local text
 | 
| 
bsw@217
 | 
    60         if issue.closed then
 | 
| 
bsw@217
 | 
    61           text = _"Someone in your delegation chain was interested"
 | 
| 
bsw@217
 | 
    62         else
 | 
| 
bsw@217
 | 
    63           text = _"Someone in your delegation chain is interested"
 | 
| 
bsw@217
 | 
    64         end
 | 
| 
bsw@217
 | 
    65         ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_delegated_star.png" }
 | 
| 
bsw@217
 | 
    66       end
 | 
| 
bsw@217
 | 
    67       slot.put(" ")
 | 
| 
bsw@217
 | 
    68       ui.link{
 | 
| 
bsw@217
 | 
    69         module = "lf2", view = "issue", id = issue.id,
 | 
| 
bsw@217
 | 
    70         content = _("Issue ##{id}", { id = issue.id })
 | 
| 
bsw@217
 | 
    71       }
 | 
| 
bsw@217
 | 
    72     end }
 | 
| 
bsw@217
 | 
    73 
 | 
| 
bsw@217
 | 
    74   end }
 | 
| 
bsw@217
 | 
    75 
 | 
| 
bsw@217
 | 
    76   if #trustees > 1 then
 | 
| 
bsw@217
 | 
    77     ui.box_row{ class = "head2", content = function()
 | 
| 
bsw@217
 | 
    78       ui.box_col{ class = "head left", content = function()
 | 
| 
bsw@217
 | 
    79         execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
 | 
| 
bsw@217
 | 
    80       end }
 | 
| 
bsw@217
 | 
    81     end }
 | 
| 
bsw@217
 | 
    82   end
 | 
| 
bsw@217
 | 
    83     
 | 
| 
bsw@217
 | 
    84   if not issue.closed and not issue.fully_frozen then
 | 
| 
bsw@217
 | 
    85     ui.box_row{ content = function()
 | 
| 
bsw@217
 | 
    86       ui.box_col{ class = "head", content = function()
 | 
| 
bsw@217
 | 
    87         if interest then
 | 
| 
bsw@217
 | 
    88           ui.link{
 | 
| 
bsw@217
 | 
    89             text = _"Remove interest",
 | 
| 
bsw@217
 | 
    90             module  = "interest", action  = "update", params  = { issue_id = issue.id, delete = true },
 | 
| 
bsw@217
 | 
    91             routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
 | 
| 
bsw@217
 | 
    92           }
 | 
| 
bsw@217
 | 
    93         elseif not issue.closed and not issue.fully_frozen then
 | 
| 
bsw@217
 | 
    94           ui.link{
 | 
| 
bsw@217
 | 
    95             text = _"Add my interest",
 | 
| 
bsw@217
 | 
    96             module  = "interest", action  = "update", params  = { issue_id = issue.id },
 | 
| 
bsw@217
 | 
    97             routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
 | 
| 
bsw@217
 | 
    98           }
 | 
| 
bsw@217
 | 
    99         end
 | 
| 
bsw@217
 | 
   100         if #trustees == 1 then
 | 
| 
bsw@217
 | 
   101           ui.link{
 | 
| 
bsw@217
 | 
   102             text = _"Set issue delegation",
 | 
| 
bsw@217
 | 
   103             module = "lf2", view = "delegation", params = { issue_id = issue.id }
 | 
| 
bsw@217
 | 
   104           }    
 | 
| 
bsw@217
 | 
   105         end
 | 
| 
bsw@217
 | 
   106         slot.put(" · ")
 | 
| 
bsw@217
 | 
   107         if not issue.closed and not issue.fully_frozen then
 | 
| 
bsw@217
 | 
   108           if trustees[1].scope_out == "issue" then
 | 
| 
bsw@217
 | 
   109             text = _"Change or revoke issue delegation"
 | 
| 
bsw@217
 | 
   110           else
 | 
| 
bsw@217
 | 
   111             text = _"Set issue delegation"
 | 
| 
bsw@217
 | 
   112           end  
 | 
| 
bsw@217
 | 
   113           ui.link{
 | 
| 
bsw@217
 | 
   114             text = text,
 | 
| 
bsw@217
 | 
   115             module = "lf2", view = "delegation", params = { issue_id = issue.id }
 | 
| 
bsw@217
 | 
   116           }    
 | 
| 
bsw@217
 | 
   117         end
 | 
| 
bsw@217
 | 
   118       end }
 | 
| 
bsw@217
 | 
   119 
 | 
| 
bsw@217
 | 
   120     end }
 | 
| 
bsw@217
 | 
   121   end
 | 
| 
bsw@217
 | 
   122   
 | 
| 
bsw@217
 | 
   123   ui.box_row{ content = function()
 | 
| 
bsw@217
 | 
   124     ui.box_col{ class = "unit_name left", content = function()
 | 
| 
bsw@217
 | 
   125       ui.link{
 | 
| 
bsw@217
 | 
   126         module = "lf2", view = "index", id = issue.area.unit_id,
 | 
| 
bsw@217
 | 
   127         params = { phase = issue.phase },
 | 
| 
bsw@217
 | 
   128         text = issue.area.unit.name
 | 
| 
bsw@217
 | 
   129       }
 | 
| 
bsw@217
 | 
   130     end }
 | 
| 
bsw@217
 | 
   131     ui.box_col{ class = "policy_name right", content = function()
 | 
| 
bsw@217
 | 
   132       ui.link{
 | 
| 
bsw@217
 | 
   133         module = "lf2", view = "policy", id = issue.policy_id,
 | 
| 
bsw@217
 | 
   134         content = issue.policy.name
 | 
| 
bsw@217
 | 
   135       }
 | 
| 
bsw@217
 | 
   136     end }
 | 
| 
bsw@217
 | 
   137   end }
 | 
| 
bsw@217
 | 
   138 
 | 
| 
bsw@217
 | 
   139   ui.box_row{ content = function()
 | 
| 
bsw@217
 | 
   140     ui.box_col{ class = "area_name left", content = function()
 | 
| 
bsw@217
 | 
   141       ui.link{
 | 
| 
bsw@217
 | 
   142         module = "lf2", view = "area", id = issue.area_id,
 | 
| 
bsw@217
 | 
   143         params = { phase = issue.phase },
 | 
| 
bsw@217
 | 
   144         text = issue.area.name
 | 
| 
bsw@217
 | 
   145       }
 | 
| 
bsw@217
 | 
   146     end }
 | 
| 
bsw@217
 | 
   147     ui.box_col{ class = "state_time_left right", content = function()
 | 
| 
bsw@217
 | 
   148       ui.tag{ content = issue.state_name }
 | 
| 
bsw@217
 | 
   149       slot.put(" · ")
 | 
| 
bsw@217
 | 
   150       ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left =  issue.state_time_left }) }
 | 
| 
bsw@217
 | 
   151     end }
 | 
| 
bsw@217
 | 
   152   end }
 | 
| 
bsw@217
 | 
   153 
 | 
| 
bsw@217
 | 
   154 
 | 
| 
bsw@217
 | 
   155   ui.box_row{ class = "subhead", content = function()
 | 
| 
bsw@217
 | 
   156     ui.box_col{ class = "head", content = _"Initiatives" }
 | 
| 
bsw@217
 | 
   157   end }
 | 
| 
bsw@217
 | 
   158 
 | 
| 
bsw@217
 | 
   159   for i, initiative in ipairs(issue.initiatives) do
 | 
| 
bsw@217
 | 
   160     ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
 | 
| 
bsw@217
 | 
   161       execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
 | 
| 
bsw@217
 | 
   162     end } end }
 | 
| 
bsw@217
 | 
   163   end
 | 
| 
bsw@217
 | 
   164   if not for_list then
 | 
| 
bsw@217
 | 
   165     -- TODO bugfix for not working reference loader
 | 
| 
bsw@217
 | 
   166     interested_members = issue:get_reference_selector("interested_members_snapshot"):exec()
 | 
| 
bsw@217
 | 
   167 
 | 
| 
bsw@217
 | 
   168     ui.box_row{ class = "subhead", content = function()
 | 
| 
bsw@217
 | 
   169       ui.box_col{ class = "head left", content = _"Members, interested in this issue" }
 | 
| 
bsw@217
 | 
   170       ui.box_col{ class = "right", content = _("#{count} members", { count = #interested_members }) }
 | 
| 
bsw@217
 | 
   171     end }
 | 
| 
bsw@217
 | 
   172     ui.box_row{ class = "interested", content = function()
 | 
| 
bsw@217
 | 
   173       ui.box_col{ class = "", content = function()
 | 
| 
bsw@217
 | 
   174         execute.view{ module = "lf2", view = "_avatars", params = { members = interested_members, issue_id = issue.id } }
 | 
| 
bsw@217
 | 
   175       end }
 | 
| 
bsw@217
 | 
   176     end }
 | 
| 
bsw@217
 | 
   177   end
 | 
| 
bsw@217
 | 
   178 end } |