@@ -7,12 +7,18 @@ var BrowserWindow = remote.require('browser-window');
77var format = require ( 'util' ) . format ;
88var bindings = require ( 'ampersand-dom-bindings' ) ;
99var fileReaderTemplate = require ( './filereader-default.jade' ) ;
10+ var assert = require ( 'assert' ) ;
1011
1112// var debug = require('debug')('scout:connect:filereader-view');
1213
1314module . exports = InputView . extend ( {
1415 template : fileReaderTemplate ,
1516 props : {
17+ multi : {
18+ type : 'boolean' ,
19+ required : true ,
20+ default : false
21+ } ,
1622 inputValue : {
1723 type : 'array' ,
1824 required : true ,
@@ -31,10 +37,11 @@ module.exports = InputView.extend({
3137 deps : [ 'inputValue' ] ,
3238 fn : function ( ) {
3339 if ( this . inputValue . length === 0 ) {
34- return 'Choose certificate (s)' ;
40+ return this . multi ? 'Choose file (s)' : 'Choose file ';
3541 } else if ( this . inputValue . length === 1 ) {
3642 return path . basename ( this . inputValue [ 0 ] ) ;
3743 }
44+ assert . equal ( this . multi , true ) ;
3845 return format ( '%d files selected' , this . inputValue . length ) ;
3946 }
4047 } ,
@@ -78,6 +85,9 @@ module.exports = InputView.extend({
7885 */
7986 initialize : function ( spec ) {
8087 spec = spec || { } ;
88+ if ( spec . multi ) {
89+ this . multi = spec . multi ;
90+ }
8191 _ . defaults ( spec , { value : [ ] } ) ;
8292 this . invalidClass = 'has-error' ;
8393 this . validityClassSelector = '.form-item-file' ;
@@ -173,8 +183,12 @@ module.exports = InputView.extend({
173183 this . runTests ( ) ;
174184 } ,
175185 loadFileButtonClicked : function ( ) {
186+ var properties = [ 'openFile' ] ;
187+ if ( this . multi ) {
188+ properties . push ( 'multiSelections' ) ;
189+ }
176190 dialog . showOpenDialog ( BrowserWindow . getFocusedWindow ( ) , {
177- properties : [ 'openFile' , 'multiSelections' ]
191+ properties : properties
178192 } , function ( filenames ) {
179193 this . inputValue = filenames || [ ] ;
180194 this . handleChange ( ) ;
0 commit comments