Skip to content

Commit ad14d5a

Browse files
committed
v1.0.0
1 parent 764c556 commit ad14d5a

File tree

5 files changed

+31
-35
lines changed

5 files changed

+31
-35
lines changed

lib/client/autoform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
AutoForm.addInputType("fileUpload", {
2-
template: "afFileUpload",
2+
template: "afFileUpload"
33
});

lib/client/fileUpload.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<template name="afFileUpload">
2-
<input value="{{fileId}}" type="hidden" {{this.atts}}>
3-
{{#if $gt uploadedFile.count 0}}
4-
{{#each uploadedFile}}
5-
<div>
6-
{{> uploadImageDemo}}
7-
</div>
8-
<a data-action="remove-file">Remove</a>
9-
{{/each}}
10-
{{else}}
11-
{{#if currentUpload}}
12-
{{#with currentUpload}}
13-
Uploading <b>{{file.name}}</b>:
14-
<span class="progress">{{progress}}%</span>
15-
{{/with}}
2+
<input value="{{fileId}}" type="hidden" {{this.atts}}>
3+
{{#if $gt uploadedFile.count 0}}
4+
{{#each uploadedFile}}
5+
<div>
6+
{{> uploadImageDemo}}
7+
</div>
8+
<a data-action="remove-file">Remove</a>
9+
{{/each}}
1610
{{else}}
17-
<input class="form-control af-file-upload-capture" type="file"/><!-- ability to add accept="image/*" capture="camera"-->
11+
{{#if currentUpload}}
12+
{{#with currentUpload}}
13+
Uploading <b>{{file.name}}</b>:
14+
<span class="progress">{{progress}}%</span>
15+
{{/with}}
16+
{{else}}
17+
<input class="form-control af-file-upload-capture" type="file"/>
18+
{{/if}}
1819
{{/if}}
19-
{{/if}}
2020
</template>

lib/client/fileUpload.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ Template.afFileUpload.onCreated(function () {
22
this.collectionName = () => this.data.atts.collection
33
this.fileId = new ReactiveVar(this.data.value);
44
this.currentUpload = new ReactiveVar(false);
5+
return;
56
});
67

7-
8-
98
Template.afFileUpload.helpers({
10-
currentUpload: function () {
9+
currentUpload() {
1110
return Template.instance().currentUpload.get();
1211
},
1312
fileId() {
@@ -23,29 +22,27 @@ Template.afFileUpload.helpers({
2322
Template.afFileUpload.events({
2423
'click [data-action="remove-file"]'(e, t) {
2524
t.fileId.set(false);
25+
return;
2626
},
27-
'change .af-file-upload-capture': function (e, template) {
27+
'change .af-file-upload-capture'(e, template) {
2828
if (e.currentTarget.files && e.currentTarget.files[0]) {
29-
// We upload only one file, in case
30-
// multiple files were selected
31-
var upload = global[template.collectionName()].insert({
29+
const upload = global[template.collectionName()].insert({
3230
file: e.currentTarget.files[0],
3331
streams: 'dynamic',
3432
chunkSize: 'dynamic'
3533
}, false);
3634

3735
upload.on('start', function () {
3836
template.currentUpload.set(this);
37+
return;
3938
});
4039

41-
upload.on('end', function (error, fileObj) {
42-
if (error) {
43-
//alert('Error during upload: ' + error);
44-
} else {
45-
//alert('File "' + fileObj.name + '" successfully uploaded');
40+
upload.on('end', (error, fileObj) => {
41+
if (!error) {
4642
template.fileId.set(fileObj._id);
4743
}
4844
template.currentUpload.set(false);
45+
return;
4946
});
5047

5148
upload.start();

lib/client/uploadImageDemo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<template name="uploadImageDemo">
2-
<img style="width:50%;" src="{{fileURL .}}"/>
2+
<img style="width:50%;" src="{{fileURL .}}"/>
33
</template>

package.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@ 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: "0.1.0",
5+
version: "1.0.0",
66
git: "https://github.com/VeliovGroup/meteor-autoform-file.git"
77
});
88

99
Package.onUse(function(api) {
10-
api.versionsFrom('METEOR@1.3');
10+
api.versionsFrom('METEOR@1.4');
1111

1212
api.use([
1313
'check',
1414
'underscore',
1515
'reactive-var',
1616
'templating',
17-
'less@1.0.0 || 2.5.1',
1817
'aldeed:autoform@5.8.0',
19-
'ostrio:files@1.5.6'
18+
'ostrio:files@1.6.9'
2019
]);
2120

2221
api.addFiles('lib/client/autoform.js', 'client');
2322
api.addFiles('lib/client/fileUpload.html', 'client');
2423
api.addFiles('lib/client/fileUpload.js', 'client');
25-
api.addFiles('lib/client/uploadImageDemo.html', 'client');
24+
api.addFiles('lib/client/uploadImageDemo.html', 'client');
2625
});

0 commit comments

Comments
 (0)