cm-admin 0.6.5 → 0.6.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07c642182c72b7087759f3fbd91c0659a35a18215750100364bbdd9ebafa30c5
4
- data.tar.gz: 7ee59e35a1aa9b219a7648cd9d6c90d716a0aadec1119e4fe8bee2cc367997aa
3
+ metadata.gz: 0644c45e1ae1e807b94e66341d607778f8ca9fbe456a1d741d34db0cf5489550
4
+ data.tar.gz: 3cb2975b1c28a7cf6e150c16bb4e235750e02fb2ce39df110a4b2bb0b17f6a7c
5
5
  SHA512:
6
- metadata.gz: 54be244142003c74f63b7e8ef269749628cd96722d86f604e7687d171f25a98f1e07646e14a6369e10e7023fe12aaf8ffc56f9bd2115408fb891dccfe404357f
7
- data.tar.gz: e937f8ed679eae29efabb5fdaf76f85a6ffe949476c36d6edf8cdd101e0ef603f7c2e22e253df56d5ddfdd5fc1f6e120c8748988886355a82ba27380cb9b982f
6
+ metadata.gz: 412c8867112a3241b3e71b9049473f437bcc99950cf9c286495d5bd85b25459446a3465d150703cf4056c49daadfa1dd556eb0172e873cab2d665090c9d9c66c
7
+ data.tar.gz: ec362ed640f95dd335b653d6040c904d40b53fb941eeb7f0eeefe94bf3d38910fdbdf5a00fb68b5b303ab15b578b680d0ed79cd764748813ef70b3556d138666
@@ -1,4 +1,4 @@
1
- $(document).ready(function(e) {
1
+ $(document).on('turbolinks:load', function () {
2
2
  $('.select-2').select2();
3
3
  flatpickr("[data-behaviour='date-only']", {})
4
4
  flatpickr("[data-behaviour='date-time']", {
@@ -7,10 +7,13 @@ $(document).ready(function(e) {
7
7
  flatpickr("[data-behaviour='filter'][data-filter-type='date']", {
8
8
  mode: 'range'
9
9
  })
10
- Sortable.create($('.columns-list')[0],{
11
- handle: '.dragger',
12
- animation: 150
13
- });
10
+ var el = document.getElementsByClassName('columns-list')
11
+ if(el[0]) {
12
+ Sortable.create(el[0],{
13
+ handle: '.dragger',
14
+ animation: 150
15
+ });
16
+ }
14
17
  });
15
18
 
16
19
  $(document).on("keypress keyup blur", "[data-behaviour='decimal-only'], [data-behaviour='filter'][data-filter-type='range']", function (e) {
@@ -4,9 +4,12 @@
4
4
  == render 'cm_admin/main/top_navbar'
5
5
  == render 'cm_admin/main/tabs'
6
6
  .show-page__inner.scrollable
7
- - @model.available_fields[:show].each do |section|
8
- .info-section
9
- p.section-heading = section.section_name
10
- .paper
11
- - section.available_section_fields.each do |field|
12
- = show_field(@ar_object, field)
7
+ - if @action.partial
8
+ == render @action.partial
9
+ - else
10
+ - @model.available_fields[:show].each do |section|
11
+ .info-section
12
+ p.section-heading = section.section_name
13
+ .paper
14
+ - section.available_section_fields.each do |field|
15
+ = show_field(@ar_object, field)
@@ -161,7 +161,7 @@ module CmAdmin
161
161
  redirect_url = @model.current_action.redirection_url || @action.redirection_url || request.referrer || "/cm_admin/#{@model.ar_model.table_name}/#{@ar_object.id}"
162
162
  format.html { redirect_to redirect_url, notice: "#{@action.name.titleize} is successful" }
163
163
  else
164
- error_messages = @ar_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
164
+ error_messages = ar_object.errors.full_messages.map{|error_message| "<li>#{error_message}</li>"}.join
165
165
  format.html { redirect_to request.referrer, alert: "<b>#{@action.name.titleize} is unsuccessful</b><br /><ul>#{error_messages}</ul>" }
166
166
  end
167
167
  end
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = "0.6.5"
2
+ VERSION = "0.6.6"
3
3
  end
@@ -6,7 +6,7 @@ module CmAdmin
6
6
  source_root File.expand_path('templates', __dir__)
7
7
 
8
8
  def copy_initializer
9
- copy_file 'cm_admin_initializer.rb', 'config/initializers/cm_admin.rb'
9
+ copy_file 'cm_admin_initializer.rb', 'config/initializers/zcm_admin.rb'
10
10
  copy_file 'custom.js', 'app/assets/javascripts/cm_admin/custom.js'
11
11
  copy_file 'custom.css', 'app/assets/stylesheets/cm_admin/custom.css'
12
12
  copy_file 'application_policy.rb', 'app/policies/application_policy.rb'
@@ -6,6 +6,8 @@ module CmAdmin
6
6
  source_root File.expand_path('templates', __dir__)
7
7
 
8
8
  def copy_policy_files
9
+ cm_model = CmAdmin::Model.find_by({name: file_name})
10
+ raise "cm_admin is not defined inside #{file_name} model" unless cm_model.present?
9
11
  template "policy.rb", "app/policies/cm_admin/#{file_name}_policy.rb"
10
12
  end
11
13
  end
@@ -1,4 +1,4 @@
1
- CmAdmin.setup do |config|
1
+ CmAdmin.configure do |config|
2
2
  # Sets the default layout to be used for admin
3
3
  config.layout = 'admin'
4
4
  end
@@ -1,5 +1,5 @@
1
1
  class CmAdmin::<%= class_name %>Policy < ApplicationPolicy
2
- <%- available_action_names = (CmAdmin::Model.find_by({name: class_name}).available_actions.map{|action| action.name}.uniq - ['custom_action', 'new', 'edit']) %>
2
+ <%- available_action_names = (cm_model.available_actions.map{|action| action.name}.uniq - ['custom_action', 'new', 'edit']) %>
3
3
  <%- available_action_names.each do |action_name| %>
4
4
  def <%= action_name %>?
5
5
  <%= CmAdmin.authorized_roles.map {|role| "@user.#{role}" }.join(' && ') %>
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: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - sajinmp
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-04-13 00:00:00.000000000 Z
13
+ date: 2022-05-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pagy