liquid_feedback_frontend

diff app/main/delegation/_info.lua @ 1045:701a5cf6b067

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents 9d4398195faf
children 32cc544d5a5b
line diff
     1.1 --- a/app/main/delegation/_info.lua	Thu Jul 10 01:02:43 2014 +0200
     1.2 +++ b/app/main/delegation/_info.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -8,6 +8,8 @@
     1.4  local area  = param.get("area", "table")
     1.5  local issue = param.get("issue", "table")
     1.6  
     1.7 +local for_title = param.get("for_title", "boolean")
     1.8 +
     1.9  local unit_id  = unit  and unit.id  or nil
    1.10  local area_id  = area  and area.id  or nil
    1.11  local issue_id = issue and issue.id or nil
    1.12 @@ -21,7 +23,6 @@
    1.13  end
    1.14  
    1.15  if area then
    1.16 -  area:load_delegation_info_once_for_member_id(member.id)
    1.17    info = area.delegation_info
    1.18    delegation_text = _"Delegate area"
    1.19  end
    1.20 @@ -31,24 +32,13 @@
    1.21    delegation_text = _"Delegate issue"
    1.22  end
    1.23  
    1.24 +if not info then
    1.25 +  --return
    1.26 +end
    1.27 +
    1.28  local function print_delegation_info()
    1.29 -  local participant_occured = false
    1.30 +  local participant_occured = info.own_participation
    1.31    
    1.32 -  if info.own_participation or info.first_trustee_id then
    1.33 -    
    1.34 -    local class = "micro_avatar"
    1.35 -    if info.own_participation then
    1.36 -      participant_occured = true
    1.37 -      class = class .. " highlighted"
    1.38 -    end
    1.39 -    
    1.40 -    execute.view{ module = "member_image", view = "_show", params = {
    1.41 -      member = member, class = class, popup_text = member.name,
    1.42 -      image_type = "avatar", show_dummy = true,
    1.43 -    } }
    1.44 -
    1.45 -  end
    1.46 -
    1.47    if not (issue and issue.state == "voting" and info.own_participation) then
    1.48      
    1.49      if info.first_trustee_id then
    1.50 @@ -154,10 +144,15 @@
    1.51            static = "delegation_arrow_24_horizontal.png"
    1.52          }
    1.53  
    1.54 -        execute.view{ module = "member_image", view = "_show", params = {
    1.55 -          member_id = info.first_trustee_id, class = "micro_avatar", popup_text = info.first_trustee_name,
    1.56 -          image_type = "avatar", show_dummy = true,
    1.57 -        } }
    1.58 +        execute.view{
    1.59 +          module = "member_image", view = "_show", params = {
    1.60 +            member_id = info.first_trustee_id, 
    1.61 +            class = "micro_avatar", 
    1.62 +            popup_text = info.first_trustee_name,
    1.63 +            image_type = "avatar",
    1.64 +            show_dummy = true,
    1.65 +          }
    1.66 +        }
    1.67        end
    1.68      
    1.69          
    1.70 @@ -174,24 +169,94 @@
    1.71    end
    1.72  end
    1.73  
    1.74 +if not param.get("no_star", "boolean") then
    1.75 +  
    1.76 +  if info.own_participation then
    1.77 +    if issue and issue.fully_frozen then
    1.78 +      ui.link{
    1.79 +        attr = { class = "right" },
    1.80 +        module = "vote", view = "list", params = {
    1.81 +          issue_id = issue.id
    1.82 +        },
    1.83 +        content = function ()
    1.84 +          ui.tag { content = _"you voted" }
    1.85 +        end
    1.86 +      }
    1.87 +    else
    1.88 +      if issue then
    1.89 +        local text = _"you are interested"
    1.90 +        ui.image { attr = { class = "star", title = text, alt = text }, static = "icons/48/eye.png" }
    1.91 +        if not issue.closed and info.own_participation and info.weight and info.weight > 1 then
    1.92 +          ui.link { 
    1.93 +            attr = { class = "right" }, content = "+" .. (info.weight - 1),
    1.94 +            module = "delegation", view = "show_incoming", params = { 
    1.95 +              issue_id = issue.id, member_id = member.id
    1.96 +            }
    1.97 +          }
    1.98 +        end
    1.99 +      else
   1.100 +        local text = _"you are subscribed"
   1.101 +        ui.image { attr = { class = "icon24 star", title = text, alt = text }, static = "icons/48/star.png" }
   1.102 +      end
   1.103 +      if not for_title then
   1.104 +        slot.put("<br />")
   1.105 +      else
   1.106 +        slot.put(" ")
   1.107 +      end
   1.108 +    end
   1.109 +  end
   1.110 +end
   1.111 +
   1.112  
   1.113  if info.own_participation or info.first_trustee_id then
   1.114 +  local class = "delegation_info"
   1.115 +  if info.own_participation then
   1.116 +    class = class .. " suspended"
   1.117 +  end
   1.118 +
   1.119 +  local voting_member_id
   1.120 +  local voting_member_name
   1.121 +  if issue and issue.fully_frozen and issue.closed then
   1.122 +    if issue.member_info.first_trustee_participation then
   1.123 +      voting_member_id = issue.member_info.first_trustee_id
   1.124 +      voting_member_name = issue.member_info.first_trustee_name
   1.125 +    elseif issue.member_info.other_trustee_participation then
   1.126 +      voting_member_id = issue.member_info.other_trustee_id
   1.127 +      voting_member_name = issue.member_info.other_trustee_name
   1.128 +    end
   1.129 +  end
   1.130 +  
   1.131    if app.session.member_id == member.id then
   1.132 -    ui.link{
   1.133 -      module = "delegation", view = "show", params = {
   1.134 -        unit_id = unit_id,
   1.135 -        area_id = area_id,
   1.136 -        issue_id = issue_id
   1.137 -      },
   1.138 -      attr = { class = "delegation_info" }, content = function()
   1.139 -        print_delegation_info()
   1.140 -      end
   1.141 -    }
   1.142 +
   1.143 +    if voting_member_id  then
   1.144 +      ui.link{
   1.145 +        module = "vote", view = "list", params = {
   1.146 +          issue_id = issue.id,
   1.147 +          member_id = voting_member_id
   1.148 +        },
   1.149 +        attr = { class = class }, content = function()
   1.150 +          print_delegation_info()
   1.151 +        end
   1.152 +      }
   1.153 +    
   1.154 +    else
   1.155 +      ui.link{
   1.156 +        module = "delegation", view = "show", params = {
   1.157 +          unit_id = unit_id,
   1.158 +          area_id = area_id,
   1.159 +          issue_id = issue_id
   1.160 +        },
   1.161 +        attr = { class = class }, content = function()
   1.162 +          print_delegation_info()
   1.163 +        end
   1.164 +      }
   1.165 +    end
   1.166    else
   1.167      ui.container{
   1.168 -      attr = { class = "delegation_info" }, content = function()
   1.169 +      attr = { class = class }, content = function()
   1.170          print_delegation_info()
   1.171        end
   1.172      }
   1.173    end
   1.174  end
   1.175 +

Impressum / About Us