0.1.6 - DEV-5

This commit is contained in:
Elvanos 2021-04-27 20:06:01 +02:00
parent 14834a6a54
commit 255a9044f6
3 changed files with 42 additions and 7 deletions

View file

@ -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())

View file

@ -5,7 +5,7 @@
>
<q-card dark class="documentCloseDialog">
<q-card-section class="row justify-center">
<h6 class="text-center q-my-sm">Discard changes to {{retrieveFieldValue(dialogDocument,'name')}}?</h6>
<h6 class="text-center q-my-sm">Discard changes to <span class="text-primary">{{retrieveFieldValue(dialogDocument,'name')}}</span>?</h6>
</q-card-section>
<q-card-actions align="around" class="q-mx-xl q-mt-lg q-mb-md">

View file

@ -61,7 +61,14 @@ const mutation: MutationTree<AllDocumentsStateInterface> = {
// 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<AllDocumentsStateInterface> = {
// 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)