Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
 - 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`
  • Loading branch information
dr-dimitru committed Aug 21, 2016
1 parent de517fe commit c7dc422
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .versions
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ mongo-id@1.0.5
npm-mongo@1.5.45
observe-sequence@1.0.12
ordered-dict@1.0.8
ostrio:autoform-files@1.0.2
ostrio:autoform-files@1.0.4
ostrio:cookies@2.0.5
ostrio:files@1.6.9
ostrio:files@1.7.0
promise@0.8.3
random@1.0.10
reactive-dict@1.1.3
Expand Down
6 changes: 6 additions & 0 deletions lib/client/autoform.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ AutoForm.addInputType("fileUpload", {
template: "afFileUpload"
});

AutoForm._globalHooks.onSuccess.push(function (type) {
if (type === 'insert') {
this.template.$('[data-reset-file]').click();
}
});

SimpleSchema.messages({
uploadError: '[value]'
});
7 changes: 5 additions & 2 deletions lib/client/fileUpload.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
{{> uploadFileDemo}}
{{/if}}
</div>
<a data-remove-file>Remove</a>
<a data-reset-file href="#" style="display:none">Reset</a>
<a data-remove-file href="#">Remove</a>
{{else}}
{{#with currentUpload}}
Uploading <b>{{file.name}}</b>:
<span class="progress">{{progress}}%</span>
<progress value="{{progress.get}}" max="100"></progress>
&nbsp;
<span class="progress">{{progress.get}}%</span>
{{else}}
<input data-files-collection-upload class="form-control af-file-upload-capture" type="file" />
{{/with}}
Expand Down
23 changes: 17 additions & 6 deletions lib/client/fileUpload.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
Template.afFileUpload.onCreated(function () {
this.collection = Meteor.connection._mongo_livedata_collections[this.data.atts.collection]
if (!this.data) {
this.data = {
atts: {}
};
}

this.collection = Meteor.connection._mongo_livedata_collections[this.data.atts.collection];
if (!this.collection) {
throw new Meteor.Error(404, '[meteor-autoform-files] No such collection "' + this.data.atts.collection + '"');
}

this.collectionName = () => this.data.atts.collection

this.collectionName = () => this.data.atts.collection;
this.currentUpload = new ReactiveVar(false);
this.inputName = this.data.name;
this.fileId = new ReactiveVar(this.data.value);
this.fileId = new ReactiveVar(this.data.value || false);
return;
});

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

Template.afFileUpload.events({
'click [data-reset-file]'(e, template) {
e.preventDefault();
template.fileId.set(false);
return false;
},
'click [data-remove-file]'(e, template) {
e.preventDefault();
template.fileId.set(false);
try {
this.remove();
} catch (e) {}
return;
} catch (error) {}
return false;
},
'change [data-files-collection-upload]'(e, template) {
if (e.currentTarget.files && e.currentTarget.files[0]) {
Expand Down
4 changes: 2 additions & 2 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package.describe({
name: "ostrio:autoform-files",
summary: "File upload for AutoForm using ostrio:files",
description: "File upload for AutoForm using ostrio:files",
version: "1.0.2",
version: "1.0.4",
git: "https://github.com/VeliovGroup/meteor-autoform-file.git"
});

Expand All @@ -15,7 +15,7 @@ Package.onUse(function(api) {
'reactive-var',
'templating',
'aldeed:autoform@5.8.0',
'ostrio:files@1.6.9'
'ostrio:files@1.7.0'
]);

api.addFiles([
Expand Down

0 comments on commit c7dc422

Please sign in to comment.