@@ -57,7 +57,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
57
57
* Update the item value on the field change
58
58
*/
59
59
private onValueChanged = ( fieldId : string , value : any ) : void => { // eslint-disable-line @typescript-eslint/no-explicit-any
60
-
60
+
61
61
this . setState ( ( prevState : ICollectionDataItemState ) : ICollectionDataItemState => {
62
62
const { crntItem } = prevState ;
63
63
// Update the changed field
@@ -78,7 +78,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
78
78
_selectedOption = {
79
79
key : value ,
80
80
text : value
81
- } ;
81
+ } ;
82
82
} else {
83
83
_selectedOption = option ;
84
84
}
@@ -92,8 +92,8 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
92
92
this . doAllFieldChecks ( ) ;
93
93
94
94
// Store this in the current state
95
-
96
- return { crntItem} ;
95
+
96
+ return { crntItem } ;
97
97
} ) ;
98
98
99
99
}
@@ -123,7 +123,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
123
123
} ;
124
124
}
125
125
126
- if ( _selected === null ) {
126
+ if ( _selected === null ) {
127
127
_selected = [ ] ;
128
128
}
129
129
@@ -144,7 +144,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
144
144
145
145
this . doAllFieldChecks ( ) ;
146
146
147
- return { crntItem} ;
147
+ return { crntItem } ;
148
148
} ) ;
149
149
}
150
150
@@ -351,7 +351,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
351
351
validation = await field . onGetErrorMessage ( value , this . props . index , item ) ;
352
352
isValid = validation === "" ;
353
353
} else if ( typeof field . minimumUsers === "number" && value . length < field . minimumUsers ) {
354
- validation = typeof field . minimumUsersMessage === "string" ? field . minimumUsersMessage : strings . CollectionDataMinimumUsersDefaultMessage . replace ( "{0}" , field . minimumUsers . toString ( ) ) ;
354
+ validation = typeof field . minimumUsersMessage === "string" ? field . minimumUsersMessage : strings . CollectionDataMinimumUsersDefaultMessage . replace ( "{0}" , field . minimumUsers . toString ( ) ) ;
355
355
}
356
356
357
357
// Store the field validation
@@ -361,14 +361,14 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
361
361
this . doAllFieldChecks ( ) ;
362
362
// Return empty the error message if needed
363
363
364
- return "" ;
364
+ return "" ;
365
365
}
366
366
367
367
private comboboxValidation = ( field : ICustomCollectionField , selected : string [ ] | string ) : void => {
368
368
let isValid = true ;
369
- let validation = "" ;
369
+ const validation = "" ;
370
370
371
- if ( field . required && ( selected === null || selected . length === 0 ) ) {
371
+ if ( field . required && ( selected === null || selected . length === 0 ) ) {
372
372
isValid = false ;
373
373
}
374
374
@@ -520,7 +520,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
520
520
value = { item [ field . id ] ? new Date ( item [ field . id ] ) : undefined }
521
521
onSelectDate = { ( date ) => { this . onValueChanged ( field . id , date ) } }
522
522
formatDate = { ( date ) => { return date ? date ?. toLocaleDateString ( ) : "" ; } }
523
- /> ;
523
+ /> ;
524
524
case CustomCollectionFieldType . custom :
525
525
if ( field . onCustomRender ) {
526
526
return field . onCustomRender ( field , item [ field . id ] , this . onValueChanged , item , item . uniqueId , this . onCustomFieldValidation ) ;
@@ -535,9 +535,9 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
535
535
if ( item [ field . id ] !== null ) {
536
536
for ( let i : number = 0 ; i < item [ field . id ] . length ; i ++ ) {
537
537
_selectedComboBoxKeys . push ( item [ field . id ] [ i ] . key ) ;
538
-
538
+
539
539
// if selected option is not in list (anymore), add it to choices
540
- if ( typeof _comboBoxOptions . find ( value => value . key === item [ field . id ] [ i ] . key ) === "undefined" ) {
540
+ if ( typeof _comboBoxOptions . find ( value => value . key === item [ field . id ] [ i ] . key ) === "undefined" ) {
541
541
_comboBoxOptions . push ( item [ field . id ] [ i ] ) ;
542
542
}
543
543
}
@@ -548,44 +548,48 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
548
548
if ( item [ field . id ] !== null ) {
549
549
_selectedComboBoxKey = item [ field . id ] . key ;
550
550
551
- if ( typeof _comboBoxOptions . find ( value => value . key === item [ field . id ] . key ) === "undefined" ) {
551
+ if ( typeof _comboBoxOptions . find ( value => value . key === item [ field . id ] . key ) === "undefined" ) {
552
552
_comboBoxOptions . push ( item [ field . id ] ) ;
553
553
}
554
554
555
555
}
556
-
556
+
557
557
}
558
558
559
- return < ComboBox
559
+ return < ComboBox
560
560
onFocus = { ( ) => this . comboboxValidation ( field , field . multiSelect ? _selectedComboBoxKeys : _selectedComboBoxKey ) }
561
561
onBlur = { ( ) => this . comboboxValidation ( field , field . multiSelect ? _selectedComboBoxKeys : _selectedComboBoxKey ) }
562
562
multiSelect = { field . multiSelect }
563
- allowFreeform = { field . allowFreeform }
563
+ allowFreeform = { field . allowFreeform }
564
564
placeholder = { field . placeholder }
565
565
options = { _comboBoxOptions }
566
- selectedKey = { field . multiSelect ? _selectedComboBoxKeys : _selectedComboBoxKey }
566
+ selectedKey = { field . multiSelect ? _selectedComboBoxKeys : _selectedComboBoxKey }
567
567
required = { field . required }
568
568
disabled = { disableFieldOnEdit }
569
- onChange = { async ( event , option , index , value ) => {
570
- field . multiSelect ? this . onValueChangedComboBoxMulti ( field . id , option , value ) : this . onValueChangedComboBoxSingle ( field . id , option , value )
571
- } }
572
-
569
+ onChange = { async ( event , option , index , value ) => {
570
+ if ( field . multiSelect ) {
571
+ this . onValueChangedComboBoxMulti ( field . id , option , value )
572
+ } else {
573
+ this . onValueChangedComboBoxSingle ( field . id , option , value )
574
+ }
575
+ } }
573
576
/> ;
574
- case CustomCollectionFieldType . peoplepicker :
575
- _selectedUsers = item [ field . id ] !== null ? item [ field . id ] : [ ] ;
577
+
578
+ case CustomCollectionFieldType . peoplepicker :
579
+ _selectedUsers = item [ field . id ] !== null ? item [ field . id ] : [ ] ;
576
580
577
- return < PeoplePicker
578
- peoplePickerCntrlclassName = { styles . peoplePicker }
579
- context = { this . props . context }
581
+ return < PeoplePicker
582
+ peoplePickerCntrlclassName = { styles . peoplePicker }
583
+ context = { this . props . context }
580
584
personSelectionLimit = { typeof field . maximumUsers === "number" ? field . maximumUsers : typeof field . multiSelect === "boolean" && field . multiSelect === false ? 1 : 99 }
581
585
principalTypes = { [ PrincipalType . User ] }
582
586
ensureUser = { true }
583
587
placeholder = { field . placeholder || field . title }
584
588
required = { field . required }
585
589
onChange = { ( items : IPersonaProps [ ] ) => {
586
- const _selected : string [ ] = items . length === 0 ? null : items . map ( ( { secondaryText} ) => secondaryText ) ;
587
- this . onValueChanged ( field . id , _selected )
588
- }
590
+ const _selected : string [ ] = items . length === 0 ? null : items . map ( ( { secondaryText } ) => secondaryText ) ;
591
+ this . onValueChanged ( field . id , _selected )
592
+ }
589
593
}
590
594
onGetErrorMessage = { async ( items : IPersonaProps [ ] ) => await this . peoplepickerValidation ( field , items , item ) }
591
595
@@ -600,7 +604,7 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
600
604
disabled = { disableFieldOnEdit }
601
605
onChange = { ( e , value ) => this . onValueChanged ( field . id , value ) }
602
606
deferredValidationTime = { field . deferredValidationTime || field . deferredValidationTime >= 0 ? field . deferredValidationTime : 200 }
603
- onGetErrorMessage = { async ( value : string ) => await this . fieldValidation ( field , value ) }
607
+ onGetErrorMessage = { async ( value : string ) => await this . fieldValidation ( field , value ) }
604
608
inputClassName = "PropertyFieldCollectionData__panel__string-field" /> ;
605
609
}
606
610
}
@@ -712,10 +716,10 @@ export class CollectionDataItem extends React.Component<ICollectionDataItemProps
712
716
< Icon iconName = "Clear" />
713
717
</ Link >
714
718
) : (
715
- < Link title = { strings . CollectionAddRowButtonLabel } className = { `${ this . disableAdd ( crntItem ) ? "" : styles . addBtn } ` } disabled = { this . disableAdd ( crntItem ) } onClick = { this . addRow } >
716
- < Icon iconName = "Add" />
717
- </ Link >
718
- )
719
+ < Link title = { strings . CollectionAddRowButtonLabel } className = { `${ this . disableAdd ( crntItem ) ? "" : styles . addBtn } ` } disabled = { this . disableAdd ( crntItem ) } onClick = { this . addRow } >
720
+ < Icon iconName = "Add" />
721
+ </ Link >
722
+ )
719
723
}
720
724
</ span >
721
725
</ div >
0 commit comments