Browse Source

fix(gui): lookup and rollup - show readonly warning only when necessary

re #4702

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4715/head
Pranav C 2 years ago
parent
commit
aeda11d5ca
  1. 27
      packages/nc-gui/components/virtual-cell/Lookup.vue
  2. 17
      packages/nc-gui/components/virtual-cell/Rollup.vue

27
packages/nc-gui/components/virtual-cell/Lookup.vue

@ -12,8 +12,8 @@ import {
isAttachment, isAttachment,
provide, provide,
ref, ref,
refAutoReset,
useMetas, useMetas,
useShowNotEditableWarning,
watch, watch,
} from '#imports' } from '#imports'
@ -75,26 +75,13 @@ provide(MetaInj, lookupTableMeta)
provide(CellUrlDisableOverlayInj, ref(true)) provide(CellUrlDisableOverlayInj, ref(true))
const timeout = 3000 // in ms const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activateShowEditNonEditableFieldWarning } =
useShowNotEditableWarning()
const showEditWarning = refAutoReset(false, timeout)
const showClearWarning = refAutoReset(false, timeout)
useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEvent) => {
switch (e.key) {
case 'Enter':
showEditWarning.value = true
break
default:
showClearWarning.value = true
}
})
</script> </script>
<template> <template>
<div class="h-full"> <div class="h-full" @dblclick="activateShowEditNonEditableFieldWarning">
<div class="h-full flex gap-1 overflow-x-auto p-1" @dblclick="showEditWarning = true"> <div class="h-full flex gap-1 overflow-x-auto p-1">
<template v-if="lookupColumn"> <template v-if="lookupColumn">
<!-- Render virtual cell --> <!-- Render virtual cell -->
<div v-if="isVirtualCol(lookupColumn)"> <div v-if="isVirtualCol(lookupColumn)">
@ -133,10 +120,10 @@ useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEven
</template> </template>
</div> </div>
<div> <div>
<div v-if="showEditWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs"> <div v-if="showEditNonEditableFieldWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs">
{{ $t('msg.info.computedFieldEditWarning') }} {{ $t('msg.info.computedFieldEditWarning') }}
</div> </div>
<div v-if="showClearWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs"> <div v-if="showClearNonEditableFieldWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs">
{{ $t('msg.info.computedFieldDeleteWarning') }} {{ $t('msg.info.computedFieldDeleteWarning') }}
</div> </div>
</div> </div>

17
packages/nc-gui/components/virtual-cell/Rollup.vue

@ -1,28 +1,23 @@
<script setup lang="ts"> <script setup lang="ts">
import { CellValueInj, inject, refAutoReset } from '#imports' import { CellValueInj, inject, useShowNotEditableWarning } from '#imports'
const value = inject(CellValueInj) const value = inject(CellValueInj)
const timeout = 3000 // in ms const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning, activateShowEditNonEditableFieldWarning } =
useShowNotEditableWarning()
const showEditWarning = refAutoReset(false, timeout)
const showClearWarning = refAutoReset(false, timeout)
useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), () => (showClearWarning.value = true))
</script> </script>
<template> <template>
<div> <div @dblclick="activateShowEditNonEditableFieldWarning">
<span class="text-center pl-3"> <span class="text-center pl-3">
{{ value }} {{ value }}
</span> </span>
<div> <div>
<div v-if="showEditWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs"> <div v-if="showEditNonEditableFieldWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs">
{{ $t('msg.info.computedFieldEditWarning') }} {{ $t('msg.info.computedFieldEditWarning') }}
</div> </div>
<div v-if="showClearWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs"> <div v-if="showClearNonEditableFieldWarning" class="text-left text-wrap mt-2 text-[#e65100] text-xs">
{{ $t('msg.info.computedFieldDeleteWarning') }} {{ $t('msg.info.computedFieldDeleteWarning') }}
</div> </div>
</div> </div>

Loading…
Cancel
Save