Skip to content

Commit

Permalink
[IMP] spreadsheet: update helpers to cache clickable cells
Browse files Browse the repository at this point in the history
Following odoo/o-spreadsheet#4090,
Some helpers are adapted to suit their use with the clickable cell
refactoring.

task-3869752
  • Loading branch information
rrahir authored and pro-odoo committed May 14, 2024
1 parent 7202d55 commit 88ed634
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion addons/spreadsheet/static/src/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cellMenuRegistry.add(
},
isVisible: (env) => {
const position = env.model.getters.getActivePosition();
return SEE_RECORD_LIST_VISIBLE(position, env);
return SEE_RECORD_LIST_VISIBLE(position, env.model.getters);
},
icon: "o-spreadsheet-Icon.SEE_RECORDS",
})
Expand Down
8 changes: 4 additions & 4 deletions addons/spreadsheet/static/src/list/list_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export const SEE_RECORD_LIST = async (position, env) => {

/**
* @param {import("@odoo/o-spreadsheet").CellPosition} position
* @param {import("@spreadsheet").SpreadsheetChildEnv} env
* @param {import("@spreadsheet").OdooGetters} getters
* @returns {boolean}
*/
export const SEE_RECORD_LIST_VISIBLE = (position, env) => {
const evaluatedCell = env.model.getters.getEvaluatedCell(position);
const cell = env.model.getters.getCell(position);
export const SEE_RECORD_LIST_VISIBLE = (position, getters) => {
const evaluatedCell = getters.getEvaluatedCell(position);
const cell = getters.getCell(position);
return (
evaluatedCell.type !== "empty" &&
evaluatedCell.type !== "error" &&
Expand Down
2 changes: 1 addition & 1 deletion addons/spreadsheet/static/src/pivot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cellMenuRegistry.add("pivot_see_records", {
},
isVisible: (env) => {
const position = env.model.getters.getActivePosition();
return SEE_RECORDS_PIVOT_VISIBLE(position, env);
return SEE_RECORDS_PIVOT_VISIBLE(position, env.model.getters);
},
icon: "o-spreadsheet-Icon.SEE_RECORDS",
});
Expand Down
22 changes: 11 additions & 11 deletions addons/spreadsheet/static/src/pivot/pivot_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const SEE_RECORDS_PIVOT = async (position, env) => {

/**
* @param {import("@odoo/o-spreadsheet").CellPosition} position
* @param {import("@spreadsheet").SpreadsheetChildEnv} env
* @param {import("@spreadsheet").OdooGetters} getters
* @returns {boolean}
*/
export const SEE_RECORDS_PIVOT_VISIBLE = (position, env) => {
const cell = env.model.getters.getCorrespondingFormulaCell(position);
const evaluatedCell = env.model.getters.getEvaluatedCell(position);
const argsDomain = env.model.getters.getPivotDomainArgsFromPosition(position);
export const SEE_RECORDS_PIVOT_VISIBLE = (position, getters) => {
const cell = getters.getCorrespondingFormulaCell(position);
const evaluatedCell = getters.getEvaluatedCell(position);
const argsDomain = getters.getPivotDomainArgsFromPosition(position);
return (
evaluatedCell.type !== "empty" &&
evaluatedCell.type !== "error" &&
Expand All @@ -64,18 +64,18 @@ export const SEE_RECORDS_PIVOT_VISIBLE = (position, env) => {
*
* @returns {boolean}
*/
export function SET_FILTER_MATCHING_CONDITION(position, env) {
if (!SEE_RECORDS_PIVOT_VISIBLE(position, env)) {
export function SET_FILTER_MATCHING_CONDITION(position, getters) {
if (!SEE_RECORDS_PIVOT_VISIBLE(position, getters)) {
return false;
}
const cell = env.model.getters.getCorrespondingFormulaCell(position);
const cell = getters.getCorrespondingFormulaCell(position);

const pivotId = env.model.getters.getPivotIdFromPosition(position);
const domainArgs = env.model.getters.getPivotDomainArgsFromPosition(position);
const pivotId = getters.getPivotIdFromPosition(position);
const domainArgs = getters.getPivotDomainArgsFromPosition(position);
if (domainArgs === undefined) {
return false;
}
const matchingFilters = env.model.getters.getFiltersMatchingPivotArgs(pivotId, domainArgs);
const matchingFilters = getters.getFiltersMatchingPivotArgs(pivotId, domainArgs);
const pivotFunction = getFirstPivotFunction(cell.compiledFormula.tokens).functionName;
return (
(pivotFunction === "PIVOT.VALUE" ||
Expand Down

0 comments on commit 88ed634

Please sign in to comment.