mirror of
https://github.com/frappe/books.git
synced 2025-01-11 10:38:14 +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();
|
this.$refs.input.focus();
|
||||||
},
|
},
|
||||||
triggerChange(value) {
|
triggerChange(value) {
|
||||||
|
value = this.parse(value);
|
||||||
this.$emit('change', value);
|
this.$emit('change', value);
|
||||||
},
|
},
|
||||||
|
parse(value) {
|
||||||
|
return value;
|
||||||
|
},
|
||||||
isNumeric(df) {
|
isNumeric(df) {
|
||||||
return ['Int', 'Float', 'Currency'].includes(df.fieldtype);
|
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,
|
extends: Link,
|
||||||
created() {
|
created() {
|
||||||
this.targetWatcher = this.$watch(`doc.${this.df.references}`, function(newTarget, oldTarget) {
|
this.targetWatcher = this.$watch(`doc.${this.df.references}`, function(newTarget, oldTarget) {
|
||||||
if (newTarget !== oldTarget) {
|
if (oldTarget && newTarget !== oldTarget) {
|
||||||
this.triggerChange('');
|
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 Check from './Check';
|
||||||
import AttachImage from './AttachImage';
|
import AttachImage from './AttachImage';
|
||||||
import DynamicLink from './DynamicLink';
|
import DynamicLink from './DynamicLink';
|
||||||
|
import Int from './Int';
|
||||||
|
import Float from './Float';
|
||||||
|
import Currency from './Currency';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FormControl',
|
name: 'FormControl',
|
||||||
@ -20,7 +23,10 @@ export default {
|
|||||||
AutoComplete,
|
AutoComplete,
|
||||||
Check,
|
Check,
|
||||||
AttachImage,
|
AttachImage,
|
||||||
DynamicLink
|
DynamicLink,
|
||||||
|
Int,
|
||||||
|
Float,
|
||||||
|
Currency
|
||||||
};
|
};
|
||||||
let { df } = this.$attrs;
|
let { df } = this.$attrs;
|
||||||
return h(controls[df.fieldtype] || Data, {
|
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