cm-admin 2.1.1 → 2.1.3
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/.yardopts +2 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/app/assets/javascripts/cm_admin/form_validation.js +8 -0
- data/app/assets/stylesheets/cm_admin/base/form.scss +4 -0
- data/app/models/cm_permission.rb +5 -6
- data/app/views/cm_admin/roles/permissions.html.slim +1 -1
- data/lib/cm_admin/version.rb +1 -1
- data/lib/cm_admin/view_helpers/form_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c68983444fcc76457f2f9c67844a6518d39a6e1a9f4656d5e869188d517ae1b7
|
4
|
+
data.tar.gz: 6dda9b94f136c52dba561e65b31db92b4a2b9036f078d2d1aaf66d1c972a49ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb734f37af1c3a6204c6b5e6aa04530410cafd8f1bb208457ae84bbf452a1b2811154acab9a7b330bfad42d7ded483f9c58c7a0f51a5c490ca7ad77a7ce5679
|
7
|
+
data.tar.gz: 3e27a73e792d282d2d8f334716c7a56692ed3f11af67eddcbccfe529f8fc117833d6aee191673b3cf44edc4af5b768d8ce3b03264e4ac366cf5560f6a348b9ed
|
data/.yardopts
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
39
39
|
|
40
40
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
41
41
|
|
42
|
+
Any markdown and ruby file added in `docs/` folder will be auto added in yard docs.
|
43
|
+
|
42
44
|
## Deployment
|
43
45
|
|
44
46
|
To release a new version of the Gem you can use Github Actions.
|
@@ -16,6 +16,7 @@ $(document).on("click", '[data-behaviour="form_submit"]', function (e) {
|
|
16
16
|
submit.push(true);
|
17
17
|
}
|
18
18
|
});
|
19
|
+
|
19
20
|
$("." + form_class + " select.required").each(function () {
|
20
21
|
$(this).removeClass("is-invalid");
|
21
22
|
let selected_value = $(this).val();
|
@@ -49,3 +50,10 @@ $(document).on("click", '[data-behaviour="form_submit"]', function (e) {
|
|
49
50
|
return $('[data-behaviour="form_submit"]').button("loading");
|
50
51
|
}
|
51
52
|
});
|
53
|
+
|
54
|
+
$(document).on("click", '[data-behaviour="discard_form"]', function (e) {
|
55
|
+
e.preventDefault();
|
56
|
+
const form = $(this).closest("form");
|
57
|
+
form[0].reset();
|
58
|
+
window.history.back();
|
59
|
+
});
|
data/app/models/cm_permission.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
class CmPermission < ApplicationRecord
|
2
|
-
|
3
2
|
after_create :create_hidden_permission
|
4
3
|
after_destroy :destroy_hidden_permission
|
5
4
|
|
6
|
-
validates :action_name, presence: true, uniqueness: {scope:
|
5
|
+
validates :action_name, presence: true, uniqueness: { scope: %i[ar_model_name cm_role_id] }
|
7
6
|
|
8
7
|
def create_hidden_permission
|
9
8
|
if action_name == 'new'
|
10
|
-
CmPermission.where(action_name: 'create', ar_model_name
|
9
|
+
CmPermission.where(action_name: 'create', ar_model_name:, cm_role_id:).first_or_create
|
11
10
|
elsif action_name == 'edit'
|
12
|
-
CmPermission.where(action_name: 'update', ar_model_name
|
11
|
+
CmPermission.where(action_name: 'update', ar_model_name:, cm_role_id:).first_or_create
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
def destroy_hidden_permission
|
17
16
|
if action_name == 'new'
|
18
|
-
CmPermission.where(action_name: 'create', ar_model_name
|
17
|
+
CmPermission.where(action_name: 'create', ar_model_name:, cm_role_id:).first&.destroy
|
19
18
|
elsif action_name == 'edit'
|
20
|
-
CmPermission.where(action_name: 'update', ar_model_name
|
19
|
+
CmPermission.where(action_name: 'update', ar_model_name:, cm_role_id:).first&.destroy
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -34,4 +34,4 @@
|
|
34
34
|
= select_tag(:policy_scope_name, options_for_select(model.policy_scopes.map{|policy_hash| [policy_hash[:display_name], policy_hash[:scope_name]]}, permission&.scope_name), {name: "role_permission[#{model.name}][#{action.name}][scope_name]", class: 'select-2', id: "policy-scope-#{model.name}-#{action.name}"})
|
35
35
|
div
|
36
36
|
= f.submit 'Save Changes', class: "btn-cta"
|
37
|
-
= link_to 'Discard', cm_admin.send('cm_role_index_path'), class: "btn
|
37
|
+
= link_to 'Discard', cm_admin.send('cm_role_index_path'), class: "btn-secondary ml-10"
|
data/lib/cm_admin/version.rb
CHANGED
@@ -161,6 +161,7 @@ module CmAdmin
|
|
161
161
|
concat split_form_into_section(resource, form_obj, entities)
|
162
162
|
concat tag.br
|
163
163
|
concat form_obj.submit 'Save', class: 'btn-cta', data: { behaviour: 'form_submit', form_class: "cm_#{form_obj.object.class.name.downcase}_form" }
|
164
|
+
concat button_tag 'Discard', class: 'btn-secondary discard-form', data: { behaviour: 'discard_form' }
|
164
165
|
end
|
165
166
|
end
|
166
167
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2024-09-
|
17
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: caxlsx_rails
|