accountant_cn
This commit is contained in:
39
accountant_cn/static/src/js/dn_fr_line_cell.js
Normal file
39
accountant_cn/static/src/js/dn_fr_line_cell.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/** @odoo-module **/
|
||||
/**
|
||||
* DN Financial Reports — one amount cell.
|
||||
*
|
||||
* A component of its own rather than an inline `<td>` in the row template, so
|
||||
* that a cell re-renders only when its own value changes. On a balance sheet
|
||||
* with 300 accounts and two comparison columns that is 900 cells; keeping them
|
||||
* as separate components is what stops a fold from repainting all of them.
|
||||
*
|
||||
* All the decisions live in `DnFrCell` (see `dn_fr_model.js`); this component
|
||||
* is deliberately thin and only maps the model onto markup.
|
||||
*/
|
||||
import { Component, computed, t, useProps } from "@odoo/owl";
|
||||
import { COMPARISON_MODE } from "./dn_fr_model";
|
||||
|
||||
export class DnFrLineCell extends Component {
|
||||
static template = "dn_financial_reports.DnFrLineCell";
|
||||
|
||||
props = useProps({
|
||||
cell: t.object(),
|
||||
});
|
||||
|
||||
/** The styling hooks, recomputed only when the value itself changes. */
|
||||
classes = computed(() => {
|
||||
const classes = this.props.cell.cssClass;
|
||||
switch (this.props.cell.comparisonMode) {
|
||||
case COMPARISON_MODE.MUTED:
|
||||
return `${classes} muted`;
|
||||
case COMPARISON_MODE.RED:
|
||||
return `${classes} text-danger`;
|
||||
default:
|
||||
return classes;
|
||||
}
|
||||
});
|
||||
|
||||
get name() {
|
||||
return this.props.cell.name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user