From 800f108be31d294fa5a188765c7dc5ea3e744d9b Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 10 Dec 2013 16:55:47 +0800 Subject: [PATCH] added enabling and disabling feature of widget count in module init --- app/controllers/admin/page_parts_controller.rb | 1 - app/models/module_app.rb | 5 +++++ app/views/admin/page_parts/edit.html.erb | 2 +- lib/orbit_app/module/registration.rb | 11 ++++++++++- vendor/built_in_modules/gallery/init.rb | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index bde46659..605b3419 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -39,7 +39,6 @@ class Admin::PagePartsController < OrbitBackendController else @tag_objects = @r_tag.classify.constantize.all rescue nil end - @html_class = "page-parts" end diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 8218731b..475dec86 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -30,6 +30,7 @@ class ModuleApp self[:enable_frontend] = reg.get_enable_frontend self[:get_widget_style] = reg.get_widgets self[:using_default_widget] = !reg.get_default_widget.blank? + self[:enable_widget_data_count] = reg.get_enable_widget_data_count self[:widgets] = reg.get_widgets self[:has_tag] = reg.get_has_tags self[:has_category] = reg.get_has_category @@ -59,6 +60,10 @@ class ModuleApp get_registration.get_default_widget end + def get_enable_widget_data_count + get_registration.get_enable_widget_data_count + end + def get_widget_for_select widgets = get_widget_style diff --git a/app/views/admin/page_parts/edit.html.erb b/app/views/admin/page_parts/edit.html.erb index f60a00c4..cdf49624 100644 --- a/app/views/admin/page_parts/edit.html.erb +++ b/app/views/admin/page_parts/edit.html.erb @@ -129,7 +129,7 @@
<%= render @partial if @partial %>
-
+
<%= f.label :widget_data_count, t(:widget_data_count), class: "control-label muted" %>
<%= f.select :widget_data_count, options_for_select(@data_count, @part.widget_data_count), {}, class: "input-mini", id: "page_count" %> diff --git a/lib/orbit_app/module/registration.rb b/lib/orbit_app/module/registration.rb index 60b62a39..66b1462a 100644 --- a/lib/orbit_app/module/registration.rb +++ b/lib/orbit_app/module/registration.rb @@ -28,7 +28,7 @@ module OrbitApp end class DataSheet - attr_reader :name,:key,:base_path,:module_label,:data_count, :has_category, :has_tag, :approvable_models, :authorizable_models, :is_approvable, :is_authorizable + attr_reader :name,:key,:base_path,:module_label,:data_count, :has_category, :has_tag, :approvable_models, :authorizable_models, :is_approvable, :is_authorizable, :enable_widget_data_count def initialize(name, &block) @name = name @@ -43,6 +43,7 @@ module OrbitApp @authorizable_models = [] @is_approvable = nil @is_authorizable = nil + @enable_widget_data_count = true block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? setup_module_app end @@ -63,6 +64,10 @@ module OrbitApp end + def get_enable_widget_data_count + @enable_widget_data_count + end + def get_label_i18n @module_label end @@ -164,6 +169,10 @@ module OrbitApp end end + def enable_widget_data_count(enable = true) + @enable_widget_data_count = enable + end + def approvable_on(klass = 'Category') @approvable_models << klass end diff --git a/vendor/built_in_modules/gallery/init.rb b/vendor/built_in_modules/gallery/init.rb index 30e50e3d..9be6b025 100644 --- a/vendor/built_in_modules/gallery/init.rb +++ b/vendor/built_in_modules/gallery/init.rb @@ -15,7 +15,7 @@ module Gallery frontend_i18n "gallery.front_end.albums" end end - + enable_widget_data_count false authorizable categorizable taggable