inline_forms 5.2.6 → 6.0.3

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: 9ea65a4e20e753d86681a5727edb61b32a2daf53
4
- data.tar.gz: 06855e03cdda0a75eb7c286ffe755d9909e91d89
3
+ metadata.gz: b40118b734934f94ff113855156c0c1ab98b49f5
4
+ data.tar.gz: e9fdf7451053f33a6d3618068d1e777a329f6a15
5
5
  SHA512:
6
- metadata.gz: 4cec5c41cba5e1fa6331348171e9ab7d5de514b407fb179577f283cc52a329e387f2129b0441e84a69af8b32a0df219e479d86a6a8c4f88a07e5ef2ab8fde8ac
7
- data.tar.gz: 51564154e2ff4cae7f4c47a7ec5846a8be99670d3cecffe7b3703ca204a55d41a313e2f79c6135355b8f8ebede3e40ec0be50c228a134e16f60ce07f46095740
6
+ metadata.gz: 5e11c687acfd2d4d3b3542f822f0b9659626dab8f0495badf4a382a9b7e90254b0cfb9cb80063fcf4a9d5624cb96642413f6464332cf42325ba8ba8a66f0aafc
7
+ data.tar.gz: f70a535591c7505033a6efcd5ba91c32e6cede9038aff2d95a56a34b1ef0b966f73b23f268d0c4c390ed82d6335d3b86ba7246f596be0b2efaaf82ee17270d59
@@ -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 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
@@ -592,7 +592,7 @@ if ENV['install_example'] == 'true'
592
592
  end
593
593
  END_EXAMPLE_TEST
594
594
 
595
- run "rspec" if ENV['runtest']
595
+ #run "rspec" if ENV['runtest']
596
596
  remove_file 'public/index.html'
597
597
  route "root :to => 'apartments#index'"
598
598
 
@@ -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.6"
3
+ VERSION = "6.0.3"
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.6
4
+ version: 6.0.3
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