diff --git a/src/components/ObjectTree.vue b/src/components/ObjectTree.vue index b2f3254..1afe36e 100644 --- a/src/components/ObjectTree.vue +++ b/src/components/ObjectTree.vue @@ -289,7 +289,7 @@ import { Component, Watch } from "vue-property-decorator" import BaseClass from "src/BaseClass" -import { I_OpenedDocument, I_ShortenedDocument } from "src/interfaces/I_OpenedDocument" +import { I_ExtraDocumentFields, I_OpenedDocument, I_ShortenedDocument } from "src/interfaces/I_OpenedDocument" import deleteDocumentCheckDialog from "src/components/dialogs/DeleteDocumentCheck.vue" import { extend, colors } from "quasar" @@ -562,6 +562,25 @@ export default class ObjectTree extends BaseClass { return sortedRoots } + mapImportantExtraFields (extraFields: I_ExtraDocumentFields[]) { + const impotantFieldIDList: string[] = [ + "name", + "parentDoc", + "documentColor", + "documentBackgroundColor", + "finishedSwitch", + "minorSwitch", + "deadSwitch", + "categorySwitch", + "order", + "tags" + ] + extraFields = extraFields.filter(field => { + return impotantFieldIDList.includes(field.id) + }) + return extraFields + } + /** * Builds a brand new sparkling hearchy tree out of available data */ @@ -606,7 +625,7 @@ export default class ObjectTree extends BaseClass { hasEdits: false, isNew: false, url: doc.url, - extraFields: (doc?.extraFields) || [], + extraFields: (doc?.extraFields) ? this.mapImportantExtraFields(doc.extraFields) : [], _id: doc._id, key: doc._id } as I_ShortenedDocument @@ -737,9 +756,10 @@ export default class ObjectTree extends BaseClass { } // Assign the finished object to the render model - // treeObject.forEach(cat => this.recursivelyFreezeChildren(cat.children)) + treeObject.forEach(cat => this.recursivelyFreezeChildren(cat.children)) // @ts-ignore this.hierarchicalTree = treeObject + console.log(treeObject) } recursivelyFreezeChildren (children: {children: []}) { @@ -1017,7 +1037,7 @@ export default class ObjectTree extends BaseClass { documentPass = null as unknown as I_OpenedDocument copyTargetDocument (currentDoc: I_OpenedDocument) { - this.documentPass = extend(true, {}, currentDoc) + this.documentPass = extend(true, {}, this.SGET_document(currentDoc._id)) const newDocument = copyDocument(this.documentPass, this.generateUID()) diff --git a/src/components/dialogs/CloseDocumentCheck.vue b/src/components/dialogs/CloseDocumentCheck.vue index aa9decd..dabd257 100644 --- a/src/components/dialogs/CloseDocumentCheck.vue +++ b/src/components/dialogs/CloseDocumentCheck.vue @@ -5,7 +5,7 @@ > -
Discard changes to {{retrieveFieldValue(dialogDocument,'name')}}?
+
Discard changes to {{retrieveFieldValue(dialogDocument,'name')}}?
diff --git a/src/store/module-allDocuments/mutations.ts b/src/store/module-allDocuments/mutations.ts index 64f821b..0193d00 100644 --- a/src/store/module-allDocuments/mutations.ts +++ b/src/store/module-allDocuments/mutations.ts @@ -61,7 +61,14 @@ const mutation: MutationTree = { // Docs, no cat const toUpdateIndexDocsWithoutCategory = state.docsWithoutCategories.docs.findIndex(doc => doc.type === input.doc.type && doc._id === input.doc._id) if (!isCategory) { - state.docsWithoutCategories.docs[toUpdateIndexDocsWithoutCategory] = input.doc + // If adding + if (toUpdateIndexDocsWithoutCategory < 0) { + state.docsWithoutCategories.docs.push(input.doc) + } + // If updating + else { + state.docsWithoutCategories.docs[toUpdateIndexDocsWithoutCategory] = input.doc + } } else { state.docsWithoutCategories.docs.splice(toUpdateIndexDocsWithoutCategory, 1) @@ -77,8 +84,16 @@ const mutation: MutationTree = { // Docs each cat, no cat const typeIndexWithoutCats = state.docbyTypeWithoutCategories.findIndex(type => type.id === input.doc.type) const toUpdateTypeIndexDocsWithoutCats = state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs.findIndex(doc => doc._id === input.doc._id) + if (!isCategory) { - state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs[toUpdateTypeIndexDocsWithoutCats] = input.doc + // If adding + if (toUpdateTypeIndexDocsWithoutCats < 0) { + state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs.push(input.doc) + } + // If updating + else { + state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs[toUpdateTypeIndexDocsWithoutCats] = input.doc + } } else { state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs.splice(toUpdateTypeIndexDocsWithoutCats, 1)