inline_forms 5.2.7 → 6.0.4

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: 4abaa91fb45416c5ec794eb3b753691c92e86110
4
- data.tar.gz: 6523675996c4f48c87034d2a8ed6cdea7cdf1a54
3
+ metadata.gz: c7951217d1207dbac72697094e7116a1e95c012e
4
+ data.tar.gz: bbc9ae8c6ff17c18c2e2e1d68c4953f65fe3dfdc
5
5
  SHA512:
6
- metadata.gz: fb6eba1e260faf596404f5a9318a9210b46985b45cf99a97c9c549fb6f98d83cc0912fd62a5bea4bb4eec93f44eedfc0138eac57a3f6b7a5b43b7783623bc6aa
7
- data.tar.gz: 8320879d5473d707798e699db2eb80fede0625bdaea5a9c1f5acbc3c3d0246f8ac19d244ffb1a820786b44fb462dd39af376a73e882acceca514cf2e931e33a1
6
+ metadata.gz: 666c1f4ff362d8104f010919dd7321d99581b985fe5431bed570062cefc9b83082e2f4d634205457191a2380cee8a19a54fc5722efe052cea9e575bfb8225e6f
7
+ data.tar.gz: 72908445fde367e2da6cea09d5844389f11cee258e2c151d2c7c493c989cccd1563e63433ab64e85b068b153155f935c40865eadd3ce9560f21f96dd5aa5224d
@@ -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 }
@@ -0,0 +1,35 @@
1
+ module InlineForms::SoftDeletable
2
+ extend ActiveSupport::Concern
3
+
4
+ # you need to put this in the model:
5
+ # include InlineForms::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
@@ -602,7 +602,7 @@ if ENV['install_example'] == 'true'
602
602
  run 'bundle exec rails s'
603
603
  else
604
604
  # run tests
605
- run "rspec" if ENV['runtest']
605
+ #run "rspec" if ENV['runtest']
606
606
  say "- Don't forget: add your secret key base in config/application.yml \n"
607
607
  end
608
608
  # done!
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency('rvm')
24
24
  s.add_dependency('thor')
25
25
  s.add_dependency('validation_hints')
26
- s.add_dependency('rails', '>= 5.0')
26
+ s.add_dependency('rails', '>= 6.0')
27
27
  s.add_dependency('rails-i18n')
28
28
 
29
29
  s.add_development_dependency(%q<rspec-rails>)
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "5.2.7"
3
+ VERSION = "6.0.4"
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: 5.2.7
4
+ version: 6.0.4
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: 2019-12-24 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
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - '>='
62
62
  - !ruby/object:Gem::Version
63
- version: '5.0'
63
+ version: '6.0'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '>='
69
69
  - !ruby/object:Gem::Version
70
- version: '5.0'
70
+ version: '6.0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rails-i18n
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -209,6 +209,7 @@ files:
209
209
  - app/helpers/form_elements/text_field.rb
210
210
  - app/helpers/form_elements/time.rb
211
211
  - app/helpers/inline_forms_helper.rb
212
+ - app/models/concerns/inline_forms/soft_deletable.rb
212
213
  - app/models/geo_code_curacao.rb
213
214
  - app/validators/curacao_id_number_validator.rb
214
215
  - app/validators/is_curacao_phone_validator.rb