simple_form_bs5_file_input 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d471d34041e586ad2c8c3ef309ccb56730677ed198daf08e5a14e014b1f66e2
4
- data.tar.gz: 45d007078895c2229164228d776be1dd0e2d6182b2140e34d1f91491ce8d1aa7
3
+ metadata.gz: 0a01187ab37b834c60ee0739e576f7b35869e27657fd2ccecaf0cc75ecabc1aa
4
+ data.tar.gz: 4f5b26770518772bf430cfffd9592125fd455b2e9247eb9af9eb20ebe0764121
5
5
  SHA512:
6
- metadata.gz: 8a232a086495c5b63b5228cb01abbffb6e6edccb3234f39a5cd1e816ef4cea5d747a2b145516d3e7562f10d67436991077757cfbde56a41e97f9c646ea8f6e05
7
- data.tar.gz: b89e928a07c3b264543779b5a798a3b11bbae7d0f9074ce8a1312d74b347023bac1c339198d11e790b1bc1a96a8244b79540a81943aeb2723aa3cc49ae7c158b
6
+ metadata.gz: 367087c90da736c938022e8bc4fd1bb6b449fc3ef7b8b60cbff799655d4133317aeb080f516e81548b9f22099b5e17a56ec8272a72f7031450017e39c9270393
7
+ data.tar.gz: 01dba7a9ed7983a2cc748292f3e41031920499d4eebe16628e790f2d6ff03de51790fc7be7fd69333a92ac459377365527de43734794576958bcc8eb97d3e2b6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_form_bs5_file_input (0.0.1)
4
+ simple_form_bs5_file_input (0.0.2)
5
5
  rails
6
6
  simple_form
7
7
 
data/README.md CHANGED
@@ -62,11 +62,35 @@ becomes
62
62
  ```
63
63
  Of course you can still add the options you want, like for example `input_html: { accept: '.jpg,.jpeg,.png' }`
64
64
 
65
- You can also add a direct preview (WARNING: preview can only work with images!) by using `preview: true` or any custom width for the preview: `preview: 500`. If you don't specify the preview size it will be 1000px witdh by default.
65
+ You can also add a direct preview (WARNING: preview can only work with images!) by using `preview: true` or any custom width for the preview: `preview: 500`. If you don't specify the preview size it will be 1000px width by default.
66
66
  Note that the preview uses the boostrap classes `img-fluid` and `img-thumbnail`.
67
67
 
68
+ ### Model
69
+ You also have to change the type of you file in your model.
70
+ So instead of declaring:
71
+ ```
72
+ has_one_attached :picture
73
+ ```
74
+
75
+ you will have to declare:
76
+ ```
77
+ has_one_attached_deletable :picture
78
+ ```
79
+
80
+ ### Controller
81
+ If you use strict parameters you will need to allow the `:[filename]_delete` and the `:[filename]_infos` params in the controller.
82
+ So instead of:
83
+ ```
84
+ params.require(:user).permit(:first_name, :last_name, :picture)
85
+ ```
86
+ you will have:
87
+ ```
88
+ params.require(:user).permit(:first_name, :last_name, :picture, :picture_delete, :picture_infos)
89
+ ```
90
+
91
+ That's all folks!
68
92
 
69
- ### Direct upload
93
+ ## Direct upload
70
94
 
71
95
  The new field is still compatible with the `direct_upload` param.
72
96
  ```erb
@@ -61,8 +61,10 @@ window.addEventListener('direct-upload:initialize', function (event) {
61
61
  'use strict';
62
62
  var target = event.target,
63
63
  $scope = $(target).parents('.js-sdfi-deletable-file');
64
- $('.sdfi-deletable-file__upload-progress', $scope).css('width', '0%');
65
- $scope.addClass('sdfi-deletable-file--uploading');
64
+ if ($scope.length > 0) {
65
+ $('.sdfi-deletable-file__upload-progress', $scope).css('width', '0%');
66
+ $scope.addClass('sdfi-deletable-file--uploading');
67
+ }
66
68
  });
67
69
 
68
70
  window.addEventListener('direct-upload:progress', function (event) {
@@ -70,7 +72,9 @@ window.addEventListener('direct-upload:progress', function (event) {
70
72
  var target = event.target,
71
73
  progress = event.detail.progress,
72
74
  $scope = $(target).parents('.js-sdfi-deletable-file');
73
- $('.sdfi-deletable-file__upload-progress', $scope).css('width', progress + '%');
75
+ if ($scope.length > 0) {
76
+ $('.sdfi-deletable-file__upload-progress', $scope).css('width', progress + '%');
77
+ }
74
78
  });
75
79
 
76
80
  window.addEventListener('direct-upload:error', function (event) {
@@ -78,8 +82,10 @@ window.addEventListener('direct-upload:error', function (event) {
78
82
  var target = event.target,
79
83
  error = event.detail.error,
80
84
  $scope = $(target).parents('.js-sdfi-deletable-file');
81
- event.preventDefault();
82
- $('.sdfi-deletable-file__upload-progress', $scope).css('width', '0%');
83
- $scope.removeClass('sdfi-deletable-file--uploading');
84
- alert(error);
85
+ if ($scope.length > 0) {
86
+ event.preventDefault();
87
+ $('.sdfi-deletable-file__upload-progress', $scope).css('width', '0%');
88
+ $scope.removeClass('sdfi-deletable-file--uploading');
89
+ alert(error);
90
+ }
85
91
  });
@@ -1,3 +1,3 @@
1
1
  module SimpleFormBs5FileInput
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_bs5_file_input
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre-andré Boissinot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -88,6 +88,7 @@ files:
88
88
  - lib/simple_form_bs5_file_input.rb
89
89
  - lib/simple_form_bs5_file_input/single_deletable_file_input.rb
90
90
  - lib/simple_form_bs5_file_input/version.rb
91
+ - pkg/simple_form_bs5_file_input-0.0.1.gem
91
92
  - simple_form_bs5_file_input.gemspec
92
93
  homepage: https://github.com/noesya/simple_form_bs5_file_input
93
94
  licenses: