mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-27 01:13:27 +03:00
UBER-916: Navigation from issue to mentioned issue break description (#3746)
Signed-off-by: Maxim Karmatskikh <mkarmatskih@gmail.com>
This commit is contained in:
parent
179973ba7f
commit
78e2393af2
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Doc, updateAttribute } from '@hcengineering/core'
|
||||
import { Doc, Class, Ref, updateAttribute } from '@hcengineering/core'
|
||||
|
||||
import { IntlString } from '@hcengineering/platform'
|
||||
import { createQuery, getAttribute, getClient, KeyedAttribute } from '@hcengineering/presentation'
|
||||
@ -32,15 +32,27 @@
|
||||
const queryClient = createQuery()
|
||||
|
||||
let description: string
|
||||
let prevObjectId: Ref<Doc>
|
||||
let prevObjectClass: Ref<Class<Doc>>
|
||||
|
||||
let haveUnsavedChanges = false
|
||||
|
||||
$: if (object && description === undefined) {
|
||||
/*
|
||||
There is no onMount when go from one issue to another one via mention
|
||||
There is a change of object when chaning a description.
|
||||
So the only way to detect if we really need to re-init the state
|
||||
is to check if object class and object id changed.
|
||||
*/
|
||||
$: if (object && (object._id !== prevObjectId || object._class !== prevObjectClass)) {
|
||||
description = getAttribute(client, object, key)
|
||||
prevObjectId = object._id
|
||||
prevObjectClass = object._class
|
||||
}
|
||||
|
||||
// We need to query the document one more time
|
||||
// To make a difference between update of description from the bottom
|
||||
// And update to if from another tab.
|
||||
|
||||
$: object &&
|
||||
queryClient.query(object._class, { _id: object._id }, async (result: Doc[]) => {
|
||||
if (result.length > 0) {
|
||||
@ -55,7 +67,7 @@
|
||||
|
||||
let descriptionBox: AttachmentStyledBox
|
||||
|
||||
async function save () {
|
||||
async function save (object: Doc, description: string) {
|
||||
clearTimeout(saveTrigger)
|
||||
if (!object) {
|
||||
return
|
||||
@ -80,7 +92,13 @@
|
||||
function triggerSave (): void {
|
||||
haveUnsavedChanges = true
|
||||
clearTimeout(saveTrigger)
|
||||
saveTrigger = setTimeout(save, 2500)
|
||||
|
||||
// Need to bind which object to save, because object could
|
||||
// change after we have set timeout
|
||||
const saveObject = object
|
||||
const saveDescription = description
|
||||
|
||||
saveTrigger = setTimeout(() => save(saveObject, saveDescription), 2500)
|
||||
}
|
||||
|
||||
export function isFocused (): boolean {
|
||||
@ -102,14 +120,14 @@
|
||||
on:attached={(e) => descriptionBox.saveNewAttachment(e.detail)}
|
||||
on:detached={(e) => descriptionBox.removeAttachmentById(e.detail)}
|
||||
showButtons
|
||||
on:blur={save}
|
||||
on:blur={() => save(object, description)}
|
||||
on:changeContent={triggerSave}
|
||||
maxHeight={'card'}
|
||||
focusable
|
||||
bind:content={description}
|
||||
{placeholder}
|
||||
on:open-document={async (event) => {
|
||||
save()
|
||||
save(object, description)
|
||||
const doc = await client.findOne(event.detail._class, { _id: event.detail._id })
|
||||
if (doc != null) {
|
||||
const location = await getObjectLinkFragment(client.getHierarchy(), doc, {}, view.component.EditDoc)
|
||||
|
Loading…
Reference in New Issue
Block a user