@@ -82,13 +82,13 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
8282
8383 < div part ="row ">
8484 < div part ="info ">
85- < div part ="done-icon " hidden$ ="[[!file. complete]] " aria-hidden ="true "> </ div >
86- < div part ="warning-icon " hidden$ ="[[!file.error ]] " aria-hidden ="true "> </ div >
85+ < div part ="done-icon " hidden$ ="[[!complete]] " aria-hidden ="true "> </ div >
86+ < div part ="warning-icon " hidden$ ="[[!errorMessage ]] " aria-hidden ="true "> </ div >
8787
8888 < div part ="meta ">
89- < div part ="name " id ="name "> [[file.name ]]</ div >
90- < div part ="status " hidden$ ="[[!file. status]] " id ="status "> [[file. status]]</ div >
91- < div part ="error " id ="error " hidden$ ="[[!file.error ]] "> [[file.error ]]</ div >
89+ < div part ="name " id ="name "> [[fileName ]]</ div >
90+ < div part ="status " hidden$ ="[[!status]] " id ="status "> [[status]]</ div >
91+ < div part ="error " id ="error " hidden$ ="[[!errorMessage ]] "> [[errorMessage ]]</ div >
9292 </ div >
9393 </ div >
9494 < div part ="commands ">
@@ -97,7 +97,7 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
9797 part ="start-button "
9898 file-event ="file-start "
9999 on-click ="_fireFileEvent "
100- hidden$ ="[[!file. held]] "
100+ hidden$ ="[[!held]] "
101101 aria-label$ ="[[i18n.file.start]] "
102102 aria-describedby ="name "
103103 > </ button >
@@ -106,7 +106,7 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
106106 part ="retry-button "
107107 file-event ="file-retry "
108108 on-click ="_fireFileEvent "
109- hidden$ ="[[!file.error ]] "
109+ hidden$ ="[[!errorMessage ]] "
110110 aria-label$ ="[[i18n.file.retry]] "
111111 aria-describedby ="name "
112112 > </ button >
@@ -131,9 +131,75 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
131131
132132 static get properties ( ) {
133133 return {
134- file : Object ,
134+ /**
135+ * True if uploading is completed, false otherwise.
136+ */
137+ complete : {
138+ type : Boolean ,
139+ value : false ,
140+ reflectToAttribute : true ,
141+ } ,
142+
143+ /**
144+ * Error message returned by the server, if any.
145+ */
146+ errorMessage : {
147+ type : String ,
148+ value : '' ,
149+ observer : '_errorMessageChanged' ,
150+ } ,
151+
152+ /**
153+ * The object representing a file.
154+ */
155+ file : {
156+ type : Object ,
157+ } ,
158+
159+ /**
160+ * Name of the uploading file.
161+ */
162+ fileName : {
163+ type : String ,
164+ } ,
165+
166+ /**
167+ * True if uploading is not started, false otherwise.
168+ */
169+ held : {
170+ type : Boolean ,
171+ value : false ,
172+ } ,
173+
174+ /**
175+ * True if remaining time is unknown, false otherwise.
176+ */
177+ indeterminate : {
178+ type : Boolean ,
179+ value : false ,
180+ reflectToAttribute : true ,
181+ } ,
135182
136- i18n : Object ,
183+ /**
184+ * The object used to localize this component.
185+ */
186+ i18n : {
187+ type : Object ,
188+ } ,
189+
190+ /**
191+ * Number representing the uploading progress.
192+ */
193+ progress : {
194+ type : Number ,
195+ } ,
196+
197+ /**
198+ * Uploading status.
199+ */
200+ status : {
201+ type : String ,
202+ } ,
137203
138204 /**
139205 * Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
@@ -145,6 +211,15 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
145211 reflectToAttribute : true ,
146212 } ,
147213
214+ /**
215+ * True if uploading is in progress, false otherwise.
216+ */
217+ uploading : {
218+ type : Boolean ,
219+ value : false ,
220+ reflectToAttribute : true ,
221+ } ,
222+
148223 /** @private */
149224 _progress : {
150225 type : Object ,
@@ -153,13 +228,7 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
153228 }
154229
155230 static get observers ( ) {
156- return [
157- '_toggleHostAttribute(file.error, "error")' ,
158- '_toggleHostAttribute(file.indeterminate, "indeterminate")' ,
159- '_toggleHostAttribute(file.uploading, "uploading")' ,
160- '_toggleHostAttribute(file.complete, "complete")' ,
161- '__updateProgress(_progress, file.progress, file.indeterminate)' ,
162- ] ;
231+ return [ '__updateProgress(_progress, progress, indeterminate)' ] ;
163232 }
164233
165234 /** @protected */
@@ -205,6 +274,11 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
205274 return event . composedPath ( ) [ 0 ] === this ;
206275 }
207276
277+ /** @private */
278+ _errorMessageChanged ( errorMessage ) {
279+ this . toggleAttribute ( 'error' , Boolean ( errorMessage ) ) ;
280+ }
281+
208282 /** @private */
209283 __updateProgress ( progress , value , indeterminate ) {
210284 if ( progress ) {
@@ -225,19 +299,6 @@ class UploadFile extends FocusMixin(ThemableMixin(ControllerMixin(PolymerElement
225299 ) ;
226300 }
227301
228- /** @private */
229- _toggleHostAttribute ( value , attributeName ) {
230- const shouldHave = Boolean ( value ) ;
231- const has = this . hasAttribute ( attributeName ) ;
232- if ( has !== shouldHave ) {
233- if ( shouldHave ) {
234- this . setAttribute ( attributeName , '' ) ;
235- } else {
236- this . removeAttribute ( attributeName ) ;
237- }
238- }
239- }
240-
241302 /**
242303 * Fired when the retry button is pressed. It is listened by `vaadin-upload`
243304 * which will start a new upload process of this file.
0 commit comments