cm-admin 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38f55f5eb7db0ce9a1ef95f111085f1aa36132e6f729fc18e9d81f09a3896b68
4
- data.tar.gz: 569e799bacc88c9bd811fbd55e0c8ee313c0af32874aa63a64786f4dd477923d
3
+ metadata.gz: 810496f7dd375b4849ce820652272c6d36dec1767807beab966e4abc1a00a922
4
+ data.tar.gz: 522f04bc7abeddf95dceebfe980c3b7d955b3d3907de9060af5923803622ed59
5
5
  SHA512:
6
- metadata.gz: 4802b0d59a4d4eed99d9ced6d3cbefb96af6cb4c610e2542e5fe5ca9035bcb432935cb7f4db61f0775d978fd0b83c8ed21de6f939c071498f26b888d25fe2fe5
7
- data.tar.gz: bdcf0cda0c49c059ed6fc87abc960c04e59b611d079b5ce3a9aaccbebaa0feaba711ecd18546eec9a466129c39537056a28cbc98b4712ff4d5ba2bd45e0fd150
6
+ metadata.gz: fc0a6ebd3f81ee0c8df337d630c71cff47d49bb7e422e1d39f9f5f1663c21e7714bd740cf8b1a37d37cbbc3827d18ccc58822031794a228696043633886466ec
7
+ data.tar.gz: 6a13e1994ea27658ac281f88970b1d5b471ee52982be02af9e8ce55dd1b9f6706085543a3f0cbddced246371254b8143243ed6e2756e413d6302fde891718c9d
data/Gemfile.lock CHANGED
@@ -59,7 +59,7 @@ GEM
59
59
  pundit (2.2.0)
60
60
  activesupport (>= 3.0.0)
61
61
  racc (1.6.0)
62
- rack (2.2.3)
62
+ rack (2.2.3.1)
63
63
  rack-proxy (0.7.2)
64
64
  rack
65
65
  rack-test (1.1.0)
@@ -34,8 +34,9 @@
34
34
  = render partial: column.drawer_partial, locals: { ar_object: ar_object}
35
35
 
36
36
  - edit_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('edit')}
37
+ - destroy_action = @model.available_actions.select{|act| act if act.action_type.eql?(:default) && act.name.eql?('destroy')}
37
38
  - custom_actions = @model.available_actions.select{|act| act if act.route_type == 'member' && [:button, :modal].include?(act.display_type)}
38
- - if custom_actions.any? || edit_action.any?
39
+ - if custom_actions.any? || edit_action.any? || destroy_action.any?
39
40
  td.row-action-cell
40
41
  .row-action-tool
41
42
  button.secondary-btn.tool-btn type="button"
@@ -50,6 +51,12 @@
50
51
  span
51
52
  i.fa.fa-edit
52
53
  | Edit
54
+ - if destroy_action.any? && policy([:cm_admin, @model.name.classify.constantize]).destroy?
55
+ = link_to "#{page_url('destroy', ar_object)}", method: :delete do
56
+ .popup-option
57
+ span
58
+ i.fa.fa-trash
59
+ | Destroy
53
60
  - custom_actions.each do |custom_action|
54
61
  - if custom_action.name.present? && has_valid_policy(@model.name, custom_action.name)
55
62
  - if custom_action.display_if.call(ar_object)
@@ -147,7 +147,7 @@ module CmAdmin
147
147
  else
148
148
  redirect_url = CmAdmin::Engine.mount_path + "/#{@model.name.underscore.pluralize}"
149
149
  end
150
- if @ar_object.save
150
+ if action_name.eql?('destroy') || @ar_object.save
151
151
  format.html { redirect_to redirect_url, notice: "#{action_name.titleize} #{@ar_object.class.name.downcase} is successful" }
152
152
  else
153
153
  format.html { render '/cm_admin/main/new', notice: "#{action_name.titleize} #{@ar_object.class.name.downcase} is unsuccessful" }
@@ -36,6 +36,11 @@ module CmAdmin
36
36
  @ar_object = @ar_model.name.classify.constantize.new(resource_params(params))
37
37
  end
38
38
 
39
+ def destroy(params)
40
+ @ar_object = @ar_model.name.classify.constantize.find(params[:id])
41
+ @ar_object.destroy
42
+ end
43
+
39
44
  def filter_by(params, records, filter_params={}, sort_params={})
40
45
  filtered_result = OpenStruct.new
41
46
  sort_column = "created_at"
@@ -68,9 +73,9 @@ module CmAdmin
68
73
  x.name
69
74
  elsif x.klass.name == "ActiveStorage::Attachment"
70
75
  if x.class.name.include?('HasOne')
71
- x.name
76
+ x.name.to_s.gsub('_attachment', '').to_sym
72
77
  elsif x.class.name.include?('HasMany')
73
- Hash[x.name.to_s, []]
78
+ Hash[x.name.to_s.gsub('_attachment', ''), []]
74
79
  end
75
80
  elsif x.klass.name == "ActionText::RichText"
76
81
  x.name.to_s.gsub('rich_text_', '').to_sym
@@ -1,3 +1,3 @@
1
1
  module CmAdmin
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
@@ -51,6 +51,8 @@ module CmAdmin
51
51
  base_path + '/new'
52
52
  when 'edit'
53
53
  base_path + "/#{ar_object.id}" + '/edit'
54
+ when 'destroy'
55
+ base_path + "/#{ar_object.id}"
54
56
  end
55
57
  end
56
58
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cm-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sajinmp
8
8
  - anbublacky
9
9
  - AdityaTiwari2102
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-06-21 00:00:00.000000000 Z
13
+ date: 2022-06-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pagy
@@ -240,7 +240,7 @@ licenses:
240
240
  metadata:
241
241
  homepage_uri: https://github.com/commutatus/cm-admin
242
242
  source_code_uri: https://github.com/commutatus/cm-admin
243
- post_install_message:
243
+ post_install_message:
244
244
  rdoc_options: []
245
245
  require_paths:
246
246
  - lib
@@ -255,8 +255,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
257
  requirements: []
258
- rubygems_version: 3.2.3
259
- signing_key:
258
+ rubygems_version: 3.2.32
259
+ signing_key:
260
260
  specification_version: 4
261
261
  summary: This is an admin panel gem
262
262
  test_files: []