Browse Source

fix(gui-v2): show notification on error

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2990/head
Pranav C 2 years ago
parent
commit
7a45513ace
  1. 2
      packages/nc-gui-v2/components/smartsheet/VirtualCell.vue
  2. 8
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  3. 16
      packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue
  4. 17
      packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue
  5. 60
      packages/nc-gui-v2/composables/useLTARStore.ts

2
packages/nc-gui-v2/components/smartsheet/VirtualCell.vue

@ -29,7 +29,7 @@ const { isLookup, isBt, isRollup, isMm, isHm, isFormula, isCount } = useVirtualC
<template> <template>
<div <div
class="nc-virtual-cell" class="nc-virtual-cell w-full"
@keydown.stop.enter.exact="emit('navigate', NavigateDir.NEXT)" @keydown.stop.enter.exact="emit('navigate', NavigateDir.NEXT)"
@keydown.stop.shift.enter.exact="emit('navigate', NavigateDir.PREV)" @keydown.stop.shift.enter.exact="emit('navigate', NavigateDir.PREV)"
> >

8
packages/nc-gui-v2/components/virtual-cell/HasMany.vue

@ -25,19 +25,19 @@ await loadRelatedTableMeta()
</script> </script>
<template> <template>
<div class="flex align-center gap-1 w-full chips-wrapper"> <div class="flex align-center gap-1 w-full min-full chips-wrapper">
<div class="chips flex align-center img-container flex-grow hm-items flex-nowrap min-w-0 overflow-hidden"> <div class="chips flex align-center img-container flex-grow hm-items flex-nowrap min-w-0 overflow-hidden">
<template v-if="value"> <template v-if="value">
<ItemChip v-for="(ch, i) in value" :key="i" :value="ch[relatedTablePrimaryValueProp]" @unlink="unlink(ch)" /> <ItemChip v-for="(ch, i) in value" :key="i" :value="ch[relatedTablePrimaryValueProp]" @unlink="unlink(ch)" />
<span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span> <span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span>
</template> </template>
</div> </div>
<div class="flex-1 flex justify-end gap-1"> <div class="flex-grow flex justify-end gap-1">
<MdiExpandIcon <MdiExpandIcon
class="select-none transform group-hover:(text-pink-500 scale-120) text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" class="select-none transform text-sm nc-action-icon text-gray-500/50 hover:text-gray-500"
@click="childListDlg = true" @click="childListDlg = true"
/> />
<MdiPlusIcon class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" @click="listItemsDlg = true" /> <MdiPlusIcon class="select-none text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" @click="listItemsDlg = true" />
</div> </div>
<ListItems v-model="listItemsDlg" /> <ListItems v-model="listItemsDlg" />
<ListChildItems v-model="childListDlg" @attach-record=";(childListDlg = false), (listItemsDlg = true)" /> <ListChildItems v-model="childListDlg" @attach-record=";(childListDlg = false), (listItemsDlg = true)" />

16
packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue

