1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-02-21 14:10:42 +01:00

refactor: v-model on custom components

This commit is contained in:
Fabio Di Stasio 2022-04-24 23:10:25 +02:00
parent 4f8bc26349
commit b8e734d827
5 changed files with 15 additions and 15 deletions

View File

@ -129,7 +129,7 @@ export default {
fieldLength: Number, fieldLength: Number,
fieldObj: Object fieldObj: Object
}, },
emits: ['update:value'], emits: ['update:modelValue'],
data () { data () {
return { return {
localType: null, localType: null,
@ -245,7 +245,7 @@ export default {
this.selectedValue = ''; this.selectedValue = '';
}, },
onChange () { onChange () {
this.$emit('update:value', { this.$emit('update:modelValue', {
group: this.selectedGroup, group: this.selectedGroup,
method: this.selectedMethod, method: this.selectedMethod,
params: this.methodParams, params: this.methodParams,

View File

@ -27,14 +27,14 @@ import { TEXT, LONG_TEXT } from 'common/fieldTypes';
export default { export default {
name: 'ForeignKeySelect', name: 'ForeignKeySelect',
props: { props: {
value: [String, Number], modelValue: [String, Number],
keyUsage: Object, keyUsage: Object,
size: { size: {
type: String, type: String,
default: '' default: ''
} }
}, },
emits: ['update:value', 'blur'], emits: ['update:modelValue', 'blur'],
data () { data () {
return { return {
foreignList: [] foreignList: []
@ -46,7 +46,7 @@ export default {
}), }),
isValidDefault () { isValidDefault () {
if (!this.foreignList.length) return true; if (!this.foreignList.length) return true;
if (this.value === null) return false; if (this.modelValue === null) return false;
return this.foreignList.some(foreign => foreign.foreign_column.toString() === this.value.toString()); return this.foreignList.some(foreign => foreign.foreign_column.toString() === this.value.toString());
} }
}, },
@ -92,7 +92,7 @@ export default {
addNotification: 'notifications/addNotification' addNotification: 'notifications/addNotification'
}), }),
onChange () { onChange () {
this.$emit('update:value', this.$refs.editField.value); this.$emit('update:modelValue', this.$refs.editField.value);
}, },
cutText (val) { cutText (val) {
if (typeof val !== 'string') return val; if (typeof val !== 'string') return val;

View File

@ -340,8 +340,8 @@ export default {
}, },
fieldLength (field) { fieldLength (field) {
if ([...BLOB, ...LONG_TEXT].includes(field.type)) return null; if ([...BLOB, ...LONG_TEXT].includes(field.type)) return null;
else if (TEXT.includes(field.type)) return field.charLength; else if (TEXT.includes(field.type)) return Number(field.charLength);
return field.length; return Number(field.length);
}, },
toggleFields (event, field) { toggleFields (event, field) {
if (event.target.checked) if (event.target.checked)

View File

@ -273,7 +273,7 @@
</div> </div>
<div class="column col-12"> <div class="column col-12">
<BaseTextEditor <BaseTextEditor
:value="exampleQuery" :model-value="exampleQuery"
mode="sql" mode="sql"
:workspace="workspace" :workspace="workspace"
:read-only="true" :read-only="true"
@ -316,12 +316,12 @@
</template> </template>
<script> <script>
import { shell } from 'electron';
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import localesNames from '@/i18n/supported-locales'; import localesNames from '@/i18n/supported-locales';
import ModalSettingsUpdate from '@/components/ModalSettingsUpdate'; import ModalSettingsUpdate from '@/components/ModalSettingsUpdate';
import ModalSettingsChangelog from '@/components/ModalSettingsChangelog'; import ModalSettingsChangelog from '@/components/ModalSettingsChangelog';
import BaseTextEditor from '@/components/BaseTextEditor'; import BaseTextEditor from '@/components/BaseTextEditor';
const { shell } = require('electron');
export default { export default {
name: 'ModalSettings', name: 'ModalSettings',

View File

@ -18,7 +18,7 @@ import Tables from '@/ipc-api/Tables';
export default { export default {
name: 'QueryEditor', name: 'QueryEditor',
props: { props: {
value: String, modelValue: String,
workspace: Object, workspace: Object,
isSelected: Boolean, isSelected: Boolean,
schema: { type: String, default: '' }, schema: { type: String, default: '' },
@ -26,7 +26,7 @@ export default {
readOnly: { type: Boolean, default: false }, readOnly: { type: Boolean, default: false },
height: { type: Number, default: 200 } height: { type: Number, default: 200 }
}, },
emits: ['update:value'], emits: ['update:modelValue'],
data () { data () {
return { return {
editor: null, editor: null,
@ -132,7 +132,7 @@ export default {
return this.editor.session.doc.positionToIndex(this.editor.getCursorPosition()); return this.editor.session.doc.positionToIndex(this.editor.getCursorPosition());
}, },
lastWord () { lastWord () {
const charsBefore = this.value.slice(0, this.cursorPosition); const charsBefore = this.modelValue.slice(0, this.cursorPosition);
const words = charsBefore.replaceAll('\n', ' ').split(' ').filter(Boolean); const words = charsBefore.replaceAll('\n', ' ').split(' ').filter(Boolean);
return words.pop(); return words.pop();
}, },
@ -213,7 +213,7 @@ export default {
this.editor = ace.edit(`editor-${this.id}`, { this.editor = ace.edit(`editor-${this.id}`, {
mode: `ace/mode/${this.mode}`, mode: `ace/mode/${this.mode}`,
theme: `ace/theme/${this.editorTheme}`, theme: `ace/theme/${this.editorTheme}`,
value: this.value, value: this.modelValue,
fontSize: '14px', fontSize: '14px',
printMargin: false, printMargin: false,
readOnly: this.readOnly readOnly: this.readOnly
@ -264,7 +264,7 @@ export default {
this.editor.session.on('change', () => { this.editor.session.on('change', () => {
const content = this.editor.getValue(); const content = this.editor.getValue();
this.$emit('update:value', content); this.$emit('update:modelValue', content);
}); });
this.editor.on('guttermousedown', e => { this.editor.on('guttermousedown', e => {