Browse Source

fix: Comments are adding to FE state before api calls

pull/6739/head
Muhammed Mustafa 1 year ago
parent
commit
dcc24fef10
  1. 22
      packages/nc-gui/composables/useExpandedFormStore.ts

22
packages/nc-gui/composables/useExpandedFormStore.ts

@ -31,6 +31,8 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
const { t } = useI18n() const { t } = useI18n()
const { user } = useGlobal()
const commentsOnly = ref(false) const commentsOnly = ref(false)
const commentsAndLogs = ref<any[]>([]) const commentsAndLogs = ref<any[]>([])
@ -58,6 +60,8 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
const { isUIAllowed } = useRoles() const { isUIAllowed } = useRoles()
const isSaving = ref(false)
// getters // getters
const displayValue = computed(() => { const displayValue = computed(() => {
if (row?.value?.row) { if (row?.value?.row) {
@ -135,6 +139,22 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
if (!rowId) return if (!rowId) return
isSaving.value = true
const createdDate = new Date().toISOString()
commentsAndLogs.value.push({
created_at: createdDate,
description: `The following comment has been created:${comment.value}`,
email: user?.value?.email,
user: user?.value?.email,
id: '',
display_name: user.value?.display_name,
row_id: rowId,
updated_at: createdDate,
op_type: 'COMMENT',
})
await api.utils.commentRow({ await api.utils.commentRow({
fk_model_id: meta.value?.id as string, fk_model_id: meta.value?.id as string,
row_id: rowId, row_id: rowId,
@ -148,6 +168,8 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
await loadCommentsAndLogs() await loadCommentsAndLogs()
} catch (e: any) { } catch (e: any) {
message.error(e.message) message.error(e.message)
} finally {
isSaving.value = false
} }
$e('a:row-expand:comment') $e('a:row-expand:comment')

Loading…
Cancel
Save