liquid_feedback_frontend

changeset 212:3e4ad069847a

Some more work at 2nd generation frontend code
author bsw
date Thu Mar 03 18:39:00 2011 +0100 (2011-03-03)
parents 4993b71b383f
children acf92c2d33f4
files app/main/_layout/lf2.html app/main/lf2/_area.lua app/main/lf2/_areas.lua app/main/lf2/_avatars.lua app/main/lf2/_delegation_global.lua app/main/lf2/_interested.lua app/main/lf2/_issues.lua app/main/lf2/_search.lua app/main/lf2/_sidebar.lua app/main/lf2/_sidebar_drafts.lua app/main/lf2/_sidebar_initiatives.lua app/main/lf2/_sidebar_issue.lua app/main/lf2/_sidebar_unit.lua app/main/lf2/area.lua app/main/lf2/delegation.lua app/main/lf2/initiative.lua app/main/lf2/issue.lua locale/translations.en.lua model/area.lua model/issue.lua
line diff
     1.1 --- a/app/main/_layout/lf2.html	Wed Mar 02 20:06:26 2011 +0100
     1.2 +++ b/app/main/_layout/lf2.html	Thu Mar 03 18:39:00 2011 +0100
     1.3 @@ -89,6 +89,7 @@
     1.4    background-color: #444;
     1.5    color: #fff;
     1.6    font-weight: bold;
     1.7 +  text-decoration: none;
     1.8  }
     1.9  
    1.10  .tab1 .right a {
    1.11 @@ -98,6 +99,7 @@
    1.12  
    1.13  .tab1 a.active {
    1.14    background-color: #7df;
    1.15 +  color: #000;
    1.16  }
    1.17  
    1.18  /*
    1.19 @@ -245,16 +247,21 @@
    1.20    padding-left: 0.2em;
    1.21  }
    1.22  
    1.23 -.box .row .col {
    1.24 -xborder: 1px solid red !important;
    1.25 -}
    1.26 -
    1.27  .box .row.head {
    1.28    background-color: #e4e7f0;
    1.29    color: #000;
    1.30    border-radius: 1ex 1ex 0 0;
    1.31  }
    1.32  
    1.33 +.box .row.last {
    1.34 +  border-radius: 0 0 1ex 1ex;
    1.35 +}
    1.36 +
    1.37 +.box .row.head .col.head {
    1.38 +  font-weight: bold;
    1.39 +  color: #444;
    1.40 +}
    1.41 +
    1.42  .box .row.head .col a {
    1.43    background-color: #e4e7f0;
    1.44    color: #3B6E7F;
    1.45 @@ -275,6 +282,11 @@
    1.46    color: #3B6E7F;
    1.47  }
    1.48  
    1.49 +.box .row.active,
    1.50 +.box .row.active a {
    1.51 +  background-color: #DDF7FF;
    1.52 +}
    1.53 +
    1.54  /* Sidebar hover button */
    1.55  
    1.56  .hoverbutton_container {
    1.57 @@ -461,7 +473,6 @@
    1.58  
    1.59  .area .name {
    1.60    color: #444;
    1.61 -  font-weight: bold;
    1.62  }
    1.63  
    1.64  .area .name a {
    1.65 @@ -473,20 +484,6 @@
    1.66    margin-top: -3px;
    1.67  }
    1.68  
    1.69 -/* Issues */
    1.70 -
    1.71 -.issue .issue_id {
    1.72 -  font-weight: bold;
    1.73 -}
    1.74 -
    1.75 -.issue .state_name {
    1.76 -  font-style: italic;
    1.77 -}
    1.78 -
    1.79 -.issue .time_left {
    1.80 -  font-style: italic;
    1.81 -}
    1.82 -
    1.83  /* Initiatives */
    1.84  
    1.85  .initiative .name,
     2.1 --- a/app/main/lf2/_area.lua	Wed Mar 02 20:06:26 2011 +0100
     2.2 +++ b/app/main/lf2/_area.lua	Thu Mar 03 18:39:00 2011 +0100
     2.3 @@ -11,8 +11,8 @@
     2.4  ui.box{ class = "area", content = function()
     2.5  
     2.6    ui.box_row{ class = "head", content = function()
     2.7 -    ui.box_col{ class = "left name", content = area.name } 
     2.8 -    ui.box_col{ class = "right", content = _("#{direct_count}+#{delegated_count} Mitglieder", {
     2.9 +    ui.box_col{ class = "head left name", content = area.name } 
    2.10 +    ui.box_col{ class = "right", content = _("#{direct_count}+#{delegated_count} members", {
    2.11        direct_count = area.direct_member_count,
    2.12        delegated_count = area.member_weight - area.direct_member_count 
    2.13      } ) }
    2.14 @@ -22,21 +22,24 @@
    2.15      ui.box_row{ class = "description", content = function() ui.box_col{ content = area.description } end }
    2.16    end
    2.17    
    2.18 -  ui.box_row{ class = "member_count", content = function()
    2.19 -  end }
    2.20 -
    2.21 -  ui.box_row{ content = function()
    2.22 -    ui.box_col{ class = "left", content = function()
    2.23 -      execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    2.24 +  if #trustees > 1 then
    2.25 +    ui.box_row{ content = function()
    2.26 +      ui.box_col{ class = "left", content = function()
    2.27 +        execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    2.28 +      end }
    2.29 +      if trustees[1].scope_out == "area" then
    2.30 +        text = _"Change or revoke area delegation..."
    2.31 +      else
    2.32 +        text = _"Set area delegation..."
    2.33 +      end  
    2.34 +      ui.box_col{ class = "right", content = function()
    2.35 +        ui.link{
    2.36 +          text = text,
    2.37 +          module = "lf2", view = "delegation", params = { area_id = area.id }
    2.38 +        }    
    2.39 +      end }
    2.40      end }
    2.41 -    ui.box_col{ class = "right", content = function()
    2.42 -      ui.tag{ content = _"[Change] or [revoke] area delegation [prefix]" }
    2.43 -      ui.link{ text = _"[Change] or [revoke] area delegation [change]" }
    2.44 -      ui.tag{ content = _"[Change] or [revoke] area delegation [midpart]" }
    2.45 -      ui.link{ text = _"[Change] or [revoke] area delegation [revoke]" }
    2.46 -      ui.tag{ content = _"[Change] or [revoke] area delegation [suffix]" }
    2.47 -    end }
    2.48 -  end }
    2.49 +  end
    2.50  
    2.51    ui.box_row{ content = function()
    2.52      ui.box_col{ class = "left", content = function()
    2.53 @@ -63,11 +66,14 @@
    2.54            text = _"Give up membership"
    2.55          }
    2.56        end
    2.57 -      if not trustees then
    2.58 +      if #trustees == 1 then
    2.59          if membership then
    2.60            slot.put(" · ")
    2.61          end
    2.62 -        ui.link{ text = _"Delegate area...", module = "lf2", view = "delegation" }
    2.63 +        ui.link{
    2.64 +          text = _"Set area delegation...",
    2.65 +          module = "lf2", view = "delegation", params = { area_id = area.id }
    2.66 +        }    
    2.67        end
    2.68      end }
    2.69    end }
     3.1 --- a/app/main/lf2/_areas.lua	Wed Mar 02 20:06:26 2011 +0100
     3.2 +++ b/app/main/lf2/_areas.lua	Thu Mar 03 18:39:00 2011 +0100
     3.3 @@ -1,19 +1,31 @@
     3.4  local areas = param.get("areas_selector", "table"):exec()
     3.5 +local current_area_id = param.get("current_area_id", atom.integer)
     3.6  local head_content = param.get("head_content", "function")
     3.7  
     3.8 -ui.box{ class = "areas", row_count = #areas, content = function()
     3.9 +if #areas == 0 then
    3.10 +  return
    3.11 +end
    3.12 +
    3.13 +areas:load("membership_for_member", { member_id = app.session.member_id}, "membership")
    3.14 +
    3.15 +ui.box{ class = "areas", row_count = #areas + 1, content = function()
    3.16    if head_content then
    3.17 -    ui.box_row{ class = "head", content = function() ui.box_col{ content = head_content } end }
    3.18 +    ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
    3.19 +      ui.link{ content = head_content, module = "lf2", view = "index" }
    3.20 +    end } end }
    3.21    end
    3.22  
    3.23    for i, area in ipairs(areas) do
    3.24      local delegation = Delegation:by_pk(app.session.member_id, area.id)
    3.25      
    3.26 +    local class = "area"
    3.27 +    if (current_area_id and area.id == current_area_id) 
    3.28 +      or (not current_area_id and area.membership)
    3.29 +    then
    3.30 +      class = class .. " active"
    3.31 +    end
    3.32      ui.box_row{ 
    3.33 -      class = "area", 
    3.34 -      toggle_content = function() 
    3.35 -        ui.image{ static = "lf2/icon_search_crossed.png" } 
    3.36 -      end,
    3.37 +      class = class, 
    3.38        content = function()
    3.39          ui.box_col{ class = "name", content = function()
    3.40            if delegation then
    3.41 @@ -26,4 +38,4 @@
    3.42      
    3.43    end
    3.44  
    3.45 -end }
    3.46 \ No newline at end of file
    3.47 +end }
     4.1 --- a/app/main/lf2/_avatars.lua	Wed Mar 02 20:06:26 2011 +0100
     4.2 +++ b/app/main/lf2/_avatars.lua	Thu Mar 03 18:39:00 2011 +0100
     4.3 @@ -22,7 +22,7 @@
     4.4        image = "lf2/icon_delegation.png"
     4.5        text = _"Issue delegation"
     4.6      end
     4.7 -    if param.get("arrows", atom.boolean) and (i > 1 or #members == 1) then
     4.8 +    if param.get("arrows", atom.boolean) and (i > 1) then
     4.9        ui.image{ attr = { title = text, alt = text, class = class }, static = image }
    4.10        slot.put(member.scope)
    4.11      end
     5.1 --- a/app/main/lf2/_delegation_global.lua	Wed Mar 02 20:06:26 2011 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,23 +0,0 @@
     5.4 -local trustees = Member:new_selector()
     5.5 -  :add_field("delegation_chain.*")
     5.6 -  :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, NULL)", "delegation_chain", "member.id = delegation_chain.member_id")
     5.7 -  :add_order_by("index")
     5.8 -  :exec()
     5.9 -
    5.10 -ui.box{ content = function()
    5.11 -  ui.box_row{ class = "head", content = function()
    5.12 -    ui.box_col{ content = _"Global delegation active" }
    5.13 -  end }
    5.14 -  ui.box_row{ content = function() ui.box_col{ content = function()
    5.15 -      execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    5.16 -  end } end }
    5.17 -  ui.box_row{ content = function() ui.box_col{ content = function()
    5.18 -    ui.tag{ content = _"[Change] or [revoke] global delegation [prefix]" }
    5.19 -    ui.link{ text = _"[Change] or [revoke] global delegation [change]" }
    5.20 -    ui.tag{ content = _"[Change] or [revoke] global delegation [midpart]" }
    5.21 -    ui.link{ text = _"[Change] or [revoke] global delegation [revoke]" }
    5.22 -    ui.tag{ content = _"[Change] or [revoke] global delegation [suffix]" }
    5.23 -    
    5.24 -  end } end }
    5.25 -end }
    5.26 -    
    5.27 \ No newline at end of file
     6.1 --- a/app/main/lf2/_interested.lua	Wed Mar 02 20:06:26 2011 +0100
     6.2 +++ b/app/main/lf2/_interested.lua	Thu Mar 03 18:39:00 2011 +0100
     6.3 @@ -1,10 +1,10 @@
     6.4  local interested_members = param.get("interested_members", "table")
     6.5  ui.box{ content = function()
     6.6    ui.box_row{ class = "head interested", content = function()
     6.7 -    ui.box_col{ class = "", content = _"Interested members" }
     6.8 +    ui.box_col{ class = "head left", content = _"Members, interested in this issue" }
     6.9 +    ui.box_col{ class = "right", content = _("#{count} members", { count = #interested_members }) }
    6.10    end }
    6.11    ui.box_row{ class = "interested", content = function()
    6.12 -    ui.box_col{ content = _"The interested members are updated after some time." }
    6.13      ui.box_col{ class = "", content = function()
    6.14        execute.view{ module = "lf2", view = "_avatars", params = { members = interested_members } }
    6.15      end }
     7.1 --- a/app/main/lf2/_issues.lua	Wed Mar 02 20:06:26 2011 +0100
     7.2 +++ b/app/main/lf2/_issues.lua	Thu Mar 03 18:39:00 2011 +0100
     7.3 @@ -34,26 +34,14 @@
     7.4  
     7.5      ui.box_row{ class = "head", content = function()
     7.6  
     7.7 -      ui.box_col{ class = "issue_id left", content = function()
     7.8 +      ui.box_col{ class = "issue_id left head", content = function()
     7.9          ui.link{
    7.10            module = "lf2", view = "issue", id = issue.id,
    7.11            content = _("Issue ##{id}", { id = issue.id })
    7.12          }
    7.13        end }
    7.14      
    7.15 -      ui.box_col{ class = "unit_name right", content = function()
    7.16 -        ui.link{ 
    7.17 -          module = "lf2", view = "unit", id = 1,
    7.18 -          content = "Dummy unit name" 
    7.19 -        }
    7.20 -      end }
    7.21 -      ui.box_col{ class = "area_name right clearright", content = function()
    7.22 -        ui.link{
    7.23 -          module = "lf2", view = "area_name", id = issue.area_id,
    7.24 -          content = issue.area.name
    7.25 -        }
    7.26 -      end }
    7.27 -      ui.box_col{ class = "policy_name left clearleft first", content = function()
    7.28 +      ui.box_col{ class = "policy_name right", content = function()
    7.29          ui.link{
    7.30            module = "lf2", view = "policy", id = issue.policy_id,
    7.31            content = issue.policy.name
    7.32 @@ -66,43 +54,80 @@
    7.33  
    7.34        ui.box_col{ class = "state_name left", content = function()
    7.35          ui.tag{ content = issue.state_name }
    7.36 -        slot.put(" · ")
    7.37 +      end }
    7.38 +      ui.box_col{ class = "state_time_left right", content = function()
    7.39          ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left =  issue.state_time_left }) }
    7.40        end }
    7.41      end }
    7.42      
    7.43 -    if interest or delegation then
    7.44 +    if #trustees > 1 then
    7.45        ui.box_row{ class = "head2", content = function()
    7.46 -        ui.box_col{ class = "interest left", content = function()
    7.47 -          if interest then
    7.48 -            ui.image{ static = "lf2/icon_star.png" }
    7.49 -            if issue.closed then
    7.50 -              slot.put(" ", _"You were interested in this issue")
    7.51 -            else
    7.52 -              slot.put(" ", _"You are interested in this issue")
    7.53 -            end
    7.54 -          elseif delegating_interest then
    7.55 -            ui.image{ static = "lf2/icon_delegated_star.png" }
    7.56 -            if issue.closed then
    7.57 -              slot.put(" ", _"You were interested in this issue by delegation")
    7.58 -            else
    7.59 -              slot.put(" ", _"You are interested in this issue by delegation")
    7.60 -            end
    7.61 -          elseif trustees then
    7.62 -            slot.put(_"You have delegated this issue")
    7.63 +        ui.box_col{ class = "left", content = function()
    7.64 +          execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    7.65 +        end }
    7.66 +        if not issue.closed and not issue.fully_frozen then
    7.67 +          if trustees[1].scope_out == "issue" then
    7.68 +            text = _"Change or revoke issue delegation..."
    7.69            else
    7.70 -            slot.put(_"You are not interested in this issue")
    7.71 -          end
    7.72 -        end } 
    7.73 -        -- TODO if delegation ist falsch
    7.74 -        if delegation then
    7.75 -          slot.put(tostring(delegation.id))
    7.76 -          ui.box_col{ class = "delegation right", content = function()
    7.77 -            execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    7.78 +            text = _"Set issue delegation..."
    7.79 +          end  
    7.80 +          ui.box_col{ class = "right", content = function()
    7.81 +            ui.link{
    7.82 +              text = text,
    7.83 +              module = "lf2", view = "delegation", params = { issue_id = issue.id }
    7.84 +            }    
    7.85            end }
    7.86          end
    7.87        end }
    7.88      end
    7.89 +
    7.90 +    ui.box_row{ class = "head2", content = function()
    7.91 +      ui.box_col{ class = "interest left", content = function()
    7.92 +        if interest then
    7.93 +          ui.image{ static = "lf2/icon_star.png" }
    7.94 +          if issue.closed then
    7.95 +            slot.put(" ", _"You were interested in this issue")
    7.96 +          else
    7.97 +            slot.put(" ", _"You are interested in this issue")
    7.98 +          end
    7.99 +        elseif delegating_interest then
   7.100 +          ui.image{ static = "lf2/icon_delegated_star.png" }
   7.101 +          if issue.closed then
   7.102 +            slot.put(" ", _"You were interested in this issue by delegation")
   7.103 +          else
   7.104 +            slot.put(" ", _"You are interested in this issue by delegation")
   7.105 +          end
   7.106 +        else
   7.107 +          slot.put(_"You are not interested in this issue")
   7.108 +        end
   7.109 +      end } 
   7.110 +      
   7.111 +      if not issue.closed and not issue.fully_frozen then
   7.112 +        ui.box_col{ class = "right", content = function()
   7.113 +          if interest then
   7.114 +            ui.link{
   7.115 +              text = _"Remove interest",
   7.116 +              module  = "interest", action  = "update", params  = { issue_id = issue.id, delete = true },
   7.117 +              routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
   7.118 +            }
   7.119 +          else
   7.120 +            ui.link{
   7.121 +              text = _"Add my interest",
   7.122 +              module  = "interest", action  = "update", params  = { issue_id = issue.id },
   7.123 +              routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
   7.124 +            }
   7.125 +          end
   7.126 +          if #trustees == 1 then
   7.127 +            slot.put(" · ")
   7.128 +            ui.link{
   7.129 +              text = _"Set issue delegation...",
   7.130 +              module = "lf2", view = "delegation", params = { issue_id = issue.id }
   7.131 +            }    
   7.132 +          end
   7.133 +        end }
   7.134 +      end
   7.135 +      
   7.136 +    end }
   7.137      
   7.138      for i, initiative in ipairs(issue.initiatives) do
   7.139        ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
     8.1 --- a/app/main/lf2/_search.lua	Wed Mar 02 20:06:26 2011 +0100
     8.2 +++ b/app/main/lf2/_search.lua	Thu Mar 03 18:39:00 2011 +0100
     8.3 @@ -1,35 +1,14 @@
     8.4 -ui.container{
     8.5 -  attr = { class = "boxhead" },
     8.6 -  content = _"Search in initiatives for text:"
     8.7 -}
     8.8 -
     8.9 -ui.container{
    8.10 -  attr = { class = "search box" },
    8.11 -  content = function()
    8.12 -    ui.container{
    8.13 -      attr = { class = "row first" },
    8.14 -      content = function()
    8.15 -        ui.container{
    8.16 -          attr = { class = "col first" },
    8.17 -          content = function()
    8.18 +ui.box{ class = "search", content = function()
    8.19 +  ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = _"Search in initiatives" } end }
    8.20  
    8.21 -            ui.form{
    8.22 -              content = function()
    8.23 -
    8.24 -                
    8.25 -                slot.put(" ")
    8.26 -              
    8.27 -                ui.tag{ tag = "input", attr = { type = "text", name = "q" } }
    8.28 -                
    8.29 -                ui.submit{ text = _"Search" }
    8.30 -
    8.31 -              end
    8.32 -            }
    8.33 -
    8.34 -          end
    8.35 -        }
    8.36 -
    8.37 +  ui.box_row{ content = function() ui.box_col{ content = function()
    8.38 +    ui.form{
    8.39 +      content = function()
    8.40 +        slot.put(" ")
    8.41 +        ui.tag{ tag = "input", attr = { type = "text", name = "q" } }
    8.42 +        ui.submit{ text = _"Search" }
    8.43        end
    8.44      }
    8.45 -  end
    8.46 -}
    8.47 \ No newline at end of file
    8.48 +  end } end }
    8.49 +
    8.50 +end }
    8.51 \ No newline at end of file
     9.1 --- a/app/main/lf2/_sidebar.lua	Wed Mar 02 20:06:26 2011 +0100
     9.2 +++ b/app/main/lf2/_sidebar.lua	Thu Mar 03 18:39:00 2011 +0100
     9.3 @@ -1,3 +1,5 @@
     9.4 +local current_area_id = param.get("current_area_id", atom.integer)
     9.5 +
     9.6  local member_areas_selector = Area:build_selector{
     9.7    member_id = app.session.member_id,
     9.8    order = "name"
     9.9 @@ -7,9 +9,10 @@
    9.10    order = "name"
    9.11  }
    9.12  
    9.13 -execute.view{ module = "lf2", view = "_delegation_global" }
    9.14 +execute.view{ module = "lf2", view = "_sidebar_unit", params = { unit = {} } } --TODO
    9.15      
    9.16  ui.form{
    9.17 +  method = "get",
    9.18    content = function()
    9.19      
    9.20      ui.container{ attr = { class = "boxhead" }, content = _"" }
    9.21 @@ -18,6 +21,7 @@
    9.22      execute.view{
    9.23        module = "lf2", view = "_areas", params = { 
    9.24          areas_selector = member_areas_selector,
    9.25 +        current_area_id = current_area_id,
    9.26          head_content = function() ui.tag{ content = _"Areas, you are member of" } end
    9.27        }
    9.28      }
    9.29 @@ -25,6 +29,7 @@
    9.30      execute.view{
    9.31        module = "lf2", view = "_areas", params = { 
    9.32          areas_selector = other_areas_selector,
    9.33 +        current_area_id = current_area_id,
    9.34          head_content = function() ui.tag{ content = _"Areas, you are not member of" } end
    9.35        }
    9.36      }
    10.1 --- a/app/main/lf2/_sidebar_drafts.lua	Wed Mar 02 20:06:26 2011 +0100
    10.2 +++ b/app/main/lf2/_sidebar_drafts.lua	Thu Mar 03 18:39:00 2011 +0100
    10.3 @@ -5,7 +5,6 @@
    10.4    :add_order_by("id DESC")
    10.5    :exec()
    10.6  
    10.7 -ui.container{ attr = { class = "boxhead" }, content = _"Draft revisions" }
    10.8  
    10.9  ui.box{ class = "drafts", content = function()
   10.10    if drafts then
   10.11 @@ -14,11 +13,14 @@
   10.12        module = "draft",
   10.13        view = "diff",
   10.14        content = function()
   10.15 +        ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = _"Draft revisions" } end }
   10.16          ui.box_row{ class = "", content = function()
   10.17            ui.box_col{ class = "scrolled", content = function()
   10.18  
   10.19              for i, draft in ipairs(drafts) do
   10.20 -              ui.box_row{ class = "draft", content = function()
   10.21 +              local class = "draft"
   10.22 +              if i == 1 then class = class .. " first" end
   10.23 +              ui.box_row{ class = class, content = function()
   10.24                  ui.box_col{ class = "left", content = function()
   10.25                    ui.link{
   10.26                      attr = { class = "created" },
    11.1 --- a/app/main/lf2/_sidebar_initiatives.lua	Wed Mar 02 20:06:26 2011 +0100
    11.2 +++ b/app/main/lf2/_sidebar_initiatives.lua	Thu Mar 03 18:39:00 2011 +0100
    11.3 @@ -1,5 +1,10 @@
    11.4 +local head_content = param.get("head_content", "function")
    11.5 +
    11.6  local initiatives = param.get("initiatives", "table")
    11.7  ui.box{ content = function()
    11.8 +  if head_content then
    11.9 +    ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = head_content } end }
   11.10 +  end
   11.11    ui.box_row{ class = "initiatives", content = function()
   11.12      ui.box_col{ class = "scrolled", content = function()
   11.13        execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = initiatives } }
    12.1 --- a/app/main/lf2/_sidebar_issue.lua	Wed Mar 02 20:06:26 2011 +0100
    12.2 +++ b/app/main/lf2/_sidebar_issue.lua	Thu Mar 03 18:39:00 2011 +0100
    12.3 @@ -35,7 +35,7 @@
    12.4  
    12.5  ui.box{ class = "issue", content = function()
    12.6  
    12.7 -  ui.box_row{ class = "issue_id head", content = function() ui.box_col{ content = function()
    12.8 +  ui.box_row{ class = "issue_id head", content = function() ui.box_col{ class = "head", content = function()
    12.9      ui.link{
   12.10        module = "lf2", view = "issue", id = issue.id,
   12.11        content = _("Issue ##{id}", { id = issue.id })
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/app/main/lf2/_sidebar_unit.lua	Thu Mar 03 18:39:00 2011 +0100
    13.3 @@ -0,0 +1,33 @@
    13.4 +local unit = param.get("unit", "table")
    13.5 +
    13.6 +local trustees = Member:new_selector()
    13.7 +  :add_field("delegation_chain.*")
    13.8 +  :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, NULL)", "delegation_chain", "member.id = delegation_chain.member_id")
    13.9 +  :add_order_by("index")
   13.10 +  :exec()
   13.11 +
   13.12 +ui.box{ content = function()
   13.13 +  ui.box_row{ class = "head", content = function()
   13.14 +    ui.box_col{ class = "head", content = _"DE / Berlin / Friedrichshain-Kreuzberg" }
   13.15 +  end }
   13.16 +  
   13.17 +  if #trustees > 1 then
   13.18 +    ui.box_row{ content = function() ui.box_col{ content = function()
   13.19 +      execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
   13.20 +    end } end }
   13.21 +  end
   13.22 +  
   13.23 +  ui.box_row{ content = function() ui.box_col{ content = function()
   13.24 +    if trustees[1].scope_out == "global" then
   13.25 +      text = _"Change or revoke unit delegation..."
   13.26 +    else
   13.27 +      text = _"Set unit delegation..."
   13.28 +    end  
   13.29 +    ui.link{
   13.30 +      text = text,
   13.31 +      module = "lf2", view = "delegation", params = { unit_id = unit.id }
   13.32 +    }    
   13.33 +  end } end }
   13.34 +  
   13.35 +end }
   13.36 +    
   13.37 \ No newline at end of file
    14.1 --- a/app/main/lf2/area.lua	Wed Mar 02 20:06:26 2011 +0100
    14.2 +++ b/app/main/lf2/area.lua	Thu Mar 03 18:39:00 2011 +0100
    14.3 @@ -3,7 +3,7 @@
    14.4  slot.set_layout("lf2")
    14.5  
    14.6  slot.select("sidebar", function()
    14.7 -  execute.view{ module = "lf2", view = "_sidebar" }
    14.8 +  execute.view{ module = "lf2", view = "_sidebar", params = { current_area_id = area.id } }
    14.9  end)
   14.10  
   14.11  execute.view{ module = "lf2", view = "_area", params = { area = area } }
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/app/main/lf2/delegation.lua	Thu Mar 03 18:39:00 2011 +0100
    15.3 @@ -0,0 +1,134 @@
    15.4 +slot.set_layout("lf2")
    15.5 +
    15.6 +local area = Area:by_id(param.get("area_id", atom.integer))
    15.7 +local issue = Issue:by_id(param.get("issue_id", atom.integer))
    15.8 +local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
    15.9 +
   15.10 +local contact_members = Member:build_selector{
   15.11 +  is_contact_of_member_id = app.session.member_id,
   15.12 +  order = "name"
   15.13 +}:exec()
   15.14 +
   15.15 +if area then
   15.16 +  title = _"Set delegation for Area '#{name}'":gsub("#{name}", area.name)
   15.17 +end
   15.18 +
   15.19 +if issue then
   15.20 +  title = _"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name)
   15.21 +end
   15.22 +
   15.23 +if not area and not issue then
   15.24 +  title = _"Set unit delegation"
   15.25 +end
   15.26 +
   15.27 +ui.box{ content = function()
   15.28 +  
   15.29 +  ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = title } end }
   15.30 +
   15.31 +  ui.form{
   15.32 +    attr = { class = "vertical" },
   15.33 +    module = "delegation",
   15.34 +    action = "update",
   15.35 +    params = {
   15.36 +      area_id = area and area.id or nil,
   15.37 +      issue_id = issue and issue.id or nil,
   15.38 +    },
   15.39 +    routing = {
   15.40 +      default = {
   15.41 +        mode = "redirect",
   15.42 +        module = "lf2",
   15.43 +        view = area and "area" or issue and "issue" or "index",
   15.44 +        id = area and area.id or issue and issue.id or nil,
   15.45 +      }
   15.46 +    },
   15.47 +    content = function()
   15.48 +      local records
   15.49 +
   15.50 +      if issue then
   15.51 +        local delegate_name = ""
   15.52 +        local scope = "no delegation set"
   15.53 +        local area_delegation = Delegation:by_pk(app.session.member_id, issue.area_id)
   15.54 +        if area_delegation then
   15.55 +          delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned"
   15.56 +          scope = _"area"
   15.57 +        else
   15.58 +        local unit_delegation = Delegation:by_pk(app.session.member_id)
   15.59 +        if unit_delegation then
   15.60 +          delegate_name = unit_delegation.trustee.name
   15.61 +          scope = _"unit"
   15.62 +        end
   15.63 +      end
   15.64 +        records = {
   15.65 +          {
   15.66 +            id = -1,
   15.67 +            name = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
   15.68 +          },
   15.69 +          {
   15.70 +            id = 0,
   15.71 +            name = _"Abandon unit and area delegations for this issue"
   15.72 +          },
   15.73 +
   15.74 +        }
   15.75 +      elseif area then
   15.76 +        local delegate_name = ""
   15.77 +        local scope = "no delegation set"
   15.78 +        local unit_delegation = Delegation:by_pk(app.session.member_id)
   15.79 +        if unit_delegation then
   15.80 +          delegate_name = unit_delegation.trustee.name
   15.81 +          scope = _"unit"
   15.82 +        end
   15.83 +        records = {
   15.84 +          {
   15.85 +            id = -1,
   15.86 +            name = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
   15.87 +          },
   15.88 +          {
   15.89 +            id = 0,
   15.90 +            name = _"Abandon unit delegation for this area"
   15.91 +          }
   15.92 +        }
   15.93 +
   15.94 +      else
   15.95 +        records = {
   15.96 +          {
   15.97 +            id = -1,
   15.98 +            name = _"No delegation"
   15.99 +          }
  15.100 +        }
  15.101 +
  15.102 +      end
  15.103 +      -- add saved members
  15.104 +      records[#records+1] = {id="_", name= "--- " .. _"Saved contacts" .. " ---"}
  15.105 +      for i, record in ipairs(contact_members) do
  15.106 +        records[#records+1] = record
  15.107 +      end
  15.108 +      -- add initiative authors
  15.109 +      if initiative then
  15.110 +        records[#records+1] = {id="_", name= "--- " .. _"Initiators" .. " ---"}
  15.111 +        for i,record in ipairs(initiative.initiators) do
  15.112 +          records[#records+1] = record.member
  15.113 +        end
  15.114 +      end
  15.115 +
  15.116 +      disabled_records = {}
  15.117 +      disabled_records["_"] = true
  15.118 +
  15.119 +      
  15.120 +      ui.box_row{ content = function() ui.box_col{ content = function()
  15.121 +        ui.field.select{
  15.122 +          label = _"Trustee",
  15.123 +          name = "trustee_id",
  15.124 +          foreign_records = records,
  15.125 +          foreign_id = "id",
  15.126 +          foreign_name = "name",
  15.127 +          disabled_records = disabled_records
  15.128 +        }
  15.129 +      end } end }
  15.130 +      
  15.131 +      ui.box_row{ content = function() ui.box_col{ content = function()
  15.132 +        ui.submit{ text = _"Save" }
  15.133 +      end } end }
  15.134 +    end
  15.135 +  }
  15.136 +
  15.137 +end }
  15.138 \ No newline at end of file
    16.1 --- a/app/main/lf2/initiative.lua	Wed Mar 02 20:06:26 2011 +0100
    16.2 +++ b/app/main/lf2/initiative.lua	Thu Mar 03 18:39:00 2011 +0100
    16.3 @@ -24,10 +24,10 @@
    16.4  slot.select("sidebar", function()
    16.5    
    16.6    execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue } }
    16.7 -  ui.container{ attr = { class = "boxhead" }, content = _"Alternative initiatives" }
    16.8    
    16.9    execute.view{ module = "lf2", view = "_sidebar_initiatives", params = {
   16.10 -    initiatives = alternative_initiatives
   16.11 +    initiatives = alternative_initiatives,
   16.12 +    head_content = function() ui.tag{ content = _"Alternative initiatives" } end
   16.13    } }
   16.14    
   16.15    execute.view{ module = "lf2", view = "_sidebar_drafts", params = {
    17.1 --- a/app/main/lf2/issue.lua	Wed Mar 02 20:06:26 2011 +0100
    17.2 +++ b/app/main/lf2/issue.lua	Thu Mar 03 18:39:00 2011 +0100
    17.3 @@ -40,7 +40,7 @@
    17.4  local delegating_interest = issue.delegating_interest
    17.5  
    17.6  slot.select("sidebar", function()
    17.7 -  execute.view{ module = "lf2", view = "_sidebar" }
    17.8 +  execute.view{ module = "lf2", view = "_sidebar", params = { current_area_id = issue.area_id } }
    17.9  end)
   17.10  
   17.11  execute.view{ module = "lf2", view = "_area", params = { area = area } }
    18.1 --- a/locale/translations.en.lua	Wed Mar 02 20:06:26 2011 +0100
    18.2 +++ b/locale/translations.en.lua	Thu Mar 03 18:39:00 2011 +0100
    18.3 @@ -678,11 +678,11 @@
    18.4  ["[Change] or [revoke] area delegation [prefix]"] = "";
    18.5  ["[Change] or [revoke] area delegation [revoke]"] = "revoke";
    18.6  ["[Change] or [revoke] area delegation [suffix]"] = " area delegation";
    18.7 -["[Change] or [revoke] global delegation [change]"] = "Change";
    18.8 -["[Change] or [revoke] global delegation [midpart]"] = " or ";
    18.9 -["[Change] or [revoke] global delegation [prefix]"] = "";
   18.10 -["[Change] or [revoke] global delegation [revoke]"] = "revoke";
   18.11 -["[Change] or [revoke] global delegation [suffix]"] = " global delegation";
   18.12 +["[Change] or [revoke] unit delegation [change]"] = "Change";
   18.13 +["[Change] or [revoke] unit delegation [midpart]"] = " or ";
   18.14 +["[Change] or [revoke] unit delegation [prefix]"] = "";
   18.15 +["[Change] or [revoke] unit delegation [revoke]"] = "revoke";
   18.16 +["[Change] or [revoke] unit delegation [suffix]"] = " unit delegation";
   18.17  ["[Registered members only]"] = false;
   18.18  ["[not displayed public]"] = false;
   18.19  ["a bit unsatisfied"] = false;
    19.1 --- a/model/area.lua	Wed Mar 02 20:06:26 2011 +0100
    19.2 +++ b/model/area.lua	Thu Mar 03 18:39:00 2011 +0100
    19.3 @@ -50,6 +50,38 @@
    19.4    ref                   = 'allowed_policies'
    19.5  }
    19.6  
    19.7 +Area:add_reference{
    19.8 +  mode          = '11',
    19.9 +  to            = "Membership",
   19.10 +  this_key      = 'id',
   19.11 +  that_key      = 'area_id',
   19.12 +  ref           = 'membership_for_member',
   19.13 +  back_ref      = 'area',
   19.14 +  selector_generator = function(list, options)
   19.15 +    local member_id = assert(options.member_id)
   19.16 +  
   19.17 +    -- build list of issue ids
   19.18 +    local ids = { sep = ", " }
   19.19 +    for i, object in ipairs(list) do
   19.20 +      local id = object.id
   19.21 +      if id ~= nil then
   19.22 +        ids[#ids+1] = {"?", id}
   19.23 +      end
   19.24 +    end
   19.25 +
   19.26 +    if #ids == 0 then
   19.27 +      return Membership:new_selector():empty_list_mode()
   19.28 +    end
   19.29 +    
   19.30 +    local selector = Membership:new_selector()
   19.31 +    selector:add_where{ 'membership.area_id IN ($)', ids }
   19.32 +    selector:add_where{ 'membership.member_id = ?', member_id }
   19.33 +    
   19.34 +    return selector
   19.35 +  end
   19.36 +}
   19.37 +
   19.38 +
   19.39  function Area.object_get:default_policy()
   19.40    return Policy:new_selector()
   19.41      :join("allowed_policy", nil, "allowed_policy.policy_id = policy.id")
    20.1 --- a/model/issue.lua	Wed Mar 02 20:06:26 2011 +0100
    20.2 +++ b/model/issue.lua	Thu Mar 03 18:39:00 2011 +0100
    20.3 @@ -166,7 +166,7 @@
    20.4      local selector = DelegatingInterestSnapshot:new_selector()
    20.5      selector:join("issue", nil, "delegating_interest_snapshot.issue_id = issue.id AND delegating_interest_snapshot.event = issue.latest_snapshot_event")
    20.6      selector:add_where{ 'delegating_interest_snapshot.issue_id IN ($)', ids }
    20.7 -    selector:add_where{ 'delegating_interest_snapshot.member_id = ?', options.member_id }
    20.8 +    selector:add_where{ 'delegating_interest_snapshot.member_id = ?', member_id }
    20.9      
   20.10      return selector
   20.11    end

Impressum / About Us