attache_rails 0.2.1 → 0.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd350eb1e6d57e9115c1adff7419fe1d049083e
|
4
|
+
data.tar.gz: e7036c6aba1b221badf9a1f073ea66149f84dd11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08aac247fa3572743792cd02b30c7d4c0747ea856d70455052bd139cb66be67c79b1e7e493506506e7379f19400f8e2e4a4ecd91fcd03ad7e19d4430d95e54dc
|
7
|
+
data.tar.gz: 997355e5e9dc8a58f39ce9911b8acf34e896184069acc38021e8ab396791f8ba87cd6ded29c4a4b14cf090dca5f6063c63dfe0f41dc5d9c3aac790072f91d562
|
@@ -5,7 +5,7 @@ var AttacheFileInput = React.createClass({displayName: "AttacheFileInput",
|
|
5
5
|
if (this.props['data-value']) $.each(JSON.parse(this.props['data-value']), function(uid, json) {
|
6
6
|
if (json) files[uid] = json;
|
7
7
|
});
|
8
|
-
return {files: files, attaches_discarded: []};
|
8
|
+
return {files: files, attaches_discarded: [], uploading: 0 };
|
9
9
|
},
|
10
10
|
|
11
11
|
onRemove: function(uid, e) {
|
@@ -32,12 +32,20 @@ var AttacheFileInput = React.createClass({displayName: "AttacheFileInput",
|
|
32
32
|
this.setState(this.state);
|
33
33
|
// upload the file via CORS
|
34
34
|
var that = this;
|
35
|
+
|
36
|
+
that.state.uploading = that.state.uploading + files.length;
|
37
|
+
if (! that.state.submit_buttons) that.state.submit_buttons = $("button,input[type='submit']", $(file_element).parents('form')[0]).filter(':not(:disabled)');
|
38
|
+
|
35
39
|
new AttacheCORSUpload({
|
36
40
|
file_element: file_element,
|
37
41
|
files: files,
|
38
|
-
onComplete:
|
42
|
+
onComplete: function() {
|
43
|
+
that.state.uploading--;
|
44
|
+
that.setFileValue.apply(this, arguments);
|
45
|
+
},
|
39
46
|
onProgress: this.setFileValue,
|
40
47
|
onError: function(uid, status) {
|
48
|
+
that.state.uploading--;
|
41
49
|
that.setFileValue(uid, { pctString: '90%', pctDesc: status, className: 'progress-bar progress-bar-danger' });
|
42
50
|
}
|
43
51
|
});
|
@@ -80,6 +88,12 @@ var AttacheFileInput = React.createClass({displayName: "AttacheFileInput",
|
|
80
88
|
render: function() {
|
81
89
|
var that = this;
|
82
90
|
|
91
|
+
if (that.state.uploading > 0) {
|
92
|
+
that.state.submit_buttons.attr('disabled', true);
|
93
|
+
} else if (that.state.submit_buttons) {
|
94
|
+
that.state.submit_buttons.attr('disabled', null);
|
95
|
+
}
|
96
|
+
|
83
97
|
var Header = eval(this.props['data-header-component'] || 'AttacheHeader');
|
84
98
|
var Preview = eval(this.props['data-preview-component'] || 'AttacheFilePreview');
|
85
99
|
var Placeholder = eval(this.props['data-placeholder-component'] || 'AttachePlaceholder');
|
@@ -5,7 +5,7 @@ var AttacheFileInput = React.createClass({
|
|
5
5
|
if (this.props['data-value']) $.each(JSON.parse(this.props['data-value']), function(uid, json) {
|
6
6
|
if (json) files[uid] = json;
|
7
7
|
});
|
8
|
-
return {files: files, attaches_discarded: []};
|
8
|
+
return {files: files, attaches_discarded: [], uploading: 0 };
|
9
9
|
},
|
10
10
|
|
11
11
|
onRemove: function(uid, e) {
|
@@ -32,12 +32,20 @@ var AttacheFileInput = React.createClass({
|
|
32
32
|
this.setState(this.state);
|
33
33
|
// upload the file via CORS
|
34
34
|
var that = this;
|
35
|
+
|
36
|
+
that.state.uploading = that.state.uploading + files.length;
|
37
|
+
if (! that.state.submit_buttons) that.state.submit_buttons = $("button,input[type='submit']", $(file_element).parents('form')[0]).filter(':not(:disabled)');
|
38
|
+
|
35
39
|
new AttacheCORSUpload({
|
36
40
|
file_element: file_element,
|
37
41
|
files: files,
|
38
|
-
onComplete:
|
42
|
+
onComplete: function() {
|
43
|
+
that.state.uploading--;
|
44
|
+
that.setFileValue.apply(this, arguments);
|
45
|
+
},
|
39
46
|
onProgress: this.setFileValue,
|
40
47
|
onError: function(uid, status) {
|
48
|
+
that.state.uploading--;
|
41
49
|
that.setFileValue(uid, { pctString: '90%', pctDesc: status, className: 'progress-bar progress-bar-danger' });
|
42
50
|
}
|
43
51
|
});
|
@@ -80,6 +88,12 @@ var AttacheFileInput = React.createClass({
|
|
80
88
|
render: function() {
|
81
89
|
var that = this;
|
82
90
|
|
91
|
+
if (that.state.uploading > 0) {
|
92
|
+
that.state.submit_buttons.attr('disabled', true);
|
93
|
+
} else if (that.state.submit_buttons) {
|
94
|
+
that.state.submit_buttons.attr('disabled', null);
|
95
|
+
}
|
96
|
+
|
83
97
|
var Header = eval(this.props['data-header-component'] || 'AttacheHeader');
|
84
98
|
var Preview = eval(this.props['data-preview-component'] || 'AttacheFilePreview');
|
85
99
|
var Placeholder = eval(this.props['data-placeholder-component'] || 'AttachePlaceholder');
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attache_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- choonkeat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|