2018-06-27 14:38:27 +00:00
|
|
|
<template>
|
2018-07-12 07:47:56 +00:00
|
|
|
<component
|
|
|
|
:is="component"
|
|
|
|
:docfield="docfield"
|
|
|
|
:value="value"
|
|
|
|
:onlyInput="onlyInput"
|
|
|
|
:disabled="isDisabled"
|
2018-09-28 13:10:02 +00:00
|
|
|
:autofocus="autofocus"
|
2019-07-16 12:40:47 +00:00
|
|
|
:doc="doc"
|
2018-07-12 07:47:56 +00:00
|
|
|
@change="$emit('change', $event)"
|
|
|
|
/>
|
2018-06-27 14:38:27 +00:00
|
|
|
</template>
|
|
|
|
<script>
|
2019-07-17 10:02:49 +00:00
|
|
|
import frappe from 'frappejs';
|
2018-07-09 13:00:57 +00:00
|
|
|
import Base from './Base';
|
2018-06-27 14:38:27 +00:00
|
|
|
import Autocomplete from './Autocomplete';
|
|
|
|
import Check from './Check';
|
|
|
|
import Code from './Code';
|
|
|
|
import Currency from './Currency';
|
|
|
|
import Data from './Data';
|
|
|
|
import Date from './Date';
|
|
|
|
import DynamicLink from './DynamicLink';
|
|
|
|
import File from './File';
|
|
|
|
import Float from './Float';
|
|
|
|
import Int from './Int';
|
|
|
|
import Link from './Link';
|
|
|
|
import Password from './Password';
|
|
|
|
import Select from './Select';
|
|
|
|
import Table from './Table';
|
|
|
|
import Text from './Text';
|
2018-07-12 15:45:43 +00:00
|
|
|
import Time from './Time';
|
2018-06-27 14:38:27 +00:00
|
|
|
|
|
|
|
export default {
|
2018-09-28 13:10:02 +00:00
|
|
|
props: ['docfield', 'value', 'onlyInput', 'doc', 'autofocus'],
|
2018-07-12 07:47:56 +00:00
|
|
|
computed: {
|
|
|
|
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()
|
|
|
|
};
|
|
|
|
}
|
2018-07-09 13:00:57 +00:00
|
|
|
|
2018-07-12 07:47:56 +00:00
|
|
|
return {
|
|
|
|
Autocomplete,
|
|
|
|
Check,
|
|
|
|
Code,
|
|
|
|
Currency,
|
|
|
|
Data,
|
|
|
|
Date,
|
|
|
|
DynamicLink,
|
|
|
|
File,
|
|
|
|
Float,
|
|
|
|
Int,
|
|
|
|
Link,
|
|
|
|
Password,
|
|
|
|
Select,
|
|
|
|
Table,
|
2018-07-12 15:45:43 +00:00
|
|
|
Text,
|
|
|
|
Time
|
2018-07-12 07:47:56 +00:00
|
|
|
}[this.docfield.fieldtype];
|
|
|
|
},
|
|
|
|
isDisabled() {
|
|
|
|
let disabled = this.docfield.disabled;
|
|
|
|
|
|
|
|
if (this.doc && this.doc.submitted) {
|
|
|
|
disabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Boolean(disabled);
|
2018-06-27 14:38:27 +00:00
|
|
|
}
|
2018-10-05 05:32:40 +00:00
|
|
|
},
|
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
dynamicLinkTarget: reference => {
|
|
|
|
return this.doc[reference];
|
|
|
|
}
|
|
|
|
};
|
2019-07-16 12:40:47 +00:00
|
|
|
}
|
2018-07-12 07:47:56 +00:00
|
|
|
};
|
2018-06-27 14:38:27 +00:00
|
|
|
</script>
|
2018-07-09 16:36:02 +00:00
|
|
|
<style scoped>
|
|
|
|
.form-group {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
</style>
|