liquid_feedback_frontend

changeset 1062:f03fbffc1800

New layout for suggestion details view
author bsw
date Wed Jul 16 21:52:17 2014 +0200 (2014-07-16)
parents 7188f8a45b3d
children 187127e290f9
files app/main/suggestion/_list_element.lua app/main/suggestion/show.lua app/main/suggestion/show_tab.lua
line diff
     1.1 --- a/app/main/suggestion/_list_element.lua	Wed Jul 16 21:51:08 2014 +0200
     1.2 +++ b/app/main/suggestion/_list_element.lua	Wed Jul 16 21:52:17 2014 +0200
     1.3 @@ -77,140 +77,6 @@
     1.4                end
     1.5              },
     1.6              {
     1.7 -              label = _"My opinion",
     1.8 -              label_attr = { style = "width: 130px; font-style: italic;" },
     1.9 -              content = function(record)
    1.10 -                local degree
    1.11 -                local opinion
    1.12 -                if app.session.member_id then
    1.13 -                  opinion = Opinion:by_pk(app.session.member.id, record.id)
    1.14 -                end
    1.15 -                if opinion then
    1.16 -                  degree = opinion.degree
    1.17 -                end
    1.18 -                ui.container{
    1.19 -                  attr = { class = "suggestion_my_opinion" },
    1.20 -                  content = function()
    1.21 -                    local has_voting_right = app.session.member and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
    1.22 -                    if app.session.member_id and has_voting_right then
    1.23 -                      if initiative.issue.state == "voting" or initiative.issue.state == "closed" then
    1.24 -                        if degree == -2 then
    1.25 -                          ui.tag{
    1.26 -                            tag = "span",
    1.27 -                            attr = {
    1.28 -                              class = "action" .. (degree == -2 and " active_red2" or "")
    1.29 -                            },
    1.30 -                            content = _"must not"
    1.31 -                          }
    1.32 -                        end
    1.33 -                        if degree == -1 then
    1.34 -                          ui.tag{
    1.35 -                            tag = "span",
    1.36 -                            attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
    1.37 -                            content = _"should not"
    1.38 -                          }
    1.39 -                        end
    1.40 -                        if degree == nil then
    1.41 -                          ui.tag{
    1.42 -                            tag = "span",
    1.43 -                            attr = { class = "action" .. (degree == nil and " active" or "") },
    1.44 -                            content = _"neutral"
    1.45 -                          }
    1.46 -                        end
    1.47 -                        if degree == 1 then
    1.48 -                          ui.tag{
    1.49 -                            tag = "span",
    1.50 -                            attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
    1.51 -                            content = _"should"
    1.52 -                          }
    1.53 -                        end
    1.54 -                        if degree == 2 then
    1.55 -                          ui.tag{
    1.56 -                            tag = "span",
    1.57 -                            attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
    1.58 -                            content = _"must"
    1.59 -                          }
    1.60 -                        end
    1.61 -                      else
    1.62 -                        -- we need to put initiative_id into the parameters to have a redirect target in case the suggestion is gone after the action
    1.63 -                        params = param.get_all_cgi()
    1.64 -                        params['initiative_id'] = initiative.id
    1.65 -
    1.66 -                        ui.link{
    1.67 -                          attr = { class = "action" .. (degree == 2 and " active_green2" or "") },
    1.68 -                          text = _"must",
    1.69 -                          module = "opinion",
    1.70 -                          action = "update",
    1.71 -                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
    1.72 -                          params = {
    1.73 -                            suggestion_id = record.id,
    1.74 -                            degree = 2
    1.75 -                          },
    1.76 -                          partial = partial
    1.77 -                        }
    1.78 -                        slot.put(" ")
    1.79 -                        ui.link{
    1.80 -                          attr = { class = "action" .. (degree == 1 and " active_green1" or "") },
    1.81 -                          text = _"should",
    1.82 -                          module = "opinion",
    1.83 -                          action = "update",
    1.84 -                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params} },
    1.85 -                          params = {
    1.86 -                            suggestion_id = record.id,
    1.87 -                            degree = 1
    1.88 -                          },
    1.89 -                          partial = partial
    1.90 -                        }
    1.91 -                        slot.put(" ")
    1.92 -                        ui.link{
    1.93 -                          attr = { class = "action" .. (degree == nil and " active" or "") },
    1.94 -                          text = _"neutral",
    1.95 -                          module = "opinion",
    1.96 -                          action = "update",
    1.97 -                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
    1.98 -                          params = {
    1.99 -                            suggestion_id = record.id,
   1.100 -                            delete = true
   1.101 -                          },
   1.102 -                          partial = partial
   1.103 -                        }
   1.104 -                        slot.put(" ")
   1.105 -                        ui.link{
   1.106 -                          attr = { class = "action" .. (degree == -1 and " active_red1" or "") },
   1.107 -                          text = _"should not",
   1.108 -                          module = "opinion",
   1.109 -                          action = "update",
   1.110 -                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
   1.111 -                          params = {
   1.112 -                            suggestion_id = record.id,
   1.113 -                            degree = -1
   1.114 -                          },
   1.115 -                          partial = partial
   1.116 -                        }
   1.117 -                        slot.put(" ")
   1.118 -                        ui.link{
   1.119 -                          attr = { class = "action" .. (degree == -2 and " active_red2" or "") },
   1.120 -                          text = _"must not",
   1.121 -                          module = "opinion",
   1.122 -                          action = "update",
   1.123 -                          routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } },
   1.124 -                          params = {
   1.125 -                            suggestion_id = record.id,
   1.126 -                            degree = -2
   1.127 -                          },
   1.128 -                          partial = partial
   1.129 -                        }
   1.130 -                      end
   1.131 -                    elseif app.session.member_id then
   1.132 -                      ui.field.text{ value = _"[No voting privilege]" }
   1.133 -                    else
   1.134 -                      ui.field.text{ value = _"[Registered members only]" }
   1.135 -                    end
   1.136 -                  end
   1.137 -                }
   1.138 -              end
   1.139 -            },
   1.140 -            {
   1.141                label = _"Suggestion currently not implemented",
   1.142                label_attr = { style = "width: 101px;" },
   1.143                content = function(record)
   1.144 @@ -250,70 +116,6 @@
   1.145                  end
   1.146                end
   1.147              },
   1.148 -            {
   1.149 -              label = app.session.member_id and _"I consider suggestion as" or nil,
   1.150 -              label_attr = { style = "width: 100px; font-style: italic;" },
   1.151 -              content = function(record)
   1.152 -                local degree
   1.153 -                local opinion
   1.154 -                if app.session.member_id then
   1.155 -                  opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.156 -                end
   1.157 -                if opinion then
   1.158 -                  degree = opinion.degree
   1.159 -                end
   1.160 -                if opinion then
   1.161 -
   1.162 -                  ui.link{
   1.163 -                    attr = { class = opinion.fulfilled and "action active" or "action" },
   1.164 -                    text = _"implemented",
   1.165 -                    module = "opinion",
   1.166 -                    action = "update",
   1.167 -                    routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.168 -                    params = {
   1.169 -                      suggestion_id = record.id,
   1.170 -                      fulfilled = true
   1.171 -                    },
   1.172 -                    partial = partial
   1.173 -                  }
   1.174 -                  slot.put("<br />")
   1.175 -                  ui.link{
   1.176 -                    attr = { class = not opinion.fulfilled and "action active" or "action" },
   1.177 -                    text = _"not implemented",
   1.178 -                    module = "opinion",
   1.179 -                    action = "update",
   1.180 -                    routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } },
   1.181 -                    params = {
   1.182 -                      suggestion_id = record.id,
   1.183 -                      fulfilled = false
   1.184 -                    },
   1.185 -                    partial = partial
   1.186 -                  }
   1.187 -
   1.188 -                end
   1.189 -              end
   1.190 -            },
   1.191 -            {
   1.192 -              label = app.session.member_id and _"So I'm" or nil,
   1.193 -              content = function(record)
   1.194 -                local opinion
   1.195 -                if app.session.member_id then
   1.196 -                  opinion = Opinion:by_pk(app.session.member.id, record.id)
   1.197 -                end
   1.198 -                if opinion then
   1.199 -                  if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then
   1.200 -                    local title = _"satisfied"
   1.201 -                    ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_happy.png" }
   1.202 -                  elseif opinion.degree == 1 or opinion.degree == -1 then
   1.203 -                    local title = _"a bit unsatisfied"
   1.204 -                    ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_unhappy.png" }
   1.205 -                  else
   1.206 -                    local title = _"more unsatisfied"
   1.207 -                    ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_unhappy_red.png" }
   1.208 -                  end
   1.209 -                end
   1.210 -              end
   1.211 -            },
   1.212            }
   1.213          }
   1.214        end
     2.1 --- a/app/main/suggestion/show.lua	Wed Jul 16 21:51:08 2014 +0200
     2.2 +++ b/app/main/suggestion/show.lua	Wed Jul 16 21:52:17 2014 +0200
     2.3 @@ -17,29 +17,112 @@
     2.4    return
     2.5  end
     2.6  
     2.7 +local initiative = suggestion.initiative
     2.8  
     2.9 -app.html_title.title = suggestion.name
    2.10 -app.html_title.subtitle = _("Suggestion ##{id}", { id = suggestion.id })
    2.11 +initiative:load_everything_for_member_id(app.session.member_id)
    2.12 +initiative.issue:load_everything_for_member_id(app.session.member_id)
    2.13 +
    2.14  
    2.15 -ui.title(_"Suggestion for initiative: '#{name}'":gsub("#{name}", suggestion.initiative.name))
    2.16 +execute.view{ module = "issue", view = "_sidebar_state", params = {
    2.17 +  initiative = initiative
    2.18 +} }
    2.19  
    2.20 -ui.actions(function()
    2.21 -  ui.link{
    2.22 -    content = function()
    2.23 -        ui.image{ static = "icons/16/resultset_previous.png" }
    2.24 -        slot.put(_"Back")
    2.25 -    end,
    2.26 -    module = "initiative",
    2.27 -    view = "show",
    2.28 -    id = suggestion.initiative.id,
    2.29 -    params = { tab = "suggestions" }
    2.30 +execute.view { 
    2.31 +  module = "issue", view = "_sidebar_issue", 
    2.32 +  params = {
    2.33 +    issue = initiative.issue,
    2.34 +    highlight_initiative_id = initiative.id
    2.35    }
    2.36 -end)
    2.37 +}
    2.38 +
    2.39 +execute.view {
    2.40 +  module = "issue", view = "_sidebar_whatcanido",
    2.41 +  params = { initiative = initiative }
    2.42 +}
    2.43  
    2.44 -execute.view{
    2.45 -  module = "suggestion",
    2.46 -  view = "show_tab",
    2.47 -  params = {
    2.48 -    suggestion = suggestion
    2.49 +execute.view { 
    2.50 +  module = "issue", view = "_sidebar_members", params = {
    2.51 +    issue = initiative.issue, initiative = initiative
    2.52 +  }
    2.53 +}
    2.54 +
    2.55 +
    2.56 +
    2.57 +execute.view {
    2.58 +  module = "issue", view = "_head", params = {
    2.59 +    issue = initiative.issue
    2.60    }
    2.61  }
    2.62 +
    2.63 +
    2.64 +ui.section( function()
    2.65 +  ui.sectionHead( function()
    2.66 +    ui.link{
    2.67 +      module = "initiative", view = "show", id = initiative.id,
    2.68 +      content = function ()
    2.69 +        ui.heading { 
    2.70 +          level = 1,
    2.71 +          content = initiative.display_name
    2.72 +        }
    2.73 +      end
    2.74 +    }
    2.75 +    ui.heading { level = 2, content = _("Suggestion for improvement #{id}", { id = suggestion.id }) }
    2.76 +  end )
    2.77 +  ui.sectionRow( function()
    2.78 +
    2.79 +    ui.heading{ level = 2, content = suggestion.name }
    2.80 +    if app.session:has_access("authors_pseudonymous") and suggestion.author then 
    2.81 +      util.micro_avatar(suggestion.author)
    2.82 +    end
    2.83 +  end )
    2.84 +  ui.sectionRow( function()
    2.85 +    ui.container{
    2.86 +      attr = { class = "suggestion_content wiki" },
    2.87 +      content = function()
    2.88 +        slot.put(suggestion:get_content("html"))
    2.89 +      end
    2.90 +    }
    2.91 +    
    2.92 +  end )
    2.93 +end )
    2.94 +
    2.95 +ui.section( function()
    2.96 +  ui.sectionHead( function()
    2.97 +    ui.heading { level = 2, content = _"Collective rating" }
    2.98 +  end )
    2.99 +  ui.sectionRow( function()
   2.100 +
   2.101 +    execute.view{
   2.102 +      module = "suggestion",
   2.103 +      view = "_list_element",
   2.104 +      params = {
   2.105 +        suggestions_selector = Suggestion:new_selector():add_where{ "id = ?", suggestion.id },
   2.106 +        initiative = suggestion.initiative,
   2.107 +        show_name = false,
   2.108 +        show_filter = false
   2.109 +      }
   2.110 +    }
   2.111 +  end)
   2.112 +end)
   2.113 +  
   2.114 +if app.session:has_access("all_pseudonymous") then
   2.115 +  ui.section( function()
   2.116 +    ui.sectionHead( function()
   2.117 +      ui.heading { level = 2, content = _"Individual ratings" }
   2.118 +    end )
   2.119 +    ui.sectionRow( function()
   2.120 +
   2.121 +      execute.view{
   2.122 +        module = "opinion",
   2.123 +        view = "_list",
   2.124 +        params = { 
   2.125 +          opinions_selector = Opinion:new_selector()
   2.126 +            :add_where{ "suggestion_id = ?", suggestion.id }
   2.127 +            :join("member", nil, "member.id = opinion.member_id")
   2.128 +            :add_order_by("member.id DESC")
   2.129 +        }
   2.130 +      }
   2.131 +
   2.132 +    end)
   2.133 +  end)
   2.134 +end
   2.135 \ No newline at end of file
     3.1 --- a/app/main/suggestion/show_tab.lua	Wed Jul 16 21:51:08 2014 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,35 +0,0 @@
     3.4 -local suggestion = param.get("suggestion", "table") or Suggestion:by_id(param.get("suggestion_id"))
     3.5 -
     3.6 -local tabs = {
     3.7 -  module = "suggestion",
     3.8 -  view = "show_tab",
     3.9 -  static_params = {
    3.10 -    suggestion_id = suggestion.id
    3.11 -  },
    3.12 -}
    3.13 -
    3.14 -tabs[#tabs+1] =
    3.15 -  {
    3.16 -    name = "description",
    3.17 -    label = _"Suggestion",
    3.18 -    module = "suggestion",
    3.19 -    view = "_suggestion",
    3.20 -    params = {
    3.21 -      suggestion = suggestion
    3.22 -    }
    3.23 -  }
    3.24 -
    3.25 -if app.session.member_id then
    3.26 -  tabs[#tabs+1] =
    3.27 -    {
    3.28 -      name = "opinions",
    3.29 -      label = _"Opinions",
    3.30 -      module = "suggestion",
    3.31 -      view = "_opinions",
    3.32 -      params = {
    3.33 -        suggestion = suggestion
    3.34 -      }
    3.35 -    }
    3.36 -end
    3.37 -
    3.38 -ui.tabs(tabs)
    3.39 \ No newline at end of file

Impressum / About Us