- {{localInput[index].label}}
+ {{stripTags(localInput[index].label)}}
|
@@ -154,7 +167,6 @@ export default class Field_SingleRelationship extends BaseClass {
@Prop() readonly editMode!: boolean
- changedInput = false
localInput = [] as unknown as I_FieldRelationship[]
@Watch("inputDataValue", { deep: true, immediate: true })
@@ -281,11 +293,14 @@ export default class Field_SingleRelationship extends BaseClass {
this.localInput = (Array.isArray(this.localInput)) ? this.localInput : []
+ let nonExistValue = false
+
this.localInput.forEach((s, index) => {
if (s._id) {
if (!allObjectsWithoutCurrent.find(e => e._id === s._id)) {
// @ts-ignore
this.localInput.splice(index, 1)
+ nonExistValue = true
}
else {
const matchedFieldContent = allObjectsWithoutCurrent.find(e => e._id === s._id)
@@ -297,6 +312,10 @@ export default class Field_SingleRelationship extends BaseClass {
}
})
+ if (nonExistValue) {
+ this.signalInput(true)
+ }
+
const allObjectsWithoutCategories: I_FieldRelationship[] = allObjectsWithoutCurrent.filter((obj) => !obj.isCategory)
this.extraInput = allObjectsWithoutCategories
@@ -312,16 +331,13 @@ export default class Field_SingleRelationship extends BaseClass {
}
@Emit()
- signalInput () {
- this.changedInput = true
-
+ signalInput (skipSave?: boolean) {
this.checkNotes()
-
this.inputNotes = this.inputNotes.filter(single => this.localInput.find(e => single.pairedId === e._id))
-
return {
value: this.localInput,
- addedValues: this.inputNotes
+ addedValues: this.inputNotes,
+ skipSave: (skipSave)
}
}
}
diff --git a/src/components/fields/Field_MultiSelect.vue b/src/components/fields/Field_MultiSelect.vue
index 673fb56..75b059f 100644
--- a/src/components/fields/Field_MultiSelect.vue
+++ b/src/components/fields/Field_MultiSelect.vue
@@ -44,6 +44,20 @@
@input="signalInput"
@keydown="signalInput"
>
+
+
+ {{ stripTags(scope.opt) }}
+
+
+
diff --git a/src/components/fields/Field_SingleRelationship.vue b/src/components/fields/Field_SingleRelationship.vue
index 7facd37..15f7f5e 100644
--- a/src/components/fields/Field_SingleRelationship.vue
+++ b/src/components/fields/Field_SingleRelationship.vue
@@ -10,12 +10,12 @@
- This is a one-way relationship. Editing this value will not have effect on the connected document/s.
+ This is a one-way relationship. Editing this value will not have effect on the connected document/s.
- This is a two-way relationship. Editing this value will also effect the connected document/s.
+ This is a two-way relationship. Editing this value will also effect the connected document/s.
@@ -29,7 +29,7 @@
class="text-primary"
@click="openExistingDocumentRoute(localInput)">
- {{localInput.label}}
+ {{stripTags(localInput.label)}}
{{retrieveNoteText()}}
@@ -45,15 +45,30 @@
dark
style="flex-grow: 1;"
dense
- :ref="`singleRelationshipField${this.inputDataBluePrint.id}`"
+ :ref="`singleRelationshipField${inputDataBluePrint.id}`"
:options="filteredInput"
use-input
outlined
input-debounce="0"
v-model="localInput"
@filter="filterSelect"
- @input="signalInput"
+ @input="signalInput(false)"
>
+
+
+ {{ stripTags(scope.opt.label) }}
+
+
+
- {{localInput.label}}
+ {{stripTags(localInput.label)}}
|
@@ -144,7 +159,6 @@ export default class Field_SingleRelationship extends BaseClass {
@Prop() readonly editMode!: boolean
- changedInput = false
localInput = "" as unknown as I_FieldRelationship
inputNote: { pairedId: string; value: string; } = {
@@ -282,6 +296,7 @@ export default class Field_SingleRelationship extends BaseClass {
if (!objectsWithoutCurrent.find(e => e._id === this.localInput._id)) {
// @ts-ignore
this.localInput = ""
+ this.signalInput(true)
}
else {
const matchedFieldContent = objectsWithoutCurrent.find(e => e._id === this.localInput._id)
@@ -295,13 +310,15 @@ export default class Field_SingleRelationship extends BaseClass {
}
}
+ debounceTimerCheck = false
+
@Emit()
- signalInput () {
- this.changedInput = true
+ signalInput (skipSave?: boolean) {
this.inputNote = (this.localInput !== null) ? this.inputNote : { pairedId: "", value: "" }
return {
value: this.localInput,
- addedValues: this.inputNote
+ addedValues: this.inputNote,
+ skipSave: (skipSave)
}
}
}
diff --git a/src/components/fields/Field_SingleSelect.vue b/src/components/fields/Field_SingleSelect.vue
index 1bddf80..1d56246 100644
--- a/src/components/fields/Field_SingleSelect.vue
+++ b/src/components/fields/Field_SingleSelect.vue
@@ -39,6 +39,21 @@
@input="signalInput"
@keydown="signalInput"
>
+
+
+ {{ scope.opt }}
+
+
+
diff --git a/src/components/fields/Field_Tags.vue b/src/components/fields/Field_Tags.vue
index 5aba014..6e49eb0 100644
--- a/src/components/fields/Field_Tags.vue
+++ b/src/components/fields/Field_Tags.vue
@@ -15,7 +15,7 @@
>
+ color="accent" text-color="dark" class="text-bold">
{{input}}
@@ -41,6 +41,19 @@
@input="signalInput"
@keydown="signalInput"
>
+
+
+ {{ stripTags(scope.opt) }}
+
+
diff --git a/src/css/app.scss b/src/css/app.scss
index 45e5dbf..de40ec1 100644
--- a/src/css/app.scss
+++ b/src/css/app.scss
@@ -75,11 +75,36 @@ body {
}
.q-field__input,
+ .q-icon,
.q-field__native span {
color: #000 !important;
}
}
+.tagSelect,
+.singleSelect,
+.multiSelect,
+.singleRelashionshipSelect,
+.multiRelashionshipSelect {
+ .q-chip {
+ height: inherit;
+
+ &--dense {
+ padding: 0.2em 0.5em;
+ }
+
+ &__content {
+ white-space: normal;
+ flex-wrap: wrap;
+ }
+
+ &__icon--remove {
+ margin-right: -0.2em;
+ margin-left: 0.2em;
+ }
+ }
+}
+
.q-menu .q-item {
transition: none !important;
}
@@ -142,5 +167,4 @@ body .q-tooltip {
color: $dark;
font-size: 13px;
font-weight: 600;
- max-width: 800px;
}
diff --git a/src/css/quasar.variables.scss b/src/css/quasar.variables.scss
index 42803cf..167db4e 100644
--- a/src/css/quasar.variables.scss
+++ b/src/css/quasar.variables.scss
@@ -13,7 +13,7 @@
// Tip: Use the "Theme Builder" on Quasar's documentation website.
$primary : #d7ac47;
-$secondary : #e3173a;
+$secondary : #f72e43;
$accent : #dde4e4;
$dark : #18303a;
@@ -28,7 +28,7 @@ $customColors: (
'gunmetal-light': lighten(#18303a, 7.5),
'gunmetal-bright': lighten(#18303a, 30),
'gunmetal-shine': lighten(#18303a, 60),
- 'ruby-red': #e3173a,
+ 'ruby-red': #f72e43,
'satin-sheen-gold': #d7ac47,
'gainsboro': #dde4e4,
'cultured': #f5f5f5
diff --git a/src/i18n/en-us/index.ts b/src/i18n/en-us/index.ts
index 9ec688f..435b729 100644
--- a/src/i18n/en-us/index.ts
+++ b/src/i18n/en-us/index.ts
@@ -3,5 +3,9 @@
export default {
failed: "Action failed",
- success: "Action was successful"
+ success: "Action was successful",
+ tooltips: {
+ advancedSearch: `stuff
+ more stuff`
+ }
}
diff --git a/src/pages/DocumentDisplay.vue b/src/pages/DocumentDisplay.vue
index b7e3710..e581e9b 100644
--- a/src/pages/DocumentDisplay.vue
+++ b/src/pages/DocumentDisplay.vue
@@ -4,30 +4,6 @@
>
-
-
-
-
-
-
console.log(e))
+ }
+
+ /**
+ * Watches on changes of the opened documents in order to load proper blueprint and object data
+ */
+ @Watch("SGET_allOpenedDocuments", { deep: true })
+ async onDocChange () {
+ await this.sleep(300)
+
+ const matchingDoc = this.findRequestedOrActiveDocument()
+ if (matchingDoc && matchingDoc._id === this.currentData._id && !matchingDoc.hasEdits) {
+ this.reloadLocalContent().catch(e => console.log(e))
+ }
+ }
+
+ async reloadLocalContent () {
// Determine the type and retrieve the right blueprint
this.bluePrintData = this.retrieveDocumentBlueprint()
@@ -251,7 +243,7 @@ export default class PageDocumentDisplay extends BaseClass {
this.SSET_addOpenedDocument(dataPass)
}
- reactToFieldUpdate (inputData: string, field: I_ExtraFields) {
+ async reactToFieldUpdate (inputData: string, field: I_ExtraFields) {
// FIELD - Text
if (field.type === "text") {
this.currentData.hasEdits = true
@@ -356,6 +348,14 @@ export default class PageDocumentDisplay extends BaseClass {
const dataCopy: I_OpenedDocument = extend(true, {}, this.currentData)
const dataPass = { doc: dataCopy, treeAction: false }
+
+ // @ts-ignore
+ if (inputData.skipSave) {
+ this.currentData.extraFields[indexToUpdate].value.skipSave = false
+ await this.triggerSaveDocument()
+ return
+ }
+
this.SSET_updateOpenedDocument(dataPass)
}
@@ -368,6 +368,14 @@ export default class PageDocumentDisplay extends BaseClass {
const dataCopy: I_OpenedDocument = extend(true, {}, this.currentData)
const dataPass = { doc: dataCopy, treeAction: false }
+
+ // @ts-ignore
+ if (inputData.skipSave) {
+ this.currentData.extraFields[indexToUpdate].value.skipSave = false
+ await this.triggerSaveDocument()
+ return
+ }
+
this.SSET_updateOpenedDocument(dataPass)
}
@@ -396,129 +404,40 @@ export default class PageDocumentDisplay extends BaseClass {
}
}
- toggleEditMode () {
- this.editMode = true
- this.currentData.editMode = true
- const dataCopy: I_OpenedDocument = extend(true, {}, this.currentData)
- const dataPass = { doc: dataCopy, treeAction: false }
- this.SSET_updateOpenedDocument(dataPass)
- }
+ async triggerSaveDocument () {
+ const currentDoc = this.currentData
- async saveDocument () {
- this.editMode = false
- this.currentData.isNew = false
- this.currentData.hasEdits = false
- this.currentData.editMode = false
+ const allDocuments = this.SGET_allOpenedDocuments
- const CurrentObjectDB = new PouchDB(this.$route.params.type)
+ const docCopy: I_OpenedDocument[] = extend(true, [], allDocuments.docs)
- let currentDocument = false as unknown as I_OpenedDocument
- try {
- currentDocument = await CurrentObjectDB.get(this.$route.params.id)
+ if (currentDoc) {
+ // @ts-ignore
+ const savedDocument: {
+ documentCopy: I_OpenedDocument,
+ allOpenedDocuments: I_OpenedDocument[]
+ } = await saveDocument(currentDoc, docCopy)
+
+ // Update the opened document
+ const dataPass = { doc: savedDocument.documentCopy, treeAction: true }
+ this.SSET_updateOpenedDocument(dataPass)
+
+ // Update all others
+ for (const doc of savedDocument.allOpenedDocuments) {
+ // Update the opened document
+ const dataPass = { doc: doc, treeAction: true }
+ this.SSET_updateOpenedDocument(dataPass)
+ }
+
+ this.editMode = false
+ this.currentData.isNew = false
+ this.currentData.hasEdits = false
+ this.currentData.editMode = false
}
- catch (error) {}
-
- let documentCopy = {} as unknown as I_OpenedDocument
- if (currentDocument) {
- documentCopy = extend(true, {}, this.currentData)
- documentCopy._rev = currentDocument?._rev
- }
- else {
- documentCopy = extend(true, {}, this.currentData)
- }
-
- // Handle relatinship fields
- const single_relationshipTypes = ["singleToSingleRelationship", "singleToManyRelationship"]
- const single_allRelationshipFields = documentCopy.extraFields.filter(field => {
- const currentField = this.bluePrintData.extraFields.find(e => e.id === field.id) as unknown as I_ExtraFields
- return (currentField && single_relationshipTypes.includes(currentField.type))
- })
- const many_relationshipTypes = ["manyToSingleRelationship", "manyToManyRelationship"]
- const many_allRelationshipFields = documentCopy.extraFields.filter(field => {
- const currentField = this.bluePrintData.extraFields.find(e => e.id === field.id) as unknown as I_ExtraFields
- return (currentField && many_relationshipTypes.includes(currentField.type))
- })
-
- // Update single fields
- for (const field of single_allRelationshipFields) {
- const single_updatedDocuments: I_OpenedDocument[] = await single_changeRelationshipToAnotherObject(field, documentCopy, currentDocument)
-
- const pairedFieldID = this.bluePrintData.extraFields.find(e => e.id === field.id)?.relationshipSettings?.connectedField
-
- const filteredDocuments = single_updatedDocuments.filter(doc => {
- return this.SGET_allOpenedDocuments.docs.find(subDoc => {
- return subDoc._id === doc._id
- })
- })
-
- // Update the particular field in each currently opened document
- filteredDocuments.forEach(doc => {
- const toUpdateIndex = doc.extraFields.findIndex(e => e.id === pairedFieldID)
-
- if (toUpdateIndex) {
- const docCopy: I_OpenedDocument = extend(true, {}, this.SGET_openedDocument(doc._id))
- docCopy.extraFields[toUpdateIndex] = doc.extraFields[toUpdateIndex]
-
- // Tree action here due to how parentDoc field works
- const dataPass = { doc: docCopy, treeAction: true }
- this.SSET_updateOpenedDocument(dataPass)
- }
- })
- }
-
- // Update many fields
- for (const field of many_allRelationshipFields) {
- const many_updatedDocuments: I_OpenedDocument[] = await many_changeRelationshipToAnotherObject(field, documentCopy, currentDocument)
-
- const pairedFieldID = this.bluePrintData.extraFields.find(e => e.id === field.id)?.relationshipSettings?.connectedField
-
- const filteredDocuments = many_updatedDocuments.filter(doc => {
- return this.SGET_allOpenedDocuments.docs.find(subDoc => {
- return subDoc._id === doc._id
- })
- })
-
- // Update the particular field in each currently opened document
- filteredDocuments.forEach(doc => {
- const toUpdateIndex = doc.extraFields.findIndex(e => e.id === pairedFieldID)
-
- if (toUpdateIndex) {
- const docCopy: I_OpenedDocument = extend(true, {}, this.SGET_openedDocument(doc._id))
- docCopy.extraFields[toUpdateIndex] = doc.extraFields[toUpdateIndex]
-
- const dataPass = { doc: docCopy, treeAction: false }
- this.SSET_updateOpenedDocument(dataPass)
- }
- })
- }
- // Save the document
- await CurrentObjectDB.put(documentCopy)
-
- // Update the opened document
- const dataPass = { doc: documentCopy, treeAction: true }
- this.SSET_updateOpenedDocument(dataPass)
}
editMode = false
- /**
- * React to keypresses
- */
- @Watch("SGET_getCurrentKeyBindData", { deep: true })
- processKeyPush () {
- // Save document
- if (this.determineKeyBind("saveDocument") && this.editMode) {
- this.saveDocument().catch(e => {
- console.log(e)
- })
- }
-
- // Edit document - CTRL + E
- if (this.determineKeyBind("editDocument") && !this.editMode) {
- this.toggleEditMode()
- }
- }
-
currentData = false as unknown as I_OpenedDocument
/**
@@ -628,15 +547,6 @@ export default class PageDocumentDisplay extends BaseClass {
const ignoredList = ["breakBasic", "name", "documentColor", "parentDoc", "order", "categorySwitch"]
return (!isCategory || ignoredList.includes(currentFieldID))
}
-
- addNewUnderParent () {
- const routeObject = {
- _id: this.currentData.type,
- parent: this.currentData._id
- }
- // @ts-ignore
- this.addNewObjectRoute(routeObject)
- }
}
diff --git a/src/scripts/databaseManager/documentManager.ts b/src/scripts/databaseManager/documentManager.ts
new file mode 100644
index 0000000..d946d6d
--- /dev/null
+++ b/src/scripts/databaseManager/documentManager.ts
@@ -0,0 +1,103 @@
+import { single_changeRelationshipToAnotherObject, many_changeRelationshipToAnotherObject } from "src/scripts/databaseManager/relationshipManager"
+import { I_OpenedDocument } from "src/interfaces/I_OpenedDocument"
+import { I_ExtraFields } from "src/interfaces/I_Blueprint"
+import { extend } from "quasar"
+import PouchDB from "pouchdb"
+
+/**
+ * Saves the given project and handles all the needed procedures
+ */
+export const saveDocument = async (document: I_OpenedDocument, allOpenedDocuments: I_OpenedDocument[]) => {
+ const BlueprintsDB = new PouchDB("blueprints")
+ const currentBlueprint: {extraFields: I_ExtraFields[]} = await BlueprintsDB.get(document.type)
+
+ const CurrentObjectDB = new PouchDB(document.type)
+
+ let currentDocument = false as unknown as I_OpenedDocument
+ try {
+ currentDocument = await CurrentObjectDB.get(document._id)
+ }
+ catch (error) {}
+
+ let documentCopy = {} as unknown as I_OpenedDocument
+ if (currentDocument) {
+ documentCopy = extend(true, {}, document)
+ documentCopy._rev = currentDocument?._rev
+ }
+ else {
+ documentCopy = extend(true, {}, document)
+ }
+
+ allOpenedDocuments = allOpenedDocuments.filter(doc => doc._id !== document._id)
+
+ // Handle relatinship fields
+ const single_relationshipTypes = ["singleToSingleRelationship", "singleToManyRelationship"]
+ const single_allRelationshipFields = documentCopy.extraFields.filter(field => {
+ const currentField = currentBlueprint.extraFields.find(e => e.id === field.id) as unknown as I_ExtraFields
+ return (currentField && single_relationshipTypes.includes(currentField.type))
+ })
+ const many_relationshipTypes = ["manyToSingleRelationship", "manyToManyRelationship"]
+ const many_allRelationshipFields = documentCopy.extraFields.filter(field => {
+ const currentField = currentBlueprint.extraFields.find(e => e.id === field.id) as unknown as I_ExtraFields
+ return (currentField && many_relationshipTypes.includes(currentField.type))
+ })
+
+ // Update single fields
+ for (const field of single_allRelationshipFields) {
+ const single_updatedDocuments: I_OpenedDocument[] = await single_changeRelationshipToAnotherObject(field, documentCopy, currentDocument)
+
+ const pairedFieldID = currentBlueprint.extraFields.find(e => e.id === field.id)?.relationshipSettings?.connectedField
+
+ const filteredDocuments = single_updatedDocuments.filter(doc => {
+ return allOpenedDocuments.find(subDoc => {
+ return subDoc._id === doc._id
+ })
+ })
+
+ // Update the particular field in each currently opened document
+ filteredDocuments.forEach(doc => {
+ const toUpdateIndex = doc.extraFields.findIndex(e => e.id === pairedFieldID)
+
+ if (toUpdateIndex) {
+ const matchingDoc = allOpenedDocuments.find(subDoc => subDoc._id === doc._id)
+ if (matchingDoc) {
+ matchingDoc.extraFields[toUpdateIndex] = doc.extraFields[toUpdateIndex]
+ }
+ }
+ })
+ }
+
+ // Update many fields
+ for (const field of many_allRelationshipFields) {
+ const many_updatedDocuments: I_OpenedDocument[] = await many_changeRelationshipToAnotherObject(field, documentCopy, currentDocument)
+
+ const pairedFieldID = currentBlueprint.extraFields.find(e => e.id === field.id)?.relationshipSettings?.connectedField
+
+ const filteredDocuments = many_updatedDocuments.filter(doc => {
+ return allOpenedDocuments.find(subDoc => {
+ return subDoc._id === doc._id
+ })
+ })
+
+ // Update the particular field in each currently opened document
+ filteredDocuments.forEach(doc => {
+ const toUpdateIndex = doc.extraFields.findIndex(e => e.id === pairedFieldID)
+
+ if (toUpdateIndex) {
+ const matchingDoc = allOpenedDocuments.find(subDoc => subDoc._id === doc._id)
+ if (matchingDoc) {
+ matchingDoc.extraFields[toUpdateIndex] = doc.extraFields[toUpdateIndex]
+ }
+ }
+ })
+ }
+
+ documentCopy.isNew = false
+ documentCopy.hasEdits = false
+ documentCopy.editMode = false
+
+ // Save the document
+ await CurrentObjectDB.put(documentCopy)
+
+ return { documentCopy, allOpenedDocuments }
+}
diff --git a/src/store/module-openedDocuments/state.ts b/src/store/module-openedDocuments/state.ts
index 87d9420..e35801e 100644
--- a/src/store/module-openedDocuments/state.ts
+++ b/src/store/module-openedDocuments/state.ts
@@ -1,11 +1,13 @@
import { I_OpenedDocument } from "./../../interfaces/I_OpenedDocument"
export interface OpenDocumentsStateInterface {
- documents: {
- timestamp: string,
- treeAction: boolean,
- docs: I_OpenedDocument[]
- }
+ documents: InnerOpenDocumentsStateInterface
+}
+
+export interface InnerOpenDocumentsStateInterface {
+ timestamp: string,
+ treeAction: boolean,
+ docs: I_OpenedDocument[]
}
function state (): OpenDocumentsStateInterface {
| |