Browse Source

refactor(gui-v2): label correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2990/head
Pranav C 2 years ago
parent
commit
7f818d0599
  1. 2
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  2. 5
      packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue
  3. 15
      packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue
  4. 13
      packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue
  5. 2
      packages/nc-gui-v2/composables/useLTARStore.ts

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

@ -40,7 +40,7 @@ await loadRelatedTableMeta()
<MdiPlusIcon class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" @click="listItemsDlg = true" /> <MdiPlusIcon class="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 @attachRecord="childListDlg=false,listItemsDlg=true" v-model="childListDlg" /> <ListChildItems v-model="childListDlg" @attachRecord=";(childListDlg = false), (listItemsDlg = true)" />
</div> </div>
</template> </template>

5
packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue

@ -32,8 +32,7 @@ await loadRelatedTableMeta()
<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" <span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span>
@click="childListDlg = true">more... </span>
</template> </template>
</div> </div>
<div class="flex-1 flex justify-end gap-1"> <div class="flex-1 flex justify-end gap-1">
@ -41,7 +40,7 @@ await loadRelatedTableMeta()
<MdiPlusIcon class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" @click="listItemsDlg = true" /> <MdiPlusIcon class="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 @attachRecord="childListDlg=false,listItemsDlg=true" v-model="childListDlg" /> <ListChildItems v-model="childListDlg" @attachRecord=";(childListDlg = false), (listItemsDlg = true)" />
</div> </div>
</template> </template>

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

@ -10,15 +10,7 @@ const emit = defineEmits(['update:modelValue', 'attachRecord'])
const vModel = useVModel(props, 'modelValue', emit) const vModel = useVModel(props, 'modelValue', emit)
const { const { childrenList, meta, deleteRelatedRow, loadChildrenList, childrenListPagination, relatedTablePrimaryValueProp, unlink } =
childrenList,
meta,
deleteRelatedRow,
loadChildrenList,
childrenListPagination,
relatedTablePrimaryValueProp,
unlink,
} =
useLTARStoreOrThrow() useLTARStoreOrThrow()
watch(vModel, () => { watch(vModel, () => {
@ -56,8 +48,7 @@ const unlinkRow = async (row: Record<string, any>) => {
</div> </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" <MdiDeleteIcon class="text-xs text-grey hover:(!text-red-500) cursor-pointer" @click="deleteRelatedRow(row)" />
@click="deleteRelatedRow(row)" />
</div> </div>
</div> </div>
</a-card> </a-card>
@ -72,7 +63,7 @@ const unlinkRow = async (row: Record<string, any>) => {
show-less-items show-less-items
/> />
</template> </template>
<a-empty class="my-10" v-else /> <a-empty v-else class="my-10" />
</div> </div>
</a-modal> </a-modal>
</template> </template>

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

@ -20,16 +20,21 @@ watch(vModel, () => {
const linkRow = async (row: Record<string, any>) => { const linkRow = async (row: Record<string, any>) => {
await link(row) await link(row)
vModel.value= false vModel.value = false
// await loadChildrenExcludedList() // await loadChildrenExcludedList()
} }
</script> </script>
<template> <template>
<a-modal v-model:visible="vModel" :footer="null" title="Related table rows"> <a-modal v-model:visible="vModel" :footer="null" title="Link Record">
<div class="max-h-[max(calc(100vh_-_300px)_,500px)] flex flex-col"> <div class="max-h-[max(calc(100vh_-_300px)_,500px)] flex flex-col">
<div class="flex mb-4 align-center gap-2"> <div class="flex mb-4 align-center gap-2">
<a-input v-model:value="childrenExcludedListPagination.query" placeholder="Filter query" class="max-w-[200px]" size="small"></a-input> <a-input
v-model:value="childrenExcludedListPagination.query"
placeholder="Filter query"
class="max-w-[200px]"
size="small"
></a-input>
<div class="flex-1" /> <div class="flex-1" />
<MdiReloadIcon class="cursor-pointer text-gray-500" @click="loadChildrenExcludedList" /> <MdiReloadIcon class="cursor-pointer text-gray-500" @click="loadChildrenExcludedList" />
<a-button type="primary" size="small" @click="emit('addNewRecord')">Add new record</a-button> <a-button type="primary" size="small" @click="emit('addNewRecord')">Add new record</a-button>
@ -55,7 +60,7 @@ const linkRow = async (row: Record<string, any>) => {
show-less-items show-less-items
/> />
</template> </template>
<a-empty class="my-10" v-else /> <a-empty v-else class="my-10" />
</div> </div>
</a-modal> </a-modal>
</template> </template>

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

@ -110,7 +110,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
$api.dbTableRow.delete(NOCO, project.value.id as string, relatedTableMeta.value.id as string, id as string) $api.dbTableRow.delete(NOCO, project.value.id as string, relatedTableMeta.value.id as string, id as string)
reloadData?.() reloadData?.()
await loadChildrenList() await loadChildrenList()
} catch (e) { } catch (e: any) {
notification.error(await extractSdkResponseErrorMsg(e)) notification.error(await extractSdkResponseErrorMsg(e))
} }
}, },

Loading…
Cancel
Save