File tree Expand file tree Collapse file tree 4 files changed +64
-23
lines changed Expand file tree Collapse file tree 4 files changed +64
-23
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,9 @@ Schemas.Posts = new SimpleSchema({
4949 autoform: {
5050 afFieldInput: {
5151 type: ' fileUpload' ,
52- collection: ' Images'
52+ collection: ' Images' ,
53+ uploadTemplate: ' uploadField' // <- Optional
54+ previewTemplate: ' uploadPreview' // <- Optional
5355 }
5456 }
5557 }
@@ -96,12 +98,11 @@ Schemas.Posts = new SimpleSchema({
9698})
9799```
98100
99- ### Custom file preview /// need to work on this
101+ ### Custom file preview
100102
101103Your custom file preview template data context will be:
102104
103- - * file* - FS.File instance
104- - * atts* - autoform atts
105+ - * file* - fileObj instance
105106
106107``` javascript
107108picture: {
@@ -116,6 +117,28 @@ picture: {
116117}
117118```
118119
120+ ### Custom upload template
121+
122+ Your custom file upload template data context will be:
123+
124+ - * file* - FS.File instance
125+ - * progress*
126+ - * status*
127+ - Other fields from [ ` FileUpload ` instance] ( https://github.com/VeliovGroup/Meteor-Files/wiki/Insert-(Upload)#fileupload-methods-and-properties )
128+
129+ ``` javascript
130+ picture: {
131+ type: String ,
132+ autoform: {
133+ afFieldInput: {
134+ type: ' fileUpload' ,
135+ collection: ' Images' ,
136+ uploadTemplate: ' myFileUpload'
137+ }
138+ }
139+ }
140+ ```
141+
119142``` html
120143<template name =" myFilePreview" >
121144 <a href =" {{fileURL file}}" >{{file.original.name}}</a >
Original file line number Diff line number Diff line change 11< template name ="afFileUpload ">
22 < input value ="{{fileId}} " type ="hidden " {{this.atts}} >
33 {{#with uploadedFile}}
4- < div >
5- {{#if isImage}}
6- {{> uploadImageDemo}}
7- {{else}}
8- {{> uploadFileDemo}}
9- {{/if}}
10- </ div >
11- < a data-reset-file href ="# " style ="display:none "> Reset</ a >
12- < a data-remove-file href ="# "> Remove</ a >
4+ {{#if previewTemplate}}
5+ {{> Template.dynamic template=previewTemplate}}
6+ {{else}}
7+ < div >
8+ {{#if isImage}}
9+ {{> uploadImageDemo}}
10+ {{else}}
11+ {{> uploadFileDemo}}
12+ {{/if}}
13+ </ div >
14+ < a data-reset-file href ="# " style ="display:none "> Reset</ a >
15+ < a data-remove-file href ="# "> Remove</ a >
16+ {{/if}}
1317 {{else}}
14- {{#with currentUpload}}
15- Uploading < b > {{file.name}}</ b > :
16- < progress value ="{{progress.get}} " max ="100 "> </ progress >
17-
18- < span class ="progress "> {{progress.get}}%</ span >
18+ {{#if uploadTemplate}}
19+ {{> Template.dynamic template=uploadTemplate data=currentUpload}}
1920 {{else}}
20- < input data-files-collection-upload class ="form-control af-file-upload-capture " type ="file " />
21- {{/with}}
21+ {{#with currentUpload}}
22+ Uploading < b > {{file.name}}</ b > :
23+ < progress value ="{{progress.get}} " max ="100 "> </ progress >
24+
25+ < span class ="progress "> {{progress.get}}%</ span >
26+ {{else}}
27+ < input data-files-collection-upload class ="form-control af-file-upload-capture " type ="file " />
28+ {{/with}}
29+ {{/if}}
2230 {{/with}}
2331</ template >
Original file line number Diff line number Diff line change 11Template . afFileUpload . onCreated ( function ( ) {
22 var self = this ;
3+
34 if ( ! this . data ) {
45 this . data = {
56 atts : { }
67 } ;
78 }
89
9- this . collection = Meteor . connection . _mongo_livedata_collections [ this . data . atts . collection ] ;
10+ this . collection = Meteor . connection . _mongo_livedata_collections [ this . data . atts . collection ] ;
11+ this . uploadTemplate = this . data . atts . uploadTemplate || null ;
12+ this . previewTemplate = this . data . atts . previewTemplate || null ;
13+
1014 if ( ! this . collection ) {
1115 throw new Meteor . Error ( 404 , '[meteor-autoform-files] No such collection "' + this . data . atts . collection + '"' ) ;
1216 }
@@ -22,6 +26,12 @@ Template.afFileUpload.onCreated(function () {
2226} ) ;
2327
2428Template . afFileUpload . helpers ( {
29+ previewTemplate : function ( ) {
30+ return Template . instance ( ) . previewTemplate ;
31+ } ,
32+ uploadTemplate : function ( ) {
33+ return Template . instance ( ) . uploadTemplate ;
34+ } ,
2535 currentUpload : function ( ) {
2636 return Template . instance ( ) . currentUpload . get ( ) ;
2737 } ,
Original file line number Diff line number Diff 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.6 " ,
5+ version : "1.0.7 " ,
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.1' ,
18- 'ostrio:files@1.7.1 '
18+ 'ostrio:files@1.7.3 '
1919 ] ) ;
2020
2121 api . addFiles ( [
You can’t perform that action at this time.
0 commit comments