Skip to content

Commit c9099c6

Browse files
committed
Merge branch 'SmarterJB-feature/use_anchorId_from_taxonomyfield_in_dynamicform' into dev
2 parents b48bfeb + a208dd9 commit c9099c6

File tree

5 files changed

+31
-39
lines changed

5 files changed

+31
-39
lines changed

src/controls/dynamicForm/DynamicForm.tsx

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
376376
field.order = order;
377377
let hiddenName = "";
378378
let termSetId = "";
379+
let anchorId = "";
379380
let lookupListId = "";
380381
let lookupField = "";
381382
const choices: IDropdownOption[] = [];
@@ -386,83 +387,74 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
386387
let principalType = "";
387388
if (item !== null) {
388389
defaultValue = item[field.EntityPropertyName];
389-
}
390-
else {
390+
} else {
391391
defaultValue = field.DefaultValue;
392392
}
393393
if (fieldType === 'Choice' || fieldType === 'MultiChoice') {
394394
field.Choices.forEach(element => {
395-
choices.push({ key: element, text: element });
395+
choices.push({key: element, text: element});
396396
});
397-
}
398-
else if (fieldType === "Note") {
397+
} else if (fieldType === "Note") {
399398
richText = field.RichText;
400-
}
401-
else if (fieldType === "Lookup") {
399+
} else if (fieldType === "Lookup") {
402400
lookupListId = field.LookupList;
403401
lookupField = field.LookupField;
404402
if (item !== null) {
405403
defaultValue = await this._spService.getLookupValue(listId, listItemId, field.EntityPropertyName, lookupField, this.webURL);
406-
}
407-
else {
404+
} else {
408405
defaultValue = [];
409406
}
410407

411-
}
412-
else if (fieldType === "LookupMulti") {
408+
} else if (fieldType === "LookupMulti") {
413409
lookupListId = field.LookupList;
414410
lookupField = field.LookupField;
415411
if (item !== null) {
416412
defaultValue = await this._spService.getLookupValues(listId, listItemId, field.EntityPropertyName, lookupField, this.webURL);
417-
}
418-
else {
413+
} else {
419414
defaultValue = [];
420415
}
421-
}
422-
else if (fieldType === "TaxonomyFieldTypeMulti") {
416+
} else if (fieldType === "TaxonomyFieldTypeMulti") {
423417
const response = await this._spService.getTaxonomyFieldInternalName(this.props.listId, field.InternalName, this.webURL);
424418
hiddenName = response.value;
425419
termSetId = field.TermSetId;
420+
anchorId = field.AnchorId;
426421
if (item !== null) {
427422
item[field.InternalName].forEach(element => {
428-
selectedTags.push({ key: element.TermGuid, name: element.Label });
423+
selectedTags.push({key: element.TermGuid, name: element.Label});
429424
});
430425

431426
defaultValue = selectedTags;
432-
}
433-
else {
427+
} else {
434428
if (defaultValue !== "") {
435429
defaultValue.split(/#|;/).forEach(element => {
436430
if (element.indexOf('|') !== -1)
437-
selectedTags.push({ key: element.split('|')[1], name: element.split('|')[0] });
431+
selectedTags.push({key: element.split('|')[1], name: element.split('|')[0]});
438432
});
439433

440434
defaultValue = selectedTags;
441435
}
442436
}
443437
if (defaultValue === "")
444438
defaultValue = null;
445-
}
446-
else if (fieldType === "TaxonomyFieldType") {
439+
} else if (fieldType === "TaxonomyFieldType") {
447440

448441
termSetId = field.TermSetId;
442+
anchorId = field.AnchorId;
449443
if (item !== null) {
450444
const response = await this._spService.getSingleManagedMtadataLabel(listId, listItemId, field.InternalName);
451445
if (response) {
452-
selectedTags.push({ key: response.TermID, name: response.Label });
446+
selectedTags.push({key: response.TermID, name: response.Label});
453447
defaultValue = selectedTags;
454448
}
455-
}
456-
else {
449+
} else {
457450
if (defaultValue !== "") {
458-
selectedTags.push({ key: defaultValue.split('|')[1], name: defaultValue.split('|')[0].split('#')[1] });
451+
selectedTags.push({key: defaultValue.split('|')[1], name: defaultValue.split('|')[0].split('#')[1]});
459452
defaultValue = selectedTags;
460453
}
461454
}
462455
if (defaultValue === "")
463456
defaultValue = null;
464-
}
465-
else if (fieldType === "DateTime") {
457+
} else if (fieldType === "DateTime") {
466458
if (item !== null && item[field.InternalName])
467459
defaultValue = new Date(item[field.InternalName]);
468460
else if (defaultValue === '[today]') {
@@ -482,34 +474,30 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
482474
}
483475
principalType = field.SchemaXml.split('UserSelectionMode="')[1];
484476
principalType = principalType.substring(0, principalType.indexOf('"'));
485-
}
486-
else if (fieldType === "Thumbnail") {
477+
} else if (fieldType === "Thumbnail") {
487478
if (defaultValue !== null) {
488479
defaultValue = this.webURL.split('/sites/')[0] + JSON.parse(defaultValue).serverRelativeUrl;
489480
}
490-
}
491-
else if (fieldType === "User") {
481+
} else if (fieldType === "User") {
492482
if (item !== null) {
493483
const userEmails: string[] = [];
494484
userEmails.push(await this._spService.getUserUPNFromFieldValue(listId, listItemId, field.InternalName, this.webURL) + '');
495485
defaultValue = userEmails;
496-
}
497-
else {
486+
} else {
498487
defaultValue = [];
499488
}
500489
principalType = field.SchemaXml.split('UserSelectionMode="')[1];
501490
principalType = principalType.substring(0, principalType.indexOf('"'));
502-
}
503-
else if (fieldType === "Location") {
491+
} else if (fieldType === "Location") {
504492
defaultValue = JSON.parse(defaultValue);
505-
}
506-
else if (fieldType === "Boolean") {
493+
} else if (fieldType === "Boolean") {
507494
defaultValue = Boolean(Number(defaultValue));
508495
}
509496

