diff --git a/back-office/app/models/category.rb b/back-office/app/models/category.rb index 7776a29..7010b6d 100644 --- a/back-office/app/models/category.rb +++ b/back-office/app/models/category.rb @@ -2,4 +2,18 @@ class Category < ActiveRecord::Base has_many :sub_categories has_many :filter_criterias, as: :owner belongs_to :section + + rails_admin do + object_label_method do + :custom_cat_name + end + end + + def custom_cat_name + return self.name if not self.section + + section = self.section.name + "#{section} -> #{self.name}" + end + end diff --git a/back-office/app/models/filter_criteria.rb b/back-office/app/models/filter_criteria.rb index 493ac63..6ca6374 100644 --- a/back-office/app/models/filter_criteria.rb +++ b/back-office/app/models/filter_criteria.rb @@ -6,4 +6,9 @@ class FilterCriteria < ActiveRecord::Base def owner_type=(class_name) super(class_name.constantize.base_class.to_s) end + + def type_enum + # Do not select any value, or add any blank field. RailsAdmin will do it for you. + [['Multi select', 1], ['Single select', 2]] + end end diff --git a/back-office/app/models/filter_criteria_value.rb b/back-office/app/models/filter_criteria_value.rb index 21e12eb..498b7b2 100644 --- a/back-office/app/models/filter_criteria_value.rb +++ b/back-office/app/models/filter_criteria_value.rb @@ -1,3 +1,16 @@ class FilterCriteriaValue < ActiveRecord::Base belongs_to :filter_criteria + + rails_admin do + object_label_method do + :custom_name + end + end + + def custom_name + filter_title = self.filter_criteria.title if self.filter_criteria + + "#{filter_title} - #{self.filter_text},#{self.filter_value}" + end + end diff --git a/back-office/app/models/sub_category.rb b/back-office/app/models/sub_category.rb index 1b535f7..6735301 100644 --- a/back-office/app/models/sub_category.rb +++ b/back-office/app/models/sub_category.rb @@ -9,8 +9,11 @@ class SubCategory < ActiveRecord::Base end def custom_subcat_name + return self.name if not self.category + cat = self.category.name section = self.category.section.name + "#{section} -> #{cat} -> #{self.name}" end end diff --git a/front-ui/app/components/browsing/byCategory.js b/front-ui/app/components/browsing/byCategory.js index adc052e..e99081d 100644 --- a/front-ui/app/components/browsing/byCategory.js +++ b/front-ui/app/components/browsing/byCategory.js @@ -97,6 +97,7 @@ var ByCategory = React.createClass({ componentWillReceiveProps: function() { var categoryId = this.getParams().id; + this.filter = this.getQuery(); this.setState({ filter: this.filter }); diff --git a/front-ui/app/components/rootApp.js b/front-ui/app/components/rootApp.js index f317e39..9998075 100644 --- a/front-ui/app/components/rootApp.js +++ b/front-ui/app/components/rootApp.js @@ -14,7 +14,7 @@ var RootApp = React.createClass({
-

Ribica.ba

+

ribica.ba