From 129b1d66a8c0cef4fcafcbbc3443e380d04f1337 Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Tue, 8 Aug 2023 10:22:11 +0300 Subject: [PATCH 1/5] adding document --- .../Angular/Ordering-Navigation-Elements.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 docs/en/UI/Angular/Ordering-Navigation-Elements.md diff --git a/docs/en/UI/Angular/Ordering-Navigation-Elements.md b/docs/en/UI/Angular/Ordering-Navigation-Elements.md new file mode 100644 index 0000000000..96a0ccbdb5 --- /dev/null +++ b/docs/en/UI/Angular/Ordering-Navigation-Elements.md @@ -0,0 +1,46 @@ + +# Sorting Navigation Elements + +When you want to add `Navigation Element` you can use `RoutesService`. For more info [click here](https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu#how-to-add-a-navigation-element). +However, in this documentation, we will talk more about how to sort navigation items via the `Routes Service` `order` attribute. + + +### Order Property +- This parameter is optional and used for sorting purposes. +- If you define this property it will be sorted by default sorting function. +- You can edit this function. + +**Default Compare Function;** +``compare-func.token.ts`` +```ts +export const SORT_COMPARE_FUNC = new InjectionToken<0 | 1 | -1>('SORT_COMPARE_FUNC'); + +export function compareFuncFactory() { + const localizationService = inject(LocalizationService); + const fn = (a,b) => { + const aName = localizationService.instant(a.name); + const bName = localizationService.instant(b.name); + + const aNumber = a.order; + const bNumber = b.order; + + if (!Number.isInteger(aNumber)) return 1; + if (!Number.isInteger(bNumber)) return -1; + + if (aNumber > bNumber) return 1 + if (aNumber < bNumber) return -1 + + if (aName > bName ) return 1; + if (aName < bName ) return -1; + + return 0 + } + return fn; +} +``` +**What this function do?** +- if order property defined, then it will be sorted by order value. +- if both navigation element has same order value then it will be sorted by name. +- If order property is not defined, it will be last element and sort by name between unordered navs. + +You can edit this sorting function behaviour as you wish. \ No newline at end of file From 7fbeef29acf9f746a194da41869078d5c7874975 Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Tue, 8 Aug 2023 10:31:21 +0300 Subject: [PATCH 2/5] change file name --- ...ring-Navigation-Elements.md => Sorting-Navigation-Elements.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/en/UI/Angular/{Ordering-Navigation-Elements.md => Sorting-Navigation-Elements.md} (100%) diff --git a/docs/en/UI/Angular/Ordering-Navigation-Elements.md b/docs/en/UI/Angular/Sorting-Navigation-Elements.md similarity index 100% rename from docs/en/UI/Angular/Ordering-Navigation-Elements.md rename to docs/en/UI/Angular/Sorting-Navigation-Elements.md From 9374dd4d03064b2e8c4c731a278260cada5f0f47 Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Tue, 8 Aug 2023 10:39:05 +0300 Subject: [PATCH 3/5] update --- docs/en/UI/Angular/Sorting-Navigation-Elements.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/UI/Angular/Sorting-Navigation-Elements.md b/docs/en/UI/Angular/Sorting-Navigation-Elements.md index 96a0ccbdb5..e43de96993 100644 --- a/docs/en/UI/Angular/Sorting-Navigation-Elements.md +++ b/docs/en/UI/Angular/Sorting-Navigation-Elements.md @@ -1,8 +1,8 @@ - # Sorting Navigation Elements +This documentation is describing how navigation elements sorted and how you can change this default behaviour. When you want to add `Navigation Element` you can use `RoutesService`. For more info [click here](https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu#how-to-add-a-navigation-element). -However, in this documentation, we will talk more about how to sort navigation items via the `Routes Service` `order` attribute. +However, in this documentation, we will talk more about how to sort navigation elements via the `Routes Service` `order` attribute. ### Order Property From 2b1e1ee7ee0bed22eb856ec350885f417590fafc Mon Sep 17 00:00:00 2001 From: Sinan997 Date: Fri, 11 Aug 2023 15:59:33 +0300 Subject: [PATCH 4/5] sort navigation elements doc added to ui/angular/customization --- docs/en/docs-nav.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 08046fa664..afdf89657c 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -1188,6 +1188,10 @@ "text": "Modifying the Menu", "path": "UI/Angular/Modifying-the-Menu.md" }, + { + "text": "Sorting Navigation Elements", + "path": "UI/Angular/Sorting-Navigation-Elements.md" + }, { "text": "Component Replacement", "path": "UI/Angular/Component-Replacement.md" From 35fddf6da1aeb487478ea04d7145302a094eb860 Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:21:30 +0300 Subject: [PATCH 5/5] Update Sorting-Navigation-Elements.md --- .../UI/Angular/Sorting-Navigation-Elements.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/en/UI/Angular/Sorting-Navigation-Elements.md b/docs/en/UI/Angular/Sorting-Navigation-Elements.md index e43de96993..3eac9901d6 100644 --- a/docs/en/UI/Angular/Sorting-Navigation-Elements.md +++ b/docs/en/UI/Angular/Sorting-Navigation-Elements.md @@ -1,13 +1,13 @@ # Sorting Navigation Elements -This documentation is describing how navigation elements sorted and how you can change this default behaviour. +This documentation describes how the navigation elements are sorted and how to change this default behaviour. -When you want to add `Navigation Element` you can use `RoutesService`. For more info [click here](https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu#how-to-add-a-navigation-element). -However, in this documentation, we will talk more about how to sort navigation elements via the `Routes Service` `order` attribute. +When you want to add the `Navigation Element` you can use the `RoutesService`. For more details, see the [document](https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu#how-to-add-a-navigation-element). +However, in this documentation, we will talk more about how to sort the navigation elements with the `order` attribute from the `Routes Service`. ### Order Property -- This parameter is optional and used for sorting purposes. -- If you define this property it will be sorted by default sorting function. +- This parameter is optional and is used for sorting purposes. +- If you define this property it will be sorted by the default sorting function. - You can edit this function. **Default Compare Function;** @@ -38,9 +38,9 @@ export function compareFuncFactory() { return fn; } ``` -**What this function do?** -- if order property defined, then it will be sorted by order value. -- if both navigation element has same order value then it will be sorted by name. -- If order property is not defined, it will be last element and sort by name between unordered navs. +**What does this function do?** +- if the order property is defined, then it will be sorted by the order value. +- if both of the navigation elements have the same order value then it will be sorted by the name. +- If the order property is not defined, it will be the last element and the unordered navs will be sorted by name. -You can edit this sorting function behaviour as you wish. \ No newline at end of file +You can edit this sorting function behaviour as you wish.