diff --git a/src/components/FormLayout.vue b/src/components/FormLayout.vue index 43a5cff0..8e8dba00 100644 --- a/src/components/FormLayout.vue +++ b/src/components/FormLayout.vue @@ -1,12 +1,25 @@ + diff --git a/src/components/controls/Base.vue b/src/components/controls/Base.vue index 92740d66..68c18d78 100644 --- a/src/components/controls/Base.vue +++ b/src/components/controls/Base.vue @@ -8,12 +8,21 @@ export default { id() { return this.docfield.fieldname + '-' + document.querySelectorAll(`[data-fieldname="${this.docfield.fieldname}"]`).length; + }, + inputClass() { + return []; + }, + wrapperClass() { + return []; + }, + labelClass() { + return []; } }, methods: { getWrapperElement(h) { return h('div', { - class: ['form-group'], + class: ['form-group', ...this.wrapperClass], attrs: { 'data-fieldname': this.docfield.fieldname } @@ -21,6 +30,7 @@ export default { }, getLabelElement(h) { return h('label', { + class: this.labelClass, attrs: { for: this.id }, @@ -30,16 +40,19 @@ export default { }); }, getInputElement(h) { - return h('input', { - class: ['form-control'], + return h(this.getInputTag(), { + class: this.getInputClass(), attrs: this.getInputAttrs(), - on: { - change: (e) => { - this.$emit('change', e.target.value) - } - }, + on: this.getInputListeners(), + domProps: this.getDomProps(), ref: 'input' - }) + }, this.getInputChildren(h)); + }, + getInputTag() { + return 'input'; + }, + getInputClass() { + return ['form-control', ...this.inputClass]; }, getInputAttrs() { return { @@ -48,6 +61,22 @@ export default { placeholder: '', value: this.value } + }, + getInputListeners() { + return { + change: (e) => { + this.$emit('change', this.parseValue(e.target.value)); + } + }; + }, + getInputChildren() { + return null; + }, + getDomProps() { + return null; + }, + parseValue(value) { + return value; } } } diff --git a/src/components/controls/Check.vue b/src/components/controls/Check.vue new file mode 100644 index 00000000..6b1ec936 --- /dev/null +++ b/src/components/controls/Check.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/components/controls/Code.vue b/src/components/controls/Code.vue new file mode 100644 index 00000000..ddfb049e --- /dev/null +++ b/src/components/controls/Code.vue @@ -0,0 +1,11 @@ + diff --git a/src/components/controls/Currency.vue b/src/components/controls/Currency.vue new file mode 100644 index 00000000..64946d7f --- /dev/null +++ b/src/components/controls/Currency.vue @@ -0,0 +1,6 @@ + diff --git a/src/components/controls/Float.vue b/src/components/controls/Float.vue new file mode 100644 index 00000000..4d15d611 --- /dev/null +++ b/src/components/controls/Float.vue @@ -0,0 +1,24 @@ + diff --git a/src/components/controls/FrappeControl.vue b/src/components/controls/FrappeControl.vue index 15f0c50d..65ad49e9 100644 --- a/src/components/controls/FrappeControl.vue +++ b/src/components/controls/FrappeControl.vue @@ -2,21 +2,30 @@ diff --git a/src/components/controls/Select.vue b/src/components/controls/Select.vue index f78dfe02..b6b1c966 100644 --- a/src/components/controls/Select.vue +++ b/src/components/controls/Select.vue @@ -3,8 +3,16 @@ import Base from './Base'; export default { extends: Base, methods: { - getInputElement(h) { - const options = this.docfield.options.map(option => + getInputTag() { + return 'select'; + }, + getInputAttrs() { + return { + id: this.id + }; + }, + getInputChildren(h) { + return this.docfield.options.map(option => h('option', { attrs: { key: option, @@ -15,19 +23,6 @@ export default { } }) ); - - return h('select', { - class: ['form-control'], - attrs: { - id: this.id - }, - on: { - change: (e) => { - this.$emit('change', e.target.value) - } - }, - ref: 'input' - }, options) } } } diff --git a/src/components/controls/Text.vue b/src/components/controls/Text.vue index a4c3d890..8c0a9e35 100644 --- a/src/components/controls/Text.vue +++ b/src/components/controls/Text.vue @@ -3,23 +3,19 @@ import Base from './Base'; export default { extends: Base, methods: { - getInputElement(h) { - return h('textarea', { - class: ['form-control'], - attrs: { - id: this.id, - rows: 3 - }, - domProps: { - value: this.value - }, - on: { - change: (e) => { - this.$emit('change', e.target.value) - } - }, - ref: 'input' - }); + getInputTag() { + return 'textarea'; + }, + getInputAttrs() { + return { + id: this.id, + rows: 3 + }; + }, + getDomProps() { + return { + value: this.value + } } } }