show how many users are filtering each tag
This commit is contained in:
parent
b2315a5728
commit
0663ea0fed
|
@ -493,7 +493,7 @@
|
|||
if (i === 0 && placeholder !== undefined && text === "") return true;
|
||||
|
||||
if (query.matcher(term, text)) {
|
||||
data.results.push({id: e.attr("value"), text: text});
|
||||
data.results.push({id: e.attr("value"), text: (e.attr("data-html") == undefined ? text : e.attr("data-html")) });
|
||||
}
|
||||
});
|
||||
query.callback(data);
|
||||
|
|
|
@ -1109,3 +1109,10 @@ div.modal_confirm_content div.modal_confirm_buttonbar input.default_button {
|
|||
-o-box-shadow : none;
|
||||
box-shadow : none;
|
||||
}
|
||||
|
||||
.select2-container .select2-results li em {
|
||||
background: none;
|
||||
color: #aaa;
|
||||
font-style: italic;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
|
|
@ -1,2 +1,16 @@
|
|||
class Tag < ActiveRecord::Base
|
||||
attr_accessor :filtered_count
|
||||
|
||||
def self.all_with_filtered_counts
|
||||
counts = TagFilter.count(:group => "tag_id")
|
||||
|
||||
Tag.order(:tag).all.map{|t|
|
||||
t.filtered_count = counts[t.id].to_i
|
||||
t
|
||||
}
|
||||
end
|
||||
|
||||
def filtered_count
|
||||
@filtered_count ||= TagFilter.where(:tag_id => self.id).count
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,9 +23,14 @@
|
|||
<div class="boxline" style="margin-bottom: 2px;">
|
||||
<%= f.label :tags_a, "Tags:", :class => "required",
|
||||
:style => "line-height: 2.3em;" %>
|
||||
<%= f.select "tags_a", Tag.order(:tag).map{|t|
|
||||
[ "#{t.tag} - #{t.description}", t.tag ] }, {},
|
||||
{ :multiple => true } %>
|
||||
<%= f.select "tags_a", options_for_select(
|
||||
Tag.all_with_filtered_counts.map{|t|
|
||||
[ "#{t.tag} - #{t.description}", t.tag, { "data-html" => raw("<strong>") +
|
||||
t.tag + raw("</strong> - ") + t.description.to_s +
|
||||
(t.filtered_count == 0 ? "" :
|
||||
raw(" <em>") + "#{t.filtered_count} user" +
|
||||
(t.filtered_count == 1 ? "" : "s") + " filtering" +
|
||||
raw("</em>")) } ]}), {}, { :multiple => true } %>
|
||||
</div>
|
||||
|
||||
<div class="boxline">
|
||||
|
|
Loading…
Reference in New Issue