Skip to content

Commit 5540cb8

Browse files
committed
fix: open edit modal when 'Add Category' clicked (add top-level category)
1 parent d0d3682 commit 5540cb8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Diff for: src/stores/settings.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,14 @@ export const useSettingsStore = defineStore('settings', {
9595
// Skip keys starting with underscore, as they are local to the vuex store.
9696
return !key.startsWith('_');
9797
});
98-
console.log('all_keys', all_keys);
9998

10099
const storage = {};
101100
for (const key of all_keys) {
102101
// If key is set in server, use that value, otherwise use localStorage
103102
const set_in_server = server_settings[key] !== undefined;
104103
const value = set_in_server ? server_settings[key] : localStorage.getItem(key);
105-
const locstr = set_in_server ? '[server]' : '[localStorage]';
106-
console.log(`${locstr} ${key}:`, value);
104+
//const locstr = set_in_server ? '[server]' : '[localStorage]';
105+
//console.debug(`${locstr} ${key}:`, value);
107106

108107
// Keys ending with 'Data' are JSON-serialized objects
109108
if (key.includes('Data') && !set_in_server) {

Diff for: src/views/settings/CategorizationSettings.vue

+14
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ div
2828
| Discard
2929
div(v-for="_class in classes_hierarchy")
3030
CategoryEditTree(:_class="_class")
31+
div(v-if="editingId !== null")
32+
CategoryEditModal(:categoryId='editingId', @hidden="hideEditModal()")
3133

3234
div.row
3335
div.col-sm-12
@@ -40,20 +42,25 @@ div
4042
<script>
4143
import { mapState, mapGetters } from 'pinia';
4244
import CategoryEditTree from '~/components/CategoryEditTree.vue';
45+
import CategoryEditModal from '~/components/CategoryEditModal.vue';
4346
import 'vue-awesome/icons/undo';
4447
import router from '~/route';
4548
4649
import { useCategoryStore } from '~/stores/categories';
4750
51+
import _ from 'lodash';
52+
4853
const confirmationMessage = 'Your categories have unsaved changes, are you sure you want to leave?';
4954
5055
export default {
5156
name: 'CategorizationSettings',
5257
components: {
5358
CategoryEditTree,
59+
CategoryEditModal,
5460
},
5561
data: () => ({
5662
categoryStore: useCategoryStore(),
63+
editingId: null,
5764
}),
5865
computed: {
5966
...mapState(useCategoryStore, ['classes_unsaved_changes']),
@@ -95,6 +102,10 @@ export default {
95102
name: ['New class'],
96103
rule: { type: 'regex', regex: 'FILL ME' },
97104
});
105+
106+
// Find the category with the max ID, and open an editor for it
107+
const lastId = _.max(_.map(this.categoryStore.classes, 'id'));
108+
this.editingId = lastId;
98109
},
99110
saveClasses: async function () {
100111
await this.categoryStore.save();
@@ -105,6 +116,9 @@ export default {
105116
restoreDefaultClasses: async function () {
106117
await this.categoryStore.restoreDefaultClasses();
107118
},
119+
hideEditModal: function () {
120+
this.editingId = null;
121+
},
108122
exportClasses: function () {
109123
console.log('Exporting categories...');
110124

0 commit comments

Comments
 (0)