From a6aa75532d5e214df5b9af75bbc8781b4b7807c0 Mon Sep 17 00:00:00 2001 From: Elvanos Date: Thu, 4 Mar 2021 13:51:11 +0100 Subject: [PATCH] fixed a hierarchy path generatio bug --- changelog.md | 1 + src/BaseClass.ts | 34 +++++--- src/components/AppHeader.vue | 2 +- src/components/DocumentControl.vue | 39 ++++++++- src/components/appHeader/TopTabs.vue | 2 +- .../dialogs/DeleteDocumentCheck.vue | 84 +++++++++++++++++++ src/components/dialogs/ExistingDocument.vue | 23 +++-- .../fields/Field_MultiRelationship.vue | 7 +- .../fields/Field_SingleRelationship.vue | 7 +- src/pages/DocumentDisplay.vue | 62 -------------- .../projectManagement/projectManagent.ts | 13 +++ 11 files changed, 183 insertions(+), 91 deletions(-) create mode 100644 src/components/dialogs/DeleteDocumentCheck.vue diff --git a/changelog.md b/changelog.md index 25bb6e6..e18137c 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,7 @@ add delete document dialog to dialog system - Lightly modified the app color-scheme to offer better readability of contrast - Changed icon for the button triggering quick-adding of new documents - Changed the looks of tooltips to go well with the current app looks +- Adjusted tab-list width to allow for more content to show - Modified selected and active indicators for already selected/active items in dropdown lists in order to not clash with the highlighting from the filter results - Slightly modified the scrollbar visuals to be less intrusive - Added a light golden tint to the background of the app to go easy on user's eyes before dark mode is added diff --git a/src/BaseClass.ts b/src/BaseClass.ts index 984b86b..1a480ae 100644 --- a/src/BaseClass.ts +++ b/src/BaseClass.ts @@ -184,6 +184,15 @@ export default class BaseClass extends Vue { @OpenedDocuments.Action("triggerTreeAction") SSET_triggerTreeAction!: () => void @OpenedDocuments.Action("resetDocuments") SSET_resetDocuments!: () => void + findRequestedOrActiveDocument (doc?: I_OpenedDocument) { + if (doc) { + return (this.SGET_allOpenedDocuments.docs.find(e => e.url === doc.url)) || false + } + else { + return (this.SGET_allOpenedDocuments.docs.find(e => e.url === this.$route.path)) || false + } + } + /** * Retrieves value of requested field. If the field doesn't exist, returns false instead * @param document - Document object that is expected to contain the field @@ -260,31 +269,34 @@ export default class BaseClass extends Vue { /****************************************************************/ // Document list management /****************************************************************/ - getDocumentHieararchicalPath (document: I_OpenedDocument, list: I_OpenedDocument[]): string { - let hierarchiString = "" + getDocumentHieararchicalPath (document: I_OpenedDocument, list: I_OpenedDocument[]) { + let hierarchicalString = "" // @ts-ignore const parentDoc = (this.retrieveFieldValue(document, "parentDoc"))?.value - if (!parentDoc) { + + const parentDocInDB = (list.find(p => p._id === parentDoc?._id)) + + if (!parentDoc || (parentDoc && !parentDocInDB)) { const singleBlueprintName = this.SGET_allBlueprints.find(e => e._id === document.type)?.nameSingular - hierarchiString += singleBlueprintName - return hierarchiString + hierarchicalString += singleBlueprintName + return hierarchicalString } + const matchingDoc = list.find((doc:I_OpenedDocument) => { - // @ts-ignore - return doc.id === parentDoc._id + return doc._id === parentDoc._id }) as I_OpenedDocument // @ts-ignore - hierarchiString += this.retrieveFieldValue(matchingDoc.doc, "name") + hierarchicalString += this.retrieveFieldValue(matchingDoc, "name") // @ts-ignore - const connectedReturn = this.getDocumentHieararchicalPath(matchingDoc.doc, list) + const connectedReturn = this.getDocumentHieararchicalPath(matchingDoc, list) if (connectedReturn) { - hierarchiString = `${connectedReturn} > ${hierarchiString}` + hierarchicalString = `${connectedReturn} > ${hierarchicalString}` } - return hierarchiString + return hierarchicalString } retrieveIconColor (document: I_ShortenedDocument): string { diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index f040219..4b133a2 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -57,7 +57,7 @@ export default class AppHeader extends BaseClass { } .topTabs { - max-width: calc(100% - 535px); + max-width: calc(100% - 415px); } .appWindowButtons { diff --git a/src/components/DocumentControl.vue b/src/components/DocumentControl.vue index 02268e2..9b4bf96 100644 --- a/src/components/DocumentControl.vue +++ b/src/components/DocumentControl.vue @@ -14,6 +14,12 @@ @trigger-dialog-close="existingObjectDialogClose" /> + + +
@@ -61,6 +67,17 @@
+ + + Delete current document + +
@@ -77,13 +94,15 @@ import { Component, Watch } from "vue-property-decorator" import BaseClass from "src/BaseClass" import newDocumentDialog from "src/components/dialogs/NewDocument.vue" import existingDocumentDialog from "src/components/dialogs/ExistingDocument.vue" +import deleteDocumentCheckDialog from "src/components/dialogs/DeleteDocumentCheck.vue" import { retrieveCurrentProjectName, exportProject } from "src/scripts/projectManagement/projectManagent" @Component({ components: { newDocumentDialog, - existingDocumentDialog + existingDocumentDialog, + deleteDocumentCheckDialog } }) export default class DocumentControl extends BaseClass { @@ -113,6 +132,24 @@ export default class DocumentControl extends BaseClass { if (this.determineKeyBind("quickExistingDocument")) { this.existingObjectAssignUID() } + + // Delete dialog - CTRL + D + if (this.determineKeyBind("deleteDocument")) { + this.deleteObjectAssignUID() + } + } + + /****************************************************************/ + // Delete dialog + /****************************************************************/ + + deleteObjectDialogTrigger: string | false = false + deleteObjectDialogClose () { + this.deleteObjectDialogTrigger = false + } + + deleteObjectAssignUID () { + this.deleteObjectDialogTrigger = this.generateUID() } /****************************************************************/ diff --git a/src/components/appHeader/TopTabs.vue b/src/components/appHeader/TopTabs.vue index af787e9..5add234 100644 --- a/src/components/appHeader/TopTabs.vue +++ b/src/components/appHeader/TopTabs.vue @@ -126,7 +126,7 @@ export default class TopTabs extends BaseClass { dialogDoc = null as unknown as I_OpenedDocument tryCloseTab (doc?: I_OpenedDocument) { - const matchingDocument = (doc) || this.localDocuments.find(e => e.url === this.$route.path) + const matchingDocument = this.findRequestedOrActiveDocument(doc) if (matchingDocument) { this.dialogDoc = matchingDocument diff --git a/src/components/dialogs/DeleteDocumentCheck.vue b/src/components/dialogs/DeleteDocumentCheck.vue new file mode 100644 index 0000000..981fd3c --- /dev/null +++ b/src/components/dialogs/DeleteDocumentCheck.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/components/dialogs/ExistingDocument.vue b/src/components/dialogs/ExistingDocument.vue index 5c54963..f1c7c3d 100644 --- a/src/components/dialogs/ExistingDocument.vue +++ b/src/components/dialogs/ExistingDocument.vue @@ -95,7 +95,7 @@