diff --git a/src/components/dialogs/ExistingDocument.vue b/src/components/dialogs/ExistingDocument.vue index 42cdf4f..7306f7d 100644 --- a/src/components/dialogs/ExistingDocument.vue +++ b/src/components/dialogs/ExistingDocument.vue @@ -80,16 +80,16 @@ flat dense dark - color="primary" - class="z-1 q-ml-md" - icon="mdi-file-tree" - size="md" - @click.stop.prevent="addNewItemUnderSelected(opt)" + color="accent" + class="z-1 q-ml-sm self-center" + icon="mdi-pencil" + size="sm" + @click.stop.prevent="editExistingInput(opt)" > - Add a new document belonging under {{ stripTags(opt.label) }} + Edit {{ stripTags(opt.label) }} Make a copy of {{ stripTags(opt.label) }} +
+ This action will always close the popup. +
+
+ + + Add a new document belonging under {{ stripTags(opt.label) }} +
+ This action will always close the popup.
+ + + + + + + + + + @@ -132,6 +213,9 @@ import { I_OpenedDocument, I_ShortenedDocument } from "src/interfaces/I_OpenedDo import { advancedDocumentFilter } from "src/scripts/utilities/advancedDocumentFilter" import { extend } from "quasar" import PouchDB from "pouchdb" + +import { createNewWithParent } from "src/scripts/documentActions/createNewWithParent" +import { copyDocumentName, copyDocumentTextColor, copyDocumentBackgroundColor } from "src/scripts/documentActions/uniqueFieldCopy" import { copyDocument } from "src/scripts/documentActions/copyDocument" import DialogBase from "src/components/dialogs/_DialogBase" @@ -369,12 +453,14 @@ export default class ExistingDocumentDialog extends DialogBase { * Either as a focus with closure of the dialog. * Or as a background tab without closing of the dialog. */ - async openExistingInput (e: I_ShortenedDocument[]) { + async openExistingInput (e: I_ShortenedDocument) { + // @ts-ignore + e = (Array.isArray(e)) ? e[0] : e // Open document and close dialog if (!this.disableCloseAftertSelectQuickSearch) { this.dialogModel = false // @ts-ignore - this.openExistingDocumentRoute(e[0]) + this.openExistingDocumentRoute(e) this.existingDocumentModel = [] } // Open document and DO NOT close the dialog @@ -382,9 +468,9 @@ export default class ExistingDocumentDialog extends DialogBase { // @ts-ignore this.existingDocumentModel = [] - const CurrentObjectDB = new PouchDB(e[0].type) + const CurrentObjectDB = new PouchDB(e.type) // @ts-ignore - const retrievedObject = await CurrentObjectDB.get(e[0].id) + const retrievedObject = await CurrentObjectDB.get(e.id) const dataPass = { doc: retrievedObject, @@ -398,19 +484,75 @@ export default class ExistingDocumentDialog extends DialogBase { } /** - * Add new item under whatever document this was called from + * Opened the existing input in two modes + * Either as a focus with closure of the dialog. + * Or as a background tab without closing of the dialog. */ - addNewItemUnderSelected (parent: any) { - const routeObject = { - _id: parent.type, - parent: parent.id - } + async editExistingInput (e: I_ShortenedDocument) { // @ts-ignore - this.addNewObjectRoute(routeObject) + e = (Array.isArray(e)) ? e[0] : e + // Open document and close dialog + if (!this.disableCloseAftertSelectQuickSearch) { + this.dialogModel = false + // @ts-ignore + this.openExistingDocumentRouteWithEdit(e) + this.existingDocumentModel = [] + } + // Open document and DO NOT close the dialog + else { + // @ts-ignore + this.existingDocumentModel = [] + + const CurrentObjectDB = new PouchDB(e.type) + // @ts-ignore + const retrievedObject = await CurrentObjectDB.get(e.id) + + // @ts-ignore + retrievedObject.hasEdits = true + + const dataPass = { + doc: retrievedObject, + treeAction: false + } + + // @ts-ignore + this.SSET_addOpenedDocument(dataPass) + await CurrentObjectDB.close() + } } documentPass = null as unknown as I_OpenedDocument + /****************************************************************/ + // Add new document under parent + /****************************************************************/ + addNewUnderParent (currentDoc: I_OpenedDocument) { + createNewWithParent(currentDoc, this) + this.dialogModel = false + } + + /****************************************************************/ + // Document field copying + /****************************************************************/ + + copyName (currentDoc: I_OpenedDocument) { + copyDocumentName(currentDoc) + + this.dialogModel = false + } + + copyTextColor (currentDoc: I_OpenedDocument) { + copyDocumentTextColor(currentDoc) + + this.dialogModel = false + } + + copyBackgroundColor (currentDoc: I_OpenedDocument) { + copyDocumentBackgroundColor(currentDoc) + + this.dialogModel = false + } + copyTargetDocument (currentDoc: I_OpenedDocument) { this.documentPass = extend(true, {}, currentDoc) @@ -432,6 +574,8 @@ export default class ExistingDocumentDialog extends DialogBase { } console.log(e) }) + + this.dialogModel = false } } diff --git a/src/components/fields/Field_MultiRelationship.vue b/src/components/fields/Field_MultiRelationship.vue index fdd197f..dc4f720 100644 --- a/src/components/fields/Field_MultiRelationship.vue +++ b/src/components/fields/Field_MultiRelationship.vue @@ -73,6 +73,63 @@ + + + + + + + + @@ -114,7 +171,7 @@ round dense flat - class="z-max" + class="z-max relationshipChipNewTab" style="color: #000 !important;" size="sm" icon="mdi-open-in-new" @@ -124,6 +181,63 @@ Open in new tab without leaving this one + + + + + + + + @@ -209,8 +381,11 @@ import FieldBase from "src/components/fields/_FieldBase" import PouchDB from "pouchdb" import { advancedDocumentFilter } from "src/scripts/utilities/advancedDocumentFilter" import { extend } from "quasar" -import { I_ShortenedDocument } from "src/interfaces/I_OpenedDocument" +import { I_ShortenedDocument, I_OpenedDocument } from "src/interfaces/I_OpenedDocument" import { I_FieldRelationship, I_RelationshipPair } from "src/interfaces/I_FieldRelationship" +import { createNewWithParent } from "src/scripts/documentActions/createNewWithParent" +import { copyDocumentName, copyDocumentTextColor, copyDocumentBackgroundColor } from "src/scripts/documentActions/uniqueFieldCopy" +import { copyDocument } from "src/scripts/documentActions/copyDocument" @Component({ components: { } @@ -494,6 +669,86 @@ export default class Field_MultiRelationship extends FieldBase { } }) } + + /****************************************************************/ + // TRIGGER ACTIONS + /****************************************************************/ + + docToFind = null as unknown as I_OpenedDocument + + fixGetCorrectDocument (e: I_OpenedDocument | I_FieldRelationship) { + this.docToFind = (this.allDocumentsWithoutCurrent.find(doc => doc._id === e._id)) as unknown as I_OpenedDocument + return this.docToFind + } + + /** + * Opened the existing input + */ + openExistingInput (e: I_OpenedDocument) { + // @ts-ignore + e = (Array.isArray(e)) ? e[0] : e + this.openExistingDocumentRoute(e) + } + + /** + * Opened the existing input in two modes + * Either as a focus with closure of the dialog. + * Or as a background tab without closing of the dialog. + */ + editExistingInput (e: I_OpenedDocument) { + // @ts-ignore + e = (Array.isArray(e)) ? e[0] : e + this.openExistingDocumentRouteWithEdit(e) + } + + documentPass = null as unknown as I_OpenedDocument + + /****************************************************************/ + // Add new document under parent + /****************************************************************/ + addNewUnderParent (currentDoc: I_OpenedDocument) { + createNewWithParent(currentDoc, this) + } + + /****************************************************************/ + // Document field copying + /****************************************************************/ + + copyName (currentDoc: I_OpenedDocument) { + console.log(currentDoc) + copyDocumentName(currentDoc) + } + + copyTextColor (currentDoc: I_OpenedDocument) { + copyDocumentTextColor(currentDoc) + } + + copyBackgroundColor (currentDoc: I_OpenedDocument) { + copyDocumentBackgroundColor(currentDoc) + } + + copyTargetDocument (currentDoc: I_OpenedDocument) { + this.documentPass = extend(true, {}, currentDoc) + + const newDocument = copyDocument(this.documentPass, this.generateUID()) + + const dataPass = { + doc: newDocument, + treeAction: false + } + + // @ts-ignore + this.SSET_addOpenedDocument(dataPass) + this.$router.push({ + path: newDocument.url + }).catch((e: {name: string}) => { + const errorName : string = e.name + if (errorName === "NavigationDuplicated") { + return + } + console.log(e) + }) + } } diff --git a/src/components/fields/Field_SingleRelationship.vue b/src/components/fields/Field_SingleRelationship.vue index 5468488..7ca5548 100644 --- a/src/components/fields/Field_SingleRelationship.vue +++ b/src/components/fields/Field_SingleRelationship.vue @@ -70,6 +70,63 @@ + + + + + + + + @@ -111,7 +168,7 @@ round dense flat - class="z-max" + class="z-max relationshipChipNewTab" style="color: #000 !important;" size="sm" icon="mdi-open-in-new" @@ -121,6 +178,63 @@ Open in new tab without leaving this one + + + + + + + + @@ -164,6 +278,65 @@ This option is unavailable for selection as it is already paired to another. + + + + + + + + + + @@ -207,8 +380,11 @@ import PouchDB from "pouchdb" import { advancedDocumentFilter } from "src/scripts/utilities/advancedDocumentFilter" import { extend } from "quasar" -import { I_ShortenedDocument } from "src/interfaces/I_OpenedDocument" +import { I_OpenedDocument, I_ShortenedDocument } from "src/interfaces/I_OpenedDocument" import { I_FieldRelationship, I_RelationshipPairSingle } from "src/interfaces/I_FieldRelationship" +import { createNewWithParent } from "src/scripts/documentActions/createNewWithParent" +import { copyDocumentName, copyDocumentTextColor, copyDocumentBackgroundColor } from "src/scripts/documentActions/uniqueFieldCopy" +import { copyDocument } from "src/scripts/documentActions/copyDocument" @Component({ components: { } @@ -470,6 +646,86 @@ export default class Field_SingleRelationship extends FieldBase { skipSave: (skipSave) } } + + /****************************************************************/ + // TRIGGER ACTIONS + /****************************************************************/ + + docToFind = null as unknown as I_OpenedDocument + + fixGetCorrectDocument (e: I_OpenedDocument | I_FieldRelationship) { + this.docToFind = (this.allDocumentsWithoutCurrent.find(doc => doc._id === e._id)) as unknown as I_OpenedDocument + return this.docToFind + } + + /** + * Opened the existing input + */ + openExistingInput (e: I_OpenedDocument) { + // @ts-ignore + e = (Array.isArray(e)) ? e[0] : e + this.openExistingDocumentRoute(e) + } + + /** + * Opened the existing input in two modes + * Either as a focus with closure of the dialog. + * Or as a background tab without closing of the dialog. + */ + editExistingInput (e: I_OpenedDocument) { + // @ts-ignore + e = (Array.isArray(e)) ? e[0] : e + this.openExistingDocumentRouteWithEdit(e) + } + + documentPass = null as unknown as I_OpenedDocument + + /****************************************************************/ + // Add new document under parent + /****************************************************************/ + addNewUnderParent (currentDoc: I_OpenedDocument) { + createNewWithParent(currentDoc, this) + } + + /****************************************************************/ + // Document field copying + /****************************************************************/ + + copyName (currentDoc: I_OpenedDocument) { + console.log(currentDoc) + copyDocumentName(currentDoc) + } + + copyTextColor (currentDoc: I_OpenedDocument) { + copyDocumentTextColor(currentDoc) + } + + copyBackgroundColor (currentDoc: I_OpenedDocument) { + copyDocumentBackgroundColor(currentDoc) + } + + copyTargetDocument (currentDoc: I_OpenedDocument) { + this.documentPass = extend(true, {}, currentDoc) + + const newDocument = copyDocument(this.documentPass, this.generateUID()) + + const dataPass = { + doc: newDocument, + treeAction: false + } + + // @ts-ignore + this.SSET_addOpenedDocument(dataPass) + this.$router.push({ + path: newDocument.url + }).catch((e: {name: string}) => { + const errorName : string = e.name + if (errorName === "NavigationDuplicated") { + return + } + console.log(e) + }) + } } diff --git a/src/pages/DocumentDisplay.vue b/src/pages/DocumentDisplay.vue index 40c6ebc..8e13e15 100644 --- a/src/pages/DocumentDisplay.vue +++ b/src/pages/DocumentDisplay.vue @@ -1013,11 +1013,13 @@ body.body--dark { border: none; } + .relationshipChipNewTab, .q-field__input, .q-icon, .q-field__native span { color: $darkModeText !important; + .q-icon, &.q-chip__icon--remove { color: #000 !important; } diff --git a/src/scripts/documentActions/createNewWithParent.ts b/src/scripts/documentActions/createNewWithParent.ts index 51c6dad..a29dc3f 100644 --- a/src/scripts/documentActions/createNewWithParent.ts +++ b/src/scripts/documentActions/createNewWithParent.ts @@ -7,7 +7,8 @@ export const createNewWithParent = (currentDoc: I_OpenedDocument, callingCompone if (currentDoc) { const routeObject = { _id: currentDoc.type, - parent: currentDoc._id + // @ts-ignore + parent: (currentDoc._id) || currentDoc.id } // eslint-disable-next-line @typescript-eslint/no-unsafe-call callingComponent.addNewObjectRoute(routeObject) diff --git a/suggestionList.md b/suggestionList.md index e8b4278..b15e305 100644 --- a/suggestionList.md +++ b/suggestionList.md @@ -1,18 +1,27 @@ - Switch field: Template (sigh... maybe???) - Mass tag rename +- Add category for diseases/curses/etc + +## THE GM BATCH - Add "Related notes" +- Floating notes corkboard +- Add hover/on-demand document preview to relationships + +- Export for MD/PDF +- Selective export per field basis +- Export templates +- DM only fields + +## THE GM BATCH END + - Add "Predecessors", "Successors", "Date of start", "Date of end" and "How long it lasted" fields to locations and all other groups - Add advanced search capabilities to the hierarchical tree - "Save all" keybind and "Save all and exit" option on the exiting -- Add hover/on-demand document preview to relationships -- Floating notes corkboard -- Export for MD/PDF - - Add intelligent responsive design to the left tree and document body (maybe button to pull the left bar in and out?) - Add "Open all search matches" button in the Quick-search that opens a new page with a list of items