Skip to content

Commit e40664b

Browse files
committed
Implement sorting of categories by name by default
1 parent 9c6e174 commit e40664b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

backend/src/views/Categories/CategoriesTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ID
1515
</TableHeaderCell>
1616
<TableHeaderCell field="name" :sort-field="sortField" :sort-direction="sortDirection"
17-
@click="sortCategories('email')">
17+
@click="sortCategories('name')">
1818
Name
1919
</TableHeaderCell>
2020
<TableHeaderCell field="slug" :sort-field="sortField" :sort-direction="sortDirection"
@@ -143,8 +143,8 @@ import {DotsVerticalIcon, PencilIcon, TrashIcon} from '@heroicons/vue/outline'
143143
import CategoryModal from "./CategoryModal.vue";
144144
145145
const categories = computed(() => store.state.categories);
146-
const sortField = ref('updated_at');
147-
const sortDirection = ref('desc')
146+
const sortField = ref('name');
147+
const sortDirection = ref('asc')
148148
149149
const category = ref({})
150150
const showCategoryModal = ref(false);

backend/src/views/Categories/CategoryModal.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ const parentCategories = computed(() => {
115115
return true;
116116
})
117117
.map(c => ({key: c.id, text: c.name}))
118+
.sort((c1, c2) => {
119+
if (c1.text < c2.text) return -1;
120+
if (c1.text > c2.text) return 1;
121+
return 0;
122+
})
118123
]
119124
})
120125

0 commit comments

Comments
 (0)