28
28
| Discard
29
29
div( v-for ="_class in classes_hierarchy" )
30
30
CategoryEditTree( :_class ="_class" )
31
+ div( v-if ="editingId !== null" )
32
+ CategoryEditModal( :categoryId ='editingId' , @hidden ="hideEditModal()" )
31
33
32
34
div.row
33
35
div.col-sm-12
40
42
<script >
41
43
import { mapState , mapGetters } from ' pinia' ;
42
44
import CategoryEditTree from ' ~/components/CategoryEditTree.vue' ;
45
+ import CategoryEditModal from ' ~/components/CategoryEditModal.vue' ;
43
46
import ' vue-awesome/icons/undo' ;
44
47
import router from ' ~/route' ;
45
48
46
49
import { useCategoryStore } from ' ~/stores/categories' ;
47
50
51
+ import _ from ' lodash' ;
52
+
48
53
const confirmationMessage = ' Your categories have unsaved changes, are you sure you want to leave?' ;
49
54
50
55
export default {
51
56
name: ' CategorizationSettings' ,
52
57
components: {
53
58
CategoryEditTree,
59
+ CategoryEditModal,
54
60
},
55
61
data : () => ({
56
62
categoryStore: useCategoryStore (),
63
+ editingId: null ,
57
64
}),
58
65
computed: {
59
66
... mapState (useCategoryStore, [' classes_unsaved_changes' ]),
@@ -95,6 +102,10 @@ export default {
95
102
name: [' New class' ],
96
103
rule: { type: ' regex' , regex: ' FILL ME' },
97
104
});
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;
98
109
},
99
110
saveClasses : async function () {
100
111
await this .categoryStore .save ();
@@ -105,6 +116,9 @@ export default {
105
116
restoreDefaultClasses : async function () {
106
117
await this .categoryStore .restoreDefaultClasses ();
107
118
},
119
+ hideEditModal : function () {
120
+ this .editingId = null ;
121
+ },
108
122
exportClasses : function () {
109
123
console .log (' Exporting categories...' );
110
124
0 commit comments