Commit 65d3181e4422e824c136c08efd77e3b4d97fd512
1 parent
310f1e11
Exists in
master
and in
29 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
... | ... | @@ -7,11 +7,11 @@ class Article < ActiveRecord::Base |
7 | 7 | acts_as_having_image |
8 | 8 | |
9 | 9 | SEARCHABLE_FIELDS = { |
10 | - :name => 10, | |
11 | - :abstract => 3, | |
12 | - :body => 2, | |
13 | - :slug => 1, | |
14 | - :filename => 1, | |
10 | + :name => {:label => _('Name'), :weight => 10}, | |
11 | + :abstract => {:label => _('Abstract'), :weight => 3}, | |
12 | + :body => {:label => _('Content'), :weight => 2}, | |
13 | + :slug => {:label => _('Slug'), :weight => 1}, | |
14 | + :filename => {:label => _('Filename'), :weight => 1}, | |
15 | 15 | } |
16 | 16 | |
17 | 17 | SEARCH_FILTERS = %w[ | ... | ... |
app/models/category.rb
... | ... | @@ -3,10 +3,10 @@ class Category < ActiveRecord::Base |
3 | 3 | attr_accessible :name, :parent_id, :display_color, :display_in_menu, :image_builder, :environment, :parent |
4 | 4 | |
5 | 5 | SEARCHABLE_FIELDS = { |
6 | - :name => 10, | |
7 | - :acronym => 5, | |
8 | - :abbreviation => 5, | |
9 | - :slug => 1, | |
6 | + :name => {:label => _('Name'), :weight => 10}, | |
7 | + :acronym => {:label => _('Acronym'), :weight => 5}, | |
8 | + :abbreviation => {:label => _('Abbreviation'), :weight => 5}, | |
9 | + :slug => {:label => _('Slug'), :weight => 1}, | |
10 | 10 | } |
11 | 11 | |
12 | 12 | validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('{fn} cannot be like that.').fix_i18n | ... | ... |
app/models/certifier.rb
... | ... | @@ -3,9 +3,9 @@ class Certifier < ActiveRecord::Base |
3 | 3 | attr_accessible :name, :environment |
4 | 4 | |
5 | 5 | SEARCHABLE_FIELDS = { |
6 | - :name => 10, | |
7 | - :description => 3, | |
8 | - :link => 1, | |
6 | + :name => {:label => _('Name'), :weight => 10}, | |
7 | + :description => {:label => _('Description'), :weight => 3}, | |
8 | + :link => {:label => _('Link'), :weight => 1}, | |
9 | 9 | } |
10 | 10 | |
11 | 11 | 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 | attr_accessible :body, :author, :name, :email, :title, :reply_of_id, :source | ... | ... |
app/models/license.rb
... | ... | @@ -3,8 +3,8 @@ class License < ActiveRecord::Base |
3 | 3 | attr_accessible :name, :url |
4 | 4 | |
5 | 5 | SEARCHABLE_FIELDS = { |
6 | - :name => 10, | |
7 | - :url => 5, | |
6 | + :name => {:label => _('Name'), :weight => 10}, | |
7 | + :url => {:label => _('URL'), :weight => 5}, | |
8 | 8 | } |
9 | 9 | |
10 | 10 | belongs_to :environment | ... | ... |
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
... | ... | @@ -12,9 +12,9 @@ class Profile < ActiveRecord::Base |
12 | 12 | end |
13 | 13 | |
14 | 14 | SEARCHABLE_FIELDS = { |
15 | - :name => 10, | |
16 | - :identifier => 5, | |
17 | - :nickname => 2, | |
15 | + :name => {:label => _('Name'), :weight => 10}, | |
16 | + :identifier => {:label => _('Username'), :weight => 5}, | |
17 | + :nickname => {:label => _('Nickname'), :weight => 2}, | |
18 | 18 | } |
19 | 19 | |
20 | 20 | SEARCH_FILTERS = %w[ | ... | ... |
app/models/qualifier.rb
app/models/scrap.rb
... | ... | @@ -3,7 +3,7 @@ class Scrap < ActiveRecord::Base |
3 | 3 | attr_accessible :content, :sender_id, :receiver_id, :scrap_id |
4 | 4 | |
5 | 5 | SEARCHABLE_FIELDS = { |
6 | - :content => 1, | |
6 | + :content => {:label => _('Content'), :weight => 1}, | |
7 | 7 | } |
8 | 8 | validates_presence_of :content |
9 | 9 | validates_presence_of :sender_id, :receiver_id | ... | ... |
app/models/user.rb
plugins/stoa/lib/ext/person.rb
... | ... | @@ -3,7 +3,7 @@ require_dependency 'person' |
3 | 3 | class Person |
4 | 4 | attr_accessible :usp_id, :invitation_code |
5 | 5 | |
6 | - SEARCHABLE_FIELDS[:usp_id] = 5 | |
6 | + SEARCHABLE_FIELDS[:usp_id] = {:label => _('USP Number'), :weight => 5} | |
7 | 7 | |
8 | 8 | validates_uniqueness_of :usp_id, :allow_nil => true |
9 | 9 | settings_items :invitation_code | ... | ... |