2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
- Dont render hidden fields
- Render Fields with Custom Template
- Disabled fields
This commit is contained in:
Faris Ansari 2018-07-09 18:30:57 +05:30
parent 180845aa0c
commit c8422eca39
3 changed files with 19 additions and 2 deletions

View File

@ -7,6 +7,7 @@
<div class="col" v-for="(column, j) in section.columns" :key="j"> <div class="col" v-for="(column, j) in section.columns" :key="j">
<frappe-control <frappe-control
v-for="fieldname in column.fields" v-for="fieldname in column.fields"
v-if="fieldIsNotHidden(fieldname)"
:key="fieldname" :key="fieldname"
:docfield="getDocField(fieldname)" :docfield="getDocField(fieldname)"
:value="$data[fieldname]" :value="$data[fieldname]"
@ -58,6 +59,9 @@ export default {
getDocField(fieldname) { getDocField(fieldname) {
return this.fields.find(df => df.fieldname === fieldname); return this.fields.find(df => df.fieldname === fieldname);
}, },
fieldIsNotHidden(fieldname) {
return !Boolean(this.getDocField(fieldname).hidden);
},
updateDoc(fieldname, value) { updateDoc(fieldname, value) {
this.doc.set(fieldname, value); this.doc.set(fieldname, value);
}, },

View File

@ -70,7 +70,8 @@ export default {
type: 'text', type: 'text',
placeholder: '', placeholder: '',
value: this.value, value: this.value,
required: this.docfield.required required: this.docfield.required,
disabled: this.docfield.disabled
} }
}, },
getInputListeners() { getInputListeners() {

View File

@ -1,5 +1,6 @@
<template> <template>
<component :is="component" <component
:is="component"
:docfield="docfield" :docfield="docfield"
:value="value" :value="value"
:onlyInput="onlyInput" :onlyInput="onlyInput"
@ -7,6 +8,7 @@
/> />
</template> </template>
<script> <script>
import Base from './Base';
import Autocomplete from './Autocomplete'; import Autocomplete from './Autocomplete';
import Check from './Check'; import Check from './Check';
import Code from './Code'; import Code from './Code';
@ -27,6 +29,16 @@ export default {
props: ['docfield', 'value', 'onlyInput'], props: ['docfield', 'value', 'onlyInput'],
computed: { computed: {
component() { component() {
if (this.docfield.template) {
// for controls with their own template
// create a vue object for it
return {
extends: Base,
render: null,
template: this.docfield.template()
}
}
return { return {
Autocomplete, Autocomplete,
Check, Check,