510497
tempFields.push({
511498
newValue: null,
512499
fieldTermSetId: termSetId,
500+
fieldAnchorId: anchorId,
513501
options: choices,
514502
lookupListID: lookupListId,
515503
lookupField: lookupField,

src/controls/dynamicForm/dynamicField/DynamicField.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
5959
const {
6060
options,
6161
fieldTermSetId,
62+
fieldAnchorId,
6263
lookupListID,
6364
lookupField,
6465
fieldType,
@@ -473,6 +474,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
473474
placeholder={placeholder}
474475
allowMultipleSelections={true}
475476
termsetNameOrID={fieldTermSetId}
477+
anchorId={fieldAnchorId}
476478
panelTitle={strings.DynamicFormTermPanelTitle}
477479
context={context}
478480
onChange={(newValue?: IPickerTerms) => { this.onChange(newValue); }}
@@ -497,6 +499,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
497499
placeholder={placeholder}
498500
allowMultipleSelections={false}
499501
termsetNameOrID={fieldTermSetId}
502+
anchorId={fieldAnchorId}
500503
panelTitle={strings.DynamicFormTermPanelTitle}
501504
context={context}
502505
onChange={(newValue?: IPickerTerms) => { this.onChange(newValue); }}

src/controls/dynamicForm/dynamicField/IDynamicFieldProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface IDynamicFieldProps {
2222
fieldDefaultValue: any; // eslint-disable-line @typescript-eslint/no-explicit-any
2323
options?: IDropdownOption[];
2424
fieldTermSetId?: string;
25+
fieldAnchorId?: string;
2526
lookupListID?: string;
2627
lookupField?: string;
2728
changedValue: any; // eslint-disable-line @typescript-eslint/no-explicit-any

src/loc/de-de.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ define([], () => {
359359
"DynamicFormLoading": "Laden...",
360360
"DynamicFormPleaseWait": "Bitte warten...",
361361
"DynamicFormRequiredErrorMessage": "Sie können dieses Feld nicht leer lassen.",
362-
"DynamicFormTermPanelTitle": "Laufzeit auswählen",
362+
"DynamicFormTermPanelTitle": "Knoten auswählen",
363363
"DynamicFormEnterURLPlaceholder": "Geben Sie eine URL ein",
364364
"DynamicFormEnterDescriptionPlaceholder": "Alternativtext",
365365
"customDisplayName": "Verwenden Sie diesen Speicherort:",

src/services/SPTermStorePickerService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class SPTermStorePickerService {
2929
*/
3030
constructor(private props: ITaxonomyPickerProps, private context: BaseComponentContext) {
3131
this.clientServiceUrl = this.context.pageContext.web.absoluteUrl + '/_vti_bin/client.svc/ProcessQuery';
32-
this.suggestionServiceUrl = this.context.pageContext.web.absoluteUrl + "/_vti_bin/TaxonomyInternalService.json/GetSuggestions";
32+
this.suggestionServiceUrl = this.context.pageContext.web.absoluteUrl + '/_vti_bin/TaxonomyInternalService.json/GetSuggestions';
3333
}
3434

3535
public async getTermLabels(termId: string): Promise<string[]> {

0 commit comments

Comments
 (0)