Skip to content

Commit c7dc422

Browse files
committed
v1.0.4
- Progress-bar aside to percentage - Reset file’s fields after form is successfully submitted - Compatibility with `Meteor@1.4.1` - Upgrade `ostrio:files@1.7.0`
1 parent de517fe commit c7dc422

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

.versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ mongo-id@1.0.5
4141
npm-mongo@1.5.45
4242
observe-sequence@1.0.12
4343
ordered-dict@1.0.8
44-
ostrio:autoform-files@1.0.2
44+
ostrio:autoform-files@1.0.4
4545
ostrio:cookies@2.0.5
46-
ostrio:files@1.6.9
46+
ostrio:files@1.7.0
4747
promise@0.8.3
4848
random@1.0.10
4949
reactive-dict@1.1.3

lib/client/autoform.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ AutoForm.addInputType("fileUpload", {
22
template: "afFileUpload"
33
});
44

5+
AutoForm._globalHooks.onSuccess.push(function (type) {
6+
if (type === 'insert') {
7+
this.template.$('[data-reset-file]').click();
8+
}
9+
});
10+
511
SimpleSchema.messages({
612
uploadError: '[value]'
713
});

lib/client/fileUpload.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
{{> uploadFileDemo}}
99
{{/if}}
1010
</div>
11-
<a data-remove-file>Remove</a>
11+
<a data-reset-file href="#" style="display:none">Reset</a>
12+
<a data-remove-file href="#">Remove</a>
1213
{{else}}
1314
{{#with currentUpload}}
1415
Uploading <b>{{file.name}}</b>:
15-
<span class="progress">{{progress}}%</span>
16+
<progress value="{{progress.get}}" max="100"></progress>
17+
&nbsp;
18+
<span class="progress">{{progress.get}}%</span>
1619
{{else}}
1720
<input data-files-collection-upload class="form-control af-file-upload-capture" type="file" />
1821
{{/with}}

lib/client/fileUpload.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
Template.afFileUpload.onCreated(function () {
2-
this.collection = Meteor.connection._mongo_livedata_collections[this.data.atts.collection]
2+
if (!this.data) {
3+
this.data = {
4+
atts: {}
5+
};
6+
}
7+
8+
this.collection = Meteor.connection._mongo_livedata_collections[this.data.atts.collection];
39
if (!this.collection) {
410
throw new Meteor.Error(404, '[meteor-autoform-files] No such collection "' + this.data.atts.collection + '"');
511
}
612

7-
this.collectionName = () => this.data.atts.collection
8-
13+
this.collectionName = () => this.data.atts.collection;
914
this.currentUpload = new ReactiveVar(false);
1015
this.inputName = this.data.name;
11-
this.fileId = new ReactiveVar(this.data.value);
16+
this.fileId = new ReactiveVar(this.data.value || false);
1217
return;
1318
});
1419

@@ -27,12 +32,18 @@ Template.afFileUpload.helpers({
2732
});
2833

2934
Template.afFileUpload.events({
35+
'click [data-reset-file]'(e, template) {
36+
e.preventDefault();
37+
template.fileId.set(false);
38+
return false;
39+
},
3040
'click [data-remove-file]'(e, template) {
41+
e.preventDefault();
3142
template.fileId.set(false);
3243
try {
3344
this.remove();
34-
} catch (e) {}
35-
return;
45+
} catch (error) {}
46+
return false;
3647
},
3748
'change [data-files-collection-upload]'(e, template) {
3849
if (e.currentTarget.files && e.currentTarget.files[0]) {

package.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package.describe({
22
name: "ostrio:autoform-files",
33
summary: "File upload for AutoForm using ostrio:files",
44
description: "File upload for AutoForm using ostrio:files",
5-
version: "1.0.2",
5+
version: "1.0.4",
66
git: "https://github.com/VeliovGroup/meteor-autoform-file.git"
77
});
88

@@ -15,7 +15,7 @@ Package.onUse(function(api) {
1515
'reactive-var',
1616
'templating',
1717
'aldeed:autoform@5.8.0',
18-
'ostrio:files@1.6.9'
18+
'ostrio:files@1.7.0'
1919
]);
2020

2121
api.addFiles([

0 commit comments

Comments
 (0)