Browse Source

fix: escape single quote in multi/single select option

re #896

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/921/head
Pranav C 3 years ago
parent
commit
01a8cbd781
  1. 2
      packages/nc-gui/components/project/spreadsheet/components/cell/enumCell.vue
  2. 2
      packages/nc-gui/components/project/spreadsheet/components/cell/setListCell.vue
  3. 8
      packages/nc-gui/components/project/spreadsheet/components/editColumn/customSelectOptions.vue
  4. 2
      packages/nc-gui/components/project/spreadsheet/components/editableCell/enumListEditableCell.vue
  5. 2
      packages/nc-gui/components/project/spreadsheet/components/editableCell/setListEditableCell.vue

2
packages/nc-gui/components/project/spreadsheet/components/cell/enumCell.vue

@ -21,7 +21,7 @@ export default {
colors() {
const col = this.$store.state.windows.darkTheme ? colors.dark : colors.light
if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')).reduce((obj, v, i) => ({
return this.column.dtxp.split(',').map(v => v.replace(/\\'/g, '\'').replace(/^'|'$/g, '')).reduce((obj, v, i) => ({
...obj,
[v]: col[i]
}), {})

2
packages/nc-gui/components/project/spreadsheet/components/cell/setListCell.vue

@ -23,7 +23,7 @@ export default {
setValues() {
if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
return this.column.dtxp.split(',').map(v => v.replace(/\\'/g, '\'').replace(/^'|'$/g, ''))
}
return []
}

8
packages/nc-gui/components/project/spreadsheet/components/editColumn/customSelectOptions.vue

@ -22,7 +22,8 @@
>
<v-icon x-small outlined color="primary" class="mr-2">
mdi-plus
</v-icon> Add option
</v-icon>
Add option
</v-btn>
</v-container>
</template>
@ -30,6 +31,7 @@
<script>
import colors from '@/components/project/spreadsheet/helpers/colors'
export default {
name: 'CustomSelectOptions',
props: ['value'],
@ -44,7 +46,7 @@ export default {
watch: {
localState: {
handler(v) {
this.$emit('input', v.map(v => `'${v}'`).join(','))
this.$emit('input', v.map(v => `'${v.replace(/'/g, '\\\'')}'`).join(','))
},
deep: true
},
@ -57,7 +59,7 @@ export default {
},
methods: {
syncState() {
this.localState = (this.value || '').split(',').map(v => v.replace(/^'|'$/g, ''))
this.localState = (this.value || '').split(',').map(v => v.replace(/\\'/g, '\'').replace(/^'|'$/g, ''))
}
}
}

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

@ -60,7 +60,7 @@ export default {
},
enumValues() {
if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
return this.column.dtxp.split(',').map(v => v.replace(/\\'/g, '\'').replace(/^'|'$/g, ''))
}
return []
},

2
packages/nc-gui/components/project/spreadsheet/components/editableCell/setListEditableCell.vue

@ -64,7 +64,7 @@ export default {
},
setValues() {
if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
return this.column.dtxp.split(',').map(v => v.replace(/\\'/g, '\'').replace(/^'|'$/g, ''))
}
return []
},

Loading…
Cancel
Save