Browse Source

fix(gui-v2): use ReadonlyInj in LTAR since editEnabled is not the right one

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3169/head
Pranav C 2 years ago
parent
commit
adb10581a5
  1. 6
      packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue
  2. 6
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  3. 6
      packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue
  4. 8
      packages/nc-gui-v2/components/virtual-cell/components/ItemChip.vue

6
packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue

@ -5,7 +5,7 @@ import {
ActiveCellInj,
CellValueInj,
ColumnInj,
EditModeInj,
ReadonlyInj,
ReloadViewDataHookInj,
RowInj,
defineAsyncComponent,
@ -31,7 +31,7 @@ const row = inject(RowInj)!
const active = inject(ActiveCellInj)!
const editEnabled = inject(EditModeInj)
const readonly = inject(ReadonlyInj, false)
const listItemsDlg = ref(false)
@ -72,7 +72,7 @@ const unlinkRef = async (rec: Record<string, any>) => {
<ItemChip :item="value" :value="value[relatedTablePrimaryValueProp]" @unlink="unlinkRef(value)" />
</template>
</div>
<div v-if="editEnabled" class="flex-1 flex justify-end gap-1 min-h-[30px] align-center">
<div v-if="!readonly" class="flex-1 flex justify-end gap-1 min-h-[30px] align-center">
<component
:is="addIcon"
class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500 select-none group-hover:(text-gray-500)"

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

@ -4,8 +4,8 @@ import type { Ref } from 'vue'
import {
CellValueInj,
ColumnInj,
EditModeInj,
IsFormInj,
ReadonlyInj,
ReloadViewDataHookInj,
RowInj,
computed,
@ -32,7 +32,7 @@ const reloadTrigger = inject(ReloadViewDataHookInj)!
const isForm = inject(IsFormInj)
const editEnabled = inject(EditModeInj)
const readonly = inject(ReadonlyInj)
const listItemsDlg = ref(false)
@ -94,7 +94,7 @@ const unlinkRef = async (rec: Record<string, any>) => {
@click="childListDlg = true"
/>
<MdiPlus
v-if="editEnabled"
v-if="!readonly"
class="select-none text-sm nc-action-icon text-gray-500/50 hover:text-gray-500"
@click="listItemsDlg = true"
/>

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

@ -4,8 +4,8 @@ import type { Ref } from 'vue'
import {
CellValueInj,
ColumnInj,
EditModeInj,
IsFormInj,
ReadonlyInj,
ReloadViewDataHookInj,
RowInj,
computed,
@ -31,7 +31,7 @@ const reloadTrigger = inject(ReloadViewDataHookInj)!
const isForm = inject(IsFormInj)
const editEnabled = inject(EditModeInj)
const readonly = inject(ReadonlyInj, false)
const listItemsDlg = ref(false)
@ -92,7 +92,7 @@ const unlinkRef = async (rec: Record<string, any>) => {
<MdiArrowExpand class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" @click="childListDlg = true" />
<MdiPlus
v-if="editEnabled"
v-if="!readonly"
class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500"
@click="listItemsDlg = true"
/>

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

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { ActiveCellInj, EditModeInj, IsFormInj, defineAsyncComponent, inject, ref, useLTARStoreOrThrow } from '#imports'
import { ActiveCellInj, IsFormInj, defineAsyncComponent, inject, ref, useLTARStoreOrThrow } from '#imports'
interface Props {
value?: string | number | boolean
@ -14,7 +14,7 @@ const ExpandedForm: any = defineAsyncComponent(() => import('../../smartsheet/ex
const { relatedTableMeta } = useLTARStoreOrThrow()!
const editEnabled = inject(EditModeInj)!
const readonly = inject(ReadonlyInj, false)
const active = inject(ActiveCellInj, ref(false))
@ -37,13 +37,13 @@ export default {
>
<span class="name">{{ value }}</span>
<div v-show="active || isForm" v-if="editEnabled" class="flex align-center">
<div v-show="active || isForm" v-if="!readonly" class="flex align-center">
<MdiCloseThick class="unlink-icon text-xs text-gray-500/50 group-hover:text-gray-500" @click.stop="emit('unlink')" />
</div>
<Suspense>
<ExpandedForm
v-if="editEnabled"
v-if="!readonly"
v-model="expandedFormDlg"
:row="{ row: item }"
:meta="relatedTableMeta"

Loading…
Cancel
Save