From 6067e897c233c1b9194f12fc4dea5ed054ff18b2 Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Mon, 24 Nov 2014 05:30:08 +0100 Subject: [PATCH 1/3] alpha_grouped_index: clicking offer tags was redirecting to inquiries --- app/controllers/tags_controller.rb | 13 +++++-------- app/helpers/posts_helper.rb | 4 ++-- app/views/tags/_grouped_index.html.haml | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ec0b472..32f6aac 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -9,24 +9,21 @@ class TagsController < ApplicationController def alpha_grouped_index permitted = tags_params(params) - post_type = permitted[:post_type] || "offer" + @current_post_type = permitted[:post_type] || "offer" @offers_tagged = [] @inquiries_tagged = [] - @alpha_tags = case post_type + redirect_to users_path and return unless current_organization + + @alpha_tags = case @current_post_type when "offer" then Offer when "inquiry" then Inquiry when "all" then Post end.by_organization(current_organization). + active. alphabetical_grouped_tags - @current_post_type = case post_type - when "offer" then "offers" - when "inquiry" then "inquiries" - when "all" then "all" - end - respond_with @alpha_tags end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index a1e25ac..af4dabb 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -6,9 +6,9 @@ module PostsHelper case when klass == String - post.eql?("offer")?offers_path(hparams):inquiries_path(hparams) + post.eql?("offers") ? offers_path(hparams) : inquiries_path(hparams) else - post.type.eql?("Offer")?offers_path(hparams):inquiries_path(hparams) + post.type.eql?("Offer") ? offers_path(hparams) : inquiries_path(hparams) end end diff --git a/app/views/tags/_grouped_index.html.haml b/app/views/tags/_grouped_index.html.haml index 3ce1a99..cf36959 100644 --- a/app/views/tags/_grouped_index.html.haml +++ b/app/views/tags/_grouped_index.html.haml @@ -10,7 +10,7 @@ %p .badge ="#{count}" - - path = get_index_path(@current_post_type,tag: tag) + - path = get_index_path(@current_post_type.pluralize, tag: tag) = link_to path do - gtag=(count==1) ? "tag" : "tags" = glyph(gtag) From ebc122834ca5d136a190402673889c76b343a709 Mon Sep 17 00:00:00 2001 From: Dani Macho Date: Sat, 29 Nov 2014 16:09:20 +0100 Subject: [PATCH 2/3] fixed error editing offers and inquiries. Tags shown per company --- app/controllers/tags_controller.rb | 13 ++++++------- app/helpers/posts_helper.rb | 18 ++++++++---------- app/views/inquiries/edit.html.haml | 3 ++- app/views/offers/edit.html.haml | 4 ++-- app/views/tags/_grouped_index.html.haml | 12 ++++++------ config/locales/ca.yml | 3 ++- config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 32f6aac..bf21fd5 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -14,14 +14,13 @@ class TagsController < ApplicationController @offers_tagged = [] @inquiries_tagged = [] - redirect_to users_path and return unless current_organization + redirect_to users_path && return unless current_organization @alpha_tags = case @current_post_type when "offer" then Offer when "inquiry" then Inquiry when "all" then Post - end.by_organization(current_organization). - active. + end.by_organization(current_organization).actives. alphabetical_grouped_tags respond_with @alpha_tags @@ -29,14 +28,14 @@ class TagsController < ApplicationController def inquiries @current_post_type = "inquiries" - @alpha_tags = Inquiry.by_organization(current_organization). + @alpha_tags = Inquiry.by_organization(current_organization).actives. alphabetical_grouped_tags render partial: "grouped_index", locals: { alpha_tags: @alpha_tags } end def offers @current_post_type = "offers" - @alpha_tags = Offer.by_organization(current_organization). + @alpha_tags = Offer.by_organization(current_organization).actives. alphabetical_grouped_tags render partial: "grouped_index", locals: { alpha_tags: @alpha_tags } end @@ -45,9 +44,9 @@ class TagsController < ApplicationController permitted = tags_params(params) tagname = permitted[:tagname] || "" - @offers_tagged = Offer.by_organization(current_organization). + @offers_tagged = Offer.by_organization(current_organization).actives. tagged_with(tagname) - @inquiries_tagged = Inquiry.by_organization(current_organization). + @inquiries_tagged = Inquiry.by_organization(current_organization).actives. tagged_with(tagname) respond_with @offers_tagged, @inquiries_tagged end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index af4dabb..1737bf6 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,15 +1,13 @@ module PostsHelper # Returns the right path to index list depending on type of post - def get_index_path(post,hparams) - - klass=post.class - - case - when klass == String - post.eql?("offers") ? offers_path(hparams) : inquiries_path(hparams) - else - post.type.eql?("Offer") ? offers_path(hparams) : inquiries_path(hparams) - end + def get_index_path(post, hparams) + klass = post.class + case + when klass == String + post.eql?("offers") ? offers_path(hparams) : inquiries_path(hparams) + else + post.type.eql?("Offer") ? offers_path(hparams) : inquiries_path(hparams) + end end end diff --git a/app/views/inquiries/edit.html.haml b/app/views/inquiries/edit.html.haml index 8c4cdfd..72ca8d8 100644 --- a/app/views/inquiries/edit.html.haml +++ b/app/views/inquiries/edit.html.haml @@ -3,7 +3,8 @@ %small = t ".edit" -= render partial: 'shared/post_form', locals: {post: @inquiry} += render partial: "shared/post_form", locals: { post: @inquiry, + label_button: t(".submit") } :javascript $("#inquiry_tag_list").tagsManager(); diff --git a/app/views/offers/edit.html.haml b/app/views/offers/edit.html.haml index e5d8e17..ccc5a0e 100644 --- a/app/views/offers/edit.html.haml +++ b/app/views/offers/edit.html.haml @@ -3,8 +3,8 @@ %small = t ".edit" -= render partial: 'shared/post_form', locals: {post: @offer} += render partial: "shared/post_form", locals: { post: @offer, + label_button: t(".submit") } :javascript $("#offer_tag_list").tagsManager(); - diff --git a/app/views/tags/_grouped_index.html.haml b/app/views/tags/_grouped_index.html.haml index cf36959..d9a38cb 100644 --- a/app/views/tags/_grouped_index.html.haml +++ b/app/views/tags/_grouped_index.html.haml @@ -1,17 +1,17 @@ .tag_list.container_fluid - alpha_tags.each_slice(6) do |gr| .row - - gr.each do |k,v| + - gr.each do |kg, vg| .col-xs-2.col-md-2 %h2.bg-info.text-center - =k - - v=v.sort_by { |k,v| v }.reverse - - v.each do |tag,count| + = kg + - vl = vg.sort_by { |_k, v| v }.reverse + - vl.each do |tag, count| %p .badge - ="#{count}" + = count - path = get_index_path(@current_post_type.pluralize, tag: tag) = link_to path do - - gtag=(count==1) ? "tag" : "tags" + - gtag = (count == 1) ? "tag" : "tags" = glyph(gtag) = tag diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 13af9ca..220fa5f 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -186,7 +186,8 @@ ca: offered_by: "Oferents" new: submit: Crear oferta - + edit: + submit: Canviar oferta inquiries: index: new_inquiry: Nova demanda diff --git a/config/locales/en.yml b/config/locales/en.yml index 7ae1390..4cf7d72 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -186,6 +186,8 @@ en: offered_by: "Offered by" new: submit: Create offer + edit: + submit: Change offer inquiries: index: diff --git a/config/locales/es.yml b/config/locales/es.yml index dd3fa88..c051443 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -186,6 +186,8 @@ es: offered_by: "Ofertantes" new: submit: Crear oferta + edit: + submit: Cambiar oferta inquiries: index: From b025aad499b29c4170f5def8ca48680ee8f12b5b Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Sun, 30 Nov 2014 01:47:47 +0100 Subject: [PATCH 3/3] Added TODO --- app/views/tags/_grouped_index.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/tags/_grouped_index.html.haml b/app/views/tags/_grouped_index.html.haml index d9a38cb..fb71cd9 100644 --- a/app/views/tags/_grouped_index.html.haml +++ b/app/views/tags/_grouped_index.html.haml @@ -5,6 +5,7 @@ .col-xs-2.col-md-2 %h2.bg-info.text-center = kg + - # TODO: move sorting to the reader, too much code in the view - vl = vg.sort_by { |_k, v| v }.reverse - vl.each do |tag, count| %p