# HG changeset patch # User bsw # Date 1405540337 -7200 # Node ID f03fbffc18008d0560ffdb6b0b45fd4e3fef974d # Parent 7188f8a45b3d41b0b5f6b9c4b3e674ad20a1dfa5 New layout for suggestion details view diff -r 7188f8a45b3d -r f03fbffc1800 app/main/suggestion/_list_element.lua --- a/app/main/suggestion/_list_element.lua Wed Jul 16 21:51:08 2014 +0200 +++ b/app/main/suggestion/_list_element.lua Wed Jul 16 21:52:17 2014 +0200 @@ -77,140 +77,6 @@ end }, { - label = _"My opinion", - label_attr = { style = "width: 130px; font-style: italic;" }, - content = function(record) - local degree - local opinion - if app.session.member_id then - opinion = Opinion:by_pk(app.session.member.id, record.id) - end - if opinion then - degree = opinion.degree - end - ui.container{ - attr = { class = "suggestion_my_opinion" }, - content = function() - local has_voting_right = app.session.member and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) - if app.session.member_id and has_voting_right then - if initiative.issue.state == "voting" or initiative.issue.state == "closed" then - if degree == -2 then - ui.tag{ - tag = "span", - attr = { - class = "action" .. (degree == -2 and " active_red2" or "") - }, - content = _"must not" - } - end - if degree == -1 then - ui.tag{ - tag = "span", - attr = { class = "action" .. (degree == -1 and " active_red1" or "") }, - content = _"should not" - } - end - if degree == nil then - ui.tag{ - tag = "span", - attr = { class = "action" .. (degree == nil and " active" or "") }, - content = _"neutral" - } - end - if degree == 1 then - ui.tag{ - tag = "span", - attr = { class = "action" .. (degree == 1 and " active_green1" or "") }, - content = _"should" - } - end - if degree == 2 then - ui.tag{ - tag = "span", - attr = { class = "action" .. (degree == 2 and " active_green2" or "") }, - content = _"must" - } - end - else - -- we need to put initiative_id into the parameters to have a redirect target in case the suggestion is gone after the action - params = param.get_all_cgi() - params['initiative_id'] = initiative.id - - ui.link{ - attr = { class = "action" .. (degree == 2 and " active_green2" or "") }, - text = _"must", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } }, - params = { - suggestion_id = record.id, - degree = 2 - }, - partial = partial - } - slot.put(" ") - ui.link{ - attr = { class = "action" .. (degree == 1 and " active_green1" or "") }, - text = _"should", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params} }, - params = { - suggestion_id = record.id, - degree = 1 - }, - partial = partial - } - slot.put(" ") - ui.link{ - attr = { class = "action" .. (degree == nil and " active" or "") }, - text = _"neutral", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } }, - params = { - suggestion_id = record.id, - delete = true - }, - partial = partial - } - slot.put(" ") - ui.link{ - attr = { class = "action" .. (degree == -1 and " active_red1" or "") }, - text = _"should not", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } }, - params = { - suggestion_id = record.id, - degree = -1 - }, - partial = partial - } - slot.put(" ") - ui.link{ - attr = { class = "action" .. (degree == -2 and " active_red2" or "") }, - text = _"must not", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = params } }, - params = { - suggestion_id = record.id, - degree = -2 - }, - partial = partial - } - end - elseif app.session.member_id then - ui.field.text{ value = _"[No voting privilege]" } - else - ui.field.text{ value = _"[Registered members only]" } - end - end - } - end - }, - { label = _"Suggestion currently not implemented", label_attr = { style = "width: 101px;" }, content = function(record) @@ -250,70 +116,6 @@ end end }, - { - label = app.session.member_id and _"I consider suggestion as" or nil, - label_attr = { style = "width: 100px; font-style: italic;" }, - content = function(record) - local degree - local opinion - if app.session.member_id then - opinion = Opinion:by_pk(app.session.member.id, record.id) - end - if opinion then - degree = opinion.degree - end - if opinion then - - ui.link{ - attr = { class = opinion.fulfilled and "action active" or "action" }, - text = _"implemented", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } }, - params = { - suggestion_id = record.id, - fulfilled = true - }, - partial = partial - } - slot.put("
") - ui.link{ - attr = { class = not opinion.fulfilled and "action active" or "action" }, - text = _"not implemented", - module = "opinion", - action = "update", - routing = { default = { mode = "redirect", module = request.get_module(), view = request.get_view(), id = param.get_id_cgi(), params = param.get_all_cgi() } }, - params = { - suggestion_id = record.id, - fulfilled = false - }, - partial = partial - } - - end - end - }, - { - label = app.session.member_id and _"So I'm" or nil, - content = function(record) - local opinion - if app.session.member_id then - opinion = Opinion:by_pk(app.session.member.id, record.id) - end - if opinion then - if (opinion.fulfilled and opinion.degree > 0) or (not opinion.fulfilled and opinion.degree < 0) then - local title = _"satisfied" - ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_happy.png" } - elseif opinion.degree == 1 or opinion.degree == -1 then - local title = _"a bit unsatisfied" - ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_unhappy.png" } - else - local title = _"more unsatisfied" - ui.image{ attr = { alt = title, title = title }, static = "icons/emoticon_unhappy_red.png" } - end - end - end - }, } } end diff -r 7188f8a45b3d -r f03fbffc1800 app/main/suggestion/show.lua --- a/app/main/suggestion/show.lua Wed Jul 16 21:51:08 2014 +0200 +++ b/app/main/suggestion/show.lua Wed Jul 16 21:52:17 2014 +0200 @@ -17,29 +17,112 @@ return end +local initiative = suggestion.initiative -app.html_title.title = suggestion.name -app.html_title.subtitle = _("Suggestion ##{id}", { id = suggestion.id }) +initiative:load_everything_for_member_id(app.session.member_id) +initiative.issue:load_everything_for_member_id(app.session.member_id) + -ui.title(_"Suggestion for initiative: '#{name}'":gsub("#{name}", suggestion.initiative.name)) +execute.view{ module = "issue", view = "_sidebar_state", params = { + initiative = initiative +} } -ui.actions(function() - ui.link{ - content = function() - ui.image{ static = "icons/16/resultset_previous.png" } - slot.put(_"Back") - end, - module = "initiative", - view = "show", - id = suggestion.initiative.id, - params = { tab = "suggestions" } +execute.view { + module = "issue", view = "_sidebar_issue", + params = { + issue = initiative.issue, + highlight_initiative_id = initiative.id } -end) +} + +execute.view { + module = "issue", view = "_sidebar_whatcanido", + params = { initiative = initiative } +} -execute.view{ - module = "suggestion", - view = "show_tab", - params = { - suggestion = suggestion +execute.view { + module = "issue", view = "_sidebar_members", params = { + issue = initiative.issue, initiative = initiative + } +} + + + +execute.view { + module = "issue", view = "_head", params = { + issue = initiative.issue } } + + +ui.section( function() + ui.sectionHead( function() + ui.link{ + module = "initiative", view = "show", id = initiative.id, + content = function () + ui.heading { + level = 1, + content = initiative.display_name + } + end + } + ui.heading { level = 2, content = _("Suggestion for improvement #{id}", { id = suggestion.id }) } + end ) + ui.sectionRow( function() + + ui.heading{ level = 2, content = suggestion.name } + if app.session:has_access("authors_pseudonymous") and suggestion.author then + util.micro_avatar(suggestion.author) + end + end ) + ui.sectionRow( function() + ui.container{ + attr = { class = "suggestion_content wiki" }, + content = function() + slot.put(suggestion:get_content("html")) + end + } + + end ) +end ) + +ui.section( function() + ui.sectionHead( function() + ui.heading { level = 2, content = _"Collective rating" } + end ) + ui.sectionRow( function() + + execute.view{ + module = "suggestion", + view = "_list_element", + params = { + suggestions_selector = Suggestion:new_selector():add_where{ "id = ?", suggestion.id }, + initiative = suggestion.initiative, + show_name = false, + show_filter = false + } + } + end) +end) + +if app.session:has_access("all_pseudonymous") then + ui.section( function() + ui.sectionHead( function() + ui.heading { level = 2, content = _"Individual ratings" } + end ) + ui.sectionRow( function() + + execute.view{ + module = "opinion", + view = "_list", + params = { + opinions_selector = Opinion:new_selector() + :add_where{ "suggestion_id = ?", suggestion.id } + :join("member", nil, "member.id = opinion.member_id") + :add_order_by("member.id DESC") + } + } + + end) + end) +end \ No newline at end of file diff -r 7188f8a45b3d -r f03fbffc1800 app/main/suggestion/show_tab.lua --- a/app/main/suggestion/show_tab.lua Wed Jul 16 21:51:08 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -local suggestion = param.get("suggestion", "table") or Suggestion:by_id(param.get("suggestion_id")) - -local tabs = { - module = "suggestion", - view = "show_tab", - static_params = { - suggestion_id = suggestion.id - }, -} - -tabs[#tabs+1] = - { - name = "description", - label = _"Suggestion", - module = "suggestion", - view = "_suggestion", - params = { - suggestion = suggestion - } - } - -if app.session.member_id then - tabs[#tabs+1] = - { - name = "opinions", - label = _"Opinions", - module = "suggestion", - view = "_opinions", - params = { - suggestion = suggestion - } - } -end - -ui.tabs(tabs) \ No newline at end of file