Skip to content

Commit

Permalink
Merge pull request #4415 from nocodb/fix/make-select-field-ediatable-…
Browse files Browse the repository at this point in the history
…in-form

Fix: Grid view - make select field editable in form view
  • Loading branch information
dstala committed Nov 17, 2022
2 parents b42088d + a0cd878 commit 2de2d00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
9 changes: 5 additions & 4 deletions packages/nc-gui/components/cell/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { SelectOptionType, SelectOptionsType } from 'nocodb-sdk'
import {
ActiveCellInj,
ColumnInj,
EditModeInj,
IsKanbanInj,
ReadonlyInj,
computed,
Expand Down Expand Up @@ -36,6 +37,8 @@ const readOnly = inject(ReadonlyInj)!
const active = inject(ActiveCellInj, ref(false))
const editable = inject(EditModeInj, ref(false))
const selectedIds = ref<string[]>([])
const aselect = ref<typeof AntSelect>()
Expand Down Expand Up @@ -86,8 +89,6 @@ const selectedTitles = computed(() =>
: [],
)
const v = Math.floor(Math.random() * 1000)
const handleClose = (e: MouseEvent) => {
if (aselect.value && !aselect.value.$el.contains(e.target)) {
isOpen.value = false
Expand Down Expand Up @@ -157,7 +158,7 @@ useSelectedCellKeyupListener(active, (e) => {
:class="{ '!ml-[-8px]': readOnly }"
:dropdown-class-name="`nc-dropdown-multi-select-cell ${isOpen ? 'active' : ''}`"
@keydown.enter.stop
@click="isOpen = active && !isOpen"
@click="isOpen = (active || editable) && !isOpen"
>
<a-select-option
v-for="op of options"
Expand Down Expand Up @@ -187,7 +188,7 @@ useSelectedCellKeyupListener(active, (e) => {
class="rounded-tag"
:style="{ display: 'flex', alignItems: 'center' }"
:color="options.find((el) => el.title === val)?.color"
:closable="active && (vModel.length > 1 || !column?.rqd)"
:closable="(active || editable) && (vModel.length > 1 || !column?.rqd)"
:close-icon="h(MdiCloseCircle, { class: ['ms-close-icon'] })"
@close="onClose"
>
Expand Down
19 changes: 16 additions & 3 deletions packages/nc-gui/components/cell/SingleSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
import tinycolor from 'tinycolor2'
import type { Select as AntSelect } from 'ant-design-vue'
import type { SelectOptionType } from 'nocodb-sdk'
import { ActiveCellInj, ColumnInj, IsKanbanInj, ReadonlyInj, computed, inject, ref, useEventListener, watch } from '#imports'
import {
ActiveCellInj,
ColumnInj,
EditModeInj,
IsKanbanInj,
ReadonlyInj,
computed,
inject,
ref,
useEventListener,
watch,
} from '#imports'
import { useSelectedCellKeyupListener } from '~/composables/useSelectedCellKeyupListener'
interface Props {
Expand All @@ -20,6 +31,8 @@ const readOnly = inject(ReadonlyInj)!
const active = inject(ActiveCellInj, ref(false))
const editable = inject(EditModeInj, ref(false))
const aselect = ref<typeof AntSelect>()
const isOpen = ref(false)
Expand Down Expand Up @@ -85,11 +98,11 @@ useSelectedCellKeyupListener(active, (e) => {
:bordered="false"
:open="isOpen"
:disabled="readOnly"
:show-arrow="!readOnly && (active || vModel === null)"
:show-arrow="!readOnly && (active || editable || vModel === null)"
:dropdown-class-name="`nc-dropdown-single-select-cell ${isOpen ? 'active' : ''}`"
@select="isOpen = false"
@keydown.enter.stop
@click="isOpen = active && !isOpen"
@click="isOpen = (active || editable) && !isOpen"
>
<a-select-option
v-for="op of options"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
:body-style="{ 'padding': 0, 'display': 'flex', 'flex-direction': 'column' }"
:closable="false"
class="nc-drawer-expanded-form"
:class="{ 'active': isExpanded }"
:class="{ active: isExpanded }"
>
<SmartsheetExpandedFormHeader :view="props.view" @cancel="onClose" />

Expand Down

0 comments on commit 2de2d00

Please sign in to comment.