Browse Source

feat(gui): add clear option for singleSelect

Added clear icon for nullable single select columns

re #261

Signed-off-by: Pranav C Balan <pranavxc@gmail.com>
pull/269/head
Pranav C Balan 3 years ago
parent
commit
ba75c65053
  1. 14
      packages/nc-gui/components/project/spreadsheet/editableCell/enumListEditableCell.vue
  2. 4
      packages/nc-gui/components/project/spreadsheet/helpers/columnStyling.js
  3. 30
      packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

14
packages/nc-gui/components/project/spreadsheet/editableCell/enumListEditableCell.vue

@ -1,5 +1,5 @@
<template> <template>
<v-select v-on="parentListeners" v-model="localState" dense flat :items="enumValues" hide-details class="mt-0"> <v-select v-on="parentListeners" v-model="localState" dense flat :items="enumValues" hide-details class="mt-0" :clearable="!column.rqd">
<!-- <option v-for="eVal of enumValues" :key="eVal" :value="eVal">{{ eVal }}</option>--> <!-- <option v-for="eVal of enumValues" :key="eVal" :value="eVal">{{ eVal }}</option>-->
<template v-slot:selection="{item}"> <template v-slot:selection="{item}">
<div class="d-100 pl-4" :class="{ <div class="d-100 pl-4" :class="{
@ -69,17 +69,9 @@ export default {
</script> </script>
<style scoped> <style scoped>
select { /deep/ .v-select{
width: 100%; min-width: 150px;
height: 100%;
color: var(--v-textColor-base);
-webkit-appearance: menulist;
/*webkit browsers */
-moz-appearance: menulist;
/*Firefox */
appearance: menulist;
} }
</style> </style>
<!-- <!--
/** /**

4
packages/nc-gui/components/project/spreadsheet/helpers/columnStyling.js

@ -5,8 +5,8 @@ export default {
'LongText': {w: '400px'}, 'LongText': {w: '400px'},
'Attachment': {}, 'Attachment': {},
'Checkbox': {}, 'Checkbox': {},
'MultiSelect': {w: '150px'}, 'MultiSelect': {w: '200px'},
'SingleSelect': {}, 'SingleSelect': {w: '200px'},
'Collaborator': {}, 'Collaborator': {},
'Date': {}, 'Date': {},
'Year': {}, 'Year': {},

30
packages/nc-gui/components/project/spreadsheet/views/xcGridView.vue

@ -312,19 +312,23 @@ export default {
columnsWidth: {type: Object} columnsWidth: {type: Object}
}, },
mounted() { mounted() {
setTimeout(() => { this.calculateColumnWidth();
const obj = {};
this.meta && this.meta.columns && this.meta.columns.forEach(c => {
obj[c._cn] = columnStyling[c.uidt] && columnStyling[c.uidt].w || undefined;
})
Array.from(this.$el.querySelectorAll('th')).forEach(el => {
const width = el.getBoundingClientRect().width;
obj[el.dataset.col] = obj[el.dataset.col] || ((width < 100 ? 100 : width) + 'px');
});
this.$emit('update:columnsWidth', {...obj, ...(this.columnWidth || {})})
}, 500)
}, },
methods: { methods: {
calculateColumnWidth() {
setTimeout(() => {
const obj = {};
this.meta && this.meta.columns && this.meta.columns.forEach(c => {
debugger
obj[c._cn] = columnStyling[c.uidt] && columnStyling[c.uidt].w || undefined;
})
Array.from(this.$el.querySelectorAll('th')).forEach(el => {
const width = el.getBoundingClientRect().width;
obj[el.dataset.col] = obj[el.dataset.col] || ((width < 100 ? 100 : width) + 'px');
});
this.$emit('update:columnsWidth', {...obj, ...(this.columnWidth || {})})
}, 500)
},
isCentrallyAligned(col) { isCentrallyAligned(col) {
return !['SingleLineText', return !['SingleLineText',
'LongText', 'LongText',
@ -796,5 +800,9 @@ th:first-child, td:first-child {
transform: rotate(90deg); transform: rotate(90deg);
} }
th{
min-width:100px;
}
</style> </style>

Loading…
Cancel
Save