updates to sorting on categories
This commit is contained in:
parent
68f4bf2cb3
commit
e286cfcbc0
|
@ -57,6 +57,7 @@ react-Faqs | [Arun Kumar Perumal](https://github.com/arunkumarperumal) - LinkedI
|
||||||
Version|Date|Comments
|
Version|Date|Comments
|
||||||
-------|----|--------
|
-------|----|--------
|
||||||
1.0|March 07, 2022|Initial release
|
1.0|March 07, 2022|Initial release
|
||||||
|
1.1|June 02, 2022|Updates to sorting on Categories
|
||||||
|
|
||||||
|
|
||||||
## Minimal path to awesome
|
## Minimal path to awesome
|
||||||
|
|
|
@ -2980,7 +2980,6 @@
|
||||||
"@types/adal-angular": "1.0.1",
|
"@types/adal-angular": "1.0.1",
|
||||||
"adal-angular": "1.0.16",
|
"adal-angular": "1.0.16",
|
||||||
"msal": "1.4.13",
|
"msal": "1.4.13",
|
||||||
"msalLegacy": "npm:msal@1.4.12",
|
|
||||||
"tslib": "~1.10.0"
|
"tslib": "~1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3099,7 +3098,6 @@
|
||||||
"@types/adal-angular": "1.0.1",
|
"@types/adal-angular": "1.0.1",
|
||||||
"adal-angular": "1.0.16",
|
"adal-angular": "1.0.16",
|
||||||
"msal": "1.4.13",
|
"msal": "1.4.13",
|
||||||
"msalLegacy": "npm:msal@1.4.12",
|
|
||||||
"tslib": "~1.10.0"
|
"tslib": "~1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -4014,7 +4012,6 @@
|
||||||
"@types/adal-angular": "1.0.1",
|
"@types/adal-angular": "1.0.1",
|
||||||
"adal-angular": "1.0.16",
|
"adal-angular": "1.0.16",
|
||||||
"msal": "1.4.13",
|
"msal": "1.4.13",
|
||||||
"msalLegacy": "npm:msal@1.4.12",
|
|
||||||
"tslib": "~1.10.0"
|
"tslib": "~1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -4396,7 +4393,6 @@
|
||||||
"@types/adal-angular": "1.0.1",
|
"@types/adal-angular": "1.0.1",
|
||||||
"adal-angular": "1.0.16",
|
"adal-angular": "1.0.16",
|
||||||
"msal": "1.4.13",
|
"msal": "1.4.13",
|
||||||
"msalLegacy": "npm:msal@1.4.12",
|
|
||||||
"tslib": "~1.10.0"
|
"tslib": "~1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -16314,14 +16310,6 @@
|
||||||
"tslib": "^1.9.3"
|
"tslib": "^1.9.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"msalLegacy": {
|
|
||||||
"version": "npm:msal@1.4.12",
|
|
||||||
"resolved": "https://registry.npmjs.org/msal/-/msal-1.4.12.tgz",
|
|
||||||
"integrity": "sha512-gjupwQ6nvNL6mZkl5NIXyUmZhTiEMRu5giNdgHMh8l5EPOnV2Xj6nukY1NIxFacSTkEYUSDB47Pej9GxDYf+1w==",
|
|
||||||
"requires": {
|
|
||||||
"tslib": "^1.9.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"multicast-dns": {
|
"multicast-dns": {
|
||||||
"version": "6.2.3",
|
"version": "6.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.3.tgz",
|
||||||
|
|
|
@ -73,6 +73,7 @@ export default class FaqsWebPart extends BaseClientSideWebPart<IFaqsWebPartProps
|
||||||
displayMode: this.displayMode,
|
displayMode: this.displayMode,
|
||||||
guid: this.guid,
|
guid: this.guid,
|
||||||
title: this.properties.title,
|
title: this.properties.title,
|
||||||
|
categoryData: this.properties.categoryData,
|
||||||
accordion:true,
|
accordion:true,
|
||||||
fUpdateProperty: (value: string) => {
|
fUpdateProperty: (value: string) => {
|
||||||
this.properties.title = value;
|
this.properties.title = value;
|
||||||
|
|
|
@ -114,7 +114,7 @@ export default class Accordions extends React.Component<IAccordionsProps, IAccor
|
||||||
|
|
||||||
|
|
||||||
public render(): React.ReactElement<IAccordionsProps> {
|
public render(): React.ReactElement<IAccordionsProps> {
|
||||||
const categoryNames = this.state.categories ? Object.keys(this.state.categories) : null;
|
const categoryNames = this.props.categoryData ? this.props.categoryData : null;
|
||||||
|
|
||||||
const searchCategoryNames = this.state.searchCategories ? Object.keys(this.state.searchCategories) : null;
|
const searchCategoryNames = this.state.searchCategories ? Object.keys(this.state.searchCategories) : null;
|
||||||
const searchValue = this.state.searchValue;
|
const searchValue = this.state.searchValue;
|
||||||
|
@ -169,13 +169,13 @@ export default class Accordions extends React.Component<IAccordionsProps, IAccor
|
||||||
<AccordionItemTitle className={styles.accordion__title} id={this.props.guid + '-title-' + index}>
|
<AccordionItemTitle className={styles.accordion__title} id={this.props.guid + '-title-' + index}>
|
||||||
<div className={styles.accordion__arrow} role="presentation" />
|
<div className={styles.accordion__arrow} role="presentation" />
|
||||||
<div className={styles["positionRelative"]} >
|
<div className={styles["positionRelative"]} >
|
||||||
{categoryName}
|
{categoryName.title}
|
||||||
</div>
|
</div>
|
||||||
</AccordionItemTitle>
|
</AccordionItemTitle>
|
||||||
<AccordionItemBody className={styles.accordion__body} hideBodyClassName={styles["accordionBodyHidden"]}>
|
<AccordionItemBody className={styles.accordion__body} hideBodyClassName={styles["accordionBodyHidden"]}>
|
||||||
{
|
{
|
||||||
// Loop over all links per group
|
// Loop over all links per group
|
||||||
this.state.categories[categoryName].map(faq => (
|
this.state.categories[categoryName.title].map(faq => (
|
||||||
|
|
||||||
<div className={styles.faqQuestionBlock}>
|
<div className={styles.faqQuestionBlock}>
|
||||||
<h2>{faq.questionTitle}</h2>
|
<h2>{faq.questionTitle}</h2>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import styles from './Faqs.module.scss';
|
||||||
import * as strings from 'FaqsWebPartStrings';
|
import * as strings from 'FaqsWebPartStrings';
|
||||||
import { IFaqsProps } from './IFaqsProps';
|
import { IFaqsProps } from './IFaqsProps';
|
||||||
import { IFaqsState } from './IFaqsState';
|
import { IFaqsState } from './IFaqsState';
|
||||||
import { escape, groupBy, toPairs, sortBy, fromPairs } from '@microsoft/sp-lodash-subset';
|
import { escape,find, groupBy, toPairs, sortBy, fromPairs } from '@microsoft/sp-lodash-subset';
|
||||||
import { Link } from 'office-ui-fabric-react/lib/components/Link';
|
import { Link } from 'office-ui-fabric-react/lib/components/Link';
|
||||||
import { WebPartTitle } from "@pnp/spfx-controls-react/lib/WebPartTitle";
|
import { WebPartTitle } from "@pnp/spfx-controls-react/lib/WebPartTitle";
|
||||||
import { Placeholder } from "@pnp/spfx-controls-react/lib/Placeholder";
|
import { Placeholder } from "@pnp/spfx-controls-react/lib/Placeholder";
|
||||||
|
@ -32,10 +32,13 @@ export default class Faqs extends React.Component<IFaqsProps, IFaqsState> {
|
||||||
private _processFaqs(): void {
|
private _processFaqs(): void {
|
||||||
const {collectionData} = this.props;
|
const {collectionData} = this.props;
|
||||||
if (collectionData && collectionData.length > 0) {
|
if (collectionData && collectionData.length > 0) {
|
||||||
|
|
||||||
|
|
||||||
// Group by the group name
|
// Group by the group name
|
||||||
let categories = groupBy(collectionData, Faq => Faq.category ? Faq.category : NO_CATEGORY_NAME);
|
let categories = groupBy(collectionData, Faq => Faq.category ? Faq.category : NO_CATEGORY_NAME);
|
||||||
// Sort the group by the property name
|
// Sort the group by the property name
|
||||||
categories = fromPairs(sortBy(toPairs(categories), 0));
|
categories = fromPairs(sortBy(toPairs(categories), 0));
|
||||||
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
categories
|
categories
|
||||||
|
@ -109,7 +112,7 @@ export default class Faqs extends React.Component<IFaqsProps, IFaqsState> {
|
||||||
public render(): React.ReactElement<IFaqsProps> {
|
public render(): React.ReactElement<IFaqsProps> {
|
||||||
|
|
||||||
// Get all group names
|
// Get all group names
|
||||||
const categoryNames = this.state.categories ? Object.keys(this.state.categories) : null;
|
const categoryNames = this.props.categoryData ? this.props.categoryData : null;
|
||||||
const searchCategoryNames = this.state.searchCategories ? Object.keys(this.state.searchCategories) : null;
|
const searchCategoryNames = this.state.searchCategories ? Object.keys(this.state.searchCategories) : null;
|
||||||
const searchValue = this.state.searchValue;
|
const searchValue = this.state.searchValue;
|
||||||
|
|
||||||
|
@ -160,11 +163,11 @@ export default class Faqs extends React.Component<IFaqsProps, IFaqsState> {
|
||||||
categories = <Pivot linkSize={PivotLinkSize.large} className={styles.faqContent}>
|
categories = <Pivot linkSize={PivotLinkSize.large} className={styles.faqContent}>
|
||||||
{
|
{
|
||||||
categoryNames.map(categoryName => (
|
categoryNames.map(categoryName => (
|
||||||
<PivotItem headerText={categoryName} key={categoryName}>
|
<PivotItem headerText={categoryName.title} key={categoryName.title}>
|
||||||
|
|
||||||
{
|
{
|
||||||
// Loop over all links per group
|
// Loop over all links per group
|
||||||
this.state.categories[categoryName].map(faq => (
|
this.state.categories[categoryName.title].map(faq => (
|
||||||
|
|
||||||
<div className={styles.faqQuestionBlock}>
|
<div className={styles.faqQuestionBlock}>
|
||||||
<h2>{faq.questionTitle}</h2>
|
<h2>{faq.questionTitle}</h2>
|
||||||
|
|
|
@ -5,7 +5,8 @@ export interface IAccordionsProps {
|
||||||
collectionData: IFaq[];
|
collectionData: IFaq[];
|
||||||
displayMode: DisplayMode;
|
displayMode: DisplayMode;
|
||||||
title: string;
|
title: string;
|
||||||
accordion: boolean;
|
accordion: boolean;
|
||||||
|
categoryData : any;
|
||||||
guid : string;
|
guid : string;
|
||||||
|
|
||||||
fUpdateProperty: (value: string) => void;
|
fUpdateProperty: (value: string) => void;
|
||||||
|
|
Loading…
Reference in New Issue