@ -10,8 +10,16 @@ const emit = defineEmits(['update:modelValue', 'attachRecord'])
const vModel = useVModel(props, 'modelValue', emit) const vModel = useVModel(props, 'modelValue', emit)
const { childrenList, meta, deleteRelatedRow, loadChildrenList, childrenListPagination, relatedTablePrimaryValueProp, unlink } = const {
useLTARStoreOrThrow() childrenList,
meta,
deleteRelatedRow,
loadChildrenList,
childrenListPagination,
relatedTablePrimaryValueProp,
unlink,
getRelatedTableRowId,
} = useLTARStoreOrThrow()
watch(vModel, () => { watch(vModel, () => {
if (vModel.value) { if (vModel.value) {
@ -44,8 +52,10 @@ const unlinkRow = async (row: Record<string, any>) => {
<a-card v-for="(row, i) of childrenList?.list ?? []" :key="i" class="ma-2 hover:(!bg-gray-200/50 shadow-md)"> <a-card v-for="(row, i) of childrenList?.list ?? []" :key="i" class="ma-2 hover:(!bg-gray-200/50 shadow-md)">
<div class="flex align-center"> <div class="flex align-center">
<div class="flex-grow overflow-hidden min-w-0"> <div class="flex-grow overflow-hidden min-w-0">
{{ row[relatedTablePrimaryValueProp] }} {{ row[relatedTablePrimaryValueProp]
}}<span class="text-gray-400 text-[11px] ml-1">(Primary key : {{ getRelatedTableRowId(row) }})</span>
</div> </div>
<div class="flex-1"></div>
<div class="flex gap-2"> <div class="flex gap-2">
<MdiUnlinkIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" @click="unlinkRow(row)" /> <MdiUnlinkIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" @click="unlinkRow(row)" />
<MdiDeleteIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" @click="deleteRelatedRow(row)" /> <MdiDeleteIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" @click="deleteRelatedRow(row)" />

17
packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue

@ -9,8 +9,14 @@ const emit = defineEmits(['update:modelValue'])
const vModel = useVModel(props, 'modelValue', emit) const vModel = useVModel(props, 'modelValue', emit)
const { childrenExcludedList, loadChildrenExcludedList, childrenExcludedListPagination, relatedTablePrimaryValueProp, link } = const {
useLTARStoreOrThrow() childrenExcludedList,
loadChildrenExcludedList,
childrenExcludedListPagination,
relatedTablePrimaryValueProp,
link,
getRelatedTableRowId,
} = useLTARStoreOrThrow()
watch(vModel, () => { watch(vModel, () => {
if (vModel.value) { if (vModel.value) {
@ -44,10 +50,13 @@ const linkRow = async (row: Record<string, any>) => {
<a-card <a-card
v-for="(row, i) in childrenExcludedList?.list ?? []" v-for="(row, i) in childrenExcludedList?.list ?? []"
:key="i" :key="i"
class="ma-2 cursor-pointer hover:(!bg-gray-200/50 shadow-md)" class="ma-2 cursor-pointer hover:(!bg-gray-200/50 shadow-md) group"
@click="linkRow(row)" @click="linkRow(row)"
> >
{{ row[relatedTablePrimaryValueProp] }} {{ row[relatedTablePrimaryValueProp]
}}<span class="hidden group-hover:(inline) text-gray-400 text-[11px] ml-1"
>(Primary key : {{ getRelatedTableRowId(row) }})</span
>
</a-card> </a-card>
</div> </div>
<a-pagination <a-pagination

60
packages/nc-gui-v2/composables/useLTARStore.ts

@ -111,7 +111,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
reloadData?.() reloadData?.()
await loadChildrenList() await loadChildrenList()
} catch (e: any) { } catch (e: any) {
notification.error(await extractSdkResponseErrorMsg(e)) notification.error({
message: 'Delete failed',
description: await extractSdkResponseErrorMsg(e),
})
} }
}, },
}) })
@ -131,18 +134,23 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
// this.$toast.info('Unlink is not possible, instead map to another parent.').goAway(3000); // this.$toast.info('Unlink is not possible, instead map to another parent.').goAway(3000);
// return; // return;
// } // }
try {
// todo: audit // todo: audit
await $api.dbTableRow.nestedRemove( await $api.dbTableRow.nestedRemove(
NOCO, NOCO,
project.value.title as string, project.value.title as string,
meta.value.title, meta.value.title,
rowId.value, rowId.value,
colOptions.type as 'mm' | 'hm', colOptions.type as 'mm' | 'hm',
column.title, column.title,
getRelatedTableRowId(row) as string, getRelatedTableRowId(row) as string,
) )
} catch (e) {
notification.error({
message: 'Unlink failed',
description: await extractSdkResponseErrorMsg(e),
})
}
reloadData?.() reloadData?.()
// todo: reload table data and children list // todo: reload table data and children list
// this.$emit('loadTableData'); // this.$emit('loadTableData');
@ -165,15 +173,22 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
// this.newRecordModal = false; // this.newRecordModal = false;
// return; // return;
// } // }
await $api.dbTableRow.nestedAdd( try {
NOCO, await $api.dbTableRow.nestedAdd(
project.value.title as string, NOCO,
meta.value.title as string, project.value.title as string,
rowId.value, meta.value.title as string,
colOptions.type as 'mm' | 'hm', rowId.value,
column.title, colOptions.type as 'mm' | 'hm',
getRelatedTableRowId(row) as string, column.title,
) getRelatedTableRowId(row) as string,
)
} catch (e) {
notification.error({
message: 'Linking failed',
description: await extractSdkResponseErrorMsg(e),
})
}
// todo: reload table data and child list // todo: reload table data and child list
// this.pid = pid; // this.pid = pid;
@ -213,6 +228,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
loadChildrenList, loadChildrenList,
row, row,
deleteRelatedRow, deleteRelatedRow,
getRelatedTableRowId,
} }
}, },
'ltar-store', 'ltar-store',

Loading…
Cancel
Save