2
0
mirror of https://github.com/frappe/books.git synced 2025-01-11 02:36:14 +00:00

refactor: markRaw pesa objects

- remove native clicks
This commit is contained in:
18alantom 2022-02-11 14:30:39 +05:30
parent 3d9344a0ed
commit 9f65a9ba9e
4 changed files with 25 additions and 22 deletions

View File

@ -56,9 +56,12 @@ module.exports = {
display = parseInt(display); display = parseInt(display);
} }
const moneyMaker = getMoneyMaker({ currency, precision, display }); this.pesa = getMoneyMaker({
// Pesa uses private fields, Vue does deep conversions to Proxy, ∴ currency,
this.pesa = (...args) => markRaw(moneyMaker(...args)); precision,
display,
wrapper: markRaw,
});
}, },
init(force) { init(force) {

View File

@ -9,7 +9,7 @@
:class="{ :class="{
'px-2 py-3': size === 'small', 'px-2 py-3': size === 'small',
'px-3 py-4': size !== 'small', 'px-3 py-4': size !== 'small',
'text-right': isNumeric(df) 'text-right': isNumeric(df),
}" }"
v-for="df in tableFields" v-for="df in tableFields"
:key="df.fieldname" :key="df.fieldname"
@ -31,7 +31,7 @@
:ratio="ratio" :ratio="ratio"
class="text-gray-500 cursor-pointer border-transparent px-2 w-full" class="text-gray-500 cursor-pointer border-transparent px-2 w-full"
v-if="!isReadOnly" v-if="!isReadOnly"
@click.native="addRow" @click="addRow"
> >
<div class="flex items-center pl-1"> <div class="flex items-center pl-1">
<feather-icon name="plus" class="w-4 h-4 text-gray-500" /> <feather-icon name="plus" class="w-4 h-4 text-gray-500" />
@ -40,7 +40,7 @@
class="flex justify-between" class="flex justify-between"
:class="{ :class="{
'px-2 py-3': size === 'small', 'px-2 py-3': size === 'small',
'px-3 py-4': size !== 'small' 'px-3 py-4': size !== 'small',
}" }"
> >
{{ t('Add Row') }} {{ t('Add Row') }}
@ -50,7 +50,7 @@
class="text-right" class="text-right"
:class="{ :class="{
'px-2 py-3': size === 'small', 'px-2 py-3': size === 'small',
'px-3 py-4': size !== 'small' 'px-3 py-4': size !== 'small',
}" }"
v-if="maxRowsBeforeOverflow && value.length > maxRowsBeforeOverflow" v-if="maxRowsBeforeOverflow && value.length > maxRowsBeforeOverflow"
> >
@ -71,15 +71,15 @@ export default {
extends: Base, extends: Base,
props: { props: {
showHeader: { showHeader: {
default: true default: true,
}, },
maxRowsBeforeOverflow: { maxRowsBeforeOverflow: {
default: 0 default: 0,
} },
}, },
components: { components: {
Row, Row,
TableRow TableRow,
}, },
data: () => ({ rowContainerHeight: null }), data: () => ({ rowContainerHeight: null }),
watch: { watch: {
@ -95,8 +95,8 @@ export default {
this.rowContainerHeight = `${containerHeight}px`; this.rowContainerHeight = `${containerHeight}px`;
}); });
} }
} },
} },
}, },
methods: { methods: {
focus() {}, focus() {},
@ -109,13 +109,13 @@ export default {
}, },
removeRow(row) { removeRow(row) {
let rows = this.value || []; let rows = this.value || [];
rows = rows.filter(_row => _row !== row); rows = rows.filter((_row) => _row !== row);
this.triggerChange(rows); this.triggerChange(rows);
}, },
scrollToRow(index) { scrollToRow(index) {
let row = this.$refs['table-row'][index]; let row = this.$refs['table-row'][index];
row && row.$el.scrollIntoView({ block: 'nearest' }); row && row.$el.scrollIntoView({ block: 'nearest' });
} },
}, },
computed: { computed: {
ratio() { ratio() {
@ -123,8 +123,8 @@ export default {
}, },
tableFields() { tableFields() {
let meta = frappe.getMeta(this.df.childtype); let meta = frappe.getMeta(this.df.childtype);
return meta.tableFields.map(fieldname => meta.getField(fieldname)); return meta.tableFields.map((fieldname) => meta.getField(fieldname));
} },
} },
}; };
</script> </script>

View File

@ -31,7 +31,7 @@
<Row <Row
gap="1rem" gap="1rem"
class="cursor-pointer text-gray-900 flex-1" class="cursor-pointer text-gray-900 flex-1"
@click.native="openForm(doc)" @click="openForm(doc)"
:columnCount="columns.length" :columnCount="columns.length"
> >
<ListCell <ListCell

View File

@ -8564,9 +8564,9 @@ performance-now@^2.1.0:
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
pesa@^1.1.3: pesa@^1.1.3:
version "1.1.3" version "1.1.6"
resolved "https://registry.yarnpkg.com/pesa/-/pesa-1.1.3.tgz#cddd43b02a1db55cd6fb7b220257d33a268588a4" resolved "https://registry.yarnpkg.com/pesa/-/pesa-1.1.6.tgz#a123dc7a31c977bbfb6dbbee14a9913c8385cd0f"
integrity sha512-WcgR2zb5h8h+k9JQb+xkLsYkdMuoxqKgqWm5uTcbi3EGNg3r0tfzcvIBpRYLtZ6TtICbyCRZxWi0WXCh5jSw0A== integrity sha512-EDs4Tj8QX7hZITkKhfHeVT/9oQRqRPyF3pVet1FqGX94/zkcqreBYb94ojUVrzZmir26+IHaKyCpTB6eqC04uw==
pg-connection-string@2.5.0: pg-connection-string@2.5.0:
version "2.5.0" version "2.5.0"