@@ -95,26 +95,39 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
95
95
}
96
96
}
97
97
98
- /**
99
- * it checks, if all entries still exist in term store. if allowMultipleSelections is true. it have to validate all values
100
- */
101
- private async validateTerms ( ) {
102
- let isValidateOnLoad = this . props . validateOnLoad && this . props . initialValues != null && this . props . initialValues . length >= 1 ;
98
+ /**
99
+ * it checks, if all entries still exist in term store. if allowMultipleSelections is true. it have to validate all values
100
+ */
101
+ private async validateTerms ( ) : Promise < void > {
102
+
103
+ const {
104
+ hideDeprecatedTags,
105
+ hideTagsNotAvailableForTagging,
106
+ initialValues,
107
+ validateOnLoad,
108
+ termsetNameOrID
109
+ } = this . props ;
110
+
111
+ let isValidateOnLoad = validateOnLoad && initialValues && initialValues . length >= 1 ;
103
112
if ( isValidateOnLoad ) {
104
- this . props . initialValues . forEach ( async pickerTerm => {
105
- if ( pickerTerm . termSet == null ) {
106
- return ;
113
+
114
+ let notFoundTerms : string [ ] = [ ] ;
115
+ const termSet = await this . termsService . getAllTerms ( termsetNameOrID , hideDeprecatedTags , hideTagsNotAvailableForTagging ) ;
116
+ const allTerms = termSet . Terms ;
117
+
118
+ for ( let i = 0 , len = initialValues . length ; i < len ; i ++ ) {
119
+ const pickerTerm = initialValues [ i ] ;
120
+
121
+ if ( ! allTerms . filter ( t => t . Id === pickerTerm . key ) . length ) {
122
+ notFoundTerms . push ( pickerTerm . name ) ;
107
123
}
124
+ }
108
125
109
- this . termsService . getAllTerms ( pickerTerm . termSet , this . props . hideDeprecatedTags , this . props . hideTagsNotAvailableForTagging ) . then ( ( response : ITermSet ) => {
110
- let selectedTerms = response ? response : null ;
111
- if ( selectedTerms == null ) {
112
- this . setState ( {
113
- errorMessage : `The selected term '${ pickerTerm . name } ' could not be found in term store.`
114
- } ) ;
115
- }
126
+ if ( notFoundTerms . length ) {
127
+ this . setState ( {
128
+ internalErrorMessage : strings . TaxonomyPickerTermsNotFound . replace ( '{0}' , notFoundTerms . join ( ', ' ) )
116
129
} ) ;
117
- } ) ;
130
+ }
118
131
}
119
132
}
120
133
@@ -365,6 +378,7 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
365
378
const {
366
379
activeNodes,
367
380
errorMessage,
381
+ internalErrorMessage,
368
382
openPanel,
369
383
loaded,
370
384
termSetAndTerms
@@ -392,7 +406,7 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
392
406
</ div >
393
407
</ div >
394
408
395
- < FieldErrorMessage errorMessage = { errorMessage } />
409
+ < FieldErrorMessage errorMessage = { errorMessage || internalErrorMessage } />
396
410
397
411
< Panel
398
412
isOpen = { openPanel }
0 commit comments