2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: Add Numeric field types

- Int
- Float
- Currency
This commit is contained in:
Faris Ansari 2019-11-27 12:20:39 +05:30
parent 3e3235b814
commit 32b3793793
6 changed files with 46 additions and 2 deletions

View File

@ -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);
}

View File

@ -0,0 +1,8 @@
<script>
import Float from './Float';
export default {
name: 'Currency',
extends: Float
};
</script>

View File

@ -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('');
}
});

View File

@ -0,0 +1,13 @@
<script>
import Int from './Int';
export default {
name: 'Float',
extends: Int,
methods: {
parse(value) {
return parseFloat(value);
}
}
};
</script>

View File

@ -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, {

View File

@ -0,0 +1,13 @@
<script>
import Data from './Data';
export default {
name: 'Int',
extends: Data,
methods: {
parse(value) {
return parseInt(value, 10);
}
}
};
</script>