faalis 2.1.1 → 2.2.0.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +1 -1
- data/app/assets/javascripts/faalis/dashboard/init.js.coffee +1 -2
- data/app/assets/javascripts/faalis/dashboard/manifest.js +5 -0
- data/app/assets/javascripts/faalis/simple.js +1 -1
- data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -2
- data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +4 -0
- data/app/assets/stylesheets/faalis/dashboard/share.scss +6 -0
- data/app/controllers/faalis/dashboard/groups_controller.rb +0 -1
- data/app/controllers/faalis/dashboard/users_controller.rb +6 -2
- data/app/helpers/faalis/dashboard_helper.rb +8 -9
- data/app/models/faalis/concerns/user/permission.rb +7 -2
- data/app/models/faalis/concerns/user/user_roles.rb +15 -11
- data/app/models/faalis/user_message.rb +1 -0
- data/app/policies/faalis/application_policy.rb +6 -2
- data/app/views/faalis/dashboard/resource/create.js.erb +1 -1
- data/app/views/faalis/dashboard/resource/index.html.slim +2 -1
- data/app/views/faalis/dashboard/resource/update.js.erb +1 -1
- data/app/views/faalis/dashboard/users/_form.html.slim +1 -1
- data/app/views/layouts/faalis/dashboard.html.erb +1 -1
- data/config/locales/devise.fa.yml +7 -0
- data/config/locales/faalis.fa.yml +46 -3
- data/db/migrate/20131013091000_devise_create_faalis_users.rb +4 -1
- data/db/migrate/20131020124701_create_faalis_groups.rb +4 -1
- data/db/migrate/20131021170923_create_faalis_permissions.rb +4 -1
- data/db/migrate/20131123120422_add_permissions_groups_table.rb +11 -3
- data/db/migrate/20140613120923_add_users_groups_table.rb +7 -2
- data/db/migrate/20160310105736_create_faalis_user_messages.rb +13 -4
- data/lib/faalis.rb +12 -5
- data/lib/faalis/concerns/authorizable.rb +3 -1
- data/lib/faalis/configuration.rb +17 -2
- data/lib/faalis/dashboard.rb +4 -5
- data/lib/faalis/dashboard/dsl.rb +0 -1
- data/lib/faalis/dashboard/dsl/base.rb +6 -3
- data/lib/faalis/dashboard/dsl/create.rb +0 -1
- data/lib/faalis/dashboard/dsl/index.rb +2 -0
- data/lib/faalis/dashboard/models.rb +2 -0
- data/lib/faalis/dashboard/models/sidebar.rb +1 -1
- data/lib/faalis/dashboard/sections.rb +2 -0
- data/lib/faalis/dashboard/sections/resource.rb +41 -54
- data/lib/faalis/dashboard/sections/resource_create.rb +17 -3
- data/lib/faalis/dashboard/sections/resources_index.rb +5 -3
- data/lib/faalis/engine.rb +6 -0
- data/lib/faalis/i18n.rb +2 -1
- data/lib/faalis/liquid.rb +7 -0
- data/lib/faalis/liquid/block.rb +14 -0
- data/lib/faalis/liquid/render_tag.rb +50 -0
- data/lib/faalis/liquid/tag.rb +51 -0
- data/lib/faalis/orm.rb +1 -0
- data/lib/faalis/{route.rb → routes.rb} +42 -20
- data/lib/faalis/version.rb +1 -1
- data/test/controllers/faalis/dashboard/resource_test.rb +118 -0
- data/test/dummy/config/boot.rb +1 -1
- metadata +60 -79
- checksums.yaml.gz.sig +0 -4
- data.tar.gz.sig +0 -1
- data/app/models/faalis/permissions/auth.rb +0 -8
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -0
- metadata.gz.sig +0 -0
@@ -1,8 +1,13 @@
|
|
1
1
|
class AddUsersGroupsTable < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :faalis_groups_users do |t|
|
4
|
-
|
5
|
-
|
4
|
+
if Faalis::Engine.use_uuid
|
5
|
+
t.uuid :user_id
|
6
|
+
t.uuid :group_id
|
7
|
+
else
|
8
|
+
t.belongs_to :user
|
9
|
+
t.belongs_to :group
|
10
|
+
end
|
6
11
|
end
|
7
12
|
end
|
8
13
|
end
|
@@ -1,8 +1,17 @@
|
|
1
1
|
class CreateFaalisUserMessages < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
args = {}
|
4
|
+
args[:id] = :uuid if Faalis::Engine.use_uuid
|
5
|
+
|
6
|
+
create_table :faalis_user_messages, **args do |t|
|
7
|
+
if Faalis::Engine.use_uuid
|
8
|
+
t.uuid :sender_id
|
9
|
+
t.uuid :receiver_id
|
10
|
+
else
|
11
|
+
t.integer :sender_id
|
12
|
+
t.integer :receiver_id
|
13
|
+
end
|
14
|
+
|
6
15
|
t.boolean :read_only
|
7
16
|
t.text :content
|
8
17
|
t.text :raw_content
|
@@ -11,6 +20,6 @@ class CreateFaalisUserMessages < ActiveRecord::Migration
|
|
11
20
|
end
|
12
21
|
|
13
22
|
add_index :faalis_user_messages, :sender_id
|
14
|
-
add_index :faalis_user_messages, :
|
23
|
+
add_index :faalis_user_messages, :receiver_id
|
15
24
|
end
|
16
25
|
end
|
data/lib/faalis.rb
CHANGED
@@ -11,17 +11,24 @@ require 'amd'
|
|
11
11
|
|
12
12
|
# Faalis Module
|
13
13
|
module Faalis
|
14
|
-
|
14
|
+
autoload :Helpers, 'faalis/helpers/autoload_helper'
|
15
|
+
autoload :Routes, 'faalis/routes'
|
16
|
+
autoload :RouteHelpers, 'faalis/routes'
|
17
|
+
autoload :Liquid, 'faalis/liquid'
|
18
|
+
# autoload :Engine, 'faalis/engine'
|
19
|
+
autoload :Dashboard, 'faalis/dashboard'
|
20
|
+
autoload :Concerns, 'faalis/concerns'
|
21
|
+
autoload :ORM, 'faalis/orm'
|
15
22
|
end
|
16
23
|
|
17
24
|
require 'faalis/engine'
|
18
|
-
require 'faalis/orm'
|
19
|
-
require 'faalis/concerns'
|
20
|
-
require 'faalis/dashboard'
|
25
|
+
#require 'faalis/orm'
|
26
|
+
#require 'faalis/concerns'
|
27
|
+
#require 'faalis/dashboard'
|
21
28
|
require 'faalis/extension'
|
22
29
|
require 'faalis/omniauth'
|
23
30
|
require 'faalis/i18n'
|
24
|
-
require 'faalis/route'
|
31
|
+
#require 'faalis/route'
|
25
32
|
require 'faalis/action_dispatch'
|
26
33
|
require 'faalis/discovery'
|
27
34
|
require 'faalis/fake_assets'
|
@@ -26,16 +26,19 @@ module Faalis
|
|
26
26
|
strings = []
|
27
27
|
model_name = model.to_s
|
28
28
|
humanize_name = ActiveModel::Name.new(model).human
|
29
|
+
|
29
30
|
if model.respond_to? :model_name
|
30
31
|
model_name = model.model_name
|
31
32
|
humanize_name = model_name.human
|
32
33
|
end
|
34
|
+
|
33
35
|
@@permissions.each do |key, value|
|
34
36
|
strings << {
|
35
37
|
name: "#{key}|#{model_name}",
|
36
38
|
string: t("faalis.permission_string", action: key.to_s, model: humanize_name)
|
37
39
|
}
|
38
40
|
end
|
41
|
+
|
39
42
|
strings
|
40
43
|
end
|
41
44
|
|
@@ -45,7 +48,6 @@ module Faalis
|
|
45
48
|
|
46
49
|
# Define permissions using this method
|
47
50
|
def permissions(*args)
|
48
|
-
|
49
51
|
args.each do |permission|
|
50
52
|
if permission.class == Symbol
|
51
53
|
if not @@permissions.include? permission
|
data/lib/faalis/configuration.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Faalis
|
2
|
+
# This module contains all the configuration of `Faalis::Engine`
|
3
|
+
# which can be setup in `config/initializer/faalis.rb`
|
2
4
|
module Configuration
|
3
5
|
|
4
6
|
@@modules_to_load = {}
|
@@ -32,6 +34,10 @@ module Faalis
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
37
|
+
mattr_accessor :i18n_debug do
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
35
41
|
# Site Title
|
36
42
|
attr_accessor :site_title do
|
37
43
|
'Faalis'
|
@@ -58,6 +64,11 @@ module Faalis
|
|
58
64
|
{}
|
59
65
|
end
|
60
66
|
|
67
|
+
# Whether using UUID with models or not.
|
68
|
+
mattr_accessor :use_uuid do
|
69
|
+
false
|
70
|
+
end
|
71
|
+
|
61
72
|
mattr_accessor :amd_dir do
|
62
73
|
'amd'
|
63
74
|
end
|
@@ -65,11 +76,15 @@ module Faalis
|
|
65
76
|
mattr_accessor :amd do
|
66
77
|
true
|
67
78
|
end
|
68
|
-
|
79
|
+
# This hash map contains all the features as keys and
|
80
|
+
# the required dependencies of each feature in form of
|
81
|
+
# an array as value
|
69
82
|
@@modules_to_load[:amd] = ['amd']
|
70
83
|
|
84
|
+
# Load all the features dependencies based on their configuration
|
85
|
+
# value. For example if `amd` class method returns true all of its
|
86
|
+
# dependencies will be loaded.
|
71
87
|
def load_dependencies_based_on_configuration
|
72
|
-
|
73
88
|
@@modules_to_load.each do |k, v|
|
74
89
|
v.map { |mod| require mod } if send(k)
|
75
90
|
end
|
data/lib/faalis/dashboard.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require_dependency 'faalis/dashboard/dsl'
|
1
|
+
#require_dependency 'faalis/dashboard/dsl'
|
2
2
|
|
3
3
|
module Faalis::Dashboard
|
4
|
-
|
5
|
-
end
|
4
|
+
autoload :DSL, 'faalis/dashboard/dsl'
|
6
5
|
|
7
6
|
module Helpers
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
autoload :Models, 'faalis/dashboard/models'
|
10
|
+
autoload :Sections, 'faalis/dashboard/sections.rb'
|
12
11
|
end
|
data/lib/faalis/dashboard/dsl.rb
CHANGED
@@ -28,7 +28,6 @@ module Faalis::Dashboard
|
|
28
28
|
# override the default view for given views or the result
|
29
29
|
# of the given block, by the one from the application
|
30
30
|
def override_views(*views, &block)
|
31
|
-
views.concat(block.call) if block_given?
|
32
31
|
|
33
32
|
define_method(:_override_views) do
|
34
33
|
result = views || []
|
@@ -34,6 +34,9 @@ module Faalis::Dashboard::DSL
|
|
34
34
|
@fields = resolve_model_reflections.reject do |field|
|
35
35
|
options[:except].include? field.to_sym
|
36
36
|
end
|
37
|
+
elsif options.include? :append
|
38
|
+
|
39
|
+
@fields += options[:append]
|
37
40
|
else
|
38
41
|
|
39
42
|
# Check for valid field names
|
@@ -57,8 +60,8 @@ module Faalis::Dashboard::DSL
|
|
57
60
|
# You can easily change it via the corresponding section dsl.
|
58
61
|
# For example in case of `index` section:
|
59
62
|
#
|
60
|
-
# in_index do
|
61
|
-
# scope do |params|
|
63
|
+
# in_index do |index|
|
64
|
+
# index.scope do |params|
|
62
65
|
# YourModel.all
|
63
66
|
# end
|
64
67
|
#
|
@@ -83,7 +86,7 @@ module Faalis::Dashboard::DSL
|
|
83
86
|
# Define a new action on the `action` place of the current section
|
84
87
|
# **options**: Is a hash which contains the action button properties.
|
85
88
|
#
|
86
|
-
# `
|
89
|
+
# `name`: Label to use with the button.
|
87
90
|
# `href`: The link href to use in the `a` tag
|
88
91
|
# `class`: classes of the button.
|
89
92
|
# `icon_class`: font awesome icon to use in button.
|
@@ -12,6 +12,8 @@ module Faalis::Dashboard::DSL
|
|
12
12
|
@fields = resolve_model_reflections.reject do |field|
|
13
13
|
options[:except].include? field.to_sym
|
14
14
|
end
|
15
|
+
elsif options.include? :append
|
16
|
+
@fields += options[:append]
|
15
17
|
else
|
16
18
|
# set new value for fields
|
17
19
|
@fields = fields_name.map(&:to_s) unless fields_name.empty?
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module Faalis::Dashboard::Sections
|
2
|
+
# This module contains several helpers method which would
|
3
|
+
# be useful for the rest of faalis dashboard operation.
|
2
4
|
module Resource
|
3
5
|
|
4
6
|
extend ActiveSupport::Concern
|
@@ -32,7 +34,7 @@ module Faalis::Dashboard::Sections
|
|
32
34
|
fail NameError, msg
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
37
|
+
def _namespace
|
36
38
|
pieces = controller_path.gsub('dashboard/', '').split('/')
|
37
39
|
return '' if pieces.length == 1
|
38
40
|
|
@@ -41,10 +43,10 @@ module Faalis::Dashboard::Sections
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def _route_engine
|
44
|
-
if
|
46
|
+
if _namespace.empty?
|
45
47
|
Rails.application
|
46
48
|
else
|
47
|
-
engine = "#{
|
49
|
+
engine = "#{_namespace.split('/')[0]}::Engine".classify
|
48
50
|
if Object.const_defined? engine
|
49
51
|
engine.constantize
|
50
52
|
else
|
@@ -82,56 +84,41 @@ module Faalis::Dashboard::Sections
|
|
82
84
|
!attachment_fields.empty?
|
83
85
|
end
|
84
86
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
name = controller_name
|
90
|
-
if name.singularize == name.pluralize
|
91
|
-
"#{scope_}#{name}_index_path"
|
92
|
-
else
|
93
|
-
"#{scope_}#{name}_path"
|
87
|
+
def _index_route
|
88
|
+
if respond_to? :index
|
89
|
+
url_for(controller: params[:controller],
|
90
|
+
action: :index)
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
97
|
-
def
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
def guess_edit_route(scope = 'dashboard')
|
106
|
-
scope_ = "#{scope}_"
|
107
|
-
scope_ = "#{scope_}#{namespace}_" if !namespace.blank? && _engine.nil?
|
108
|
-
|
109
|
-
resource_name = controller_name.singularize.underscore
|
110
|
-
"edit_#{scope_}#{resource_name}_path".gsub('/', '_')
|
94
|
+
def _show_route(id)
|
95
|
+
if respond_to? :show
|
96
|
+
url_for(controller: params[:controller],
|
97
|
+
action: :show,
|
98
|
+
id: id)
|
99
|
+
end
|
111
100
|
end
|
112
101
|
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
102
|
+
def _edit_route(id)
|
103
|
+
if respond_to? :edit
|
104
|
+
url_for(controller: params[:controller],
|
105
|
+
action: :edit,
|
106
|
+
id: id)
|
107
|
+
end
|
119
108
|
end
|
120
109
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
resource_name = controller_name.singularize.underscore
|
126
|
-
"edit_#{scope_}#{resource_name}_path".gsub('/', '_')
|
110
|
+
def _new_route
|
111
|
+
if respond_to? :new
|
112
|
+
url_for(controller: params[:controller], action: :new)
|
113
|
+
end
|
127
114
|
end
|
128
115
|
|
129
116
|
def setup_named_routes
|
130
117
|
@engine = _engine || _route_engine
|
131
|
-
@index_route =
|
132
|
-
@new_route =
|
133
|
-
@show_route =
|
134
|
-
@edit_route =
|
118
|
+
@index_route = method(:_index_route)
|
119
|
+
@new_route = method(:_new_route)
|
120
|
+
@show_route = method(:_show_route)
|
121
|
+
@edit_route = method(:_edit_route)
|
135
122
|
end
|
136
123
|
|
137
124
|
def successful_response(section, msg = nil)
|
@@ -143,12 +130,9 @@ module Faalis::Dashboard::Sections
|
|
143
130
|
f.html
|
144
131
|
else
|
145
132
|
flash[:success] = msg
|
146
|
-
|
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
|
133
|
+
|
150
134
|
f.js { render "faalis/dashboard/resource/#{section}" }
|
151
|
-
f.html { redirect_to
|
135
|
+
f.html { redirect_to _index_route }
|
152
136
|
end
|
153
137
|
end
|
154
138
|
end
|
@@ -163,16 +147,11 @@ module Faalis::Dashboard::Sections
|
|
163
147
|
else
|
164
148
|
flash[:error] = msg
|
165
149
|
|
166
|
-
|
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' }
|
150
|
+
f.js { render 'faalis/dashboard/shared/errors' }
|
172
151
|
if block_given?
|
173
152
|
f.html(&block)
|
174
153
|
else
|
175
|
-
f.html { redirect_to
|
154
|
+
f.html { redirect_to _index_route }
|
176
155
|
end
|
177
156
|
end
|
178
157
|
end
|
@@ -205,6 +184,14 @@ module Faalis::Dashboard::Sections
|
|
205
184
|
end
|
206
185
|
end
|
207
186
|
|
187
|
+
# Using this method user can override the route namespace guessed by
|
188
|
+
# Faalis.
|
189
|
+
def route_namespace(name, &block)
|
190
|
+
define_method(:_namespace) do
|
191
|
+
return block.call if block_given?
|
192
|
+
name
|
193
|
+
end
|
194
|
+
end
|
208
195
|
# Set the engine name of current controller. It's necessary to provide and
|
209
196
|
# engine name if the controller belongs to an engine other than Faalis or
|
210
197
|
# Rails.application.
|
@@ -47,7 +47,7 @@ module Faalis::Dashboard::Sections
|
|
47
47
|
new_params = creation_params
|
48
48
|
new_params.merge(reflections_hash) if reflections_hash
|
49
49
|
|
50
|
-
# Customize update behaviour
|
50
|
+
# Customize update behaviour before updating resource
|
51
51
|
before_update_hook(@resource)
|
52
52
|
|
53
53
|
# TODO: Move this method to a suitable place instead of controller
|
@@ -57,6 +57,8 @@ module Faalis::Dashboard::Sections
|
|
57
57
|
@resource.assign_attributes(**new_params)
|
58
58
|
|
59
59
|
if @resource.save
|
60
|
+
# Customize update behaviour after updating resource
|
61
|
+
after_update_hook(@resource)
|
60
62
|
successful_response(:update)
|
61
63
|
else
|
62
64
|
errorful_resopnse(:update, @resource.errors) do
|
@@ -77,6 +79,7 @@ module Faalis::Dashboard::Sections
|
|
77
79
|
|
78
80
|
# TODO: Handle M2M relations in here
|
79
81
|
if @resource.save
|
82
|
+
after_create_hook(@resource)
|
80
83
|
successful_response(:create)
|
81
84
|
else
|
82
85
|
errorful_resopnse(:create, @resource.errors) do
|
@@ -132,15 +135,26 @@ module Faalis::Dashboard::Sections
|
|
132
135
|
private
|
133
136
|
|
134
137
|
# You can override this method to change the behaviour of `create`
|
135
|
-
# action
|
138
|
+
# action before save resource
|
136
139
|
def before_create_hook(resource)
|
137
140
|
end
|
138
141
|
|
142
|
+
# You can override this method to change the behaviour of `create`
|
143
|
+
# action afer save resource
|
144
|
+
def after_create_hook(resource)
|
145
|
+
end
|
146
|
+
|
139
147
|
# You can override this method to change the behaviour of `update`
|
140
|
-
# action
|
148
|
+
# action before save resource
|
141
149
|
def before_update_hook(resource)
|
142
150
|
end
|
143
151
|
|
152
|
+
|
153
|
+
# You can override this method to change the behaviour of `update`
|
154
|
+
# action after save resource
|
155
|
+
def after_update_hook(resource)
|
156
|
+
end
|
157
|
+
|
144
158
|
# You can override this method to change the behaviour of `new`
|
145
159
|
# action
|
146
160
|
def new_hook(resource)
|