1616
1717import FormFieldBase from "./FormFieldBase.js" ;
1818
19- /**
20- * Class representing components based on FileInput.
21- * @extends module:FormView~FormFileInput
22- */
23- class FormFileInput extends FormFieldBase {
2419
25- constructor ( params ) {
26- super ( params ) ;
27- }
20+ /**
21+ * @module FormView
22+ */
2823
29- setModel ( model ) {
30- super . setModel ( model ) ;
31- if ( this . widgetObject == null ) {
32- this . widgetObject = new FileInputWidget ( this . widgetFields ) ;
33- }
34- }
24+ /**
25+ * Class representing components based on FileInput.
26+ * @extends module:FormView~FormFieldBase
27+ */
28+ class FormFileInput extends FormFieldBase {
3529
36- updateValue ( value ) {
37- if ( this . widgetObject == null ) {
38- this . widgetObject = new FileInputWidget ( this . widgetFields ) ;
39- }
40- this . widgetObject . setValue ( value ) ;
41- super . updateEmptyStatus ( ) ;
30+ constructor ( params ) {
31+ super ( params ) ;
32+ }
33+
34+ setModel ( model ) {
35+ super . setModel ( model ) ;
36+ if ( this . widgetObject == null ) {
37+ this . widgetObject = new FileInputWidget ( this . widgetFields ) ;
4238 }
39+ }
4340
44- syncWidget ( ) {
45- let widgetElement = this . getWidget ? this . getWidget ( ) : null ;
46- if ( widgetElement ) {
47- widgetElement . id = this . getId ( ) + "__widget" ;
48- this . getAttachButtonLabel ( ) . setAttribute ( 'for' , this . getId ( ) + "__widget" ) ;
49- }
41+ updateValue ( value ) {
42+ if ( this . widgetObject == null ) {
43+ this . widgetObject = new FileInputWidget ( this . widgetFields ) ;
5044 }
45+ this . widgetObject . setValue ( value ) ;
46+ super . updateEmptyStatus ( ) ;
47+ }
5148
52- /*
53- We are overriding the syncLabel method of the FormFieldBase class because for all components,
54- we pass the widgetId in 'for' attribute. However, for the file input component,
55- we already have a widget, so we should not pass the widgetId twice
56- */
57- syncLabel ( ) {
58- let labelElement = typeof this . getLabel === 'function' ? this . getLabel ( ) : null ;
59- if ( labelElement ) {
60- labelElement . setAttribute ( 'for' , this . getId ( ) ) ;
61- }
49+ syncWidget ( ) {
50+ let widgetElement = this . getWidget ? this . getWidget ( ) : null ;
51+ if ( widgetElement ) {
52+ widgetElement . id = this . getId ( ) + "__widget" ;
53+ this . getAttachButtonLabel ( ) . setAttribute ( 'for' , this . getId ( ) + "__widget" ) ;
6254 }
55+ }
6356
64- syncMarkupWithModel ( ) {
65- super . syncMarkupWithModel ( ) ;
66- this . syncWidget ( ) ;
67- this . syncLabel ( ) ;
57+ /*
58+ We are overriding the syncLabel method of the FormFieldBase class because for all components,
59+ we pass the widgetId in 'for' attribute. However, for the file input component,
60+ we already have a widget, so we should not pass the widgetId twice
61+ */
62+ syncLabel ( ) {
63+ let labelElement = typeof this . getLabel === 'function' ? this . getLabel ( ) : null ;
64+ if ( labelElement ) {
65+ labelElement . setAttribute ( 'for' , this . getId ( ) ) ;
6866 }
6967 }
68+
69+ syncMarkupWithModel ( ) {
70+ super . syncMarkupWithModel ( ) ;
71+ this . syncWidget ( ) ;
72+ this . syncLabel ( ) ;
73+ }
74+ }
7075
7176export default FormFileInput ;
0 commit comments