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"
|
||||
>
|
||||
<Item
|
||||
v-for="(item, index) in items"
|
||||
v-for="(item, index) in sortedItems"
|
||||
:id="`${index}_${makeId(item.title)}`"
|
||||
:key="`${index}_${makeId(item.title)}`"
|
||||
:url="item.url"
|
||||
|
@ -49,6 +49,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { sortOrder as defaultSortOrder } from '@/utils/defaults';
|
||||
import Item from '@/components/LinkItems/Item.vue';
|
||||
import Collapsable from '@/components/LinkItems/Collapsable.vue';
|
||||
import IframeModal from '@/components/LinkItems/IframeModal.vue';
|
||||
|
@ -71,6 +72,18 @@ export default {
|
|||
IframeModal,
|
||||
},
|
||||
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() {
|
||||
return this.displayData.itemSize || this.itemSize;
|
||||
},
|
||||
|
|
|
@ -25,6 +25,8 @@ module.exports = {
|
|||
fontAwesomeKey: '0821c65656',
|
||||
/* Default API to use for fetching of user service favicon icons (if enabled) */
|
||||
faviconApi: 'faviconkit',
|
||||
/* The default sort order for sections */
|
||||
sortOrder: 'auto',
|
||||
/* The page paths for each route within the app for the router */
|
||||
routePaths: {
|
||||
home: '/home',
|
||||
|
|
Loading…
Reference in New Issue