mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 01:39:53 +00:00
UBER-872: StyleTextEditor: No update when change text in another text (#3698)
Signed-off-by: Maxim Karmatskikh <mkarmatskih@gmail.com>
This commit is contained in:
parent
d3183a278b
commit
3ca0cff505
@ -69,7 +69,10 @@
|
|||||||
|
|
||||||
$: if (oldContent !== content) {
|
$: if (oldContent !== content) {
|
||||||
oldContent = content
|
oldContent = content
|
||||||
rawValue = content
|
if (rawValue !== content) {
|
||||||
|
rawValue = content
|
||||||
|
textEditor?.setContent(content)
|
||||||
|
}
|
||||||
modified = false
|
modified = false
|
||||||
}
|
}
|
||||||
$: if (!modified && rawValue !== content) modified = true
|
$: if (!modified && rawValue !== content) modified = true
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Class, Doc, Ref, updateAttribute } from '@hcengineering/core'
|
import { Doc, updateAttribute } from '@hcengineering/core'
|
||||||
|
|
||||||
import { IntlString } from '@hcengineering/platform'
|
import { IntlString } from '@hcengineering/platform'
|
||||||
import { createQuery, getAttribute, getClient, KeyedAttribute } from '@hcengineering/presentation'
|
import { createQuery, getAttribute, getClient, KeyedAttribute } from '@hcengineering/presentation'
|
||||||
@ -27,27 +27,27 @@
|
|||||||
export let key: KeyedAttribute
|
export let key: KeyedAttribute
|
||||||
export let placeholder: IntlString
|
export let placeholder: IntlString
|
||||||
export let focusIndex = -1
|
export let focusIndex = -1
|
||||||
let _id: Ref<Doc> | undefined = undefined
|
|
||||||
let _class: Ref<Class<Doc>> | undefined = undefined
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
const queryClient = createQuery()
|
const queryClient = createQuery()
|
||||||
|
|
||||||
let description = ''
|
let description: string
|
||||||
|
let haveUnsavedChanges = false
|
||||||
|
|
||||||
let doc: Doc | undefined
|
$: if (object && description === undefined) {
|
||||||
function checkForNewObject (object: Doc) {
|
description = getAttribute(client, object, key)
|
||||||
if (object._id !== _id) return true
|
|
||||||
if (object._class !== _class) return true
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 &&
|
$: object &&
|
||||||
queryClient.query(object._class, { _id: object._id }, async (result) => {
|
queryClient.query(object._class, { _id: object._id }, async (result: Doc[]) => {
|
||||||
;[doc] = result
|
if (result.length > 0) {
|
||||||
if (doc && checkForNewObject(object)) {
|
if (!haveUnsavedChanges) {
|
||||||
_class = object._class
|
const doc = result[0]
|
||||||
_id = object._id
|
description = getAttribute(client, doc, key)
|
||||||
description = getAttribute(client, object, key)
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -64,10 +64,13 @@
|
|||||||
const old = getAttribute(client, object, key)
|
const old = getAttribute(client, object, key)
|
||||||
if (description !== old) {
|
if (description !== old) {
|
||||||
await updateAttribute(client, object, object._class, key, description)
|
await updateAttribute(client, object, object._class, key, description)
|
||||||
|
haveUnsavedChanges = false
|
||||||
dispatch('saved', true)
|
dispatch('saved', true)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dispatch('saved', false)
|
dispatch('saved', false)
|
||||||
}, 2500)
|
}, 2500)
|
||||||
|
} else {
|
||||||
|
haveUnsavedChanges = false
|
||||||
}
|
}
|
||||||
|
|
||||||
await descriptionBox.createAttachments()
|
await descriptionBox.createAttachments()
|
||||||
@ -75,6 +78,7 @@
|
|||||||
|
|
||||||
let saveTrigger: any
|
let saveTrigger: any
|
||||||
function triggerSave (): void {
|
function triggerSave (): void {
|
||||||
|
haveUnsavedChanges = true
|
||||||
clearTimeout(saveTrigger)
|
clearTimeout(saveTrigger)
|
||||||
saveTrigger = setTimeout(save, 2500)
|
saveTrigger = setTimeout(save, 2500)
|
||||||
}
|
}
|
||||||
@ -84,7 +88,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#key doc?._id}
|
{#key object?._id}
|
||||||
<AttachmentStyledBox
|
<AttachmentStyledBox
|
||||||
{focusIndex}
|
{focusIndex}
|
||||||
enableBackReferences={true}
|
enableBackReferences={true}
|
||||||
|
Loading…
Reference in New Issue
Block a user