inline_forms 5.2.5 → 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: 01397992883a1147f81b166cc1c2902412b3e17a
4
- data.tar.gz: 4b3132b2fd738cb8412b2417b82b2ce3a22f2ceb
3
+ metadata.gz: 7c6e41d884135a6e7124801d5cc33048e16b5542
4
+ data.tar.gz: 180fa9e1324cc7545daee4483f5011852d96989b
5
5
  SHA512:
6
- metadata.gz: d9f52f1649b48ec11798c9b93f174a03a87ddb3ec51a4ee68e3c103ba1a28d6b022385c9d0c0a3d7d37970eae8f1d734c348004c71cf475f7bbd9a3d0fe662fa
7
- data.tar.gz: ac8985fdd72bba0e5eb74ee296d8af9a16e18b926678a6220dfdea679ba356da7369ef23688411d316db54d5d9382e72e2d696a3fbddef0fdd44663c735b8444
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 }
@@ -295,8 +295,8 @@ say "- Add ckeditor autoload_paths to application.rb..."
295
295
  application "config.autoload_paths += %W(\#{config.root}/app/models/ckeditor)"
296
296
 
297
297
  # see https://github.com/galetahub/ckeditor/issues/579
298
- say "- Set languages for ckeditor to ['en', 'nl'] in config/initializers/ckeditor.rb..."
299
- insert_into_file "config/initializers/ckeditor.rb", " config.assets_languages = ['en', 'nl']\n", :after => "config.assets_languages = ['en', 'uk']\n"
298
+ #say "- Set languages for ckeditor to ['en', 'nl'] in config/initializers/ckeditor.rb..."
299
+ #insert_into_file "config/initializers/ckeditor.rb", " config.assets_languages = ['en', 'nl']\n", :after => "config.assets_languages = ['en', 'uk']\n"
300
300
 
301
301
  say "- Paper_trail install..."
302
302
  generate "paper_trail:install --with-changes"
@@ -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.5"
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: 5.2.5
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: 2019-12-18 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
@@ -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