Merge pull request #84 from coopdevs/tags_per_company

Tags per company
This commit is contained in:
Saverio Trioni
2014-11-30 01:49:02 +01:00
8 changed files with 35 additions and 34 deletions
+9 -13
View File
@@ -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
+8 -10
View File
@@ -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
+2 -1
View File
@@ -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();
+2 -2
View File
@@ -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();
+8 -7
View File
@@ -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
+2 -1
View File
@@ -186,7 +186,8 @@ ca:
offered_by: "Oferents"
new:
submit: Crear oferta
edit:
submit: Canviar oferta
inquiries:
index:
new_inquiry: Nova demanda
+2
View File
@@ -186,6 +186,8 @@ en:
offered_by: "Offered by"
new:
submit: Create offer
edit:
submit: Change offer
inquiries:
index:
+2
View File
@@ -186,6 +186,8 @@ es:
offered_by: "Ofertantes"
new:
submit: Crear oferta
edit:
submit: Cambiar oferta
inquiries:
index: