Browse Source

fix(gui): show pointer for select field if not readonly

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4957/head
Pranav C 2 years ago
parent
commit
e708465697
  1. 93
      packages/nc-gui/components/cell/MultiSelect.vue

93
packages/nc-gui/components/cell/MultiSelect.vue

@ -114,13 +114,13 @@ const selectedTitles = computed(() =>
? typeof modelValue === 'string' ? typeof modelValue === 'string'
? isMysql(column.value.base_id) ? isMysql(column.value.base_id)
? modelValue.split(',').sort((a, b) => { ? modelValue.split(',').sort((a, b) => {
const opa = options.value.find((el) => el.title === a) const opa = options.value.find((el) => el.title === a)
const opb = options.value.find((el) => el.title === b) const opb = options.value.find((el) => el.title === b)
if (opa && opb) { if (opa && opb) {
return opa.order! - opb.order! return opa.order! - opb.order!
} }
return 0 return 0
}) })
: modelValue.split(',') : modelValue.split(',')
: modelValue : modelValue
: [], : [],
@ -233,7 +233,7 @@ async function addIfMissingAndSave() {
// Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped // Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped
if (!isMysql(column.value.base_id)) { if (!isMysql(column.value.base_id)) {
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, '\'') updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'")
} }
} }
@ -276,8 +276,11 @@ const onTagClick = (e: Event, onClose: Function) => {
</script> </script>
<template> <template>
<div class="nc-multi-select h-full w-full flex items-center" <div
@click="isOpen = editAllowed && !isOpen" :class="{ 'read-only': readOnly }"> class="nc-multi-select h-full w-full flex items-center"
:class="{ 'read-only': readOnly }"
@click="isOpen = editAllowed && !isOpen"
>
<a-select <a-select
ref="aselect" ref="aselect"
v-model:value="vModel" v-model:value="vModel"
@ -287,9 +290,8 @@ const onTagClick = (e: Event, onClose: Function) => {
clear-icon clear-icon
show-search show-search
:show-arrow="hasEditRoles && !readOnly && (editable || (active && vModel.length === 0))" :show-arrow="hasEditRoles && !readOnly && (editable || (active && vModel.length === 0))"
:open="isOpen && (active || editable)" :open="isOpen && editAllowed"
@update:open="isOpen = $event" :disabled="readOnly || !editAllowed"
:disabled="readOnly || !(active || editable)"
:class="{ '!ml-[-8px]': readOnly, 'caret-transparent': !hasEditRoles }" :class="{ '!ml-[-8px]': readOnly, 'caret-transparent': !hasEditRoles }"
:dropdown-class-name="`nc-dropdown-multi-select-cell ${isOpen ? 'active' : ''}`" :dropdown-class-name="`nc-dropdown-multi-select-cell ${isOpen ? 'active' : ''}`"
@search="search" @search="search"
@ -303,17 +305,17 @@ const onTagClick = (e: Event, onClose: Function) => {
@click.stop @click.stop
> >
<a-tag class="rounded-tag" :color="op.color"> <a-tag class="rounded-tag" :color="op.color">
<span <span
:style="{ :style="{
'color': tinycolor.isReadable(op.color || '#ccc', '#fff', { level: 'AA', size: 'large' }) 'color': tinycolor.isReadable(op.color || '#ccc', '#fff', { level: 'AA', size: 'large' })
? '#fff' ? '#fff'
: tinycolor.mostReadable(op.color || '#ccc', ['#0b1d05', '#fff']).toHex8String(), : tinycolor.mostReadable(op.color || '#ccc', ['#0b1d05', '#fff']).toHex8String(),
'font-size': '13px', 'font-size': '13px',
}" }"
:class="{ 'text-sm': isKanban }" :class="{ 'text-sm': isKanban }"
> >
{{ op.title }} {{ op.title }}
</span> </span>
</a-tag> </a-tag>
</a-select-option> </a-select-option>
@ -336,34 +338,34 @@ const onTagClick = (e: Event, onClose: Function) => {
class="rounded-tag nc-selected-option" class="rounded-tag nc-selected-option"
:style="{ display: 'flex', alignItems: 'center' }" :style="{ display: 'flex', alignItems: 'center' }"
:color="options.find((el) => el.title === val)?.color" :color="options.find((el) => el.title === val)?.color"
:closable="editAllowed && (active || editable) && (vModel.length > 1 || !column?.rqd)" :closable="editAllowed && (vModel.length > 1 || !column?.rqd)"
:close-icon="h(MdiCloseCircle, { class: ['ms-close-icon'] })" :close-icon="h(MdiCloseCircle, { class: ['ms-close-icon'] })"
@click="onTagClick($event, onClose)" @click="onTagClick($event, onClose)"
@close="onClose" @close="onClose"
> >
<span <span
:style="{ :style="{
'color': tinycolor.isReadable(options.find((el) => el.title === val)?.color || '#ccc', '#fff', { 'color': tinycolor.isReadable(options.find((el) => el.title === val)?.color || '#ccc', '#fff', {
level: 'AA', level: 'AA',
size: 'large', size: 'large',
}) })
? '#fff' ? '#fff'
: tinycolor : tinycolor
.mostReadable(options.find((el) => el.title === val)?.color || '#ccc', ['#0b1d05', '#fff']) .mostReadable(options.find((el) => el.title === val)?.color || '#ccc', ['#0b1d05', '#fff'])
.toHex8String(), .toHex8String(),
'font-size': '13px', 'font-size': '13px',
}" }"
:class="{ 'text-sm': isKanban }" :class="{ 'text-sm': isKanban }"
> >
{{ val }} {{ val }}
</span> </span>
</a-tag> </a-tag>
</template> </template>
</a-select> </a-select>
</div> </div>
</template> </template>
<style scoped> <style scoped lang="scss">
.ms-close-icon { .ms-close-icon {
color: rgba(0, 0, 0, 0.25); color: rgba(0, 0, 0, 0.25);
cursor: pointer; cursor: pointer;
@ -408,4 +410,11 @@ const onTagClick = (e: Event, onClose: Function) => {
:deep(.ant-select-selection-overflow) { :deep(.ant-select-selection-overflow) {
@apply flex-nowrap; @apply flex-nowrap;
} }
.nc-multi-select:not(.read-only) {
:deep(.ant-select-selector),
:deep(.ant-select-selector input) {
@apply "!cursor-pointer";
}
}
</style> </style>

Loading…
Cancel
Save