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,12 +8,7 @@ class InviteController < PublicController | ||
8 | @import_from = params[:import_from] || "manual" | 8 | @import_from = params[:import_from] || "manual" |
9 | @mail_template = params[:mail_template] || environment.invitation_mail_template(profile) | 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 | last = labels.pop | 12 | last = labels.pop |
18 | label = labels.join(', ') | 13 | label = labels.join(', ') |
19 | @search_friend_fields = "#{label} #{_('or')} #{last}" | 14 | @search_friend_fields = "#{label} #{_('or')} #{last}" |
app/models/article.rb
@@ -5,11 +5,11 @@ class Article < ActiveRecord::Base | @@ -5,11 +5,11 @@ class Article < ActiveRecord::Base | ||
5 | acts_as_having_image | 5 | acts_as_having_image |
6 | 6 | ||
7 | SEARCHABLE_FIELDS = { | 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 | SEARCH_FILTERS = %w[ | 15 | SEARCH_FILTERS = %w[ |
app/models/category.rb
1 | class Category < ActiveRecord::Base | 1 | class Category < ActiveRecord::Base |
2 | 2 | ||
3 | SEARCHABLE_FIELDS = { | 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 | validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('{fn} cannot be like that.').fix_i18n | 10 | validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('{fn} cannot be like that.').fix_i18n |
app/models/certifier.rb
1 | class Certifier < ActiveRecord::Base | 1 | class Certifier < ActiveRecord::Base |
2 | 2 | ||
3 | SEARCHABLE_FIELDS = { | 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 | belongs_to :environment | 9 | belongs_to :environment |
app/models/comment.rb
1 | class Comment < ActiveRecord::Base | 1 | class Comment < ActiveRecord::Base |
2 | 2 | ||
3 | SEARCHABLE_FIELDS = { | 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 | validates_presence_of :body | 9 | validates_presence_of :body |
app/models/license.rb
1 | class License < ActiveRecord::Base | 1 | class License < ActiveRecord::Base |
2 | 2 | ||
3 | SEARCHABLE_FIELDS = { | 3 | SEARCHABLE_FIELDS = { |
4 | - :name => 10, | ||
5 | - :url => 5, | 4 | + :name => {:label => _('Name'), :weight => 10}, |
5 | + :url => {:label => _('URL'), :weight => 5}, | ||
6 | } | 6 | } |
7 | 7 | ||
8 | belongs_to :environment | 8 | belongs_to :environment |
app/models/national_region.rb
1 | class NationalRegion < ActiveRecord::Base | 1 | class NationalRegion < ActiveRecord::Base |
2 | 2 | ||
3 | SEARCHABLE_FIELDS = { | 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 | def self.search_city(city_name, like = false, state = nil) | 8 | def self.search_city(city_name, like = false, state = nil) |
app/models/product.rb
1 | class Product < ActiveRecord::Base | 1 | class Product < ActiveRecord::Base |
2 | 2 | ||
3 | SEARCHABLE_FIELDS = { | 3 | SEARCHABLE_FIELDS = { |
4 | - :name => 10, | ||
5 | - :description => 1, | 4 | + :name => {:label => _('Name'), :weight => 10}, |
5 | + :description => {:label => _('Description'), :weight => 1}, | ||
6 | } | 6 | } |
7 | 7 | ||
8 | SEARCH_FILTERS = %w[ | 8 | SEARCH_FILTERS = %w[ |
app/models/profile.rb
@@ -4,9 +4,9 @@ | @@ -4,9 +4,9 @@ | ||
4 | class Profile < ActiveRecord::Base | 4 | class Profile < ActiveRecord::Base |
5 | 5 | ||
6 | SEARCHABLE_FIELDS = { | 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 | SEARCH_FILTERS = %w[ | 12 | SEARCH_FILTERS = %w[ |
app/models/qualifier.rb
app/models/scrap.rb
1 | class Scrap < ActiveRecord::Base | 1 | class Scrap < ActiveRecord::Base |
2 | SEARCHABLE_FIELDS = { | 2 | SEARCHABLE_FIELDS = { |
3 | - :content => 1, | 3 | + :content => {:label => _('Content'), :weight => 1}, |
4 | } | 4 | } |
5 | validates_presence_of :content | 5 | validates_presence_of :content |
6 | validates_presence_of :sender_id, :receiver_id | 6 | validates_presence_of :sender_id, :receiver_id |
app/models/user.rb
@@ -9,7 +9,7 @@ class User < ActiveRecord::Base | @@ -9,7 +9,7 @@ class User < ActiveRecord::Base | ||
9 | N_('Terms accepted') | 9 | N_('Terms accepted') |
10 | 10 | ||
11 | SEARCHABLE_FIELDS = { | 11 | SEARCHABLE_FIELDS = { |
12 | - :email => 5, | 12 | + :email => {:label => _('Email'), :weight => 5}, |
13 | } | 13 | } |
14 | 14 | ||
15 | def self.[](login) | 15 | def self.[](login) |
plugins/stoa/lib/ext/person.rb
1 | require_dependency 'person' | 1 | require_dependency 'person' |
2 | 2 | ||
3 | class Person | 3 | class Person |
4 | - SEARCHABLE_FIELDS[:usp_id] = 5 | 4 | + SEARCHABLE_FIELDS[:usp_id] = {:label => _('USP Number'), :weight => 5} |
5 | 5 | ||
6 | validates_uniqueness_of :usp_id, :allow_nil => true | 6 | validates_uniqueness_of :usp_id, :allow_nil => true |
7 | settings_items :invitation_code | 7 | settings_items :invitation_code |