Commit 024d804a4a3518fa40fa46ea6cc60ff53f8da08b
1 parent
82ba86f1
Exists in
master
and in
27 other branches
Adds a label string to SEARCHABLE_FIELDS
To make presentation easier, adds a label to SEARCHABLE_FIELDS as part of a hash.
Showing
13 changed files
with
29 additions
and
34 deletions
Show diff stats
app/controllers/public/invite_controller.rb
... | ... | @@ -8,12 +8,7 @@ class InviteController < PublicController |
8 | 8 | @import_from = params[:import_from] || "manual" |
9 | 9 | @mail_template = params[:mail_template] || environment.invitation_mail_template(profile) |
10 | 10 | |
11 | - extra_labels = Profile::SEARCHABLE_FIELDS.keys - [:name, :identifier, :nickname] | |
12 | - labels = [ | |
13 | - _('Name'), | |
14 | - _('Username'), | |
15 | - _('Email'), | |
16 | - ] + extra_labels.map { |label| Profile.human_attribute_name(label) } | |
11 | + labels = Profile::SEARCHABLE_FIELDS.except(:nickname).merge(User::SEARCHABLE_FIELDS).map { |name,info| info[:label] } | |
17 | 12 | last = labels.pop |
18 | 13 | label = labels.join(', ') |
19 | 14 | @search_friend_fields = "#{label} #{_('or')} #{last}" | ... | ... |
app/models/article.rb
... | ... | @@ -5,11 +5,11 @@ class Article < ActiveRecord::Base |
5 | 5 | acts_as_having_image |
6 | 6 | |
7 | 7 | SEARCHABLE_FIELDS = { |
8 | - :name => 10, | |
9 | - :abstract => 3, | |
10 | - :body => 2, | |
11 | - :slug => 1, | |
12 | - :filename => 1, | |
8 | + :name => {:label => _('Name'), :weight => 10}, | |
9 | + :abstract => {:label => _('Abstract'), :weight => 3}, | |
10 | + :body => {:label => _('Content'), :weight => 2}, | |
11 | + :slug => {:label => _('Slug'), :weight => 1}, | |
12 | + :filename => {:label => _('Filename'), :weight => 1}, | |
13 | 13 | } |
14 | 14 | |
15 | 15 | SEARCH_FILTERS = %w[ | ... | ... |
app/models/category.rb
1 | 1 | class Category < ActiveRecord::Base |
2 | 2 | |
3 | 3 | SEARCHABLE_FIELDS = { |
4 | - :name => 10, | |
5 | - :acronym => 5, | |
6 | - :abbreviation => 5, | |
7 | - :slug => 1, | |
4 | + :name => {:label => _('Name'), :weight => 10}, | |
5 | + :acronym => {:label => _('Acronym'), :weight => 5}, | |
6 | + :abbreviation => {:label => _('Abbreviation'), :weight => 5}, | |
7 | + :slug => {:label => _('Slug'), :weight => 1}, | |
8 | 8 | } |
9 | 9 | |
10 | 10 | validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('{fn} cannot be like that.').fix_i18n | ... | ... |
app/models/certifier.rb
1 | 1 | class Certifier < ActiveRecord::Base |
2 | 2 | |
3 | 3 | SEARCHABLE_FIELDS = { |
4 | - :name => 10, | |
5 | - :description => 3, | |
6 | - :link => 1, | |
4 | + :name => {:label => _('Name'), :weight => 10}, | |
5 | + :description => {:label => _('Description'), :weight => 3}, | |
6 | + :link => {:label => _('Link'), :weight => 1}, | |
7 | 7 | } |
8 | 8 | |
9 | 9 | belongs_to :environment | ... | ... |
app/models/comment.rb
1 | 1 | class Comment < ActiveRecord::Base |
2 | 2 | |
3 | 3 | SEARCHABLE_FIELDS = { |
4 | - :title => 10, | |
5 | - :name => 4, | |
6 | - :body => 2, | |
4 | + :title => {:label => _('Title'), :weight => 10}, | |
5 | + :name => {:label => _('Name'), :weight => 4}, | |
6 | + :body => {:label => _('Content'), :weight => 2}, | |
7 | 7 | } |
8 | 8 | |
9 | 9 | validates_presence_of :body | ... | ... |
app/models/license.rb
app/models/national_region.rb
1 | 1 | class NationalRegion < ActiveRecord::Base |
2 | 2 | |
3 | 3 | SEARCHABLE_FIELDS = { |
4 | - :name => 1, | |
5 | - :national_region_code => 1, | |
4 | + :name => {:label => _('Name'), :weight => 1}, | |
5 | + :national_region_code => {:label => _('Region Code'), :weight => 1}, | |
6 | 6 | } |
7 | 7 | |
8 | 8 | def self.search_city(city_name, like = false, state = nil) | ... | ... |
app/models/product.rb
app/models/profile.rb
... | ... | @@ -4,9 +4,9 @@ |
4 | 4 | class Profile < ActiveRecord::Base |
5 | 5 | |
6 | 6 | SEARCHABLE_FIELDS = { |
7 | - :name => 10, | |
8 | - :identifier => 5, | |
9 | - :nickname => 2, | |
7 | + :name => {:label => _('Name'), :weight => 10}, | |
8 | + :identifier => {:label => _('Username'), :weight => 5}, | |
9 | + :nickname => {:label => _('Nickname'), :weight => 2}, | |
10 | 10 | } |
11 | 11 | |
12 | 12 | SEARCH_FILTERS = %w[ | ... | ... |
app/models/qualifier.rb
app/models/scrap.rb
app/models/user.rb
plugins/stoa/lib/ext/person.rb