ez-resources 0.1.2 → 0.1.3

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: ebc92d0fcd558df5916ff3a76e2a050bf8e2f23f636a9ae2c7f0cd0cc2d017a9
4
- data.tar.gz: c3edef2deeb5367ae837162831821dacd174a4aa24459b52c2f5df71ad990685
3
+ metadata.gz: faeed954e2b59068bceac5d87b8d94029e8ee5c75ee32831c1daf539a8c8ef5f
4
+ data.tar.gz: 9341e3858d0273d8afae03827f7b541462c47668eeb7fba2a572087b2774d2db
5
5
  SHA512:
6
- metadata.gz: e63df64cf4285a99602dfa2cc2e1ddf8942222ee894f5eb7749ae14816ebeafe370371f6cdd6648090da163327fcabc02777d01fdc050d8892be37961e990b84
7
- data.tar.gz: 76d771724829b4b4e7998df1707924bb1ea267402a96a6971280db3ea1fdbc731629f0b2c8cdee62c6ff7a11d8965cf6f829ff4e5df79e740c1fdc0e19d0c285
6
+ metadata.gz: 77ee0e92778121182d86b24788a37d6572b5ebe1511f0e137298f1556ad6a9e4979dd25045fb9ce401da04388b8a8de1c55a79e62e72e88a89b20e7b9de32b13
7
+ data.tar.gz: 36a4a91698f181fae7e04141c15a08a13adcd746f1eb29005a75aa55e765adcd418e5c6f79ccd9f4ff795e0cd3c14bba04100950cd01b5ee4dc55335456f52ab
@@ -81,7 +81,12 @@ module Ez
81
81
  end
82
82
 
83
83
  def remove_link(record)
84
- # TODO
84
+ return unless model.actions.include?(:destroy)
85
+ return unless Manager::Hooks.can?(:can_destroy?, model, record)
86
+
87
+ link_to t('actions.remove'), model.path_for(action: :destroy, id: record.id),
88
+ method: :delete,
89
+ class: css_for('collection-table-td-action-item')
85
90
  end
86
91
 
87
92
  def pagination
@@ -89,8 +89,16 @@ module Ez
89
89
  end
90
90
  end
91
91
 
92
- # TODO: Later
93
- def destroy; end
92
+ def destroy
93
+ Manager::Hooks.can?(:can_destroy?, ez_resource_config, ez_resource_config.data)
94
+ ez_resource_config.data.delete
95
+
96
+ flash[:notice] = t('messages.removed',
97
+ resource_name: ez_resource_config.resource_name,
98
+ scope: Ez::Resources.config.i18n_scope)
99
+
100
+ redirect_to ez_resource_config.path_for(action: :index)
101
+ end
94
102
 
95
103
  private
96
104
 
@@ -18,11 +18,12 @@ module Ez
18
18
 
19
19
  def data
20
20
  @data ||= case controller.action_name
21
- when 'index' then collection
22
- when 'new' then new_resource
23
- when 'show' then resource
24
- when 'edit' then resource
25
- when 'update' then resource
21
+ when 'index' then collection
22
+ when 'new' then new_resource
23
+ when 'show' then resource
24
+ when 'edit' then resource
25
+ when 'update' then resource
26
+ when 'destroy' then resource
26
27
  else
27
28
  raise ConfigurationError, "Invalid action #{controller.action_name}"
28
29
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ez
4
4
  module Resources
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ez-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-28 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cells-rails