Aktualisiere Version auf 1.1.0, füge Unterstützung für verwaltete Metadatenkategorien hinzu und verbessere die Filterung in der Accordion-Komponente
This commit is contained in:
@@ -126,13 +126,18 @@ export default class AccordionWebPart extends BaseClientSideWebPart<IAccordionWe
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
const fieldOptions: IPropertyPaneDropdownOption[] = this.fields.map((field: IAccordionFieldOption): IPropertyPaneDropdownOption => ({
|
||||
const standardFields: IAccordionFieldOption[] = this.fields.filter((field: IAccordionFieldOption): boolean =>
|
||||
!this.isTaxonomyField(field));
|
||||
const fieldOptions: IPropertyPaneDropdownOption[] = standardFields.map((field: IAccordionFieldOption): IPropertyPaneDropdownOption => ({
|
||||
key: field.internalName, text: field.title + ' (' + field.internalName + ')'
|
||||
}));
|
||||
const categoryFieldOptions: IPropertyPaneDropdownOption[] = this.fields.map((field: IAccordionFieldOption): IPropertyPaneDropdownOption => ({
|
||||
key: field.internalName, text: field.title + ' (' + field.internalName + ')'
|
||||
}));
|
||||
const categoryOptions: IPropertyPaneDropdownOption[] = [{ key: '', text: strings.NoCategoryOption }];
|
||||
const categoryValueOptions: IPropertyPaneDropdownOption[] = [{ key: '', text: strings.AllCategoriesOption }];
|
||||
const listOptions: IPropertyPaneDropdownOption[] = [{ key: '', text: strings.SelectOption }];
|
||||
for (let i: number = 0; i < fieldOptions.length; i++) { categoryOptions.push(fieldOptions[i]); }
|
||||
for (let i: number = 0; i < categoryFieldOptions.length; i++) { categoryOptions.push(categoryFieldOptions[i]); }
|
||||
for (let i: number = 0; i < this.categories.length; i++) {
|
||||
categoryValueOptions.push({ key: this.categories[i], text: this.categories[i] });
|
||||
}
|
||||
@@ -247,26 +252,35 @@ export default class AccordionWebPart extends BaseClientSideWebPart<IAccordionWe
|
||||
}
|
||||
|
||||
private applyFieldDefaults(): void {
|
||||
const names: string[] = this.fields.map((field: IAccordionFieldOption): string => field.internalName);
|
||||
const standardFields: IAccordionFieldOption[] = this.fields.filter((field: IAccordionFieldOption): boolean =>
|
||||
!this.isTaxonomyField(field));
|
||||
const names: string[] = standardFields.map((field: IAccordionFieldOption): string => field.internalName);
|
||||
const categoryNames: string[] = this.fields.map((field: IAccordionFieldOption): string => field.internalName);
|
||||
if (names.indexOf(this.properties.titleField) < 0) {
|
||||
this.properties.titleField = names.indexOf('Title') >= 0 ? 'Title' : (names[0] || '');
|
||||
}
|
||||
if (names.indexOf(this.properties.contentField) < 0) {
|
||||
const note: IAccordionFieldOption = this.fields.filter((field: IAccordionFieldOption): boolean =>
|
||||
const note: IAccordionFieldOption = standardFields.filter((field: IAccordionFieldOption): boolean =>
|
||||
field.type === 'Note' && field.internalName !== this.properties.titleField)[0];
|
||||
this.properties.contentField = note ? note.internalName : this.firstDifferentField(this.properties.titleField);
|
||||
}
|
||||
if (names.indexOf(this.properties.categoryField) < 0) { this.properties.categoryField = ''; }
|
||||
if (categoryNames.indexOf(this.properties.categoryField) < 0) { this.properties.categoryField = ''; }
|
||||
if (names.indexOf(this.properties.sortField) < 0) { this.properties.sortField = this.properties.titleField; }
|
||||
}
|
||||
|
||||
private firstDifferentField(excluded: string): string {
|
||||
for (let i: number = 0; i < this.fields.length; i++) {
|
||||
if (this.fields[i].internalName !== excluded) { return this.fields[i].internalName; }
|
||||
if (this.fields[i].internalName !== excluded && !this.isTaxonomyField(this.fields[i])) {
|
||||
return this.fields[i].internalName;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private isTaxonomyField(field: IAccordionFieldOption): boolean {
|
||||
return field.type === 'TaxonomyFieldType' || field.type === 'TaxonomyFieldTypeMulti';
|
||||
}
|
||||
|
||||
private isConfigured(): boolean {
|
||||
return !!(this.service && this.properties.listId && this.properties.titleField && this.properties.contentField);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user