diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ec0b472..bf21fd5 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -9,37 +9,33 @@ 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 && 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). + end.by_organization(current_organization).actives. 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 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 @@ -48,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 a1e25ac..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?("offer")?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 3ce1a99..fb71cd9 100644 --- a/app/views/tags/_grouped_index.html.haml +++ b/app/views/tags/_grouped_index.html.haml @@ -1,17 +1,18 @@ .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 + - # 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 .badge - ="#{count}" - - path = get_index_path(@current_post_type,tag: tag) + = 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: