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
4042<script >
4143import { mapState , mapGetters } from ' pinia' ;
4244import CategoryEditTree from ' ~/components/CategoryEditTree.vue' ;
45+ import CategoryEditModal from ' ~/components/CategoryEditModal.vue' ;
4346import ' vue-awesome/icons/undo' ;
4447import router from ' ~/route' ;
4548
4649import { useCategoryStore } from ' ~/stores/categories' ;
4750
51+ import _ from ' lodash' ;
52+
4853const confirmationMessage = ' Your categories have unsaved changes, are you sure you want to leave?' ;
4954
5055export 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