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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +26 -2
- data/assets/javascripts/simple_form_bs5_file_input.js +13 -7
- data/lib/simple_form_bs5_file_input/version.rb +1 -1
- data/pkg/simple_form_bs5_file_input-0.0.1.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a01187ab37b834c60ee0739e576f7b35869e27657fd2ccecaf0cc75ecabc1aa
|
|
4
|
+
data.tar.gz: 4f5b26770518772bf430cfffd9592125fd455b2e9247eb9af9eb20ebe0764121
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 367087c90da736c938022e8bc4fd1bb6b449fc3ef7b8b60cbff799655d4133317aeb080f516e81548b9f22099b5e17a56ec8272a72f7031450017e39c9270393
|
|
7
|
+
data.tar.gz: 01dba7a9ed7983a2cc748292f3e41031920499d4eebe16628e790f2d6ff03de51790fc7be7fd69333a92ac459377365527de43734794576958bcc8eb97d3e2b6
|
data/Gemfile.lock
CHANGED
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
|
|
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
|
-
|
|
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
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
});
|
|
Binary file
|
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.
|
|
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-
|
|
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:
|