From 14834a6a54c2638c97ac0951c6854c7e14283c7b Mon Sep 17 00:00:00 2001 From: Elvanos Date: Tue, 27 Apr 2021 17:13:46 +0200 Subject: [PATCH] 0.1.6 - DEV - 4 --- src/components/appHeader/AppControl.vue | 52 +++- src/components/dialogs/ProgramSettings.vue | 2 +- src/components/dialogs/RepairProject.vue | 259 ++++++++++++++++++ .../fields/Field_MultiRelationship.vue | 47 ++-- .../fields/Field_SingleRelationship.vue | 1 - src/documents/changeLog.md | 5 +- src/pages/DocumentDisplay.vue | 3 +- .../databaseManager/documentManager.ts | 2 - .../projectManagement/projectManagent.ts | 1 + src/store/module-allDocuments/mutations.ts | 5 +- 10 files changed, 348 insertions(+), 29 deletions(-) create mode 100644 src/components/dialogs/RepairProject.vue diff --git a/src/components/appHeader/AppControl.vue b/src/components/appHeader/AppControl.vue index 93bfdd1..79b3be5 100644 --- a/src/components/appHeader/AppControl.vue +++ b/src/components/appHeader/AppControl.vue @@ -83,6 +83,12 @@ @trigger-dialog-close="licenseDialogClose" /> + + + + + Advanced project tools + + + + + + + + Repair legacy project + + + + + + + + + + + diff --git a/src/components/dialogs/ProgramSettings.vue b/src/components/dialogs/ProgramSettings.vue index 3389abb..eed953e 100644 --- a/src/components/dialogs/ProgramSettings.vue +++ b/src/components/dialogs/ProgramSettings.vue @@ -314,7 +314,7 @@ Prevent auto-scrolling - Determines if the documents will recall their scroll distances and auto-scroll on switching ot not. + Determines if the documents will recall their scroll distances and auto-scroll on switching or not. diff --git a/src/components/dialogs/RepairProject.vue b/src/components/dialogs/RepairProject.vue new file mode 100644 index 0000000..9ee60e4 --- /dev/null +++ b/src/components/dialogs/RepairProject.vue @@ -0,0 +1,259 @@ + + + + + diff --git a/src/components/fields/Field_MultiRelationship.vue b/src/components/fields/Field_MultiRelationship.vue index d8eadd9..64ba6b8 100644 --- a/src/components/fields/Field_MultiRelationship.vue +++ b/src/components/fields/Field_MultiRelationship.vue @@ -479,10 +479,11 @@ export default class Field_MultiRelationship extends FieldBase { * Also reload the local object list */ @Watch("inputDataValue", { deep: true, immediate: true }) - reactToInputChanges () { - this.localInput = (this.inputDataValue?.value) ? this.inputDataValue.value : [] + reactToInputChanges (val : I_RelationshipPair) { + const localCopy: I_RelationshipPair = extend(true, {}, val) + this.localInput = (localCopy?.value) ? localCopy.value : [] - const notes = (!this.inputDataValue?.addedValues) ? [] : this.inputDataValue.addedValues + const notes = (!localCopy?.addedValues) ? [] : localCopy.addedValues this.inputNotes = notes.filter(single => this.localInput.find(e => single.pairedId === e._id)) this.checkNotes() @@ -615,30 +616,41 @@ export default class Field_MultiRelationship extends FieldBase { // Do a quick check on formatting of the current input (if something is wrong with it, set it as empty array) this.localInput = (Array.isArray(this.localInput)) ? this.localInput : [] - this.localInput.forEach((s, index) => { + const toRemoveIndexList: number[] = [] + + for (const [index] of this.localInput.entries()) { // Proceed only if the local input is properly set up - if (s._id) { + if (this.localInput[index]._id) { // If the matched object doesn't exist in the object, assume it has been deleted or newer existed and silently emit a signal input which auto-updates the document - if (!allDbObjects.docs.find(e => e._id === s._id)) { - // @ts-ignore - this.localInput.splice(index, 1) + + if (!allDbObjects.docs.find(e => e._id === this.localInput[index]._id)) { + allDbObjects.docs.forEach(e => { + if (e._id === this.localInput[index]._id) { + console.log(extend(true, {}, this.localInput[index])) + console.log(extend(true, {}, e)) + } + }) + toRemoveIndexList.push(index) } // If the object does exist, make sure we have the newest available name by reasigning the label if it is different. Then trigger a silent update else { - const matchedFieldContent = allDbObjects.docs.find(e => e._id === s._id) - - if (matchedFieldContent && ( - this.localInput[index].label !== matchedFieldContent.label || - this.localInput[index]?.isDead !== matchedFieldContent.extraFields.find(e => e.id === "deadSwitch")?.value) - ) { + const matchedFieldContent = allDbObjects.docs.find(e => e._id === this.localInput[index]._id) + if (matchedFieldContent) { this.localInput[index].label = matchedFieldContent.label this.localInput[index].isDead = matchedFieldContent.extraFields.find(e => e.id === "deadSwitch")?.value } } } - }) + } this.allTypeDocuments = allDbObjects.docs + + if (toRemoveIndexList.length > 0) { + toRemoveIndexList.forEach((e, i) => { + this.localInput.splice(i, 1) + }) + this.signalInput(true) + } } } @@ -692,7 +704,7 @@ export default class Field_MultiRelationship extends FieldBase { * Signals the input change to the document body parent component */ @Emit() - signalInput () { + signalInput (isSilent = false) { this.checkNotes() this.inputNotes = this.inputNotes.filter(single => this.localInput.find(e => single.pairedId === e._id)) @@ -706,7 +718,8 @@ export default class Field_MultiRelationship extends FieldBase { pairedField: (this.inputDataBluePrint?.relationshipSettings?.connectedField) || "" } }), - addedValues: this.inputNotes + addedValues: this.inputNotes, + isSilent: isSilent } } diff --git a/src/components/fields/Field_SingleRelationship.vue b/src/components/fields/Field_SingleRelationship.vue index 3822030..b34f34a 100644 --- a/src/components/fields/Field_SingleRelationship.vue +++ b/src/components/fields/Field_SingleRelationship.vue @@ -578,7 +578,6 @@ export default class Field_SingleRelationship extends FieldBase { ])] } }) - // Proceed only if the local input is properly set up if (this.localInput._id) { // If the matched object doesn't exist in the object, assume it has been deleted or never existed diff --git a/src/documents/changeLog.md b/src/documents/changeLog.md index 21658f6..63cc56c 100644 --- a/src/documents/changeLog.md +++ b/src/documents/changeLog.md @@ -7,19 +7,18 @@ ### Known issues -- POSSIBLY FIXED: When creating a brand new project, Fantasia Archive sometimes doesn't load the default categories in the left hierarchical tree. A temporary workaround before the issue is fixed is restarting the program - the project stays intact, can be normally edited and no data loss occurs. -- POSSIBLY FIXED: Some users report that dialog (popups) don't function the very first time you start FA. This is solved by restarting the application. The bug doesn't seem to appear again once FA has been started at least once before. - Overusing Tags currently causes app crashes on some PCs. If you suffer from this issue, reduce the number of tags in your project below 10. ### Bugfixes & Optimizations -- Massive overhaul of how data is being handles across the app! +- **Massive overhaul of how data is being handles across the app!** - Fixed buttons for moving list items up and down also showing outside of edit mode - Fixed `Resume project` button working in instances where it shouldnt - Fixed a visual bug in the top document control bar - Added a check against invalid characters in new project name to prevent issues while exporting on different OSs - Hopefully finally fixed the new project creation bugs that have been plaguing the app for last 3 releases - Fixed app starting in mutliple windows when ran multiple times. +- FIxed more typos across the app ### New features diff --git a/src/pages/DocumentDisplay.vue b/src/pages/DocumentDisplay.vue index 7b905c7..59187bf 100644 --- a/src/pages/DocumentDisplay.vue +++ b/src/pages/DocumentDisplay.vue @@ -632,8 +632,7 @@ export default class PageDocumentDisplay extends BaseClass { this.localDataCopy = extend(true, {}, this.currentData) const dataPass = { doc: this.localDataCopy, treeAction: false } // @ts-ignore - if (inputData.skipSave) { - this.currentData.extraFields[indexToUpdate].value.skipSave = false + if (inputData.isSilent) { dataPass.doc.hasEdits = false } diff --git a/src/scripts/databaseManager/documentManager.ts b/src/scripts/databaseManager/documentManager.ts index 8104688..790acf6 100644 --- a/src/scripts/databaseManager/documentManager.ts +++ b/src/scripts/databaseManager/documentManager.ts @@ -169,8 +169,6 @@ export const addFieldToDocument = async (targetDocumentID: string, fieldID: stri targetDocument.extraFields.push(newField) - console.log(newField) - // eslint-disable-next-line @typescript-eslint/no-unsafe-call await window.FA_dbs[currentBlueprint._id].put(targetDocument) } diff --git a/src/scripts/projectManagement/projectManagent.ts b/src/scripts/projectManagement/projectManagent.ts index b8a9af5..a78e5e8 100644 --- a/src/scripts/projectManagement/projectManagent.ts +++ b/src/scripts/projectManagement/projectManagent.ts @@ -47,6 +47,7 @@ export const createNewProject = async (projectName: string, vueRouter: any, quas message: `New project succesfully created` }) vueInstance.SSET_resetDocuments() + vueInstance.SSET_resetAllDocuments() /* eslint-enable */ await ProjectDB.close() diff --git a/src/store/module-allDocuments/mutations.ts b/src/store/module-allDocuments/mutations.ts index b4cd565..64f821b 100644 --- a/src/store/module-allDocuments/mutations.ts +++ b/src/store/module-allDocuments/mutations.ts @@ -14,6 +14,7 @@ const mutation: MutationTree = { doc: I_ShortenedDocument, }) { const timestamp = uid() + const isCategory = input.doc.extraFields.find(e => e.id === "categorySwitch")?.value // Docs const toAddIndexDocs = state.docs.docs.findIndex(doc => doc.type === input.doc.type && doc._id === input.doc._id) @@ -24,7 +25,7 @@ const mutation: MutationTree = { // Docs, no cat const toAddIndexDocsWithoutCategory = state.docsWithoutCategories.docs.findIndex(doc => doc.type === input.doc.type && doc._id === input.doc._id) - if (toAddIndexDocsWithoutCategory < 0) { + if (toAddIndexDocsWithoutCategory < 0 && !isCategory) { state.docsWithoutCategories.docs.push(input.doc) state.docsWithoutCategories.timestamp = timestamp } @@ -40,7 +41,7 @@ const mutation: MutationTree = { // Docs each cat, no cat const typeIndexWithoutCats = state.docbyTypeWithoutCategories.findIndex(type => type.id === input.doc.type) const toAddTypeIndexDocsWithoutCats = state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs.findIndex(doc => doc._id === input.doc._id) - if (toAddTypeIndexDocsWithoutCats < 0) { + if (toAddTypeIndexDocsWithoutCats < 0 && !isCategory) { state.docbyTypeWithoutCategories[typeIndexWithoutCats].docs.push(input.doc) state.docbyTypeWithoutCategories[typeIndex].timestamp = timestamp }