mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
fix: Add Numeric field types
- Int - Float - Currency
This commit is contained in:
parent
3e3235b814
commit
32b3793793
@ -68,8 +68,12 @@ export default {
|
||||
this.$refs.input.focus();
|
||||
},
|
||||
triggerChange(value) {
|
||||
value = this.parse(value);
|
||||
this.$emit('change', value);
|
||||
},
|
||||
parse(value) {
|
||||
return value;
|
||||
},
|
||||
isNumeric(df) {
|
||||
return ['Int', 'Float', 'Currency'].includes(df.fieldtype);
|
||||
}
|
||||
|
8
src/components/Controls/Currency.vue
Normal file
8
src/components/Controls/Currency.vue
Normal file
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import Float from './Float';
|
||||
|
||||
export default {
|
||||
name: 'Currency',
|
||||
extends: Float
|
||||
};
|
||||
</script>
|
@ -6,7 +6,7 @@ export default {
|
||||
extends: Link,
|
||||
created() {
|
||||
this.targetWatcher = this.$watch(`doc.${this.df.references}`, function(newTarget, oldTarget) {
|
||||
if (newTarget !== oldTarget) {
|
||||
if (oldTarget && newTarget !== oldTarget) {
|
||||
this.triggerChange('');
|
||||
}
|
||||
});
|
||||
|
13
src/components/Controls/Float.vue
Normal file
13
src/components/Controls/Float.vue
Normal file
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Int from './Int';
|
||||
|
||||
export default {
|
||||
name: 'Float',
|
||||
extends: Int,
|
||||
methods: {
|
||||
parse(value) {
|
||||
return parseFloat(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -7,6 +7,9 @@ import AutoComplete from './AutoComplete';
|
||||
import Check from './Check';
|
||||
import AttachImage from './AttachImage';
|
||||
import DynamicLink from './DynamicLink';
|
||||
import Int from './Int';
|
||||
import Float from './Float';
|
||||
import Currency from './Currency';
|
||||
|
||||
export default {
|
||||
name: 'FormControl',
|
||||
@ -20,7 +23,10 @@ export default {
|
||||
AutoComplete,
|
||||
Check,
|
||||
AttachImage,
|
||||
DynamicLink
|
||||
DynamicLink,
|
||||
Int,
|
||||
Float,
|
||||
Currency
|
||||
};
|
||||
let { df } = this.$attrs;
|
||||
return h(controls[df.fieldtype] || Data, {
|
||||
|
13
src/components/Controls/Int.vue
Normal file
13
src/components/Controls/Int.vue
Normal file
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Data from './Data';
|
||||
|
||||
export default {
|
||||
name: 'Int',
|
||||
extends: Data,
|
||||
methods: {
|
||||
parse(value) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user