From 7ea9945af050fc3d48e646a4f3d8c9ff09b7a310 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Mon, 8 Jul 2013 17:34:32 +0800 Subject: [PATCH] Location - category fixes Conflicts: app/models/category.rb vendor/built_in_modules/location/init.rb --- app/models/category.rb | 25 ++++++++++++++++++- .../location/back_end/locations_controller.rb | 2 ++ .../location/app/models/location.rb | 1 + .../back_end/locations/_form.html.erb | 10 ++++++++ vendor/built_in_modules/location/init.rb | 21 ++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/models/category.rb b/app/models/category.rb index 974914b0..02dca2ac 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -5,6 +5,8 @@ class Category field :disable, type: Boolean, default: false field :title, localize: true + field :custom, type: Boolean, default: false + field :custom_value validates :title, :at_least_one => true @@ -12,5 +14,26 @@ class Category has_many :buffer_categories scope :enabled, where(:disable.in => [false, nil, '']) +end -end \ No newline at end of file + + + # base.instance_eval("scope :admin_manager_all,find(:all)") + + # base.define_singleton_method :find do |*args| + # if args ==[:all] + # unscoped + # else + # res = unscoped.find(args) + # res.count == 1 ? res[0] : res + # end + # end + + # base.define_singleton_method :first do |*args| + # all.first + # end + + # base.define_singleton_method :last do |*args| + # all.last + # end +>>>>>>> 87741bf... Location - category fixes diff --git a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb index 5594bb7f..936a94ef 100644 --- a/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb +++ b/vendor/built_in_modules/location/app/controllers/panel/location/back_end/locations_controller.rb @@ -6,6 +6,7 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController def index @location_infos = LocationInfo.all + @categories = get_categories_for_index respond_to do |format| format.html # new.html.erb format.json { render json: @locations } @@ -14,6 +15,7 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController def new @location_info = LocationInfo.new + @categories = get_categories_for_index respond_to do |format| format.html # new.html.erb diff --git a/vendor/built_in_modules/location/app/models/location.rb b/vendor/built_in_modules/location/app/models/location.rb index 58d032bd..f381e720 100644 --- a/vendor/built_in_modules/location/app/models/location.rb +++ b/vendor/built_in_modules/location/app/models/location.rb @@ -1,6 +1,7 @@ class Location include Mongoid::Document include Mongoid::Timestamps + include OrbitCategory::Categorizable mount_uploader :file, LocationUploader diff --git a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb index d38b744c..e3d4e53e 100644 --- a/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb +++ b/vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb @@ -23,6 +23,16 @@ <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> + + +
+ +
+ <%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %> +
+
+ +
diff --git a/vendor/built_in_modules/location/init.rb b/vendor/built_in_modules/location/init.rb index 566bf5c1..843ef56a 100644 --- a/vendor/built_in_modules/location/init.rb +++ b/vendor/built_in_modules/location/init.rb @@ -30,6 +30,8 @@ module Location # # item "index","location.widget.index",:default_template=>true,:fields=>["title","category","postdate"] # # item "bulletins_and_web_links","location.widget.bulletins_and_web_links" # end + + categorizable side_bar do head_label_i18n 'location.location',:icon_class=>"icons-location" @@ -38,6 +40,25 @@ module Location head_link_path "panel_location_back_end_locations_path" + context_link 'location.all_locations', + :link_path=>"panel_location_back_end_locations_path" , + :priority=>1, + :active_for_action=>{:localtions=>:index}, + :available_for => [:manager] + + context_link 'location.add_location', + :link_path=>"new_panel_location_back_end_location_path" , + :priority=>1, + :active_for_action=>{:localtions=>:new}, + :available_for => [:manager] + + + context_link 'location.categories', + :link_path=>"admin_module_app_categories_path(get_module_app)" , + :priority=>1, + :active_for_action=>{:localtion_categories=>:index}, + :available_for => [:manager] + end end end