Merge branch 'development' of https://github.com/Rulingcom/orbit into development
This commit is contained in:
commit
91b1cf6edc
|
@ -144,7 +144,7 @@ class Admin::AuthorizationsController < OrbitBackendController
|
|||
|
||||
def setup_vars
|
||||
@module_app = ModuleApp.first(conditions: {:key => params[:module]} ) if params[:module]
|
||||
@category = Category.find(params[:category]) rescue nil
|
||||
@category = Category.find(params[:id]) rescue nil
|
||||
@type = params[:type]
|
||||
end
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ module OrbitBackendHelper
|
|||
if object.is_hidden?
|
||||
res << content_tag(:span, t(:hidden), class: "label") + ' '
|
||||
end
|
||||
if @approvable
|
||||
if object.is_pending?
|
||||
res << content_tag(:span, t(:pending), class: "label") + ' '
|
||||
end
|
||||
|
@ -115,6 +116,7 @@ module OrbitBackendHelper
|
|||
if object.is_rejected?
|
||||
res << content_tag(:span, t(:rejected), class: "label") + ' '
|
||||
end
|
||||
end
|
||||
when 'tags'
|
||||
object.sorted_tags.each do |tag|
|
||||
res << content_tag(:span, tag.name, class: "label label-warning")
|
||||
|
@ -154,8 +156,8 @@ module OrbitBackendHelper
|
|||
end
|
||||
|
||||
def set_default_index(&block)
|
||||
@approvable = false
|
||||
@authorization = false
|
||||
@approvable = @module_app.is_approvable
|
||||
@authorization = @module_app.is_authorizable
|
||||
@fields = []
|
||||
@filter_fields =[]
|
||||
@filterable = false
|
||||
|
@ -167,14 +169,6 @@ module OrbitBackendHelper
|
|||
|
||||
protected
|
||||
|
||||
def approvable
|
||||
@approvable = true
|
||||
end
|
||||
|
||||
def authorization
|
||||
@authorization = true
|
||||
end
|
||||
|
||||
# ===============================================================
|
||||
# type:
|
||||
# check "get_value"
|
||||
|
|
|
@ -14,24 +14,3 @@ class Category
|
|||
scope :enabled, where(:disable.in => [false, nil, ''])
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
# 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
|
|
@ -22,7 +22,9 @@ class ModuleApp
|
|||
self[:widgets] = reg.get_widgets
|
||||
self[:has_tag] = reg.get_has_tags
|
||||
self[:has_category] = reg.get_has_category
|
||||
self[:is_approvable] = reg.get_is_approvable
|
||||
self[:is_authorizable] = reg.get_is_authorizable
|
||||
self[:authorizable_models] = reg.get_authorizable_models
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ Orbit::Application.routes.draw do
|
|||
resources :ad_images ,:except => [:show,:index]
|
||||
end
|
||||
|
||||
match 'authorizations/add_roles/:module(/:type(/:category))' => 'authorizations#add_roles', :as => :add_roles_authorizations
|
||||
match 'authorizations/add_users/:module(/:type(/:category))' => 'authorizations#add_users', :as => :add_users_authorizations
|
||||
match 'authorizations/modal_select/:module(/:type(/:category))' => 'authorizations#modal_select', :as => :modal_select_authorizations
|
||||
match 'authorizations/remove_users/:module(/:type(/:category))' => 'authorizations#remove_users', :as => :remove_users_authorizations, :via => :delete
|
||||
match 'authorizations(/:module(/:type(/:category)))' => 'authorizations#index', :as => :authorizations
|
||||
match 'authorizations/add_roles/:module(/:type(/:id))' => 'authorizations#add_roles', :as => :add_roles_authorizations
|
||||
match 'authorizations/add_users/:module(/:type(/:id))' => 'authorizations#add_users', :as => :add_users_authorizations
|
||||
match 'authorizations/modal_select/:module(/:type(/:id))' => 'authorizations#modal_select', :as => :modal_select_authorizations
|
||||
match 'authorizations/remove_users/:module(/:type(/:id))' => 'authorizations#remove_users', :as => :remove_users_authorizations, :via => :delete
|
||||
match 'authorizations(/:module(/:type(/:id)))' => 'authorizations#index', :as => :authorizations
|
||||
|
||||
resources :dashboards do
|
||||
collection do
|
||||
|
|
|
@ -28,7 +28,7 @@ module OrbitApp
|
|||
end
|
||||
|
||||
class DataSheet
|
||||
attr_reader :name,:key,:base_path,:module_label,:data_count, :has_tag
|
||||
attr_reader :name,:key,:base_path,:module_label,:data_count, :has_category, :has_tag, :authorizable_models, :is_approvable, :is_authorizable
|
||||
|
||||
def initialize(name, &block)
|
||||
@name = name
|
||||
|
@ -39,6 +39,8 @@ module OrbitApp
|
|||
@data_count = 1..15 # as default
|
||||
@has_category = nil
|
||||
@has_tag = nil
|
||||
@authorizable_models = []
|
||||
@is_approvable = nil
|
||||
@is_authorizable = nil
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
setup_module_app
|
||||
|
@ -123,7 +125,7 @@ module OrbitApp
|
|||
end
|
||||
|
||||
def side_bar(&block) #setter for side_bar from init
|
||||
@side_bar = SideBarRegisition::SideBar.new(@name,@key,method(:get_module_app),&block)
|
||||
@side_bar = SideBarRegisition::SideBar.new(@name,@key,method(:get_module_app), is_approvable_with_link?, is_authorizable_with_link?, &block)
|
||||
end
|
||||
|
||||
def personal_plugin(params) #setter for personal_plugin from init
|
||||
|
@ -143,8 +145,21 @@ module OrbitApp
|
|||
define_method(field){|var| instance_variable_set( "@" + field, var)}
|
||||
end
|
||||
|
||||
def authorizable
|
||||
@is_authorizable = true
|
||||
def approvable(link=true)
|
||||
@is_approvable = {:with_link => link}
|
||||
end
|
||||
|
||||
def authorizable(link=true, &block)
|
||||
@is_authorizable = {:with_link => link}
|
||||
if block
|
||||
block.call
|
||||
else
|
||||
authorizable_on
|
||||
end
|
||||
end
|
||||
|
||||
def authorizable_on(klass = 'Category')
|
||||
@authorizable_models << klass
|
||||
end
|
||||
|
||||
def categorizable
|
||||
|
@ -155,16 +170,32 @@ module OrbitApp
|
|||
@has_tag = true
|
||||
end
|
||||
|
||||
def get_authorizable_models
|
||||
@authorizable_models
|
||||
end
|
||||
|
||||
def get_has_category
|
||||
@has_category.nil? ? false : true
|
||||
@has_category == true
|
||||
end
|
||||
|
||||
def get_has_tags
|
||||
@has_tag.nil? ? false : true
|
||||
@has_tag == true
|
||||
end
|
||||
|
||||
def get_is_approvable
|
||||
!@is_approvable.blank?
|
||||
end
|
||||
|
||||
def get_is_authorizable
|
||||
@is_authorizable.nil? ? false : true
|
||||
!@is_authorizable.blank?
|
||||
end
|
||||
|
||||
def is_approvable_with_link?
|
||||
@is_approvable && @is_approvable[:with_link]
|
||||
end
|
||||
|
||||
def is_authorizable_with_link?
|
||||
@is_authorizable && @is_authorizable[:with_link]
|
||||
end
|
||||
|
||||
end # of class DataSheet
|
||||
|
|
|
@ -41,7 +41,7 @@ module OrbitApp
|
|||
# include AdminHelper
|
||||
include SideBarRenderer
|
||||
|
||||
def initialize(name = '',key,get_module_app,&block)
|
||||
def initialize(name = '',key,get_module_app, approvable_with_link, authorizable_with_link, &block)
|
||||
@head_label = name
|
||||
@context_links = []
|
||||
@available_for = []
|
||||
|
@ -54,6 +54,8 @@ module OrbitApp
|
|||
@module_app_key = key
|
||||
@get_module_app = get_module_app
|
||||
@sidebar_order = 0
|
||||
@approvable_with_link = approvable_with_link
|
||||
@authorizable_with_link = authorizable_with_link
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
# setup_module_app(module_app_key)
|
||||
finalize!
|
||||
|
@ -107,6 +109,19 @@ module OrbitApp
|
|||
def finalize!
|
||||
set_controllers_scope
|
||||
# set_default_active_app_auth
|
||||
current_priority = @context_links.count
|
||||
if @approvable_with_link
|
||||
context_link 'approval_setting',
|
||||
:link_path => "admin_authorizations_path(get_module_app.key, 'approval')",
|
||||
:priority => current_priority + 1,
|
||||
:available_for => [:manager]
|
||||
end
|
||||
if @authorizable_with_link
|
||||
context_link 'module_authorization',
|
||||
:link_path => "admin_authorizations_path(get_module_app.key)",
|
||||
:priority => current_priority + 2,
|
||||
:available_for => [:manager]
|
||||
end
|
||||
@context_links.each do |t|
|
||||
# t.set_module_app = @module_app
|
||||
t.finalize!
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<% set_default_index do
|
||||
objects @bulletins
|
||||
approvable
|
||||
authorization
|
||||
filterable
|
||||
sortable
|
||||
quick_edit_link type: 'edit',
|
||||
|
|
|
@ -26,6 +26,7 @@ module Announcement
|
|||
data_count 3..10
|
||||
|
||||
authorizable
|
||||
approvable
|
||||
categorizable
|
||||
taggable
|
||||
|
||||
|
@ -84,16 +85,6 @@ module Announcement
|
|||
:priority=>4,
|
||||
:active_for_tag => 'Announcement',
|
||||
:available_for => [:manager]
|
||||
context_link 'approval_setting',
|
||||
:link_path=>"admin_authorizations_path(get_module_app.key, 'approval')" ,
|
||||
:priority=>5,
|
||||
:active_for_action=>{:approvals=>:setting},
|
||||
:active_for_object_auth => 'BulletinCategory',
|
||||
:available_for => [:manager]
|
||||
context_link 'module_authorization',
|
||||
:link_path=>"admin_authorizations_path(get_module_app.key)",
|
||||
:priority=>6,
|
||||
:available_for => [:manager]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Reference in New Issue