liquid_feedback_frontend

diff app/main/issue/_show.lua @ 525:63d6549cc00b

Delegation chain preview improved, better visualisation of current context, code cleanup
author bsw
date Fri May 18 19:07:07 2012 +0200 (2012-05-18)
parents
children 4cee33ad5e16
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/issue/_show.lua	Fri May 18 19:07:07 2012 +0200
     1.3 @@ -0,0 +1,175 @@
     1.4 +local issue = param.get("issue", "table")
     1.5 +local initiative_limit = param.get("initiative_limit", atom.integer)
     1.6 +local for_listing = param.get("for_listing", atom.boolean)
     1.7 +
     1.8 +local direct_voter
     1.9 +if app.session.member_id then
    1.10 +  direct_voter = DirectVoter:by_pk(issue.id, app.session.member.id)
    1.11 +end
    1.12 +
    1.13 +local voteable = app.session.member_id and issue.state == 'voting' and
    1.14 +       app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
    1.15 +
    1.16 +local vote_link_text = direct_voter and _"Change vote" or "Vote now"
    1.17 +
    1.18 +
    1.19 +local class = "issue"
    1.20 +if issue.is_interested then
    1.21 +  class = class .. " interested"
    1.22 +elseif issue.is_interested_by_delegation_to_member_id then
    1.23 +  class = class .. " interested_by_delegation"
    1.24 +end
    1.25 +
    1.26 +ui.container{ attr = { class = class }, content = function()
    1.27 +
    1.28 +  execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
    1.29 +
    1.30 +  if for_listing then
    1.31 +    ui.container{ attr = { class = "context" }, content = function()
    1.32 +      ui.tag{ content = issue.area.unit.name }
    1.33 +      slot.put(" · ")
    1.34 +      ui.tag{ content = issue.area.name }
    1.35 +    end }
    1.36 +  end
    1.37 +  ui.container{ attr = { class = "title" }, content = function()
    1.38 +    
    1.39 +    ui.link{
    1.40 +      attr = { class = "issue_id" },
    1.41 +      text = _("#{policy_name} ##{issue_id}", {
    1.42 +        policy_name = issue.policy.name,
    1.43 +        issue_id = issue.id
    1.44 +      }),
    1.45 +      module = "issue",
    1.46 +      view = "show",
    1.47 +      id = issue.id
    1.48 +    }
    1.49 +  end }
    1.50 +  
    1.51 +  ui.tag{
    1.52 +    attr = { class = "content issue_policy_info" },
    1.53 +    tag = "div",
    1.54 +    content = function()
    1.55 +    
    1.56 +      ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
    1.57 +
    1.58 +      if issue.state_time_left then
    1.59 +        slot.put(" · ")
    1.60 +        if issue.state_time_left:sub(1,1) == "-" then
    1.61 +          if issue.state == "new" then
    1.62 +            ui.tag{ content = _("Discussion starts soon") }
    1.63 +          elseif issue.state == "discussion" then
    1.64 +            ui.tag{ content = _("Verification starts soon") }
    1.65 +          elseif issue.state == "frozen" then
    1.66 +            ui.tag{ content = _("Voting starts soon") }
    1.67 +          elseif issue.state == "voting" then
    1.68 +            ui.tag{ content = _("Counting starts soon") }
    1.69 +          end
    1.70 +        else
    1.71 +          ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
    1.72 +        end
    1.73 +      end
    1.74 +
    1.75 +    end
    1.76 +  }
    1.77 +
    1.78 +  ui.container{
    1.79 +    attr = { class = "content actions" }, content = function()
    1.80 +  
    1.81 +    if voteable then
    1.82 +      ui.link{
    1.83 +        content = vote_link_text,
    1.84 +        module = "vote",
    1.85 +        view = "list",
    1.86 +        params = { issue_id = issue.id }
    1.87 +      }
    1.88 +      slot.put(" · ")
    1.89 +    end
    1.90 +
    1.91 +    if app.session.member_id then
    1.92 +      execute.view{
    1.93 +        module = "interest",
    1.94 +        view = "_show_box",
    1.95 +        params = { issue = issue, initiative = initiative }
    1.96 +      }
    1.97 +      slot.put(" · ")
    1.98 +    end
    1.99 +
   1.100 +    if config.issue_discussion_url_func then
   1.101 +      local url = config.issue_discussion_url_func(issue)
   1.102 +      ui.link{
   1.103 +        attr = { target = "_blank" },
   1.104 +        external = url,
   1.105 +        content = _"Discussion on issue"
   1.106 +      }
   1.107 +      slot.put(" · ")
   1.108 +    end
   1.109 +
   1.110 +    if config.etherpad and app.session.member then
   1.111 +      ui.link{
   1.112 +        attr = { target = "_blank" },
   1.113 +        external = issue.etherpad_url,
   1.114 +        content = _"Issue pad"
   1.115 +      }
   1.116 +      slot.put(" · ")
   1.117 +    end
   1.118 +
   1.119 +
   1.120 +    if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
   1.121 +      if not issue.fully_frozen and not issue.closed then
   1.122 +        ui.link{
   1.123 +          attr   = { class = "action" },
   1.124 +          text   = _"Create alternative initiative",
   1.125 +          module = "initiative",
   1.126 +          view   = "new",
   1.127 +          params = { issue_id = issue.id }
   1.128 +        }
   1.129 +      end
   1.130 +    end
   1.131 +
   1.132 +  end }
   1.133 +
   1.134 +  if not for_listing then
   1.135 +    
   1.136 +    if voteable then
   1.137 +      ui.container{
   1.138 +        attr = { class = "voting_active_info" },
   1.139 +        content = function()
   1.140 +          slot.put(_"Voting for this issue is currently running!")
   1.141 +          slot.put(" ")
   1.142 +          if app.session.member_id then
   1.143 +            ui.link{
   1.144 +              content = vote_link_text,
   1.145 +              module = "vote",
   1.146 +              view = "list",
   1.147 +              params = { issue_id = issue.id }
   1.148 +            }
   1.149 +          end
   1.150 +        end
   1.151 +      }
   1.152 +    end
   1.153 +
   1.154 +  end
   1.155 +
   1.156 +  ui.container{ attr = { class = "initiative_list" }, content = function()
   1.157 +
   1.158 +    local initiatives_selector = issue:get_reference_selector("initiatives")
   1.159 +    local highlight_string = param.get("highlight_string")
   1.160 +    if highlight_string then
   1.161 +      initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
   1.162 +    end
   1.163 +    execute.view{
   1.164 +      module = "initiative",
   1.165 +      view = "_list",
   1.166 +      params = {
   1.167 +        issue = issue,
   1.168 +        initiatives_selector = initiatives_selector,
   1.169 +        highlight_string = highlight_string,
   1.170 +        per_page = initiative_limit,
   1.171 +        no_sort = true,
   1.172 +        limit = initiative_limit,
   1.173 +        for_member = for_member
   1.174 +      }
   1.175 +    }
   1.176 +  end }
   1.177 +end }
   1.178 +

Impressum / About Us