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