ez-permissions-ui 0.4.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +61 -0
- data/Rakefile +30 -0
- data/app/cells/ez/permissions/application_cell.rb +42 -0
- data/app/cells/ez/permissions/roles/form/show.slim +12 -0
- data/app/cells/ez/permissions/roles/form_cell.rb +19 -0
- data/app/cells/ez/permissions/roles/index/show.slim +30 -0
- data/app/cells/ez/permissions/roles/index_cell.rb +29 -0
- data/app/cells/ez/permissions/roles/permissions/show.slim +55 -0
- data/app/cells/ez/permissions/roles/permissions_cell.rb +68 -0
- data/app/controllers/ez/permissions/application_controller.rb +13 -0
- data/app/controllers/ez/permissions/permissions_controller.rb +30 -0
- data/app/controllers/ez/permissions/roles_controller.rb +66 -0
- data/config/routes.rb +11 -0
- data/lib/ez/permissions/ui.rb +11 -0
- data/lib/ez/permissions/ui/engine.rb +16 -0
- data/lib/ez/permissions/ui/railtie.rb +10 -0
- data/lib/ez/permissions/ui/routes.rb +9 -0
- data/lib/ez/permissions/ui/version.rb +9 -0
- metadata +279 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8357075d7c5c1bd7f9e2606ffced909d351649a2cf15d9132985abcb76815241
|
4
|
+
data.tar.gz: 876876bb23135b402452c35ca8e4700809d574c455aee4f2e3fdf056aeebfe6d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2439f5e36a629b03f220d7b53ce2bca073ae57303bd6dd4c52d06698951813dc5d33c84c0276dd15d2a1fb5c0ba42645b9e730521df9cb623fe1586b103037c
|
7
|
+
data.tar.gz: 54948f661fc95389389099ad662889bc6d9cf6317b77ad9d3d9a90850c454874aa844ccdc938ce49b865c982f73ab9d631456862b673a58ed768518a613fc566
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Volodymyr Sveredyuk
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Ez::Permissions::UI
|
2
|
+
|
3
|
+
### Configuration
|
4
|
+
|
5
|
+
Configuration interface allows you to change default behavior
|
6
|
+
```ruby
|
7
|
+
Ez::Permissions.configure do |config|
|
8
|
+
# Use permissions UI capabilities
|
9
|
+
require 'ez/permissions/ui'
|
10
|
+
|
11
|
+
# Define your base UI controller and routes
|
12
|
+
config.ui_base_controller = 'ApplicationController'
|
13
|
+
config.ui_base_routes = '/permissions'
|
14
|
+
|
15
|
+
# Add custom code to Ez::Permissions::RolesController
|
16
|
+
config.ui_roles_controller_context = proc do
|
17
|
+
before_action :authorize_user!
|
18
|
+
before_action do
|
19
|
+
Ez::Permissions::API.authorize!(current_user, :manage, :permissions)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add custom code to Ez::Permissions::PermissionsController
|
24
|
+
config.ui_permissions_controller_context = proc do
|
25
|
+
before_action :authorize_user!
|
26
|
+
before_action do
|
27
|
+
Ez::Permissions::API.authorize!(current_user, :manage, :permissions)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# By default actions ordered by name as create > read > update > delete
|
32
|
+
config.ui_actions_ordering = %w[list create read update delete]
|
33
|
+
|
34
|
+
# Permissions UI ships with default generated CSS classes.
|
35
|
+
# You always can inspect them in the browser and override
|
36
|
+
config.ui_custom_css_map = {
|
37
|
+
'ez-permissions-roles-container' => 'you custom css classes here'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
### UI routes
|
43
|
+
In your `routes.rb`
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
Rails.application.routes.draw do
|
47
|
+
namespace :admin do
|
48
|
+
ez_permissions_ui_routes
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## TODO
|
54
|
+
- [ ] Cached permissions. If single UI has multiple checks for one user - we can cache it!
|
55
|
+
- [ ] Not all permissions should be manageable through UI, like roles and permissions.
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
Contribution directions go here.
|
59
|
+
|
60
|
+
## License
|
61
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rdoc/task'
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'Ez::Permissions'
|
14
|
+
rdoc.options << '--line-numbers'
|
15
|
+
rdoc.rdoc_files.include('README.md')
|
16
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
20
|
+
load 'rails/tasks/engine.rake'
|
21
|
+
|
22
|
+
load 'rails/tasks/statistics.rake'
|
23
|
+
|
24
|
+
require 'bundler/gem_tasks'
|
25
|
+
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
|
28
|
+
RSpec::Core::RakeTask.new(:spec)
|
29
|
+
|
30
|
+
task default: :spec
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
class ApplicationCell < Cell::ViewModel
|
6
|
+
self.view_paths = ["#{Ez::Permissions::UI::Engine.root}/app/cells"]
|
7
|
+
|
8
|
+
I18N_SCOPE = 'ez_permissions'
|
9
|
+
CSS_SCOPE = 'ez-permissions'
|
10
|
+
BASE_ROUTES = Ez::Permissions.config.ui_base_routes || '/permissions'
|
11
|
+
|
12
|
+
def self.form
|
13
|
+
include ActionView::Helpers::FormHelper
|
14
|
+
include SimpleForm::ActionViewExtensions::FormHelper
|
15
|
+
include ActionView::RecordIdentifier
|
16
|
+
include ActionView::Helpers::FormOptionsHelper
|
17
|
+
end
|
18
|
+
|
19
|
+
def div_for(item, &block)
|
20
|
+
content_tag :div, class: css_for(item), &block
|
21
|
+
end
|
22
|
+
|
23
|
+
def css_for(item)
|
24
|
+
scoped_item = "#{CSS_SCOPE}-#{item}"
|
25
|
+
|
26
|
+
custom_css_map[scoped_item] || scoped_item
|
27
|
+
end
|
28
|
+
|
29
|
+
def custom_css_map
|
30
|
+
@custom_css_map ||= Ez::Permissions.config.ui_custom_css_map || {}
|
31
|
+
end
|
32
|
+
|
33
|
+
def t(args)
|
34
|
+
I18n.t(args, scope: I18N_SCOPE)
|
35
|
+
end
|
36
|
+
|
37
|
+
def path_for(tail = nil)
|
38
|
+
[BASE_ROUTES, tail].join('/')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
= div_for 'container'
|
2
|
+
= div_for 'inner-container'
|
3
|
+
= div_for 'form-container'
|
4
|
+
= div_for 'form-inner-container'
|
5
|
+
= simple_form_for model, as: :role, url: form_url, method: form_method do |f|
|
6
|
+
= div_for 'form-field'
|
7
|
+
= f.input :name, label: t('roles.fields.name'), html: { required: true }
|
8
|
+
|
9
|
+
br/
|
10
|
+
= div_for 'form-submit-button-container'
|
11
|
+
= f.submit t('roles.actions.submit'), class: css_for('form-submit-button')
|
12
|
+
= link_to t('roles.actions.cancel'), path_for
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
module Roles
|
6
|
+
class FormCell < ApplicationCell
|
7
|
+
form
|
8
|
+
|
9
|
+
def form_url
|
10
|
+
model.new_record? ? path_for('roles') : path_for("roles/#{model.id}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def form_method
|
14
|
+
model.new_record? ? :post : :put
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
= div_for 'container'
|
2
|
+
= div_for 'inner-container'
|
3
|
+
|
4
|
+
= div_for 'header-container'
|
5
|
+
= div_for 'header-inner-container'
|
6
|
+
h2 class=(css_for 'header-label') = "#{t('roles.label')} (#{model.size})"
|
7
|
+
|
8
|
+
= div_for 'add-button-container'
|
9
|
+
= link_to t('roles.actions.add'), path_for('roles/new'), class: css_for('add-button')
|
10
|
+
|
11
|
+
table class=(css_for 'table')
|
12
|
+
thead class=(css_for 'table-thead')
|
13
|
+
tr class=(css_for 'table-thead-tr')
|
14
|
+
th class=(css_for 'table-thead-th') = t('roles.fields.name')
|
15
|
+
th class=(css_for 'table-thead-th') colspan="3"
|
16
|
+
tbody class=(css_for 'table-tbody')
|
17
|
+
- model.each do |role|
|
18
|
+
tr class=(css_for 'table-tbody-tr') id=("role-#{role.name}")
|
19
|
+
td class=(css_for 'table-tbody-td-name') style="width: 70%" = role.name.humanize
|
20
|
+
|
21
|
+
- if can_edit?
|
22
|
+
td class=(css_for 'table-tbody-td-actions')
|
23
|
+
= link_to t('roles.actions.edit'), path_for("roles/#{role.id}/edit"), class: css_for('table-edit-link')
|
24
|
+
|
25
|
+
- if can_remove?
|
26
|
+
td class=(css_for 'table-tbody-td-actions')
|
27
|
+
= link_to t('roles.actions.remove'), path_for("roles/#{role.id}"), method: :delete, data: { confirm: t('roles.messages.remove_confirmation') }, class: css_for('table-remove-link')
|
28
|
+
|
29
|
+
td class=(css_for 'table-tbody-td-actions')
|
30
|
+
= role_permissions_link(role)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
module Roles
|
6
|
+
class IndexCell < ApplicationCell
|
7
|
+
def can_edit?
|
8
|
+
available_actions.include?(:edit)
|
9
|
+
end
|
10
|
+
|
11
|
+
def can_remove?
|
12
|
+
available_actions.include?(:remove)
|
13
|
+
end
|
14
|
+
|
15
|
+
def role_permissions_link(role)
|
16
|
+
link_to t('roles.actions.permissions'),
|
17
|
+
path_for("roles/#{role.id}/permissions"),
|
18
|
+
class: css_for('roles-table-permissions-link')
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def available_actions
|
24
|
+
@available_actions ||= Ez::Permissions.config.ui_roles_actions || []
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
= div_for 'container'
|
2
|
+
= div_for 'inner-container'
|
3
|
+
|
4
|
+
= div_for 'header-container'
|
5
|
+
= div_for 'header-inner-container'
|
6
|
+
h2 class=(css_for 'header-label') = model.name.humanize
|
7
|
+
|
8
|
+
= div_for 'permissions-grant-all-container'
|
9
|
+
= check_box_tag "grant_all", "grant_all", all_granted?, onclick: "checkAll(this)", id: 'permission-grant-all'
|
10
|
+
= label_tag "grant_all", t('permissions.actions.grant_all')
|
11
|
+
|
12
|
+
= form_for :permissions, url: form_url do |f|
|
13
|
+
table class=(css_for 'table')
|
14
|
+
thead class=(css_for 'table-thead')
|
15
|
+
tr class=(css_for 'table-thead-tr')
|
16
|
+
th class=(css_for 'table-thead-th') = t('permissions.fields.resource')
|
17
|
+
th class=(css_for 'table-thead-th') = t('permissions.fields.all')
|
18
|
+
- actions_names.each do |action_name|
|
19
|
+
th class=(css_for 'table-thead-th') = action_name.humanize
|
20
|
+
tbody class=(css_for 'table-tbody')
|
21
|
+
- resources_names.each do |resource_name|
|
22
|
+
tr class=(css_for 'table-tbody-tr') id=("resource-#{resource_name}")
|
23
|
+
td class=(css_for 'table-tbody-td-name') style="width: 70%" = resource_name.humanize
|
24
|
+
td class=(css_for 'table-tbody-td-action') id=("permission-#{resource_name}-all")
|
25
|
+
= check_box_tag "all_permissions[]", "all-permission-#{resource_name}", all_granted?(resource_name), class: 'toggle-all-resource-actions', id: "permission-checkbox-#{resource_name}"
|
26
|
+
- actions_names.each do |action_name|
|
27
|
+
td class=(css_for 'table-tbody-td-action') id=("permission-#{resource_name}-#{action_name}")
|
28
|
+
= permission_checkbox(resource_name, action_name)
|
29
|
+
|
30
|
+
|
31
|
+
= f.submit t('permissions.actions.update'), class: css_for('permissions-submit-button')
|
32
|
+
= link_to t('permissions.actions.cancel'), path_for, class: css_for('permissions-cancel-link')
|
33
|
+
|
34
|
+
javascript:
|
35
|
+
// Toggle all checkboxes
|
36
|
+
function checkAll(bx) {
|
37
|
+
var cbs = document.getElementsByTagName('input');
|
38
|
+
for(var i=0; i < cbs.length; i++) {
|
39
|
+
if(cbs[i].type == 'checkbox') {
|
40
|
+
cbs[i].checked = bx.checked;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
// Toggle only row checkboxes
|
46
|
+
var checkboxes = document.querySelectorAll('.toggle-all-resource-actions');
|
47
|
+
[].forEach.call(checkboxes, function(checkbox) {
|
48
|
+
checkbox.onchange = function() {
|
49
|
+
var currentRow = this.parentNode.parentNode;
|
50
|
+
var cbElems = currentRow.querySelectorAll('[type="checkbox"]');
|
51
|
+
[].forEach.call(cbElems, function(cb) {
|
52
|
+
cb.checked = this.checked;
|
53
|
+
}.bind(this))
|
54
|
+
};
|
55
|
+
});
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
module Roles
|
6
|
+
class PermissionsCell < ApplicationCell
|
7
|
+
COMMON_ACTIONS_ORDER = Ez::Permissions.config.ui_actions_ordering || %w[create read update delete].freeze
|
8
|
+
|
9
|
+
form
|
10
|
+
|
11
|
+
def actions_names
|
12
|
+
@actions_names ||= permissions_actions
|
13
|
+
.map(&:action)
|
14
|
+
.uniq
|
15
|
+
.sort_by { |a| (COMMON_ACTIONS_ORDER.index(a).to_s || a) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def resources_names
|
19
|
+
@resources_names ||= permissions_actions.map(&:resource).uniq.sort
|
20
|
+
end
|
21
|
+
|
22
|
+
def permissions_actions
|
23
|
+
@permissions_actions ||= Ez::Permissions::Permission.all.to_a
|
24
|
+
end
|
25
|
+
|
26
|
+
def role_permissions
|
27
|
+
@role_permissions ||= model.permissions.to_a
|
28
|
+
end
|
29
|
+
|
30
|
+
def role_permission_ids
|
31
|
+
@role_permission_ids ||= role_permissions.map(&:id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def permission_id(resource_name, action_name)
|
35
|
+
permissions_actions.find { |p| p.resource == resource_name && p.action == action_name }&.id
|
36
|
+
end
|
37
|
+
|
38
|
+
def granted_permission?(permission_id)
|
39
|
+
role_permission_ids.include?(permission_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def permission_checkbox(resource_name, action_name)
|
43
|
+
permission_id = permission_id(resource_name, action_name)
|
44
|
+
|
45
|
+
return unless permission_id
|
46
|
+
|
47
|
+
check_box_tag 'permissions[]',
|
48
|
+
permission_id,
|
49
|
+
granted_permission?(permission_id),
|
50
|
+
id: "permission-checkbox-#{resource_name}-#{action_name}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def all_granted?(resource_name = nil)
|
54
|
+
if resource_name
|
55
|
+
role_permissions.select { |p| p.resource == resource_name }.size ==
|
56
|
+
permissions_actions.select { |p| p.resource == resource_name }.size
|
57
|
+
else
|
58
|
+
role_permissions.size == permissions_actions.size
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def form_url
|
63
|
+
"#{Ez::Permissions.config.ui_base_routes}/roles/#{model.id}/permissions"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
class ApplicationController < Ez::Permissions.config.ui_base_controller.constantize
|
6
|
+
protect_from_forgery with: :exception
|
7
|
+
|
8
|
+
def view(cell_name, *args)
|
9
|
+
render html: cell("ez/permissions/#{cell_name}", *args), layout: true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
class PermissionsController < Ez::Permissions::ApplicationController
|
6
|
+
if Ez::Permissions.config.ui_permissions_controller_context
|
7
|
+
instance_exec(&Ez::Permissions.config.ui_permissions_controller_context)
|
8
|
+
end
|
9
|
+
|
10
|
+
def index
|
11
|
+
view 'roles/permissions', role, permissions: []
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
role.permission_ids = params.to_unsafe_hash['permissions'] || []
|
16
|
+
|
17
|
+
redirect_to(
|
18
|
+
Ez::Permissions.config.ui_base_routes,
|
19
|
+
notice: t('permissions.messages.updated', scope: ApplicationCell::I18N_SCOPE)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def role
|
26
|
+
@role ||= Ez::Permissions::Role.find(params[:role_id])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Permissions
|
5
|
+
class RolesController < Ez::Permissions::ApplicationController
|
6
|
+
if Ez::Permissions.config.ui_roles_controller_context
|
7
|
+
instance_exec(&Ez::Permissions.config.ui_roles_controller_context)
|
8
|
+
end
|
9
|
+
|
10
|
+
def index
|
11
|
+
view 'roles/index', Ez::Permissions::Role.all
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
view 'roles/form', Ez::Permissions::Role.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@role = Ez::Permissions::Role.new(role_params)
|
20
|
+
|
21
|
+
if @role.save
|
22
|
+
redirect_to(
|
23
|
+
Ez::Permissions.config.ui_base_routes,
|
24
|
+
notice: t('roles.messages.created', scope: ApplicationCell::I18N_SCOPE)
|
25
|
+
)
|
26
|
+
else
|
27
|
+
flash[:alert] = t('roles.messages.invalid', scope: ApplicationCell::I18N_SCOPE)
|
28
|
+
view 'roles/form', @role
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def edit
|
33
|
+
flash[:alert] = t('roles.messages.update_warning', scope: ApplicationCell::I18N_SCOPE)
|
34
|
+
view 'roles/form', role
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
if role.update(role_params)
|
39
|
+
redirect_to(
|
40
|
+
Ez::Permissions.config.ui_base_routes,
|
41
|
+
notice: t('roles.messages.created', scope: ApplicationCell::I18N_SCOPE)
|
42
|
+
)
|
43
|
+
else
|
44
|
+
flash[:alert] = t('roles.messages.invalid', scope: ApplicationCell::I18N_SCOPE)
|
45
|
+
view 'roles/form', role
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy
|
50
|
+
role.destroy
|
51
|
+
flash[:alert] = t('roles.messages.removed', scope: ApplicationCell::I18N_SCOPE)
|
52
|
+
redirect_to Ez::Permissions.config.ui_base_routes
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def role
|
58
|
+
@role ||= Ez::Permissions::Role.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
def role_params
|
62
|
+
params.require(:role).permit(:name)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ez/permissions/ui/routes'
|
4
|
+
|
5
|
+
require 'cells-rails'
|
6
|
+
require 'cells-slim'
|
7
|
+
require 'simple_form'
|
8
|
+
|
9
|
+
module Ez
|
10
|
+
module Permissions
|
11
|
+
module UI
|
12
|
+
class Engine < ::Rails::Engine
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Style/ClassAndModuleChildren:
|
4
|
+
class ActionDispatch::Routing::Mapper
|
5
|
+
def ez_permissions_ui_routes
|
6
|
+
mount Ez::Permissions::UI::Engine, at: '/permissions', as: :ez_permissions
|
7
|
+
end
|
8
|
+
end
|
9
|
+
# rubocop:enable Style/ClassAndModuleChildren:
|
metadata
ADDED
@@ -0,0 +1,279 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ez-permissions-ui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Volodya Sveredyuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ez-permissions
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cells-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cells-slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.6
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.6
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.2'
|
62
|
+
- - "<="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '7.0'
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '5.2'
|
72
|
+
- - "<="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '7.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: simple_form
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 5.0.1
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 5.0.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: bundler
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: capybara
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: faker
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: guard-rspec
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: launchy
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: pry-rails
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: rspec-rails
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: rubocop
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
type: :development
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: simplecov
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
type: :development
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: sqlite3
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - "~>"
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '1.4'
|
222
|
+
type: :development
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - "~>"
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '1.4'
|
229
|
+
description: UI extension for ez-permissions.
|
230
|
+
email:
|
231
|
+
- sveredyuk@gmail.com
|
232
|
+
executables: []
|
233
|
+
extensions: []
|
234
|
+
extra_rdoc_files: []
|
235
|
+
files:
|
236
|
+
- MIT-LICENSE
|
237
|
+
- README.md
|
238
|
+
- Rakefile
|
239
|
+
- app/cells/ez/permissions/application_cell.rb
|
240
|
+
- app/cells/ez/permissions/roles/form/show.slim
|
241
|
+
- app/cells/ez/permissions/roles/form_cell.rb
|
242
|
+
- app/cells/ez/permissions/roles/index/show.slim
|
243
|
+
- app/cells/ez/permissions/roles/index_cell.rb
|
244
|
+
- app/cells/ez/permissions/roles/permissions/show.slim
|
245
|
+
- app/cells/ez/permissions/roles/permissions_cell.rb
|
246
|
+
- app/controllers/ez/permissions/application_controller.rb
|
247
|
+
- app/controllers/ez/permissions/permissions_controller.rb
|
248
|
+
- app/controllers/ez/permissions/roles_controller.rb
|
249
|
+
- config/routes.rb
|
250
|
+
- lib/ez/permissions/ui.rb
|
251
|
+
- lib/ez/permissions/ui/engine.rb
|
252
|
+
- lib/ez/permissions/ui/railtie.rb
|
253
|
+
- lib/ez/permissions/ui/routes.rb
|
254
|
+
- lib/ez/permissions/ui/version.rb
|
255
|
+
homepage: https://github.com/ez-engines/ez-permissions-ui
|
256
|
+
licenses:
|
257
|
+
- MIT
|
258
|
+
metadata:
|
259
|
+
allowed_push_host: https://rubygems.org
|
260
|
+
post_install_message:
|
261
|
+
rdoc_options: []
|
262
|
+
require_paths:
|
263
|
+
- lib
|
264
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
265
|
+
requirements:
|
266
|
+
- - ">="
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
version: '0'
|
269
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
|
+
requirements:
|
271
|
+
- - ">="
|
272
|
+
- !ruby/object:Gem::Version
|
273
|
+
version: '0'
|
274
|
+
requirements: []
|
275
|
+
rubygems_version: 3.0.6
|
276
|
+
signing_key:
|
277
|
+
specification_version: 4
|
278
|
+
summary: UI extension for ez-permissions.
|
279
|
+
test_files: []
|