inline_forms 6.0.1 → 6.0.2

This diff has not been reviewed by any users.
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
  SHA1:
3
- metadata.gz: 41ec2dde956377e84c7ae4cb228cac6098ad42f5
4
- data.tar.gz: 6a4e558788cdf92506ac80918050a80e63a11591
3
+ metadata.gz: 7c6e41d884135a6e7124801d5cc33048e16b5542
4
+ data.tar.gz: 180fa9e1324cc7545daee4483f5011852d96989b
5
5
  SHA512:
6
- metadata.gz: 79279055494c7c915500d0a73b618e35405e482d7b6531544bebc4b29b83bba96a18e9d529d508b57389ff8c3af168e38c24206a27daf622548451ae5214a7bf
7
- data.tar.gz: 08db08a5be24d890abca786fc978fbf43954add84f8732e268ba16e7a95338d534d9a6022c9ac5956003c2d33fd81c289e8e8e4fba96228d974fc3c8ab7548b1
6
+ metadata.gz: d53f228b7ba478ce80348740f9210802ab3d503433f43a819ba1aba383ed07f2997404c2874370d95343c14fad5de8c5633376a0ba1fdc9539549696625e1111
7
+ data.tar.gz: df0c99e1ec6e24fdbb0cdefe80f626f601e7141bb35aa247ad24988800733995eb4e9cad97269289acdb6246a68f306ce29c462ec23e19f29fe64cffa5dbbd28
@@ -0,0 +1,35 @@
1
+ module SoftDeletable
2
+ extend ActiveSupport::Concern
3
+
4
+ # you need to put this in the model:
5
+ # include SoftDeletable
6
+ # enum deleted: { active: 1, deleted: 2 }
7
+
8
+ # you need a migration like this:
9
+ # class AddDeletedAtColumnToUser < ActiveRecord::Migration[6.0]
10
+ # def change
11
+ # add_column :users, :deleted_at, :datetime, default: nil
12
+ # add_column :users, :deleted, :integer, default: 1
13
+ # add_column :users, :deleted_by, :integer, default: nil
14
+ # end
15
+ # end
16
+
17
+ def soft_deletable?
18
+ true
19
+ end
20
+
21
+ def soft_delete(current_user)
22
+ deleted = 2
23
+ deleter = current_user
24
+ deleted_at = Time.current
25
+ save
26
+ end
27
+
28
+ def soft_restore
29
+ deleted = 1
30
+ deleted_by = nil
31
+ deleted_at = nil
32
+ save
33
+ end
34
+
35
+ end
@@ -185,13 +185,21 @@ class InlineFormsController < ApplicationController
185
185
  @update_span = params[:update]
186
186
  @object = referenced_object
187
187
  if current_user.role? :superadmin
188
- @object.destroy
189
- respond_to do |format|
190
- format.html { } unless @Klass.not_accessible_through_html?
191
- format.js { render :show_undo }
188
+ if (@Klass.soft_deletable? rescue false)
189
+ @object.soft_delete(current_user)
190
+ respond_to do |format|
191
+ format.html { } unless @Klass.not_accessible_through_html?
192
+ format.js { render :close }
193
+ end
194
+ elsif
195
+ @object.destroy
196
+ respond_to do |format|
197
+ format.html { } unless @Klass.not_accessible_through_html?
198
+ format.js { render :show_undo }
199
+ end
192
200
  end
193
- elsif (@Klass.safe_deletable? rescue false)
194
- @object.safe_delete(current_user)
201
+ elsif (@Klass.soft_deletable? rescue false)
202
+ @object.soft_delete(current_user)
195
203
  respond_to do |format|
196
204
  format.html { } unless @Klass.not_accessible_through_html?
197
205
  format.js { render :close }
@@ -204,17 +212,26 @@ class InlineFormsController < ApplicationController
204
212
  def revert
205
213
  @update_span = params[:update]
206
214
  if current_user.role? :superadmin
207
- @version = PaperTrail::Version.find(params[:id])
208
- @version.reify.save!
209
- @object = @Klass.find(@version.item_id)
210
- authorize!(:revert, @object) if cancan_enabled?
211
- respond_to do |format|
212
- format.html { } unless @Klass.not_accessible_through_html?
213
- format.js { render :close }
215
+ if (@Klass.soft_deletable? rescue false)
216
+ @object = referenced_object
217
+ @object.soft_restore
218
+ respond_to do |format|
219
+ format.html { } unless @Klass.not_accessible_through_html?
220
+ format.js { render :close }
221
+ end
222
+ elsif
223
+ @version = PaperTrail::Version.find(params[:id])
224
+ @version.reify.save!
225
+ @object = @Klass.find(@version.item_id)
226
+ authorize!(:revert, @object) if cancan_enabled?
227
+ respond_to do |format|
228
+ format.html { } unless @Klass.not_accessible_through_html?
229
+ format.js { render :close }
230
+ end
214
231
  end
215
- elsif (@Klass.safe_deletable? rescue false)
232
+ elsif (@Klass.soft_deletable? rescue false)
216
233
  @object = referenced_object
217
- @object.safe_restore
234
+ @object.soft_restore
218
235
  respond_to do |format|
219
236
  format.html { } unless @Klass.not_accessible_through_html?
220
237
  format.js { render :close }
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "6.0.1"
3
+ VERSION = "6.0.2"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-06-08 00:00:00.000000000 Z
13
+ date: 2020-06-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rvm
@@ -163,6 +163,7 @@ files:
163
163
  - app/assets/stylesheets/inline_forms/foundation_and_overrides.scss
164
164
  - app/assets/stylesheets/inline_forms/inline_forms.scss
165
165
  - app/controllers/concerns/cancan_concern.rb
166
+ - app/controllers/concerns/soft_deletable_concern.rb
166
167
  - app/controllers/concerns/versions_concern.rb
167
168
  - app/controllers/geo_code_curacao_controller.rb
168
169
  - app/controllers/inline_forms_application_controller.rb