mirror of
https://github.com/Elvanos/fantasia-archive.git
synced 2024-06-29 03:20:54 +12:00
0.1.8 - finished export/document templates
This commit is contained in:
parent
4bdecc7559
commit
57c78c08c0
|
@ -3,10 +3,10 @@
|
||||||
<q-dialog
|
<q-dialog
|
||||||
v-model="dialogModel"
|
v-model="dialogModel"
|
||||||
@before-hide="triggerDialogClose"
|
@before-hide="triggerDialogClose"
|
||||||
:persistent="exportOngoing || editingExportTemplates"
|
:persistent="exportOngoing || editingDocumentTemplates"
|
||||||
>
|
>
|
||||||
<q-card
|
<q-card
|
||||||
v-if="!exportOngoing && !editingExportTemplates"
|
v-if="!exportOngoing && !editingDocumentTemplates"
|
||||||
class="exportDialog"
|
class="exportDialog"
|
||||||
dark
|
dark
|
||||||
>
|
>
|
||||||
|
@ -286,12 +286,12 @@
|
||||||
dark
|
dark
|
||||||
filled
|
filled
|
||||||
class="flex-grow"
|
class="flex-grow"
|
||||||
:options="exportTemplateList"
|
:options="documentTemplateList"
|
||||||
use-input
|
use-input
|
||||||
v-model="selectedExportTemplate"
|
v-model="selectedDocumentTemplate"
|
||||||
menu-anchor="bottom middle"
|
menu-anchor="bottom middle"
|
||||||
menu-self="top middle"
|
menu-self="top middle"
|
||||||
label="Selected export template"
|
label="Selected template"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
clearable
|
clearable
|
||||||
>
|
>
|
||||||
|
@ -316,20 +316,20 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="selectedExportTemplate"
|
v-if="selectedDocumentTemplate"
|
||||||
class="col-auto flex items-center q-ml-md q-mb-lg"
|
class="col-auto flex items-center q-ml-md q-mb-lg"
|
||||||
>
|
>
|
||||||
<q-btn round dense flat icon="mdi-pencil" @click.stop.prevent="editExistingExportTemplate">
|
<q-btn round dense flat icon="mdi-pencil" @click.stop.prevent="editExistingDocumentTemplate">
|
||||||
<q-tooltip :delay="500">
|
<q-tooltip :delay="500">
|
||||||
Edit this export template
|
Edit this template
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-auto flex items-center q-ml-md q-mb-lg">
|
<div class="col-auto flex items-center q-ml-md q-mb-lg">
|
||||||
<q-btn round dense flat icon="mdi-plus" @click.stop.prevent="setupNewExportTemplate">
|
<q-btn round dense flat icon="mdi-plus" @click.stop.prevent="setupNewDocumentTemplate">
|
||||||
<q-tooltip :delay="500">
|
<q-tooltip :delay="500">
|
||||||
Add a new export template
|
Add a new template
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
|
@ -484,7 +484,7 @@
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<q-card v-if="editingExportTemplates" dark class="exportTemplates">
|
<q-card v-if="editingDocumentTemplates" dark class="exportTemplates">
|
||||||
<div style="width: 100%;">
|
<div style="width: 100%;">
|
||||||
<q-input
|
<q-input
|
||||||
class="exportTemplateNameInput"
|
class="exportTemplateNameInput"
|
||||||
|
@ -493,16 +493,16 @@
|
||||||
:bottom-slots="false"
|
:bottom-slots="false"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
:label="(editedExportTemplate.name.length === 0) ? 'Enter template name' : 'Export template name'"
|
:label="(editedDocumentTemplate.name.length === 0) ? 'Enter template name' : 'Export template name'"
|
||||||
v-model="editedExportTemplate.name"
|
v-model="editedDocumentTemplate.name"
|
||||||
:error="editedExportTemplate.name.length === 0"
|
:error="editedDocumentTemplate.name.length === 0"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="exportTemplatesInner">
|
<div class="exportTemplatesInner">
|
||||||
<q-card-section horizontal class="exportTemplatesTabList">
|
<q-card-section horizontal class="exportTemplatesTabList">
|
||||||
<q-tabs
|
<q-tabs
|
||||||
v-model="activeExportTemplateTab"
|
v-model="activeDocumentTemplateTab"
|
||||||
class="text-accent"
|
class="text-accent"
|
||||||
active-color="primary"
|
active-color="primary"
|
||||||
indicator-color="primary"
|
indicator-color="primary"
|
||||||
|
@ -520,7 +520,7 @@
|
||||||
:key="blueprint._id"
|
:key="blueprint._id"
|
||||||
:icon="blueprint.icon"
|
:icon="blueprint.icon"
|
||||||
:name="blueprint._id"
|
:name="blueprint._id"
|
||||||
:label="`${blueprint.namePlural} - ${selectedExportTableData[index].fields.length}/${exportTableData[index].fields.length}`"
|
:label="`${blueprint.namePlural} - ${selecteddocumentTemplateTableData[index].fields.length}/${documentTemplateTableData[index].fields.length}`"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</q-tabs>
|
</q-tabs>
|
||||||
|
@ -530,7 +530,7 @@
|
||||||
<q-card-section horizontal class="exportTemplatesTabContent">
|
<q-card-section horizontal class="exportTemplatesTabContent">
|
||||||
<q-tab-panels
|
<q-tab-panels
|
||||||
dark
|
dark
|
||||||
v-model="activeExportTemplateTab"
|
v-model="activeDocumentTemplateTab"
|
||||||
animated
|
animated
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
vertical
|
vertical
|
||||||
|
@ -546,14 +546,14 @@
|
||||||
|
|
||||||
<q-table
|
<q-table
|
||||||
:title="blueprint.namePlural"
|
:title="blueprint.namePlural"
|
||||||
:data="exportTableData[index].fields"
|
:data="documentTemplateTableData[index].fields"
|
||||||
:columns="exportDataColumns"
|
:columns="documentTemplateDataColumns"
|
||||||
virtual-scroll
|
virtual-scroll
|
||||||
:rows-per-page-options="[0]"
|
:rows-per-page-options="[0]"
|
||||||
:virtual-scroll-sticky-size-start="48"
|
:virtual-scroll-sticky-size-start="48"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
selection="multiple"
|
selection="multiple"
|
||||||
:selected.sync="selectedExportTableData[index].fields"
|
:selected.sync="selecteddocumentTemplateTableData[index].fields"
|
||||||
dark
|
dark
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
|
@ -567,26 +567,28 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-card-actions align="right" class="q-mb-lg q-mt-md q-mr-xl controlButtons">
|
<q-card-actions align="right" class="q-mb-lg q-mt-md q-mx-xl controlButtons">
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
label="Delete template"
|
label="Delete template"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
class="align-self-start"
|
class="q-mr-auto deleteTemplateButton"
|
||||||
|
v-if="!adddingNewTemplate"
|
||||||
|
@click="deleteDocumentTemplate"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
flat
|
flat
|
||||||
label="Cancel editing"
|
label="Cancel editing"
|
||||||
color="accent"
|
color="accent"
|
||||||
class="q-mr-lg"
|
class="q-mr-lg"
|
||||||
@click="editingExportTemplates = false"
|
@click="editingDocumentTemplates = false"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
outline
|
outline
|
||||||
:disable="editedExportTemplate.name.length === 0"
|
:disable="editedDocumentTemplate.name.length === 0"
|
||||||
label="Save template"
|
label="Save template"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="saveExportTemplate"
|
@click="saveDocumentTemplate"
|
||||||
/>
|
/>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
|
|
||||||
|
@ -641,13 +643,13 @@ import documentPreview from "src/components/DocumentPreview.vue"
|
||||||
import { I_ExportObject } from "src/interfaces/I_ExportObject"
|
import { I_ExportObject } from "src/interfaces/I_ExportObject"
|
||||||
import { I_ShortenedDocument } from "src/interfaces/I_OpenedDocument"
|
import { I_ShortenedDocument } from "src/interfaces/I_OpenedDocument"
|
||||||
import { I_Blueprint } from "src/interfaces/I_Blueprint"
|
import { I_Blueprint } from "src/interfaces/I_Blueprint"
|
||||||
import { I_ExportTemplate } from "src/interfaces/I_ExportTemplate"
|
import { I_DocumentTemplate } from "src/interfaces/I_DocumentTemplate"
|
||||||
|
|
||||||
import { I_PDFKitDocument } from "src/interfaces/I_PDFKitDocument"
|
import { I_PDFKitDocument } from "src/interfaces/I_PDFKitDocument"
|
||||||
import { I_HtmlParserNode } from "src/interfaces/I_HtmlParserNode"
|
import { I_HtmlParserNode } from "src/interfaces/I_HtmlParserNode"
|
||||||
import { advancedDocumentFilter } from "src/scripts/utilities/advancedDocumentFilter"
|
import { advancedDocumentFilter } from "src/scripts/utilities/advancedDocumentFilter"
|
||||||
|
|
||||||
import { saveExportTemplateIntoDB, retrieveAllExportTemplatesFromDB } from "src/scripts/projectManagement/exportTemplates"
|
import { saveDocumentTemplateIntoDB, retrieveAllDocumentTemplatesFromDB, removeDocumentTemplateFromDB } from "src/scripts/projectManagement/documentTemplates"
|
||||||
|
|
||||||
import RobotoRegular from "src/assets/fonts/Roboto-Regular.ttf"
|
import RobotoRegular from "src/assets/fonts/Roboto-Regular.ttf"
|
||||||
import RobotoBold from "src/assets/fonts/Roboto-Bold.ttf"
|
import RobotoBold from "src/assets/fonts/Roboto-Bold.ttf"
|
||||||
|
@ -675,7 +677,7 @@ export default class ExportProject extends DialogBase {
|
||||||
this.SSET_setDialogState(true)
|
this.SSET_setDialogState(true)
|
||||||
this.dialogModel = true
|
this.dialogModel = true
|
||||||
|
|
||||||
this.exportTemplateList = await retrieveAllExportTemplatesFromDB()
|
this.documentTemplateList = await retrieveAllDocumentTemplatesFromDB()
|
||||||
|
|
||||||
this.resetLocalData()
|
this.resetLocalData()
|
||||||
this.reloadOptions()
|
this.reloadOptions()
|
||||||
|
@ -707,6 +709,8 @@ export default class ExportProject extends DialogBase {
|
||||||
this.exportDocumentsModel = []
|
this.exportDocumentsModel = []
|
||||||
this.exportOngoing = false
|
this.exportOngoing = false
|
||||||
this.exportList = []
|
this.exportList = []
|
||||||
|
// @ts-ignore
|
||||||
|
this.selectedDocumentTemplate = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Prop(({
|
@Prop(({
|
||||||
|
@ -804,72 +808,76 @@ export default class ExportProject extends DialogBase {
|
||||||
listCopy: I_ShortenedDocument[] = []
|
listCopy: I_ShortenedDocument[] = []
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local list of all predefined export templates
|
* Local list of all predefined document templates
|
||||||
*/
|
*/
|
||||||
exportTemplateList: I_ExportTemplate[] = []
|
documentTemplateList: I_DocumentTemplate[] = []
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently selected export templates
|
* Currently selected document templates
|
||||||
*/
|
*/
|
||||||
selectedExportTemplate = null as unknown as I_ExportTemplate
|
selectedDocumentTemplate = null as unknown as I_DocumentTemplate
|
||||||
|
|
||||||
editingExportTemplates = false
|
editingDocumentTemplates = false
|
||||||
|
|
||||||
editedExportTemplate = {
|
editedDocumentTemplate = {
|
||||||
id: "",
|
id: "",
|
||||||
name: "",
|
name: "",
|
||||||
documentTypeList: []
|
documentTypeList: []
|
||||||
} as I_ExportTemplate
|
} as I_DocumentTemplate
|
||||||
|
|
||||||
activeExportTemplateTab = ""
|
activeDocumentTemplateTab = ""
|
||||||
|
|
||||||
setupNewExportTemplate () {
|
adddingNewTemplate = false
|
||||||
this.editedExportTemplate.id = uid()
|
|
||||||
this.editedExportTemplate.name = ""
|
|
||||||
this.activeExportTemplateTab = this.SGET_allBlueprints[0]._id
|
|
||||||
|
|
||||||
this.editedExportTemplate.documentTypeList = this.SGET_allBlueprints.map(blueprint => {
|
setupNewDocumentTemplate () {
|
||||||
|
this.adddingNewTemplate = true
|
||||||
|
this.editedDocumentTemplate.id = uid()
|
||||||
|
this.editedDocumentTemplate.name = ""
|
||||||
|
this.activeDocumentTemplateTab = this.SGET_allBlueprints[0]._id
|
||||||
|
|
||||||
|
this.editedDocumentTemplate.documentTypeList = this.SGET_allBlueprints.map(blueprint => {
|
||||||
return {
|
return {
|
||||||
documentTypeID: blueprint._id,
|
documentTypeID: blueprint._id,
|
||||||
excludedFieldIDList: []
|
excludedFieldIDList: []
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.mapExportFieldTableData()
|
this.mapDocumentFieldTableData()
|
||||||
this.editingExportTemplates = true
|
this.editingDocumentTemplates = true
|
||||||
}
|
}
|
||||||
|
|
||||||
editExistingExportTemplate () {
|
editExistingDocumentTemplate () {
|
||||||
this.editedExportTemplate.id = this.selectedExportTemplate.id
|
this.adddingNewTemplate = false
|
||||||
this.editedExportTemplate.name = this.selectedExportTemplate.name
|
this.editedDocumentTemplate.id = this.selectedDocumentTemplate.id
|
||||||
this.activeExportTemplateTab = this.SGET_allBlueprints[0]._id
|
this.editedDocumentTemplate.name = this.selectedDocumentTemplate.name
|
||||||
|
this.activeDocumentTemplateTab = this.SGET_allBlueprints[0]._id
|
||||||
|
|
||||||
this.editedExportTemplate.documentTypeList = this.selectedExportTemplate.documentTypeList
|
this.editedDocumentTemplate.documentTypeList = this.selectedDocumentTemplate.documentTypeList
|
||||||
this.mapExportFieldTableData()
|
this.mapDocumentFieldTableData()
|
||||||
this.editingExportTemplates = true
|
this.editingDocumentTemplates = true
|
||||||
}
|
}
|
||||||
|
|
||||||
exportTableData: {
|
documentTemplateTableData: {
|
||||||
timestamp: string
|
timestamp: string
|
||||||
blueprintID: string
|
blueprintID: string
|
||||||
fields: I_ShotrenedExtraField[]
|
fields: I_ShotrenedExtraField[]
|
||||||
}[] = []
|
}[] = []
|
||||||
|
|
||||||
selectedExportTableData: {
|
selecteddocumentTemplateTableData: {
|
||||||
timestamp: string
|
timestamp: string
|
||||||
blueprintID: string
|
blueprintID: string
|
||||||
fields: I_ShotrenedExtraField[]
|
fields: I_ShotrenedExtraField[]
|
||||||
}[] = []
|
}[] = []
|
||||||
|
|
||||||
mapExportFieldTableData () {
|
mapDocumentFieldTableData () {
|
||||||
for (let index = 0; index < this.SGET_allBlueprints.length; index++) {
|
for (let index = 0; index < this.SGET_allBlueprints.length; index++) {
|
||||||
const blueprint = this.SGET_allBlueprints[index]
|
const blueprint = this.SGET_allBlueprints[index]
|
||||||
|
|
||||||
this.exportTableData[index] = {
|
this.documentTemplateTableData[index] = {
|
||||||
timestamp: uid(),
|
timestamp: uid(),
|
||||||
blueprintID: blueprint._id,
|
blueprintID: blueprint._id,
|
||||||
fields: []
|
fields: []
|
||||||
}
|
}
|
||||||
this.selectedExportTableData[index] = {
|
this.selecteddocumentTemplateTableData[index] = {
|
||||||
timestamp: uid(),
|
timestamp: uid(),
|
||||||
blueprintID: blueprint._id,
|
blueprintID: blueprint._id,
|
||||||
fields: []
|
fields: []
|
||||||
|
@ -899,12 +907,12 @@ export default class ExportProject extends DialogBase {
|
||||||
field.id !== "documentBackgroundColor" &&
|
field.id !== "documentBackgroundColor" &&
|
||||||
field.id !== "breakDocumentSettings"
|
field.id !== "breakDocumentSettings"
|
||||||
) {
|
) {
|
||||||
this.exportTableData[index].fields.push(remappedField)
|
this.documentTemplateTableData[index].fields.push(remappedField)
|
||||||
|
|
||||||
const matchedExludedList = this.editedExportTemplate.documentTypeList.find(list => list.documentTypeID === blueprint._id)?.excludedFieldIDList
|
const matchedExludedList = this.editedDocumentTemplate.documentTypeList.find(list => list.documentTypeID === blueprint._id)?.excludedFieldIDList
|
||||||
|
|
||||||
if (!matchedExludedList || !matchedExludedList.includes(remappedField.id)) {
|
if (!matchedExludedList || !matchedExludedList.includes(remappedField.id)) {
|
||||||
this.selectedExportTableData[index].fields.push(remappedField)
|
this.selecteddocumentTemplateTableData[index].fields.push(remappedField)
|
||||||
}
|
}
|
||||||
counter++
|
counter++
|
||||||
}
|
}
|
||||||
|
@ -913,18 +921,18 @@ export default class ExportProject extends DialogBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
reactToRowUpdate () {
|
reactToRowUpdate () {
|
||||||
this.selectedExportTableData = this.selectedExportTableData.map(single => {
|
this.selecteddocumentTemplateTableData = this.selecteddocumentTemplateTableData.map(single => {
|
||||||
single.timestamp = uid()
|
single.timestamp = uid()
|
||||||
return single
|
return single
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveExportTemplate () {
|
async saveDocumentTemplate () {
|
||||||
const newExportTemplate: I_ExportTemplate = extend(true, [], this.editedExportTemplate)
|
const newDocumentTemplate: I_DocumentTemplate = extend(true, [], this.editedDocumentTemplate)
|
||||||
newExportTemplate.documentTypeList = newExportTemplate.documentTypeList.map(docType => {
|
newDocumentTemplate.documentTypeList = newDocumentTemplate.documentTypeList.map(docType => {
|
||||||
const matchedBlueprint = this.SGET_blueprint(docType.documentTypeID)
|
const matchedBlueprint = this.SGET_blueprint(docType.documentTypeID)
|
||||||
const matchedTableRow = this.exportTableData.find(row => row.blueprintID === matchedBlueprint._id)
|
const matchedTableRow = this.documentTemplateTableData.find(row => row.blueprintID === matchedBlueprint._id)
|
||||||
const matchedSelectTableRow = this.selectedExportTableData.find(row => row.blueprintID === matchedBlueprint._id)
|
const matchedSelectTableRow = this.selecteddocumentTemplateTableData.find(row => row.blueprintID === matchedBlueprint._id)
|
||||||
|
|
||||||
if (matchedTableRow && matchedSelectTableRow) {
|
if (matchedTableRow && matchedSelectTableRow) {
|
||||||
const excludedFieldIDList = matchedTableRow.fields
|
const excludedFieldIDList = matchedTableRow.fields
|
||||||
|
@ -945,9 +953,9 @@ export default class ExportProject extends DialogBase {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await saveExportTemplateIntoDB(newExportTemplate)
|
await saveDocumentTemplateIntoDB(newDocumentTemplate)
|
||||||
this.exportTemplateList = await retrieveAllExportTemplatesFromDB()
|
this.documentTemplateList = await retrieveAllDocumentTemplatesFromDB()
|
||||||
this.editingExportTemplates = false
|
this.editingDocumentTemplates = false
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
group: false,
|
group: false,
|
||||||
type: "positive",
|
type: "positive",
|
||||||
|
@ -957,7 +965,25 @@ export default class ExportProject extends DialogBase {
|
||||||
await this.$nextTick()
|
await this.$nextTick()
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.selectedExportTemplate = this.exportTemplateList.find(t => t.id === newExportTemplate.id)
|
this.selectedDocumentTemplate = this.documentTemplateList.find(t => t.id === newDocumentTemplate.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteDocumentTemplate () {
|
||||||
|
const newDocumentTemplate: I_DocumentTemplate = extend(true, [], this.editedDocumentTemplate)
|
||||||
|
|
||||||
|
await removeDocumentTemplateFromDB(newDocumentTemplate)
|
||||||
|
|
||||||
|
this.documentTemplateList = await retrieveAllDocumentTemplatesFromDB()
|
||||||
|
this.editingDocumentTemplates = false
|
||||||
|
this.$q.notify({
|
||||||
|
group: false,
|
||||||
|
type: "positive",
|
||||||
|
message: "Template succesfully deleted"
|
||||||
|
})
|
||||||
|
|
||||||
|
await this.$nextTick()
|
||||||
|
// @ts-ignore
|
||||||
|
this.selectedDocumentTemplate = null
|
||||||
}
|
}
|
||||||
|
|
||||||
mapFields (fieldType: string) {
|
mapFields (fieldType: string) {
|
||||||
|
@ -1012,7 +1038,7 @@ export default class ExportProject extends DialogBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exportDataColumns = [
|
documentTemplateDataColumns = [
|
||||||
{
|
{
|
||||||
name: "order",
|
name: "order",
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -1254,6 +1280,24 @@ export default class ExportProject extends DialogBase {
|
||||||
.filter(field => field.id !== "breakDocumentSettings")
|
.filter(field => field.id !== "breakDocumentSettings")
|
||||||
.filter(field => !field.isLegacy)
|
.filter(field => !field.isLegacy)
|
||||||
.filter(field => !field.isSpoiler || this.includeSpoilers)
|
.filter(field => !field.isSpoiler || this.includeSpoilers)
|
||||||
|
.filter(field => {
|
||||||
|
if (this.selectedDocumentTemplate) {
|
||||||
|
const currentFieldID = field.id
|
||||||
|
const curentBlueprintID = blueprint._id
|
||||||
|
|
||||||
|
const matchedTemplateRow = this.selectedDocumentTemplate.documentTypeList.find(e => e.documentTypeID === curentBlueprintID)
|
||||||
|
|
||||||
|
if (matchedTemplateRow) {
|
||||||
|
return !(matchedTemplateRow.excludedFieldIDList.includes(currentFieldID))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
.filter(field => {
|
.filter(field => {
|
||||||
if (input.extraFields.find(e => e.id === "categorySwitch")?.value) {
|
if (input.extraFields.find(e => e.id === "categorySwitch")?.value) {
|
||||||
if (catIgnoreList.includes(field.id)) {
|
if (catIgnoreList.includes(field.id)) {
|
||||||
|
@ -2082,6 +2126,10 @@ export default class ExportProject extends DialogBase {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deleteTemplateButton {
|
||||||
|
margin-left: 330px;
|
||||||
|
}
|
||||||
|
|
||||||
.exportTemplatesInner {
|
.exportTemplatesInner {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
max-width: calc(100vw - 100px) !important;
|
max-width: calc(100vw - 100px) !important;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
export interface I_ExportTemplate{
|
export interface I_DocumentTemplate{
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
documentTypeList: {
|
documentTypeList: {
|
92
src/scripts/projectManagement/documentTemplates.ts
Normal file
92
src/scripts/projectManagement/documentTemplates.ts
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
import { I_DocumentTemplate } from "./../../interfaces/I_DocumentTemplate"
|
||||||
|
// @ts-ignore
|
||||||
|
import PouchDB from "pouchdb"
|
||||||
|
import { extend } from "quasar"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save a document template
|
||||||
|
*/
|
||||||
|
export const saveDocumentTemplateIntoDB = async (editedDocumentTemplate: I_DocumentTemplate) => {
|
||||||
|
editedDocumentTemplate = extend(true, {}, editedDocumentTemplate)
|
||||||
|
|
||||||
|
if (!window.FA_dbs) {
|
||||||
|
// @ts-ignore
|
||||||
|
window.FA_dbs = {}
|
||||||
|
}
|
||||||
|
window.FA_dbs["project-data"] = new PouchDB("project-data")
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
const projectData = await window.FA_dbs["project-data"].allDocs({ include_docs: true })
|
||||||
|
|
||||||
|
const projectDataObject = projectData.rows[0].doc as {documentTemplates: I_DocumentTemplate[]}
|
||||||
|
|
||||||
|
if (!projectDataObject.documentTemplates) {
|
||||||
|
projectDataObject.documentTemplates = []
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingIndex = projectDataObject.documentTemplates.findIndex(t => t.id === editedDocumentTemplate.id)
|
||||||
|
|
||||||
|
if (existingIndex > -1) {
|
||||||
|
projectDataObject.documentTemplates[existingIndex] = editedDocumentTemplate
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
projectDataObject.documentTemplates.push(editedDocumentTemplate)
|
||||||
|
}
|
||||||
|
|
||||||
|
projectDataObject.documentTemplates.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
await window.FA_dbs["project-data"].put(projectDataObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all document templates from the database
|
||||||
|
*/
|
||||||
|
export const retrieveAllDocumentTemplatesFromDB = async (): Promise<I_DocumentTemplate[]> => {
|
||||||
|
if (!window.FA_dbs) {
|
||||||
|
// @ts-ignore
|
||||||
|
window.FA_dbs = {}
|
||||||
|
}
|
||||||
|
window.FA_dbs["project-data"] = new PouchDB("project-data")
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
const projectData = await window.FA_dbs["project-data"].allDocs({ include_docs: true })
|
||||||
|
|
||||||
|
const projectDataObject = projectData.rows[0].doc as {documentTemplates: I_DocumentTemplate[]}
|
||||||
|
|
||||||
|
if (projectDataObject.documentTemplates) {
|
||||||
|
return projectDataObject.documentTemplates
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a document template from the databse
|
||||||
|
*/
|
||||||
|
export const removeDocumentTemplateFromDB = async (editedDocumentTemplate: I_DocumentTemplate) => {
|
||||||
|
editedDocumentTemplate = extend(true, {}, editedDocumentTemplate)
|
||||||
|
|
||||||
|
if (!window.FA_dbs) {
|
||||||
|
// @ts-ignore
|
||||||
|
window.FA_dbs = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.FA_dbs["project-data"] = new PouchDB("project-data")
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
const projectData = await window.FA_dbs["project-data"].allDocs({ include_docs: true })
|
||||||
|
|
||||||
|
const projectDataObject = projectData.rows[0].doc as {documentTemplates: I_DocumentTemplate[]}
|
||||||
|
|
||||||
|
if (!projectDataObject.documentTemplates) {
|
||||||
|
projectDataObject.documentTemplates = []
|
||||||
|
}
|
||||||
|
|
||||||
|
const indexToRemove = projectDataObject.documentTemplates.findIndex(t => t.id === editedDocumentTemplate.id)
|
||||||
|
|
||||||
|
if (indexToRemove > -1) {
|
||||||
|
projectDataObject.documentTemplates.splice(indexToRemove, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
await window.FA_dbs["project-data"].put(projectDataObject)
|
||||||
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
import { I_ExportTemplate } from "./../../interfaces/I_ExportTemplate"
|
|
||||||
// @ts-ignore
|
|
||||||
import PouchDB from "pouchdb"
|
|
||||||
import { extend } from "quasar"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save export template
|
|
||||||
*/
|
|
||||||
export const saveExportTemplateIntoDB = async (editedExportInput: I_ExportTemplate) => {
|
|
||||||
editedExportInput = extend(true, {}, editedExportInput)
|
|
||||||
|
|
||||||
if (!window.FA_dbs) {
|
|
||||||
// @ts-ignore
|
|
||||||
window.FA_dbs = {}
|
|
||||||
}
|
|
||||||
window.FA_dbs["project-data"] = new PouchDB("project-data")
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
||||||
const projectData = await window.FA_dbs["project-data"].allDocs({ include_docs: true })
|
|
||||||
|
|
||||||
const projectDataObject = projectData.rows[0].doc as {exportTemplates: I_ExportTemplate[]}
|
|
||||||
|
|
||||||
if (!projectDataObject.exportTemplates) {
|
|
||||||
projectDataObject.exportTemplates = []
|
|
||||||
}
|
|
||||||
|
|
||||||
const existingIndex = projectDataObject.exportTemplates.findIndex(t => t.id === editedExportInput.id)
|
|
||||||
|
|
||||||
if (existingIndex > -1) {
|
|
||||||
projectDataObject.exportTemplates[existingIndex] = editedExportInput
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
projectDataObject.exportTemplates.push(editedExportInput)
|
|
||||||
}
|
|
||||||
|
|
||||||
projectDataObject.exportTemplates.sort((a, b) => a.name.localeCompare(b.name))
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
||||||
await window.FA_dbs["project-data"].put(projectDataObject)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all export templates from the database
|
|
||||||
*/
|
|
||||||
export const retrieveAllExportTemplatesFromDB = async (): Promise<I_ExportTemplate[]> => {
|
|
||||||
if (!window.FA_dbs) {
|
|
||||||
// @ts-ignore
|
|
||||||
window.FA_dbs = {}
|
|
||||||
}
|
|
||||||
window.FA_dbs["project-data"] = new PouchDB("project-data")
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
||||||
const projectData = await window.FA_dbs["project-data"].allDocs({ include_docs: true })
|
|
||||||
|
|
||||||
const projectDataObject = projectData.rows[0].doc as {exportTemplates: I_ExportTemplate[]}
|
|
||||||
|
|
||||||
if (projectDataObject.exportTemplates) {
|
|
||||||
return projectDataObject.exportTemplates
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue