mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-01 21:31:04 +00:00
UBER-424: description not saving fix (#3434)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
2e142ba194
commit
f180ea4b10
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Doc, Markup, updateAttribute } from '@hcengineering/core'
|
import { Class, Doc, Markup, Ref, 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'
|
||||||
@ -28,7 +28,8 @@
|
|||||||
export let placeholder: IntlString
|
export let placeholder: IntlString
|
||||||
export let focusIndex = -1
|
export let focusIndex = -1
|
||||||
export let updateBacklinks: ((doc: Doc, description: Markup) => void) | undefined = undefined
|
export let updateBacklinks: ((doc: Doc, description: Markup) => void) | undefined = undefined
|
||||||
|
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()
|
||||||
@ -36,13 +37,20 @@
|
|||||||
let description = ''
|
let description = ''
|
||||||
|
|
||||||
let doc: Doc | undefined
|
let doc: Doc | undefined
|
||||||
|
function checkForNewObject (object: Doc) {
|
||||||
$: queryClient.query(object._class, { _id: object._id }, async (result) => {
|
if (object._id !== _id) return true
|
||||||
;[doc] = result
|
if (object._class !== _class) return true
|
||||||
if (doc) {
|
return false
|
||||||
description = getAttribute(client, object, key)
|
}
|
||||||
}
|
$: object &&
|
||||||
})
|
queryClient.query(object._class, { _id: object._id }, async (result) => {
|
||||||
|
;[doc] = result
|
||||||
|
if (doc && checkForNewObject(object)) {
|
||||||
|
_class = object._class
|
||||||
|
_id = object._id
|
||||||
|
description = getAttribute(client, object, key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -56,7 +64,7 @@
|
|||||||
|
|
||||||
const old = getAttribute(client, object, key)
|
const old = getAttribute(client, object, key)
|
||||||
if (description !== old) {
|
if (description !== old) {
|
||||||
updateAttribute(client, object, object._class, key, description)
|
await updateAttribute(client, object, object._class, key, description)
|
||||||
dispatch('saved', true)
|
dispatch('saved', true)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dispatch('saved', false)
|
dispatch('saved', false)
|
||||||
|
@ -365,7 +365,6 @@
|
|||||||
on:blur
|
on:blur
|
||||||
on:focus
|
on:focus
|
||||||
on:open-document
|
on:open-document
|
||||||
on:open-document
|
|
||||||
on:attach={() => {
|
on:attach={() => {
|
||||||
attach()
|
attach()
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user