mirror of https://github.com/Lissy93/dashy.git
✨ Implements optional alphabetical sort for sections
This commit is contained in:
parent
a66636bde8
commit
48533f397a
|
@ -17,7 +17,7 @@
|
||||||
:style="gridStyle"
|
:style="gridStyle"
|
||||||
>
|
>
|
||||||
<Item
|
<Item
|
||||||
v-for="(item, index) in items"
|
v-for="(item, index) in sortedItems"
|
||||||
:id="`${index}_${makeId(item.title)}`"
|
:id="`${index}_${makeId(item.title)}`"
|
||||||
:key="`${index}_${makeId(item.title)}`"
|
:key="`${index}_${makeId(item.title)}`"
|
||||||
:url="item.url"
|
:url="item.url"
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { sortOrder as defaultSortOrder } from '@/utils/defaults';
|
||||||
import Item from '@/components/LinkItems/Item.vue';
|
import Item from '@/components/LinkItems/Item.vue';
|
||||||
import Collapsable from '@/components/LinkItems/Collapsable.vue';
|
import Collapsable from '@/components/LinkItems/Collapsable.vue';
|
||||||
import IframeModal from '@/components/LinkItems/IframeModal.vue';
|
import IframeModal from '@/components/LinkItems/IframeModal.vue';
|
||||||
|
@ -71,6 +72,18 @@ export default {
|
||||||
IframeModal,
|
IframeModal,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
sortOrder() {
|
||||||
|
return this.displayData.sortBy || defaultSortOrder;
|
||||||
|
},
|
||||||
|
sortedItems() {
|
||||||
|
const { items } = this;
|
||||||
|
if (this.sortOrder === 'alphabetical') {
|
||||||
|
items.sort((a, b) => (a.title > b.title ? 1 : -1));
|
||||||
|
} else if (this.sortOrder === 'reverse-alphabetical') {
|
||||||
|
items.sort((a, b) => (a.title < b.title ? 1 : -1));
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
},
|
||||||
newItemSize() {
|
newItemSize() {
|
||||||
return this.displayData.itemSize || this.itemSize;
|
return this.displayData.itemSize || this.itemSize;
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,6 +25,8 @@ module.exports = {
|
||||||
fontAwesomeKey: '0821c65656',
|
fontAwesomeKey: '0821c65656',
|
||||||
/* Default API to use for fetching of user service favicon icons (if enabled) */
|
/* Default API to use for fetching of user service favicon icons (if enabled) */
|
||||||
faviconApi: 'faviconkit',
|
faviconApi: 'faviconkit',
|
||||||
|
/* The default sort order for sections */
|
||||||
|
sortOrder: 'auto',
|
||||||
/* The page paths for each route within the app for the router */
|
/* The page paths for each route within the app for the router */
|
||||||
routePaths: {
|
routePaths: {
|
||||||
home: '/home',
|
home: '/home',
|
||||||
|
|
Loading…
Reference in New Issue