faalis 2.0.8 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/Rakefile +15 -9
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +4 -3
- data/app/assets/javascripts/faalis/dashboard/init.js.coffee +1 -1
- data/{spec/dummy/public/favicon.ico → app/assets/javascripts/faalis/dashboard/lib/amd.js.coffee.erb} +0 -0
- data/app/assets/stylesheets/faalis/dashboard/share.scss +5 -0
- data/app/controllers/faalis/assets_controller.rb +6 -0
- data/app/controllers/faalis/dashboard/user_messages_controller.rb +27 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/faalis/group.rb +4 -3
- data/app/models/faalis/permission.rb +2 -2
- data/app/models/faalis/user.rb +1 -7
- data/app/models/faalis/user_message.rb +6 -0
- data/app/policies/faalis/user_message_policy.rb +9 -0
- data/app/policies/faalis/user_policy.rb +1 -1
- data/app/views/faalis/dashboard/resource/edit.html.slim +1 -1
- data/app/views/faalis/dashboard/resource/show.html.slim +1 -2
- data/app/views/faalis/dashboard/shared/_header.html.erb +2 -2
- data/app/views/faalis/dashboard/user_messages/_form.html.slim +0 -0
- data/app/views/faalis/dashboard/user_messages/create.js.erb +0 -0
- data/app/views/faalis/dashboard/user_messages/destroy.js.erb +0 -0
- data/app/views/faalis/dashboard/user_messages/new.html.slim +72 -0
- data/app/views/layouts/faalis/dashboard.html.erb +2 -1
- data/config/locales/faalis.en.yml +2 -1
- data/config/routes.rb +6 -21
- data/db/migrate/20160310105736_create_faalis_user_messages.rb +16 -0
- data/lib/faalis.rb +1 -1
- data/lib/faalis/configuration.rb +79 -52
- data/lib/faalis/dashboard/dsl.rb +1 -0
- data/lib/faalis/dashboard/models/sidebar.rb +42 -16
- data/lib/faalis/dashboard/sections/resource.rb +152 -130
- data/lib/faalis/dashboard/sections/resource_create.rb +1 -3
- data/lib/faalis/engine.rb +7 -5
- data/lib/faalis/orm.rb +5 -5
- data/lib/faalis/version.rb +1 -1
- data/{spec → test}/dummy/README.rdoc +0 -0
- data/{spec → test}/dummy/Rakefile +0 -0
- data/{spec → test}/dummy/app/assets/javascripts/application.js +0 -0
- data/{spec → test}/dummy/app/assets/javascripts/dashboard/application.js +0 -0
- data/{spec → test}/dummy/app/assets/stylesheets/application.css +0 -0
- data/{spec → test}/dummy/app/assets/stylesheets/dashboard/ltr/application.css +0 -0
- data/{spec → test}/dummy/app/assets/stylesheets/dashboard/rtl/application.css +0 -0
- data/{spec → test}/dummy/app/assets/stylesheets/ltr/application.css +0 -0
- data/{spec → test}/dummy/app/assets/stylesheets/rtl/application.css +0 -0
- data/{spec → test}/dummy/app/controllers/api_controller.rb +0 -0
- data/{spec → test}/dummy/app/controllers/application_controller.rb +0 -0
- data/{spec → test}/dummy/app/controllers/dashboard/application_controller.rb +0 -0
- data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
- data/{spec → test}/dummy/app/policies/application_policy.rb +0 -0
- data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{spec → test}/dummy/bin/bundle +0 -0
- data/{spec → test}/dummy/bin/rails +0 -0
- data/{spec → test}/dummy/bin/rake +0 -0
- data/{spec → test}/dummy/config.ru +0 -0
- data/{spec → test}/dummy/config/application.rb +0 -0
- data/{spec → test}/dummy/config/boot.rb +0 -0
- data/{spec → test}/dummy/config/database.yml +0 -0
- data/{spec → test}/dummy/config/environment.rb +0 -0
- data/{spec → test}/dummy/config/environments/development.rb +0 -0
- data/{spec → test}/dummy/config/environments/production.rb +0 -0
- data/{spec → test}/dummy/config/environments/test.rb +2 -0
- data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{spec → test}/dummy/config/initializers/devise.rb +0 -0
- data/{spec → test}/dummy/config/initializers/faalis.rb +0 -0
- data/{spec → test}/dummy/config/initializers/faalis_assets.rb +0 -0
- data/{spec → test}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{spec → test}/dummy/config/initializers/formstatic.rb +0 -0
- data/{spec → test}/dummy/config/initializers/formtastic.rb +0 -0
- data/{spec → test}/dummy/config/initializers/inflections.rb +0 -0
- data/{spec → test}/dummy/config/initializers/kaminari_config.rb +0 -0
- data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
- data/{spec → test}/dummy/config/initializers/secret_token.rb +0 -0
- data/{spec → test}/dummy/config/initializers/session_store.rb +0 -0
- data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{spec → test}/dummy/config/locales/en.yml +0 -0
- data/{spec → test}/dummy/config/routes.rb +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/{spec → test}/dummy/lib/templates/slim/scaffold/_form.html.slim +0 -0
- data/test/dummy/log/test.log +0 -0
- data/{spec → test}/dummy/public/404.html +0 -0
- data/{spec → test}/dummy/public/422.html +0 -0
- data/{spec → test}/dummy/public/500.html +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fabricators/faalis/groups.rb +27 -0
- data/test/fabricators/faalis/permissions.rb +14 -0
- data/test/fabricators/faalis/users.rb +17 -0
- data/test/generators/install_generator_test.rb +84 -0
- data/test/integration/faalis/authentication_test.rb +36 -0
- data/test/integration/faalis/dashboard_test.rb +64 -0
- data/test/test_helper.rb +72 -0
- metadata +291 -150
- metadata.gz.sig +1 -0
- data/app/controllers/faalis/api/v1/conversations_controller.rb +0 -120
- data/app/controllers/faalis/api/v1/groups_controller.rb +0 -71
- data/app/controllers/faalis/api/v1/logs_controller.rb +0 -12
- data/app/controllers/faalis/api/v1/permissions_controller.rb +0 -61
- data/app/controllers/faalis/api/v1/profiles_controller.rb +0 -42
- data/app/controllers/faalis/api/v1/users_controller.rb +0 -75
- data/lib/faalis_application.rb +0 -446
- data/lib/faalis_plugin.rb +0 -477
- data/spec/factories/faalis/groups.rb +0 -31
- data/spec/factories/faalis/permissions.rb +0 -16
- data/spec/factories/faalis/users.rb +0 -23
- data/spec/features/dashboard_spec.rb +0 -36
- data/spec/features/record_not_found_spec.rb +0 -24
- data/spec/features/sign_in_spec.rb +0 -37
- data/spec/generators/install_spec.rb +0 -58
- data/spec/models/faalis/group_spec.rb +0 -32
- data/spec/models/faalis/permission_spec.rb +0 -15
- data/spec/models/faalis/user_spec.rb +0 -100
- data/spec/policies/faalis/admin_only_policy_spec.rb +0 -39
- data/spec/policies/faalis/application_policy_spec.rb +0 -49
- data/spec/spec_helper.rb +0 -89
- data/spec/support/factory_girl.rb +0 -3
data/lib/faalis/configuration.rb
CHANGED
@@ -1,56 +1,83 @@
|
|
1
|
-
module Faalis
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
@@logger = Logger.new(STDOUT)
|
6
|
-
|
7
|
-
# Dashboard url prefix
|
8
|
-
mattr_accessor :dashboard_namespace
|
9
|
-
@@dashboard_namespace = :dashboard
|
10
|
-
|
11
|
-
# ==> ORM configuration
|
12
|
-
# Load and configure the ORM. Supports :active_record (default) and
|
13
|
-
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
14
|
-
# available as additional gems.
|
15
|
-
# ORM name to use. either 'active_record' or 'mongoid'
|
16
|
-
mattr_accessor :orm
|
17
|
-
|
18
|
-
def orm=(orm_name)
|
19
|
-
@@orm = orm_name
|
20
|
-
require "devise/orm/#{orm_name}"
|
21
|
-
end
|
1
|
+
module Faalis
|
2
|
+
module Configuration
|
3
|
+
|
4
|
+
@@modules_to_load = {}
|
22
5
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
# Configure logger
|
7
|
+
mattr_accessor :logger do
|
8
|
+
Logger.new(STDOUT)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Dashboard url prefix
|
12
|
+
mattr_accessor :dashboard_namespace do
|
13
|
+
:dashboard
|
14
|
+
end
|
15
|
+
|
16
|
+
# ==> ORM configuration
|
17
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
18
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
19
|
+
# available as additional gems.
|
20
|
+
# ORM name to use. either 'active_record' or 'mongoid'
|
21
|
+
mattr_accessor :orm
|
22
|
+
|
23
|
+
def orm=(orm_name)
|
24
|
+
@@orm = orm_name
|
25
|
+
require "devise/orm/#{orm_name}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# We have to move this method somewhere else
|
29
|
+
def collect_i18n_missing_keys=(value)
|
30
|
+
if value
|
31
|
+
::I18n.exception_handler = Faalis::I18n::MissingKeyHandler.new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Site Title
|
36
|
+
attr_accessor :site_title do
|
37
|
+
'Faalis'
|
38
|
+
end
|
39
|
+
|
40
|
+
mattr_accessor :slug
|
41
|
+
|
42
|
+
# Dashboard default javascript manifest
|
43
|
+
mattr_accessor :dashboard_js_manifest do
|
44
|
+
'dashboard/application.js'
|
27
45
|
end
|
28
|
-
end
|
29
46
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
# Devise options
|
48
|
+
# Include default devise modules. Others available are:
|
49
|
+
# :token_authenticatable, :confirmable,
|
50
|
+
# :lockable, :timeoutable and :omniauthable
|
51
|
+
mattr_accessor :devise_options do
|
52
|
+
[:database_authenticatable, :registerable,
|
53
|
+
:recoverable, :rememberable, :trackable,
|
54
|
+
:lockable, :timeoutable, :validatable]
|
55
|
+
end
|
56
|
+
|
57
|
+
mattr_accessor :devise_for do
|
58
|
+
{}
|
59
|
+
end
|
60
|
+
|
61
|
+
mattr_accessor :amd_dir do
|
62
|
+
'amd'
|
63
|
+
end
|
64
|
+
|
65
|
+
mattr_accessor :amd do
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
@@modules_to_load[:amd] = ['amd']
|
70
|
+
|
71
|
+
def load_dependencies_based_on_configuration
|
72
|
+
|
73
|
+
@@modules_to_load.each do |k, v|
|
74
|
+
v.map { |mod| require mod } if send(k)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def enabled?(configuration)
|
79
|
+
puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<", configuration, @@modules_to_load.include?(configuration)
|
80
|
+
@@modules_to_load.include? configuration
|
81
|
+
end
|
82
|
+
end
|
56
83
|
end
|
data/lib/faalis/dashboard/dsl.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Faalis::Dashboard::Models
|
2
2
|
class Item
|
3
3
|
|
4
|
-
attr_reader :title, :url, :icon, :model
|
4
|
+
attr_reader :title, :url, :icon, :model, :members_only
|
5
5
|
def initialize(title, options)
|
6
6
|
@title = title
|
7
7
|
@model = nil
|
@@ -28,11 +28,11 @@ module Faalis::Dashboard::Models
|
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
31
|
+
def extract_options(options)
|
32
|
+
options.each do |key, value|
|
33
|
+
instance_variable_set("@#{key}", value)
|
35
34
|
end
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
class Menu < Item
|
@@ -45,6 +45,15 @@ module Faalis::Dashboard::Models
|
|
45
45
|
@children << child
|
46
46
|
end
|
47
47
|
|
48
|
+
def initialize(title, options)
|
49
|
+
children = options.delete :children
|
50
|
+
if children
|
51
|
+
@children = children.map do |child|
|
52
|
+
Item.new(child.delete(:title), child)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
super
|
56
|
+
end
|
48
57
|
end
|
49
58
|
|
50
59
|
class RootMenu < Array
|
@@ -91,23 +100,40 @@ module Faalis::Dashboard::Models
|
|
91
100
|
|
92
101
|
def faalis_entries
|
93
102
|
menu(t('faalis.dashboard.user_management'),
|
94
|
-
|
95
|
-
|
103
|
+
icon: 'fa fa-users',
|
104
|
+
model: 'Faalis::User') do
|
96
105
|
item(I18n.t('faalis.dashboard.users'),
|
97
|
-
|
98
|
-
|
106
|
+
model: 'Faalis::User',
|
107
|
+
url: Faalis::Engine.routes.url_helpers.dashboard_auth_users_path)
|
99
108
|
|
100
109
|
item(I18n.t('faalis.dashboard.groups'),
|
101
|
-
|
102
|
-
|
110
|
+
model: 'Faalis::Group',
|
111
|
+
url: Faalis::Engine.routes.url_helpers.dashboard_auth_groups_path)
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
menu(t('faalis.dashboard.user_messages'),
|
116
|
+
icon: 'fa fa-envelope-o',
|
117
|
+
model: 'Faalis::UserMessage') do
|
118
|
+
|
119
|
+
item(I18n.t('faalis.dashboard.user_messages.inbox'),
|
120
|
+
model: 'Faalis::UserMessage',
|
121
|
+
url: Faalis::Engine.routes.url_helpers.dashboard_user_messages_path)
|
122
|
+
item(I18n.t('faalis.dashboard.user_messages.sent'),
|
123
|
+
model: 'Faalis::UserMessage',
|
124
|
+
url: Faalis::Engine.routes.url_helpers.dashboard_user_messages_path)
|
125
|
+
item(I18n.t('faalis.dashboard.user_messages.draft'),
|
126
|
+
model: 'Faalis::UserMessage',
|
127
|
+
url: Faalis::Engine.routes.url_helpers.dashboard_user_messages_path)
|
128
|
+
|
103
129
|
end
|
104
130
|
end
|
105
131
|
|
106
132
|
private
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
133
|
+
def extract_options(options)
|
134
|
+
@icon = options.delete(:icon)
|
135
|
+
@id = options.delete(:id)
|
136
|
+
@class = options.delete(:class)
|
137
|
+
end
|
112
138
|
end
|
113
139
|
end
|
@@ -13,176 +13,175 @@ module Faalis::Dashboard::Sections
|
|
13
13
|
|
14
14
|
protected
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def _resources
|
17
|
+
instance_variable_get("@{plural_name")
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
def plural_name
|
21
|
+
controller_name.underscore
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def model_name
|
25
|
+
"::#{controller_path.gsub('dashboard/', '').classify}"
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
28
|
+
def model
|
29
|
+
model_name.constantize
|
30
|
+
rescue
|
31
|
+
msg = "Can't find model '#{model_name}'. Please override 'model' method in your dashboard controller."
|
32
|
+
fail NameError, msg
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def namespace
|
36
|
+
pieces = controller_path.gsub('dashboard/', '').split('/')
|
37
|
+
return '' if pieces.length == 1
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
pieces.pop
|
40
|
+
pieces.join('/')
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
def _route_engine
|
44
|
+
if namespace.empty?
|
45
|
+
Rails.application
|
46
|
+
else
|
47
|
+
engine = "#{namespace.split('/')[0]}::Engine".classify
|
48
|
+
if Object.const_defined? engine
|
49
|
+
engine.constantize
|
47
50
|
else
|
48
|
-
|
49
|
-
|
50
|
-
engine.constantize
|
51
|
-
else
|
52
|
-
logger.info 'You are using locale modules please define route_engine in your controller'
|
53
|
-
Rails.application
|
54
|
-
end
|
51
|
+
logger.info 'You are using locale modules please define route_engine in your controller'
|
52
|
+
Rails.application
|
55
53
|
end
|
56
54
|
end
|
55
|
+
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
# Return the array of action buttons in given `property_object`.
|
58
|
+
# `property_object` is an instance of once of DSL classes.
|
59
|
+
def action_buttons(property_object)
|
60
|
+
@_action_buttons = property_object.action_buttons || []
|
61
|
+
end
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
def _engine
|
64
|
+
nil
|
65
|
+
end
|
67
66
|
|
68
67
|
private
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
def attachment_fields
|
75
|
-
if model.respond_to? :attachment_definitions
|
76
|
-
return model.attachment_definitions.keys
|
77
|
-
end
|
69
|
+
def _route_name
|
70
|
+
nil
|
71
|
+
end
|
78
72
|
|
79
|
-
|
73
|
+
def attachment_fields
|
74
|
+
if model.respond_to? :attachment_definitions
|
75
|
+
return model.attachment_definitions.keys
|
80
76
|
end
|
81
77
|
|
82
|
-
|
83
|
-
|
84
|
-
end
|
78
|
+
[]
|
79
|
+
end
|
85
80
|
|
86
|
-
|
87
|
-
|
88
|
-
|
81
|
+
def has_attachment?
|
82
|
+
!attachment_fields.empty?
|
83
|
+
end
|
89
84
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
85
|
+
def guess_index_route(scope = 'dashboard')
|
86
|
+
scope_ = "#{scope}_"
|
87
|
+
scope_ = "#{scope_}#{namespace}_" if !namespace.blank? && _engine.nil?
|
88
|
+
|
89
|
+
name = controller_name
|
90
|
+
if name.singularize == name.pluralize
|
91
|
+
"#{scope_}#{name}_index_path"
|
92
|
+
else
|
93
|
+
"#{scope_}#{name}_path"
|
96
94
|
end
|
95
|
+
end
|
97
96
|
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
def guess_show_route(scope = 'dashboard')
|
98
|
+
scope_ = "#{scope}_"
|
99
|
+
scope_ = "#{scope_}#{namespace}_" if !namespace.blank? && _engine.nil?
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
resource_name = controller_name.singularize.underscore
|
102
|
+
"#{scope_}#{resource_name}_path".gsub('/', '_')
|
103
|
+
end
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
def guess_edit_route(scope = 'dashboard')
|
106
|
+
scope_ = "#{scope}_"
|
107
|
+
scope_ = "#{scope_}#{namespace}_" if !namespace.blank? && _engine.nil?
|
109
108
|
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
resource_name = controller_name.singularize.underscore
|
110
|
+
"edit_#{scope_}#{resource_name}_path".gsub('/', '_')
|
111
|
+
end
|
113
112
|
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
def guess_new_route(scope = 'dashboard')
|
114
|
+
scope_ = "#{scope}_"
|
115
|
+
scope_ = "#{scope_}#{namespace}_" if !namespace.blank? && _engine.nil?
|
117
116
|
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
resource_name = controller_name.singularize.underscore
|
118
|
+
"new_#{scope_}#{resource_name}_path".gsub('/', '_')
|
119
|
+
end
|
121
120
|
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
def guess_edit_route(scope = 'dashboard')
|
122
|
+
scope_ = "#{scope}_"
|
123
|
+
scope_ = "#{scope_}#{namespace}_" if !namespace.blank? && _engine.nil?
|
125
124
|
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
resource_name = controller_name.singularize.underscore
|
126
|
+
"edit_#{scope_}#{resource_name}_path".gsub('/', '_')
|
127
|
+
end
|
129
128
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
def setup_named_routes
|
130
|
+
@engine = _engine || _route_engine
|
131
|
+
@index_route = guess_index_route
|
132
|
+
@new_route = guess_new_route
|
133
|
+
@show_route = guess_show_route
|
134
|
+
@edit_route = guess_edit_route
|
135
|
+
end
|
137
136
|
|
138
|
-
|
139
|
-
|
137
|
+
def successful_response(section, msg = nil)
|
138
|
+
@_msg = msg
|
140
139
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
140
|
+
respond_to do |f|
|
141
|
+
if _override_views.include? section.to_sym
|
142
|
+
f.js
|
143
|
+
f.html
|
144
|
+
else
|
145
|
+
flash[:success] = msg
|
146
|
+
# Engine to fetch the route from
|
147
|
+
engine = _engine || Rails.application
|
148
|
+
path = engine.routes.url_helpers.send(@index_route)
|
149
|
+
# TODO: We really need to put setup routed on top of this method
|
150
|
+
f.js { render "faalis/dashboard/resource/#{section}" }
|
151
|
+
f.html { redirect_to path }
|
154
152
|
end
|
155
153
|
end
|
154
|
+
end
|
156
155
|
|
157
|
-
|
158
|
-
|
156
|
+
def errorful_resopnse(section, msg = nil, &block)
|
157
|
+
@_msg = msg
|
158
|
+
|
159
|
+
respond_to do |f|
|
160
|
+
if _override_views.include? section.to_sym
|
161
|
+
f.js { render :errors }
|
162
|
+
f.html { render :errors }
|
163
|
+
else
|
164
|
+
flash[:error] = msg
|
159
165
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
166
|
+
# Engine to fetch the route from
|
167
|
+
engine = _engine || Rails.application
|
168
|
+
path = engine.routes.url_helpers.send(@index_route)
|
169
|
+
# TODO: We really need to put setup routed on top of this method
|
170
|
+
|
171
|
+
f.js { render 'faalis/shared/errors' }
|
172
|
+
if block_given?
|
173
|
+
f.html(&block)
|
164
174
|
else
|
165
|
-
|
166
|
-
|
167
|
-
# Engine to fetch the route from
|
168
|
-
engine = _engine || Rails.application
|
169
|
-
path = engine.routes.url_helpers.send(@index_route)
|
170
|
-
# TODO: We really need to put setup routed on top of this method
|
171
|
-
|
172
|
-
f.js { render 'faalis/shared/errors' }
|
173
|
-
if block_given?
|
174
|
-
f.html(&block)
|
175
|
-
else
|
176
|
-
f.html { redirect_to path }
|
177
|
-
end
|
175
|
+
f.html { redirect_to path }
|
178
176
|
end
|
179
177
|
end
|
180
178
|
end
|
179
|
+
end
|
181
180
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
181
|
+
# TODO: Move this method to a suitable place
|
182
|
+
def symbolify_keys(hash)
|
183
|
+
hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
184
|
+
end
|
186
185
|
|
187
186
|
# The actual DSL for resource ages
|
188
187
|
module ClassMethods
|
@@ -214,6 +213,29 @@ module Faalis::Dashboard::Sections
|
|
214
213
|
name.constantize
|
215
214
|
end
|
216
215
|
end
|
216
|
+
|
217
|
+
# Specify the model name of controller. This method overrides the
|
218
|
+
# `model_class` **class method** and `model_name` instance method.
|
219
|
+
def model_name(name)
|
220
|
+
define_singleton_method :model_class do
|
221
|
+
name.constantize
|
222
|
+
end
|
223
|
+
|
224
|
+
define_method :model_name do
|
225
|
+
name
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
# Returns the actual model class by looking at `controller_name` and
|
230
|
+
# and `controller_path`. If user uses the `model_name` **class method**
|
231
|
+
# (the `model_name` DSL) then this method will override by the
|
232
|
+
# `model_name` defination of `model_class`
|
233
|
+
def model_class
|
234
|
+
name = controller_name
|
235
|
+
path = controller_path.gsub(name, '').gsub(/dashboard\//, '')
|
236
|
+
|
237
|
+
"#{path}#{name}".classify.constantize
|
238
|
+
end
|
217
239
|
end
|
218
240
|
|
219
241
|
end
|