[REF] web: remove unused props in reporting views
Now that the module web_dashboard has been removed https://github.com/odoo/enterprise/pull/31641, some props of the reporting views graph and pivot have become unused. We remove the code related to those props. X-original-commit: 7d231d1d37707dab4b0ecdd4e2e7cc4535ba6196 Part-of: odoo/odoo#102761
This commit is contained in:
@@ -122,17 +122,8 @@ export class GraphController extends Component {
|
||||
GraphController.template = "web.GraphView";
|
||||
GraphController.components = { Dropdown, DropdownItem, GroupByMenu, Layout };
|
||||
|
||||
GraphController.defaultProps = {
|
||||
additionalMeasures: [],
|
||||
displayGroupByMenu: false,
|
||||
displayScaleLabels: true,
|
||||
};
|
||||
|
||||
GraphController.props = {
|
||||
...standardViewProps,
|
||||
additionalMeasures: { type: Array, elements: String, optional: true },
|
||||
displayGroupByMenu: { type: Boolean, optional: true },
|
||||
displayScaleLabels: { type: Boolean, optional: true },
|
||||
Model: Function,
|
||||
modelParams: Object,
|
||||
Renderer: Function,
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
<t t-set="activeMeasures" t-value="[model.metaData.measure]"/>
|
||||
</t>
|
||||
</div>
|
||||
<t t-if="props.displayGroupByMenu">
|
||||
<div class="btn-group" role="toolbar" aria-label="Group By">
|
||||
<GroupByMenu showCaretDown="true"/>
|
||||
</div>
|
||||
</t>
|
||||
<div class="btn-group" role="toolbar" aria-label="Change graph">
|
||||
<button class="btn btn-light fa fa-bar-chart o_graph_button" data-tooltip="Bar Chart" aria-label="Bar Chart" data-mode="bar"
|
||||
t-on-click="() => this.onModeSelected('bar')"
|
||||
|
||||
@@ -165,12 +165,9 @@ export class GraphModel extends Model {
|
||||
|
||||
this._normalize(metaData);
|
||||
|
||||
metaData.measures = computeReportMeasures(
|
||||
metaData.fields,
|
||||
metaData.fieldAttrs,
|
||||
[metaData.measure],
|
||||
metaData.additionalMeasures
|
||||
);
|
||||
metaData.measures = computeReportMeasures(metaData.fields, metaData.fieldAttrs, [
|
||||
metaData.measure,
|
||||
]);
|
||||
|
||||
return Object.assign(metaData, params);
|
||||
}
|
||||
|
||||
@@ -419,7 +419,6 @@ export class GraphRenderer extends Component {
|
||||
getScaleOptions() {
|
||||
const {
|
||||
allIntegers,
|
||||
displayScaleLabels,
|
||||
fields,
|
||||
groupBy,
|
||||
measure,
|
||||
@@ -433,14 +432,13 @@ export class GraphRenderer extends Component {
|
||||
const xAxe = {
|
||||
type: "category",
|
||||
scaleLabel: {
|
||||
display: Boolean(groupBy.length && displayScaleLabels),
|
||||
display: Boolean(groupBy.length),
|
||||
labelString: groupBy.length ? fields[groupBy[0].fieldName].string : "",
|
||||
},
|
||||
};
|
||||
const yAxe = {
|
||||
type: "linear",
|
||||
scaleLabel: {
|
||||
display: displayScaleLabels,
|
||||
labelString: measures[measure].string,
|
||||
},
|
||||
ticks: {
|
||||
|
||||
@@ -28,13 +28,11 @@ export const graphView = {
|
||||
if (genericProps.state) {
|
||||
modelParams = genericProps.state.metaData;
|
||||
} else {
|
||||
const { arch, fields, resModel, additionalMeasures, displayScaleLabels } = genericProps;
|
||||
const { arch, fields, resModel } = genericProps;
|
||||
const parser = new view.ArchParser();
|
||||
const archInfo = parser.parse(arch, fields);
|
||||
modelParams = {
|
||||
additionalMeasures: additionalMeasures,
|
||||
disableLinking: Boolean(archInfo.disableLinking),
|
||||
displayScaleLabels: displayScaleLabels,
|
||||
fieldAttrs: archInfo.fieldAttrs,
|
||||
fields: fields,
|
||||
groupBy: archInfo.groupBy,
|
||||
|
||||
@@ -135,12 +135,8 @@ PivotController.components = { Dropdown, DropdownItem, Layout };
|
||||
|
||||
PivotController.props = {
|
||||
...standardViewProps,
|
||||
additionalMeasures: { type: Array, elements: String, optional: 1 },
|
||||
Model: Function,
|
||||
modelParams: Object,
|
||||
Renderer: Function,
|
||||
buttonTemplate: String,
|
||||
};
|
||||
PivotController.defaultProps = {
|
||||
additionalMeasures: [],
|
||||
};
|
||||
|
||||
@@ -708,8 +708,7 @@ export class PivotModel extends Model {
|
||||
metaData.measures = computeReportMeasures(
|
||||
metaData.fields,
|
||||
metaData.fieldAttrs,
|
||||
metaData.activeMeasures,
|
||||
metaData.additionalMeasures
|
||||
metaData.activeMeasures
|
||||
);
|
||||
const config = { metaData, data: this.data };
|
||||
return this._loadData(config);
|
||||
|
||||
@@ -29,7 +29,7 @@ export const pivotView = {
|
||||
modelParams.data = genericProps.state.data;
|
||||
modelParams.metaData = genericProps.state.metaData;
|
||||
} else {
|
||||
const { arch, additionalMeasures, fields, resModel } = genericProps;
|
||||
const { arch, fields, resModel } = genericProps;
|
||||
|
||||
// parse arch
|
||||
const archInfo = new view.ArchParser().parse(arch);
|
||||
@@ -40,7 +40,6 @@ export const pivotView = {
|
||||
|
||||
modelParams.metaData = {
|
||||
activeMeasures: archInfo.activeMeasures,
|
||||
additionalMeasures: additionalMeasures,
|
||||
colGroupBys: archInfo.colGroupBys,
|
||||
defaultOrder: archInfo.defaultOrder,
|
||||
disableLinking: Boolean(archInfo.disableLinking),
|
||||
|
||||
@@ -54,15 +54,9 @@ export function archParseBoolean(str, trueIfEmpty = false) {
|
||||
* @param {Object} fields
|
||||
* @param {Object} fieldAttrs
|
||||
* @param {string[]} activeMeasures
|
||||
* @param {string[]} [additionalMeasures=[]]
|
||||
* @returns {Object}
|
||||
*/
|
||||
export const computeReportMeasures = (
|
||||
fields,
|
||||
fieldAttrs,
|
||||
activeMeasures,
|
||||
additionalMeasures = []
|
||||
) => {
|
||||
export const computeReportMeasures = (fields, fieldAttrs, activeMeasures) => {
|
||||
const measures = {
|
||||
__count: { name: "__count", string: _t("Count"), type: "integer" },
|
||||
};
|
||||
@@ -71,13 +65,10 @@ export const computeReportMeasures = (
|
||||
continue;
|
||||
}
|
||||
const { isInvisible } = fieldAttrs[fieldName] || {};
|
||||
if (isInvisible && !additionalMeasures.includes(fieldName)) {
|
||||
if (isInvisible) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
["integer", "float", "monetary"].includes(field.type) ||
|
||||
additionalMeasures.includes(fieldName)
|
||||
) {
|
||||
if (["integer", "float", "monetary"].includes(field.type)) {
|
||||
measures[fieldName] = field;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2947,25 +2947,6 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.strictEqual(getYAxeLabel(graph), "Product");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"a many2one field can be added as measure in additionalMeasures",
|
||||
async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
const graph = await makeView({
|
||||
serverData,
|
||||
type: "graph",
|
||||
resModel: "foo",
|
||||
arch: `<graph/>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
});
|
||||
await toggleMenu(target, "Measures");
|
||||
await toggleMenuItem(target, "Product");
|
||||
checkLegend(assert, graph, "Product");
|
||||
assert.strictEqual(getYAxeLabel(graph), "Product");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test('graph view "graph_measure" field in context', async function (assert) {
|
||||
assert.expect(6);
|
||||
const graph = await makeView({
|
||||
@@ -3041,34 +3022,7 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"an invisible field in additional measure can be found in the 'Measures' menu",
|
||||
async function (assert) {
|
||||
assert.expect(8);
|
||||
const graph = await makeView({
|
||||
serverData,
|
||||
type: "graph",
|
||||
resModel: "foo",
|
||||
arch: `
|
||||
<graph>
|
||||
<field name="revenue" invisible="1"/>
|
||||
</graph>
|
||||
`,
|
||||
additionalMeasures: ["revenue"],
|
||||
});
|
||||
checkTooltip(assert, graph, { lines: [{ label: "Total", value: "8" }] }, 0);
|
||||
await toggleMenu(target, "Measures");
|
||||
await toggleMenuItem(target, "Revenue");
|
||||
checkTooltip(
|
||||
assert,
|
||||
graph,
|
||||
{ title: "Revenue", lines: [{ label: "Total", value: "23" }] },
|
||||
0
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"an invisible field not in additional measure can not be found in the 'Measures' menu",
|
||||
"an invisible field can not be found in the 'Measures' menu",
|
||||
async function (assert) {
|
||||
assert.expect(5);
|
||||
const graph = await makeView({
|
||||
|
||||
@@ -3136,35 +3136,6 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.hasClass(target.querySelector(".o_cp_bottom_left .dropdown-item"), "selected");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"use a many2one as a measure with specified additional measure",
|
||||
async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
await makeView({
|
||||
type: "pivot",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<pivot>
|
||||
<field name="product_id"/>
|
||||
<field name="date" interval="month" type="col"/>
|
||||
</pivot>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
});
|
||||
await click(target.querySelector(".o_cp_bottom_left button.dropdown-toggle"));
|
||||
assert.containsN(target, ".o_cp_bottom_left .dropdown-item", 2);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_cp_bottom_left .dropdown-item").innerText,
|
||||
"Product"
|
||||
);
|
||||
assert.doesNotHaveClass(
|
||||
target.querySelector(".o_cp_bottom_left .dropdown-item"),
|
||||
"selected"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("pivot view with many2one field as a measure", async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -3212,62 +3183,6 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"pivot view with same many2one field as a measure and grouped by",
|
||||
async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await makeView({
|
||||
type: "pivot",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<pivot>
|
||||
<field name="product_id" type="row"/>
|
||||
</pivot>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
});
|
||||
|
||||
await click(target.querySelector(".o_cp_bottom_left button.dropdown-toggle"));
|
||||
await click(target.querySelector(".o_cp_bottom_left .dropdown-item"));
|
||||
assert.strictEqual(
|
||||
[...target.querySelectorAll(".o_pivot_cell_value")]
|
||||
.map((c) => c.innerText)
|
||||
.join(""),
|
||||
"421131",
|
||||
"should have loaded the proper data"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"pivot view with same many2one field as a measure and grouped by (and drill down)",
|
||||
async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
await makeView({
|
||||
type: "pivot",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<pivot>
|
||||
<field name="product_id" type="measure"/>
|
||||
</pivot>`,
|
||||
});
|
||||
|
||||
await click(target.querySelector("tbody .o_pivot_header_cell_closed"));
|
||||
await click(target.querySelectorAll("tbody .dropdown-item")[4]);
|
||||
|
||||
assert.strictEqual(
|
||||
[...target.querySelectorAll(".o_pivot_cell_value")]
|
||||
.map((c) => c.innerText)
|
||||
.join(""),
|
||||
"211",
|
||||
"should have loaded the proper data"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("Row and column groupbys plus a domain", async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
@@ -3472,8 +3387,6 @@ QUnit.module("Views", (hooks) => {
|
||||
});
|
||||
|
||||
QUnit.test("rendering of pivot view with comparison", async function (assert) {
|
||||
assert.expect(8);
|
||||
|
||||
serverData.models.partner.records[0].date = "2016-12-15";
|
||||
serverData.models.partner.records[1].date = "2016-12-17";
|
||||
serverData.models.partner.records[2].date = "2016-11-22";
|
||||
@@ -3494,7 +3407,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<search>
|
||||
<filter name="date_filter" date="date" domain="[]" default_period='last_year'/>
|
||||
</search>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
context: { search_default_date_filter: 1 },
|
||||
mockRPC(route, args) {
|
||||
if (args.method === "create_or_replace") {
|
||||
@@ -3579,64 +3491,10 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.strictEqual(getCurrentValues(target), values.join());
|
||||
|
||||
await click(target.querySelector(".o_cp_bottom_left button.dropdown-toggle"));
|
||||
|
||||
await click(target.querySelectorAll(".o_cp_bottom_left .dropdown-menu .dropdown-item")[0]);
|
||||
await click(target.querySelectorAll(".o_cp_bottom_left .dropdown-menu .dropdown-item")[1]);
|
||||
values = [
|
||||
"1",
|
||||
"0",
|
||||
"-100%",
|
||||
"0",
|
||||
"2",
|
||||
"100%",
|
||||
"1",
|
||||
"2",
|
||||
"100%",
|
||||
"1",
|
||||
"0",
|
||||
"-100%",
|
||||
"0",
|
||||
"1",
|
||||
"100%",
|
||||
"1",
|
||||
"1",
|
||||
"0%",
|
||||
"0",
|
||||
"1",
|
||||
"100%",
|
||||
"0",
|
||||
"1",
|
||||
"100%",
|
||||
];
|
||||
assert.strictEqual(getCurrentValues(target), values.join());
|
||||
|
||||
await click(target.querySelectorAll(".o_cp_bottom_left .dropdown-menu .dropdown-item")[2]);
|
||||
await click(target.querySelectorAll(".o_cp_bottom_left .dropdown-menu .dropdown-item")[1]);
|
||||
values = [
|
||||
"2",
|
||||
"0",
|
||||
"-100%",
|
||||
"0",
|
||||
"2",
|
||||
"100%",
|
||||
"2",
|
||||
"2",
|
||||
"0%",
|
||||
"2",
|
||||
"0",
|
||||
"-100%",
|
||||
"0",
|
||||
"1",
|
||||
"100%",
|
||||
"2",
|
||||
"1",
|
||||
"-50%",
|
||||
"0",
|
||||
"1",
|
||||
"100%",
|
||||
"0",
|
||||
"1",
|
||||
"100%",
|
||||
];
|
||||
values = ["2,0,-100%,0,2,100%,2,2,0%,2,0,-100%,0,1,100%,2,1,-50%,0,1,100%,0,1,100%"];
|
||||
assert.strictEqual(getCurrentValues(target), values.join());
|
||||
|
||||
await click(target.querySelector("thead .o_pivot_header_cell_opened"));
|
||||
@@ -3813,7 +3671,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<search>
|
||||
<filter name="date_filter" date="date" domain="[]" default_period='this_month'/>
|
||||
</search>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
context: { search_default_date_filter: 1 },
|
||||
});
|
||||
|
||||
@@ -4189,7 +4046,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<search>
|
||||
<filter name="date_filter" date="date" domain="[]" default_period='this_month'/>
|
||||
</search>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
context: { search_default_date_filter: 1 },
|
||||
});
|
||||
|
||||
@@ -4300,7 +4156,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<search>
|
||||
<filter name="date_filter" date="date" domain="[]" default_period='this_month'/>
|
||||
</search>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
@@ -4475,7 +4330,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<pivot>
|
||||
<field name="foo" type="measure"/>
|
||||
</pivot>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
@@ -4550,7 +4404,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<pivot>
|
||||
<field name="foo" type="measure"/>
|
||||
</pivot>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
});
|
||||
|
||||
// add a col groupby on Product
|
||||
@@ -4950,6 +4803,12 @@ QUnit.module("Views", (hooks) => {
|
||||
|
||||
QUnit.test("consecutively toggle several measures", async function (assert) {
|
||||
let def;
|
||||
serverData.models.partner.fields.foo2 = {
|
||||
...serverData.models.partner.fields.foo,
|
||||
string: "Foo2",
|
||||
store: true,
|
||||
};
|
||||
|
||||
await makeView({
|
||||
type: "pivot",
|
||||
resModel: "partner",
|
||||
@@ -4959,7 +4818,6 @@ QUnit.module("Views", (hooks) => {
|
||||
<field name="foo" type="measure"/>
|
||||
<field name="product_id" type="row"/>
|
||||
</pivot>`,
|
||||
additionalMeasures: ["product_id"],
|
||||
mockRPC(route, args) {
|
||||
if (args.method === "read_group") {
|
||||
return Promise.resolve(def);
|
||||
@@ -4972,7 +4830,7 @@ QUnit.module("Views", (hooks) => {
|
||||
// Toggle several measures (the reload is blocked, so all measures should be toggled in once)
|
||||
def = makeDeferred();
|
||||
await toggleMenu(target, "Measures");
|
||||
await toggleMenuItem(target, "Product"); // add product
|
||||
await toggleMenuItem(target, "Foo2"); // add foo2
|
||||
assert.strictEqual(getCurrentValues(target), ["32", "12", "20"].join(","));
|
||||
await toggleMenuItem(target, "Foo"); // remove foo
|
||||
assert.strictEqual(getCurrentValues(target), ["32", "12", "20"].join(","));
|
||||
@@ -4982,7 +4840,7 @@ QUnit.module("Views", (hooks) => {
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
|
||||
assert.strictEqual(getCurrentValues(target), ["2", "4", "1", "1", "1", "3"].join(","));
|
||||
assert.strictEqual(getCurrentValues(target), ["0", "4", "0", "1", "0", "3"].join(","));
|
||||
});
|
||||
|
||||
QUnit.test("flip axis while loading a filter", async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user