New UI changes(tags, categories, authorisations, module index…)
To run: - ruby lib/remove_old_tags.rb DB_NAME - rake new_ui:migrate_tags - rake new_ui:migrate_categories['APP_KEY,''MODEL_NAME'] (check new_ui.rake for more details)
This commit is contained in:
1 parent
07b3857465
commit
856898016b
1495 files changed
+52132
-9876
No files matched your search
@@ -0,0 +1,41 @@
|
||||
module OrbitCategory
|
||||
module Categorizable
|
||||
|
||||
def self.included(base)
|
||||
base.extend ClassMethods
|
||||
base.class_eval 'categorizable'
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
def categorizable
|
||||
class_eval do
|
||||
field :category_id, type: BSON::ObjectId
|
||||
has_one :buffer_category, as: :categorizable, autosave: true, dependent: :destroy
|
||||
accepts_nested_attributes_for :buffer_category, allow_destroy: true
|
||||
end
|
||||
send :include, InstanceMethods
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def remove_id(id)
|
||||
self.update_attribute(:category_id, id)
|
||||
end
|
||||
|
||||
def category
|
||||
self.buffer_category.category if self.buffer_category
|
||||
end
|
||||
|
||||
def category=(id)
|
||||
self.buffer_category.destroy if self.buffer_category
|
||||
self.build_buffer_category(category_id: id)
|
||||
self.category_id = id
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
module OrbitCategory
|
||||
module Categorizing
|
||||
|
||||
def get_categories_for_index
|
||||
if is_manager? || is_admin?
|
||||
@module_app.categories.all
|
||||
else
|
||||
@module_app.categories.enabled
|
||||
end
|
||||
end
|
||||
|
||||
def get_categories_for_form(func_authed_for_sub_manager = "submit_#{@module_app.key}")
|
||||
categories = if is_manager? || is_admin?
|
||||
@module_app.categories.enabled
|
||||
elsif is_sub_manager?
|
||||
@module_app.categories.enabled.authed_for_user(current_user, func_authed_for_sub_manager)
|
||||
end
|
||||
if categories.empty?
|
||||
flash[:alert] = t(:no_category)
|
||||
redirect_to :action => :index
|
||||
end
|
||||
categories
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user