2021-02-26 14:50:46 +13:00
|
|
|
<template>
|
|
|
|
<q-dialog
|
2021-03-18 10:26:08 +13:00
|
|
|
no-route-dismiss
|
2021-02-26 14:50:46 +13:00
|
|
|
v-model="dialogModel"
|
2021-05-09 02:05:13 +12:00
|
|
|
@before-hide="triggerDialogClose"
|
2021-02-26 14:50:46 +13:00
|
|
|
>
|
|
|
|
<q-card
|
|
|
|
dark
|
|
|
|
class="existingDocumentPopup"
|
|
|
|
>
|
|
|
|
|
|
|
|
<q-card-section class="row items-center">
|
|
|
|
<h6 class="text-center q-my-sm">Open existing document</h6>
|
|
|
|
</q-card-section>
|
|
|
|
|
2021-02-28 06:00:57 +13:00
|
|
|
<q-card-section class="column items-center">
|
2021-04-06 12:15:17 +12:00
|
|
|
<div class="q-mb-md">
|
2021-03-18 10:26:08 +13:00
|
|
|
<q-checkbox dark color="primary" v-model="includeCategories" label="Include categories in the list?" />
|
2021-02-28 06:00:57 +13:00
|
|
|
</div>
|
2021-04-06 12:15:17 +12:00
|
|
|
|
2021-02-26 14:50:46 +13:00
|
|
|
<q-select
|
2021-02-28 06:00:57 +13:00
|
|
|
style="width: 400px;"
|
2021-02-26 14:50:46 +13:00
|
|
|
ref="ref_existingDocument"
|
|
|
|
dense
|
2021-03-03 08:59:56 +13:00
|
|
|
class="existingDocumentSelect"
|
2021-02-26 14:50:46 +13:00
|
|
|
dark
|
2021-05-01 02:27:23 +12:00
|
|
|
popup-content-class="menuResizer"
|
2021-02-28 06:00:57 +13:00
|
|
|
menu-anchor="bottom middle"
|
|
|
|
menu-self="top middle"
|
2021-02-26 14:50:46 +13:00
|
|
|
:options="filteredExistingInput"
|
|
|
|
use-input
|
2021-03-18 10:26:08 +13:00
|
|
|
multiple
|
|
|
|
filled
|
2021-04-27 02:14:23 +12:00
|
|
|
input-debounce="500"
|
2021-02-26 14:50:46 +13:00
|
|
|
v-model="existingDocumentModel"
|
|
|
|
@filter="filterExistingSelect"
|
|
|
|
@input="openExistingInput"
|
|
|
|
>
|
2021-04-15 08:25:01 +12:00
|
|
|
<template v-slot:append v-if="!hideAdvSearchCheatsheetButton">
|
2021-04-13 13:32:59 +12:00
|
|
|
<q-btn round dense flat icon="mdi-help-rhombus" @click.stop.prevent="SSET_setAdvSearchWindowVisible"
|
|
|
|
>
|
|
|
|
<q-tooltip :delay="500">
|
|
|
|
Open search cheatsheet
|
|
|
|
</q-tooltip>
|
|
|
|
</q-btn>
|
|
|
|
</template>
|
2021-02-26 14:50:46 +13:00
|
|
|
<template v-slot:option="{ itemProps, itemEvents, opt }">
|
|
|
|
<q-item
|
2021-04-06 12:15:17 +12:00
|
|
|
:class="{'hasTextShadow': textShadow, 'isMinor':opt.isMinor}"
|
2021-02-26 14:50:46 +13:00
|
|
|
v-bind="itemProps"
|
|
|
|
v-on="itemEvents"
|
2021-04-06 12:15:17 +12:00
|
|
|
:key="opt.id"
|
|
|
|
:style="`color: ${opt.color}; background-color: ${opt.bgColor}`"
|
2021-05-08 13:27:05 +12:00
|
|
|
@mouseleave="setDocumentPreviewClose"
|
2021-02-26 14:50:46 +13:00
|
|
|
>
|
2021-05-08 13:27:05 +12:00
|
|
|
<documentPreview
|
2021-05-09 02:05:13 +12:00
|
|
|
v-if="!preventPreviewsPopups"
|
2021-05-08 13:27:05 +12:00
|
|
|
:document-id="opt._id"
|
|
|
|
:external-close-trigger="documentPreviewClose"
|
|
|
|
:special-z-index="999999999"
|
2021-05-09 02:05:13 +12:00
|
|
|
:custom-anchor="'top start'"
|
|
|
|
:custom-self="'center right'"
|
2021-05-08 13:27:05 +12:00
|
|
|
/>
|
2021-03-04 13:27:07 +13:00
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon
|
|
|
|
:style="`color: ${retrieveIconColor(opt)}`"
|
|
|
|
:name="(opt.isCategory) ? 'fas fa-folder-open' : opt.icon"
|
|
|
|
/>
|
|
|
|
</q-item-section>
|
2021-02-26 14:50:46 +13:00
|
|
|
<q-item-section>
|
2021-04-07 02:01:37 +12:00
|
|
|
<q-item-label>
|
|
|
|
<span class="isDeadIndicator" v-if="opt.isDead">
|
|
|
|
†
|
|
|
|
</span>
|
2021-04-10 12:22:31 +12:00
|
|
|
<span :class="{'isDead': (opt.isDead && !hideDeadCrossThrough)}" v-html="opt.label">
|
2021-04-07 02:01:37 +12:00
|
|
|
</span>
|
|
|
|
</q-item-label>
|
2021-03-03 08:59:56 +13:00
|
|
|
<q-item-label caption class="text-cultured" v-html="opt.hierarchicalPath"></q-item-label>
|
2021-03-03 14:10:05 +13:00
|
|
|
<q-item-label caption class="text-cultured" v-if="opt.tags">
|
|
|
|
<q-chip
|
|
|
|
v-for="(input,index) in opt.tags" :key="index"
|
|
|
|
outline
|
|
|
|
style="opacity: 0.8;"
|
|
|
|
size="12px"
|
2021-03-04 13:27:07 +13:00
|
|
|
class="text-cultured"
|
2021-03-03 14:10:05 +13:00
|
|
|
v-html="`${input}`"
|
|
|
|
>
|
|
|
|
</q-chip>
|
|
|
|
</q-item-label>
|
2021-02-26 14:50:46 +13:00
|
|
|
</q-item-section>
|
|
|
|
<q-btn
|
|
|
|
tabindex="-1"
|
|
|
|
round
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
dark
|
2021-04-12 12:11:47 +12:00
|
|
|
color="accent"
|
|
|
|
class="z-1 q-ml-sm self-center"
|
|
|
|
icon="mdi-pencil"
|
|
|
|
size="sm"
|
|
|
|
@click.stop.prevent="editExistingInput(opt)"
|
2021-02-26 14:50:46 +13:00
|
|
|
>
|
|
|
|
<q-tooltip
|
|
|
|
:delay="300"
|
|
|
|
>
|
2021-04-12 12:11:47 +12:00
|
|
|
Edit {{ stripTags(opt.label) }}
|
2021-02-26 14:50:46 +13:00
|
|
|
</q-tooltip>
|
|
|
|
</q-btn>
|
2021-04-10 12:22:31 +12:00
|
|
|
<q-btn
|
|
|
|
tabindex="-1"
|
|
|
|
round
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
dark
|
2021-04-12 12:11:47 +12:00
|
|
|
color="primary"
|
|
|
|
class="z-1 q-ml-sm self-center"
|
2021-04-10 12:22:31 +12:00
|
|
|
icon="mdi-content-copy"
|
2021-04-12 12:11:47 +12:00
|
|
|
size="sm"
|
2021-04-10 12:22:31 +12:00
|
|
|
@click.stop.prevent="copyTargetDocument(opt)"
|
|
|
|
>
|
|
|
|
<q-tooltip
|
|
|
|
:delay="300"
|
|
|
|
>
|
|
|
|
Make a copy of {{ stripTags(opt.label) }}
|
2021-04-12 12:11:47 +12:00
|
|
|
<br>
|
|
|
|
This action will always close the popup.
|
|
|
|
</q-tooltip>
|
|
|
|
</q-btn>
|
|
|
|
<q-btn
|
|
|
|
tabindex="-1"
|
|
|
|
round
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
dark
|
|
|
|
color="primary"
|
|
|
|
class="z-1 q-ml-sm self-center"
|
|
|
|
icon="mdi-file-tree"
|
|
|
|
size="sm"
|
|
|
|
@click.stop.prevent="addNewUnderParent(opt)"
|
|
|
|
>
|
|
|
|
<q-tooltip
|
|
|
|
:delay="300"
|
|
|
|
>
|
|
|
|
Add a new document belonging under {{ stripTags(opt.label) }}
|
|
|
|
<br>
|
|
|
|
This action will always close the popup.
|
2021-04-10 12:22:31 +12:00
|
|
|
</q-tooltip>
|
|
|
|
</q-btn>
|
2021-04-12 12:11:47 +12:00
|
|
|
|
|
|
|
<q-menu
|
|
|
|
touch-position
|
|
|
|
context-menu
|
|
|
|
auto-close
|
|
|
|
separate-close-popup
|
2021-05-09 11:01:23 +12:00
|
|
|
content-style="z-index: 1000000000 !important;"
|
2021-04-12 12:11:47 +12:00
|
|
|
>
|
|
|
|
|
2021-04-16 07:03:18 +12:00
|
|
|
<q-list class="bg-gunmetal-light text-accent">
|
2021-04-12 12:11:47 +12:00
|
|
|
|
|
|
|
<template>
|
|
|
|
<q-item clickable @click="copyName(opt)">
|
|
|
|
<q-item-section>Copy name</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon name="mdi-text-recognition" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item clickable @click="copyTextColor(opt)">
|
|
|
|
<q-item-section>Copy text color</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon name="mdi-eyedropper" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item clickable @click="copyBackgroundColor(opt)">
|
|
|
|
<q-item-section>Copy background color</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon name="mdi-format-color-fill" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
2021-04-17 00:46:34 +12:00
|
|
|
<q-separator dark />
|
2021-04-12 12:11:47 +12:00
|
|
|
<q-item clickable @click="openExistingInput(opt)">
|
|
|
|
<q-item-section>Open document</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon name="mdi-book-open-page-variant-outline" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item clickable @click="editExistingInput(opt)">
|
|
|
|
<q-item-section>Edit document</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon name="mdi-pencil" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item clickable @click="addNewUnderParent(opt)">
|
|
|
|
<q-item-section>Create new document with this document as parent</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon color="primary" name="mdi-file-tree" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
<q-item clickable @click="copyTargetDocument(opt)">
|
|
|
|
<q-item-section>Copy this document</q-item-section>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon color="primary" name="mdi-content-copy" />
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</q-list>
|
|
|
|
|
|
|
|
</q-menu>
|
2021-02-26 14:50:46 +13:00
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
</q-select>
|
|
|
|
</q-card-section>
|
|
|
|
|
|
|
|
<q-card-section>
|
2021-03-04 13:27:07 +13:00
|
|
|
<q-card-actions align="around" class="q-mb-sm">
|
|
|
|
<q-btn flat label="Close" color="accent" v-close-popup />
|
2021-02-26 14:50:46 +13:00
|
|
|
</q-card-actions>
|
|
|
|
</q-card-section>
|
|
|
|
|
|
|
|
</q-card>
|
|
|
|
</q-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
|
|
|
import { Component, Watch } from "vue-property-decorator"
|
2021-04-10 12:22:31 +12:00
|
|
|
import { I_OpenedDocument, I_ShortenedDocument } from "src/interfaces/I_OpenedDocument"
|
2021-03-03 08:59:56 +13:00
|
|
|
import { advancedDocumentFilter } from "src/scripts/utilities/advancedDocumentFilter"
|
2021-05-08 13:27:05 +12:00
|
|
|
import { extend, uid } from "quasar"
|
2021-04-12 12:11:47 +12:00
|
|
|
|
|
|
|
import { createNewWithParent } from "src/scripts/documentActions/createNewWithParent"
|
|
|
|
import { copyDocumentName, copyDocumentTextColor, copyDocumentBackgroundColor } from "src/scripts/documentActions/uniqueFieldCopy"
|
2021-04-10 12:22:31 +12:00
|
|
|
import { copyDocument } from "src/scripts/documentActions/copyDocument"
|
2021-02-26 14:50:46 +13:00
|
|
|
|
|
|
|
import DialogBase from "src/components/dialogs/_DialogBase"
|
2021-03-18 10:26:08 +13:00
|
|
|
import { I_Blueprint } from "src/interfaces/I_Blueprint"
|
2021-05-08 13:27:05 +12:00
|
|
|
import documentPreview from "src/components/DocumentPreview.vue"
|
2021-02-26 14:50:46 +13:00
|
|
|
|
|
|
|
@Component({
|
2021-05-08 13:27:05 +12:00
|
|
|
components: {
|
|
|
|
documentPreview
|
|
|
|
}
|
2021-02-26 14:50:46 +13:00
|
|
|
})
|
|
|
|
export default class ExistingDocumentDialog extends DialogBase {
|
2021-04-03 12:33:49 +13:00
|
|
|
/****************************************************************/
|
|
|
|
// DIALOG CONTROL
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React to dialog opening request
|
|
|
|
*/
|
2021-02-26 14:50:46 +13:00
|
|
|
@Watch("dialogTrigger")
|
|
|
|
openDialog (val: string|false) {
|
|
|
|
if (val) {
|
|
|
|
if (this.SGET_getDialogsState) {
|
|
|
|
return
|
|
|
|
}
|
2021-03-18 10:26:08 +13:00
|
|
|
this.isCloseAbleViaKeybind = false
|
2021-02-26 14:50:46 +13:00
|
|
|
this.SSET_setDialogState(true)
|
|
|
|
this.dialogModel = true
|
|
|
|
|
2021-03-18 10:26:08 +13:00
|
|
|
this.reloadOptions()
|
2021-02-26 14:50:46 +13:00
|
|
|
this.populateExistingObjectDialog().catch(e => console.log(e))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/****************************************************************/
|
|
|
|
// COMPONENT SETTINGS
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Watch options and react to changes
|
|
|
|
*/
|
|
|
|
@Watch("SGET_options", { immediate: true, deep: true })
|
|
|
|
onSettingsChange () {
|
|
|
|
this.reloadOptions()
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reloads local options
|
|
|
|
*/
|
|
|
|
reloadOptions () {
|
|
|
|
this.closeWithSameClick = this.SGET_options.allowQuickPopupSameKeyClose
|
|
|
|
this.disableCloseAftertSelectQuickSearch = this.SGET_options.disableCloseAftertSelectQuickSearch
|
|
|
|
this.includeCategories = !this.SGET_options.disableQuickSearchCategoryPrecheck
|
|
|
|
this.textShadow = this.SGET_options.textShadow
|
2021-04-10 12:22:31 +12:00
|
|
|
this.hideDeadCrossThrough = this.SGET_options.hideDeadCrossThrough
|
2021-04-15 08:25:01 +12:00
|
|
|
this.hideAdvSearchCheatsheetButton = this.SGET_options.hideAdvSearchCheatsheetButton
|
2021-05-09 02:05:13 +12:00
|
|
|
this.preventPreviewsPopups = this.SGET_options.preventPreviewsPopups
|
2021-04-03 12:33:49 +13:00
|
|
|
}
|
|
|
|
|
2021-05-09 02:05:13 +12:00
|
|
|
/**
|
|
|
|
* Determines if the document previews should be disabled or not
|
|
|
|
*/
|
|
|
|
preventPreviewsPopups = false
|
|
|
|
|
2021-04-15 08:25:01 +12:00
|
|
|
/**
|
|
|
|
* Hides the advanced search cheatsheet help button in relationship type fields.
|
|
|
|
*/
|
|
|
|
hideAdvSearchCheatsheetButton = false
|
|
|
|
|
2021-04-10 12:22:31 +12:00
|
|
|
/**
|
|
|
|
* Determines if the "dead" document type should have a cross-text decoration or not
|
|
|
|
*/
|
|
|
|
hideDeadCrossThrough = false
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Determines if the popup shouldnt close after a document is selected from the dropdown list
|
|
|
|
*/
|
|
|
|
disableCloseAftertSelectQuickSearch = false
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the popup is closeable with the same keybind that summoned it
|
|
|
|
*/
|
|
|
|
closeWithSameClick = false
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if text shadow will be shows for accesiblity reasons or not
|
|
|
|
*/
|
|
|
|
textShadow = false
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A local lock that prevents double-triggering and instant re-closing of the dialog via keybinds
|
|
|
|
*/
|
|
|
|
isCloseAbleViaKeybind = false
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
// LOCAL KEYBINDS
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Local keybinds
|
|
|
|
*/
|
|
|
|
@Watch("SGET_getCurrentKeyBindData", { deep: true })
|
|
|
|
processKeyPush () {
|
|
|
|
// Keybind cheatsheet
|
|
|
|
if (this.determineKeyBind("quickExistingDocument") && this.dialogModel && this.closeWithSameClick && this.isCloseAbleViaKeybind && this.SGET_getDialogsState) {
|
|
|
|
this.dialogModel = false
|
|
|
|
this.SSET_setDialogState(false)
|
|
|
|
// @ts-ignore
|
|
|
|
this.existingDocumentModel = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
// PRE-FILTERING
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Model for pre-filtering via categories
|
|
|
|
*/
|
|
|
|
includeCategories = true
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React to the category checkbox changes
|
|
|
|
*/
|
|
|
|
@Watch("includeCategories")
|
2021-04-06 12:15:17 +12:00
|
|
|
reactToCategoryCheckboxChange () {
|
|
|
|
this.preFilterDocuments()
|
|
|
|
}
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Prefilter documents based on what is in the checkbox
|
|
|
|
*/
|
|
|
|
preFilterDocuments () {
|
2021-04-06 12:15:17 +12:00
|
|
|
this.existingObjectPrefilteredList = this.existingObjectsFullList
|
|
|
|
.filter(e => !((!this.includeCategories && e.isCategory)))
|
2021-04-03 12:33:49 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
// SELECT LIST MANAGEMENT
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Raw list of objects retrieved from the database
|
|
|
|
*/
|
|
|
|
existingObjectPrefilteredList = [] as I_ShortenedDocument[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pre-filtered list based on the category inclussion or exlcussion
|
|
|
|
*/
|
|
|
|
existingObjectsFullList = [] as I_ShortenedDocument[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All currently loaded blueprints
|
|
|
|
*/
|
2021-03-18 10:26:08 +13:00
|
|
|
allDocumentBluePrints = [] as I_Blueprint[]
|
2021-02-26 14:50:46 +13:00
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Set up up all data in to the dialog on popup load
|
|
|
|
*/
|
2021-02-26 14:50:46 +13:00
|
|
|
async populateExistingObjectDialog () {
|
2021-03-18 10:26:08 +13:00
|
|
|
this.allDocumentBluePrints = this.SGET_allBlueprints
|
2021-03-05 01:51:11 +13:00
|
|
|
|
2021-04-26 09:01:41 +12:00
|
|
|
this.existingObjectsFullList = this.SGET_allDocuments.docs
|
2021-04-03 12:33:49 +13:00
|
|
|
this.preFilterDocuments()
|
2021-02-26 14:50:46 +13:00
|
|
|
|
2021-03-04 13:27:07 +13:00
|
|
|
await this.$nextTick()
|
|
|
|
|
|
|
|
if (this.$refs.ref_existingDocument) {
|
|
|
|
/*eslint-disable */
|
2021-04-26 09:01:41 +12:00
|
|
|
await this.sleep(100)
|
2021-03-04 13:27:07 +13:00
|
|
|
// @ts-ignore
|
|
|
|
this.$refs.ref_existingDocument.focus()
|
|
|
|
/* eslint-enable */
|
|
|
|
}
|
2021-03-18 10:26:08 +13:00
|
|
|
this.isCloseAbleViaKeybind = true
|
2021-02-26 14:50:46 +13:00
|
|
|
}
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Currently being opened document
|
|
|
|
*/
|
2021-03-18 10:26:08 +13:00
|
|
|
existingDocumentModel = []
|
2021-02-26 14:50:46 +13:00
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Filtered list of items
|
|
|
|
*/
|
2021-02-26 14:50:46 +13:00
|
|
|
filteredExistingInput = null as unknown as I_ShortenedDocument[]
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Refocuses the first value in the selct upon filtering for intuitive keyboard control
|
|
|
|
*/
|
2021-03-04 13:27:07 +13:00
|
|
|
async refocusSelect () {
|
|
|
|
await this.$nextTick()
|
|
|
|
/*eslint-disable */
|
|
|
|
// @ts-ignore
|
|
|
|
this.$refs.ref_existingDocument.setOptionIndex(-1)
|
|
|
|
// @ts-ignore
|
|
|
|
this.$refs.ref_existingDocument.moveOptionSelection(1, true)
|
|
|
|
/* eslint-enable */
|
|
|
|
}
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
|
|
|
* Local list copty for filtering in order to not mess up the original list
|
|
|
|
*/
|
|
|
|
listCopy: I_ShortenedDocument[] = []
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter the pre-filtered list
|
|
|
|
*/
|
2021-02-26 14:50:46 +13:00
|
|
|
filterExistingSelect (val: string, update: (e: () => void) => void) {
|
|
|
|
if (val === "") {
|
|
|
|
update(() => {
|
2021-04-12 13:41:25 +12:00
|
|
|
this.filteredExistingInput = this.existingObjectPrefilteredList.filter((obj) => !obj.isMinor)
|
2021-03-04 13:27:07 +13:00
|
|
|
if (this.$refs.ref_existingDocument && this.filteredExistingInput.length > 0) {
|
|
|
|
this.refocusSelect().catch(e => console.log(e))
|
2021-02-26 14:50:46 +13:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
update(() => {
|
|
|
|
const needle = val.toLowerCase()
|
2021-04-03 12:33:49 +13:00
|
|
|
this.listCopy = extend(true, [], this.existingObjectPrefilteredList)
|
|
|
|
this.filteredExistingInput = advancedDocumentFilter(needle, this.listCopy, this.allDocumentBluePrints, this.existingObjectsFullList)
|
2021-03-03 08:59:56 +13:00
|
|
|
|
2021-03-04 13:27:07 +13:00
|
|
|
if (this.$refs.ref_existingDocument && this.filteredExistingInput.length > 0) {
|
|
|
|
this.refocusSelect().catch(e => console.log(e))
|
2021-02-26 14:50:46 +13:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/****************************************************************/
|
|
|
|
// TRIGGER ACTIONS
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2021-04-26 09:01:41 +12:00
|
|
|
openExistingInput (e: I_ShortenedDocument) {
|
2021-04-12 12:11:47 +12:00
|
|
|
// @ts-ignore
|
|
|
|
e = (Array.isArray(e)) ? e[0] : e
|
2021-04-03 12:33:49 +13:00
|
|
|
// Open document and close dialog
|
2021-03-18 10:26:08 +13:00
|
|
|
if (!this.disableCloseAftertSelectQuickSearch) {
|
|
|
|
this.dialogModel = false
|
|
|
|
// @ts-ignore
|
2021-04-12 12:11:47 +12:00
|
|
|
this.openExistingDocumentRoute(e)
|
2021-03-18 10:26:08 +13:00
|
|
|
this.existingDocumentModel = []
|
|
|
|
}
|
2021-04-03 12:33:49 +13:00
|
|
|
// Open document and DO NOT close the dialog
|
2021-03-18 10:26:08 +13:00
|
|
|
else {
|
|
|
|
this.existingDocumentModel = []
|
|
|
|
|
2021-04-26 09:01:41 +12:00
|
|
|
const retrievedObject = (this.SGET_openedDocument(e._id)) || this.SGET_document(e._id)
|
|
|
|
|
2021-03-18 10:26:08 +13:00
|
|
|
const dataPass = {
|
|
|
|
doc: retrievedObject,
|
|
|
|
treeAction: false
|
|
|
|
}
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
this.SSET_addOpenedDocument(dataPass)
|
|
|
|
}
|
2021-02-26 14:50:46 +13:00
|
|
|
}
|
|
|
|
|
2021-04-03 12:33:49 +13:00
|
|
|
/**
|
2021-04-12 12:11:47 +12:00
|
|
|
* 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.
|
2021-04-03 12:33:49 +13:00
|
|
|
*/
|
2021-04-26 09:01:41 +12:00
|
|
|
editExistingInput (e: I_ShortenedDocument) {
|
2021-02-26 14:50:46 +13:00
|
|
|
// @ts-ignore
|
2021-04-12 12:11:47 +12:00
|
|
|
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 = []
|
|
|
|
|
2021-04-26 09:01:41 +12:00
|
|
|
const retrievedObject = (this.SGET_openedDocument(e._id)) || this.SGET_document(e._id)
|
2021-04-12 12:11:47 +12:00
|
|
|
|
|
|
|
retrievedObject.hasEdits = true
|
|
|
|
|
|
|
|
const dataPass = {
|
|
|
|
doc: retrievedObject,
|
|
|
|
treeAction: false
|
|
|
|
}
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
this.SSET_addOpenedDocument(dataPass)
|
|
|
|
}
|
2021-02-26 14:50:46 +13:00
|
|
|
}
|
2021-04-10 12:22:31 +12:00
|
|
|
|
|
|
|
documentPass = null as unknown as I_OpenedDocument
|
|
|
|
|
2021-04-12 12:11:47 +12:00
|
|
|
/****************************************************************/
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2021-04-10 12:22:31 +12:00
|
|
|
copyTargetDocument (currentDoc: I_OpenedDocument) {
|
|
|
|
this.documentPass = extend(true, {}, currentDoc)
|
|
|
|
|
2021-05-02 02:31:33 +12:00
|
|
|
const blueprint = this.SGET_blueprint(this.documentPass.type)
|
|
|
|
const newDocument = copyDocument(this.documentPass, this.generateUID(), blueprint)
|
2021-04-10 12:22:31 +12:00
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
2021-04-12 12:11:47 +12:00
|
|
|
|
|
|
|
this.dialogModel = false
|
2021-04-10 12:22:31 +12:00
|
|
|
}
|
2021-05-08 13:27:05 +12:00
|
|
|
|
|
|
|
setDocumentPreviewClose () {
|
|
|
|
this.documentPreviewClose = uid()
|
|
|
|
}
|
|
|
|
|
|
|
|
documentPreviewClose = ""
|
2021-02-26 14:50:46 +13:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
.existingDocumentPopup {
|
|
|
|
min-width: 600px;
|
|
|
|
margin-top: 100px;
|
|
|
|
align-self: flex-start;
|
|
|
|
|
|
|
|
h6 {
|
|
|
|
display: block;
|
|
|
|
text-align: center;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|