Skip to content

Commit

Permalink
fix: open edit modal when 'Add Category' clicked (add top-level categ…
Browse files Browse the repository at this point in the history
…ory)
  • Loading branch information
ErikBjare committed Nov 22, 2023
1 parent d0d3682 commit 5540cb8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,14 @@ export const useSettingsStore = defineStore('settings', {
// Skip keys starting with underscore, as they are local to the vuex store.
return !key.startsWith('_');
});
console.log('all_keys', all_keys);

const storage = {};
for (const key of all_keys) {
// If key is set in server, use that value, otherwise use localStorage
const set_in_server = server_settings[key] !== undefined;
const value = set_in_server ? server_settings[key] : localStorage.getItem(key);
const locstr = set_in_server ? '[server]' : '[localStorage]';
console.log(`${locstr} ${key}:`, value);
//const locstr = set_in_server ? '[server]' : '[localStorage]';
//console.debug(`${locstr} ${key}:`, value);

// Keys ending with 'Data' are JSON-serialized objects
if (key.includes('Data') && !set_in_server) {
Expand Down
14 changes: 14 additions & 0 deletions src/views/settings/CategorizationSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ div
| Discard
div(v-for="_class in classes_hierarchy")
CategoryEditTree(:_class="_class")
div(v-if="editingId !== null")
CategoryEditModal(:categoryId='editingId', @hidden="hideEditModal()")

div.row
div.col-sm-12
Expand All @@ -40,20 +42,25 @@ div
<script>
import { mapState, mapGetters } from 'pinia';
import CategoryEditTree from '~/components/CategoryEditTree.vue';
import CategoryEditModal from '~/components/CategoryEditModal.vue';
import 'vue-awesome/icons/undo';
import router from '~/route';
import { useCategoryStore } from '~/stores/categories';
import _ from 'lodash';
const confirmationMessage = 'Your categories have unsaved changes, are you sure you want to leave?';
export default {
name: 'CategorizationSettings',
components: {
CategoryEditTree,
CategoryEditModal,
},
data: () => ({
categoryStore: useCategoryStore(),
editingId: null,
}),
computed: {
...mapState(useCategoryStore, ['classes_unsaved_changes']),
Expand Down Expand Up @@ -95,6 +102,10 @@ export default {
name: ['New class'],
rule: { type: 'regex', regex: 'FILL ME' },
});
// Find the category with the max ID, and open an editor for it
const lastId = _.max(_.map(this.categoryStore.classes, 'id'));
this.editingId = lastId;
},
saveClasses: async function () {
await this.categoryStore.save();
Expand All @@ -105,6 +116,9 @@ export default {
restoreDefaultClasses: async function () {
await this.categoryStore.restoreDefaultClasses();
},
hideEditModal: function () {
this.editingId = null;
},
exportClasses: function () {
console.log('Exporting categories...');
Expand Down

1 comment on commit 5540cb8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.12.3b11 (click to expand)

Screenshots using aw-server-rust master (click to expand)

Screenshots using aw-server-rust v0.12.3b11 (click to expand)

Please sign in to comment.