Skip to content

Commit

Permalink
v1.0.6
Browse files Browse the repository at this point in the history
 - Move codebase to ES5
 - Fix #6
  • Loading branch information
dr-dimitru committed Aug 27, 2016
1 parent 8700390 commit a883ad4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
ostrio:[email protected].5
ostrio:[email protected].6
ostrio:[email protected]
ostrio:[email protected]
[email protected]
Expand Down
22 changes: 13 additions & 9 deletions lib/client/fileUpload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Template.afFileUpload.onCreated(function () {
var self = this;
if (!this.data) {
this.data = {
atts: {}
Expand All @@ -10,44 +11,47 @@ Template.afFileUpload.onCreated(function () {
throw new Meteor.Error(404, '[meteor-autoform-files] No such collection "' + this.data.atts.collection + '"');
}

this.collectionName = () => this.data.atts.collection;
this.collectionName = function () {
return self.data.atts.collection;
};

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

Template.afFileUpload.helpers({
currentUpload() {
currentUpload: function () {
return Template.instance().currentUpload.get();
},
fileId() {
fileId: function () {
return Template.instance().fileId.get();
},
uploadedFile() {
uploadedFile: function () {
return global[Template.instance().collectionName()].findOne({
_id: Template.instance().fileId.get()
});
}
});

Template.afFileUpload.events({
'click [data-reset-file]'(e, template) {
'click [data-reset-file]': function (e, template) {
e.preventDefault();
template.fileId.set(false);
return false;
},
'click [data-remove-file]'(e, template) {
'click [data-remove-file]': function (e, template) {
e.preventDefault();
template.fileId.set(false);
try {
this.remove();
} catch (error) {}
return false;
},
'change [data-files-collection-upload]'(e, template) {
'change [data-files-collection-upload]': function (e, template) {
if (e.currentTarget.files && e.currentTarget.files[0]) {
const upload = global[template.collectionName()].insert({
var upload = global[template.collectionName()].insert({
file: e.currentTarget.files[0],
streams: 'dynamic',
chunkSize: 'dynamic'
Expand All @@ -66,7 +70,7 @@ Template.afFileUpload.events({
return;
});

upload.on('end', (error, fileObj) => {
upload.on('end', function (error, fileObj) {
if (!error) {
if (template) {
template.fileId.set(fileObj._id);
Expand Down
2 changes: 1 addition & 1 deletion 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.5",
version: "1.0.6",
git: "https://github.com/VeliovGroup/meteor-autoform-file.git"
});

Expand Down

0 comments on commit a883ad4

Please sign in to comment.