rails-uploader 0.5.4 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/uploader/jquery.uploader.js +87 -0
- data/lib/uploader/asset.rb +1 -1
- data/lib/uploader/authorization.rb +1 -2
- data/lib/uploader/version.rb +1 -1
- data/lib/uploader.rb +1 -0
- metadata +3 -3
- data/app/assets/javascripts/uploader/jquery.uploader.js.coffee +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12397692cb77791fc651ff6ee848e3e9a376327eb531187a0bccb14d3208f18f
|
4
|
+
data.tar.gz: 013dd49aaca77295f886e66c1b8fc5e2d3ed86af4b0c027a2d645532c8e9dae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3f7ff5f6530a221a1d91dc55fd231d6d78baa63d3b6511ec2ef5c5aff46c10b9e1ef5d4068d4d314bd422ae6919f209a54bb48c7d6eeca1186333ed9a293058
|
7
|
+
data.tar.gz: f1d41d67e22055e0b6fe8cbb13fa86c9eabc4326c93b8ac53b86f03d88a9c6b62547d50813f3080280af66182708f68d5602a8bae2281856d8385e57dce4f753
|
@@ -0,0 +1,87 @@
|
|
1
|
+
(function() {
|
2
|
+
var $, UploaderWidget;
|
3
|
+
|
4
|
+
$ = jQuery;
|
5
|
+
|
6
|
+
$.fn.uploaderWidget = function(options) {
|
7
|
+
if (options == null) {
|
8
|
+
options = {};
|
9
|
+
}
|
10
|
+
return this.each(function() {
|
11
|
+
var $this, data;
|
12
|
+
$this = $(this);
|
13
|
+
data = $this.data('uploaderWidget');
|
14
|
+
if (!data) {
|
15
|
+
$this.data('uploaderWidget', new UploaderWidget(this, options));
|
16
|
+
}
|
17
|
+
if (typeof options === 'string') {
|
18
|
+
return data[options]();
|
19
|
+
}
|
20
|
+
});
|
21
|
+
};
|
22
|
+
|
23
|
+
UploaderWidget = (function() {
|
24
|
+
function UploaderWidget(dom_id, options) {
|
25
|
+
var defaults;
|
26
|
+
this.dom_id = dom_id;
|
27
|
+
if (options == null) {
|
28
|
+
options = {};
|
29
|
+
}
|
30
|
+
defaults = {
|
31
|
+
dataType: 'json',
|
32
|
+
autoUpload: true,
|
33
|
+
paramName: 'asset[data]',
|
34
|
+
formData: function(form) {
|
35
|
+
return [];
|
36
|
+
},
|
37
|
+
namespace: 'uploader',
|
38
|
+
uploadTemplateId: 'template-upload-',
|
39
|
+
downloadTemplateId: 'template-download-'
|
40
|
+
};
|
41
|
+
this.options = $.extend(defaults, options);
|
42
|
+
this._setup();
|
43
|
+
}
|
44
|
+
|
45
|
+
UploaderWidget.prototype._setup = function() {
|
46
|
+
this.element = $(this.dom_id);
|
47
|
+
this.container = this.element.find('.uploader-files');
|
48
|
+
this.template = this.element.data('tpml');
|
49
|
+
this.input = this.element.find('input[type="file"]:eq(0)');
|
50
|
+
this.options['dropZone'] = this.element;
|
51
|
+
this.options['filesContainer'] = this.container;
|
52
|
+
this.options['uploadTemplateId'] += this.template;
|
53
|
+
this.options['downloadTemplateId'] += this.template;
|
54
|
+
this.options.singular = !this.input.prop('multiple');
|
55
|
+
return this._initFileupload();
|
56
|
+
};
|
57
|
+
|
58
|
+
UploaderWidget.prototype._initFileupload = function() {
|
59
|
+
this.input.fileupload(this.options);
|
60
|
+
this.uploader = this.input.data('blueimp-fileupload') || this.input.data('fileupload');
|
61
|
+
if (this.element.data('exists')) {
|
62
|
+
return this._load();
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
UploaderWidget.prototype._load = function() {
|
67
|
+
return $.ajax({
|
68
|
+
url: this.input.data('url'),
|
69
|
+
dataType: 'json',
|
70
|
+
method: 'GET',
|
71
|
+
success: (function(_this) {
|
72
|
+
return function(data) {
|
73
|
+
if (data['files'] != null) {
|
74
|
+
return _this.render(data['files']);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
})(this)
|
78
|
+
});
|
79
|
+
};
|
80
|
+
|
81
|
+
UploaderWidget.prototype.render = function(files) {
|
82
|
+
return this.uploader._renderDownload(files).appendTo(this.container);
|
83
|
+
};
|
84
|
+
|
85
|
+
return UploaderWidget;
|
86
|
+
})();
|
87
|
+
}).call(this);
|
data/lib/uploader/asset.rb
CHANGED
@@ -51,7 +51,7 @@ module Uploader
|
|
51
51
|
#
|
52
52
|
def fileupload_create(params, _request = nil)
|
53
53
|
self[Uploader.guid_column] = params[:guid]
|
54
|
-
return false unless
|
54
|
+
return false unless update(self.class.fileupload_assetable_options(params))
|
55
55
|
|
56
56
|
if fileupload_destroy_other_on_singular?(params)
|
57
57
|
self.class.fileupload_find_assets(params).where.not(id: id).destroy_all
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/concern'
|
4
|
-
require_relative 'json_rendering'
|
5
4
|
|
6
5
|
module Uploader
|
7
6
|
module Authorization
|
8
7
|
extend ActiveSupport::Concern
|
9
8
|
|
10
9
|
included do
|
11
|
-
include JsonRendering
|
10
|
+
include Uploader::JsonRendering
|
12
11
|
include ActionController::Rescue
|
13
12
|
|
14
13
|
rescue_from Uploader::AccessDenied, with: :dispatch_uploader_access_denied
|
data/lib/uploader/version.rb
CHANGED
data/lib/uploader.rb
CHANGED
@@ -13,6 +13,7 @@ module Uploader
|
|
13
13
|
autoload :UploadRequest, 'uploader/upload_request'
|
14
14
|
autoload :FilePart, 'uploader/file_part'
|
15
15
|
autoload :FileuploadGlue, 'uploader/fileupload_glue'
|
16
|
+
autoload :JsonRendering, 'uploader/json_rendering'
|
16
17
|
|
17
18
|
# Just Rails helpers
|
18
19
|
module Helpers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
@@ -64,7 +64,7 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
66
|
- app/assets/javascripts/uploader/application.js
|
67
|
-
- app/assets/javascripts/uploader/jquery.uploader.js
|
67
|
+
- app/assets/javascripts/uploader/jquery.uploader.js
|
68
68
|
- app/assets/stylesheets/uploader/application.css
|
69
69
|
- app/controllers/uploader/attachments_controller.rb
|
70
70
|
- app/views/uploader/default/_container.html.erb
|
@@ -1,59 +0,0 @@
|
|
1
|
-
$ = jQuery
|
2
|
-
|
3
|
-
$.fn.uploaderWidget = (options = {}) ->
|
4
|
-
@each ->
|
5
|
-
$this = $(this)
|
6
|
-
data = $this.data('uploaderWidget')
|
7
|
-
if (!data)
|
8
|
-
$this.data('uploaderWidget', new UploaderWidget(this, options))
|
9
|
-
if (typeof options is 'string')
|
10
|
-
data[options]()
|
11
|
-
|
12
|
-
class UploaderWidget
|
13
|
-
constructor: (@dom_id, options = {}) ->
|
14
|
-
defaults =
|
15
|
-
dataType: 'json'
|
16
|
-
autoUpload: true
|
17
|
-
paramName: 'asset[data]'
|
18
|
-
formData: (form) -> return []
|
19
|
-
namespace: 'uploader'
|
20
|
-
uploadTemplateId: 'template-upload-'
|
21
|
-
downloadTemplateId: 'template-download-'
|
22
|
-
|
23
|
-
@options = $.extend defaults, options
|
24
|
-
|
25
|
-
this._setup()
|
26
|
-
|
27
|
-
_setup: ->
|
28
|
-
@element = $(@dom_id)
|
29
|
-
@container = @element.find('.uploader-files')
|
30
|
-
@template = @element.data('tpml')
|
31
|
-
@input = @element.find('input[type="file"]:eq(0)')
|
32
|
-
|
33
|
-
@options['dropZone'] = @element
|
34
|
-
@options['filesContainer'] = @container
|
35
|
-
@options['uploadTemplateId'] += @template
|
36
|
-
@options['downloadTemplateId'] += @template
|
37
|
-
@options.singular = !@input.prop('multiple')
|
38
|
-
|
39
|
-
this._initFileupload()
|
40
|
-
|
41
|
-
_initFileupload: ->
|
42
|
-
@input.fileupload(@options)
|
43
|
-
|
44
|
-
@uploader = (@input.data('blueimp-fileupload') || @input.data('fileupload'))
|
45
|
-
|
46
|
-
this._load() if @element.data('exists')
|
47
|
-
|
48
|
-
_load: ->
|
49
|
-
$.ajax(
|
50
|
-
url: @input.data('url')
|
51
|
-
dataType: 'json'
|
52
|
-
method: 'GET'
|
53
|
-
success: (data) =>
|
54
|
-
if data['files']?
|
55
|
-
this.render(data['files'])
|
56
|
-
)
|
57
|
-
|
58
|
-
render: (files) ->
|
59
|
-
@uploader._renderDownload(files).appendTo(@container)
|