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, ActiveCellInj,
CellValueInj, CellValueInj,
ColumnInj, ColumnInj,
EditModeInj, ReadonlyInj,
ReloadViewDataHookInj, ReloadViewDataHookInj,
RowInj, RowInj,
defineAsyncComponent, defineAsyncComponent,
@ -31,7 +31,7 @@ const row = inject(RowInj)!
const active = inject(ActiveCellInj)! const active = inject(ActiveCellInj)!
const editEnabled = inject(EditModeInj) const readonly = inject(ReadonlyInj, false)
const listItemsDlg = ref(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)" /> <ItemChip :item="value" :value="value[relatedTablePrimaryValueProp]" @unlink="unlinkRef(value)" />
</template> </template>
</div> </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 <component
:is="addIcon" :is="addIcon"
class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500 select-none group-hover:(text-gray-500)" 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 { import {
CellValueInj, CellValueInj,
ColumnInj, ColumnInj,
EditModeInj,
IsFormInj, IsFormInj,
ReadonlyInj,
ReloadViewDataHookInj, ReloadViewDataHookInj,
RowInj, RowInj,
computed, computed,
@ -32,7 +32,7 @@ const reloadTrigger = inject(ReloadViewDataHookInj)!
const isForm = inject(IsFormInj) const isForm = inject(IsFormInj)
const editEnabled = inject(EditModeInj) const readonly = inject(ReadonlyInj)
const listItemsDlg = ref(false) const listItemsDlg = ref(false)
@ -94,7 +94,7 @@ const unlinkRef = async (rec: Record<string, any>) => {
@click="childListDlg = true" @click="childListDlg = true"
/> />
<MdiPlus <MdiPlus
v-if="editEnabled" v-if="!readonly"
class="select-none text-sm nc-action-icon text-gray-500/50 hover:text-gray-500" class="select-none text-sm nc-action-icon text-gray-500/50 hover:text-gray-500"
@click="listItemsDlg = true" @click="listItemsDlg = true"
/> />

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

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

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

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

Loading…
Cancel
Save