@odoo/o-spreadsheet 16.1.2 → 16.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2824,7 +2824,7 @@
2824
2824
  return `background-color: ${this.background}`;
2825
2825
  }
2826
2826
  get chartRuntime() {
2827
- const runtime = this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
2827
+ const runtime = this.env.model.getters.getChartRuntime(this.props.figure.id);
2828
2828
  if (!("chartJsConfig" in runtime)) {
2829
2829
  throw new Error("Unsupported chart runtime");
2830
2830
  }
@@ -3078,7 +3078,7 @@
3078
3078
  this.ctx = document.createElement("canvas").getContext("2d");
3079
3079
  }
3080
3080
  get runtime() {
3081
- return this.env.model.getters.getChartRuntime(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
3081
+ return this.env.model.getters.getChartRuntime(this.props.figure.id);
3082
3082
  }
3083
3083
  get title() {
3084
3084
  return this.runtime.title;
@@ -3469,7 +3469,7 @@
3469
3469
  CommandResult[CommandResult["InvalidRange"] = 25] = "InvalidRange";
3470
3470
  CommandResult[CommandResult["InvalidZones"] = 26] = "InvalidZones";
3471
3471
  CommandResult[CommandResult["InvalidSheetId"] = 27] = "InvalidSheetId";
3472
- CommandResult[CommandResult["DuplicatedImageId"] = 28] = "DuplicatedImageId";
3472
+ CommandResult[CommandResult["InvalidFigureId"] = 28] = "InvalidFigureId";
3473
3473
  CommandResult[CommandResult["InputAlreadyFocused"] = 29] = "InputAlreadyFocused";
3474
3474
  CommandResult[CommandResult["MaximumRangesReached"] = 30] = "MaximumRangesReached";
3475
3475
  CommandResult[CommandResult["InvalidChartDefinition"] = 31] = "InvalidChartDefinition";
@@ -3526,6 +3526,7 @@
3526
3526
  CommandResult[CommandResult["DuplicatedFigureId"] = 82] = "DuplicatedFigureId";
3527
3527
  CommandResult[CommandResult["InvalidSelectionStep"] = 83] = "InvalidSelectionStep";
3528
3528
  CommandResult[CommandResult["DuplicatedChartId"] = 84] = "DuplicatedChartId";
3529
+ CommandResult[CommandResult["ChartDoesNotExist"] = 85] = "ChartDoesNotExist";
3529
3530
  })(exports.CommandResult || (exports.CommandResult = {}));
3530
3531
 
3531
3532
  var DIRECTION;
@@ -6066,7 +6067,7 @@
6066
6067
  return registry;
6067
6068
  }
6068
6069
  get chartType() {
6069
- return this.env.model.getters.getChartType(this.env.model.getters.getActiveSheetId(), this.props.figure.id);
6070
+ return this.env.model.getters.getChartType(this.props.figure.id);
6070
6071
  }
6071
6072
  onContextMenu(ev) {
6072
6073
  const position = {
@@ -18801,7 +18802,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18801
18802
  name: _lt("Reset size"),
18802
18803
  sequence: 3,
18803
18804
  action: () => {
18804
- const size = this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(), this.figureId).size;
18805
+ const size = this.env.model.getters.getImageSize(this.figureId);
18805
18806
  const { height, width } = getMaxFigureSize(this.env.model.getters, size);
18806
18807
  this.env.model.dispatch("UPDATE_FIGURE", {
18807
18808
  sheetId: this.env.model.getters.getActiveSheetId(),
@@ -18852,8 +18853,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
18852
18853
  return this.props.figure.id;
18853
18854
  }
18854
18855
  get getImagePath() {
18855
- return this.env.model.getters.getImage(this.env.model.getters.getActiveSheetId(), this.figureId)
18856
- .path;
18856
+ return this.env.model.getters.getImagePath(this.figureId);
18857
18857
  }
18858
18858
  }
18859
18859
  ImageFigure.template = "o-spreadsheet-ImageFigure";
@@ -19808,7 +19808,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
19808
19808
  LineBarPieConfigPanel.template = "o-spreadsheet-LineBarPieConfigPanel";
19809
19809
  LineBarPieConfigPanel.components = { SelectionInput };
19810
19810
  LineBarPieConfigPanel.props = {
19811
- sheetId: String,
19812
19811
  figureId: String,
19813
19812
  definition: Object,
19814
19813
  updateChart: Function,
@@ -20012,7 +20011,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20012
20011
  }
20013
20012
  onColorClick(color) {
20014
20013
  if (color) {
20015
- this.props.onColorPicked(color);
20014
+ this.props.onColorPicked(toHex(color));
20016
20015
  }
20017
20016
  }
20018
20017
  getCheckMarkColor() {
@@ -20027,8 +20026,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20027
20026
  this.state.isCurrentColorInvalid = true;
20028
20027
  return;
20029
20028
  }
20029
+ const color = toHex(this.state.currentColor);
20030
20030
  this.state.isCurrentColorInvalid = false;
20031
- this.props.onColorPicked(this.state.currentColor);
20031
+ this.props.onColorPicked(color);
20032
+ this.state.currentColor = color;
20032
20033
  }
20033
20034
  toggleColorPicker() {
20034
20035
  this.state.showGradient = !this.state.showGradient;
@@ -20138,7 +20139,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20138
20139
  GaugeChartConfigPanel.template = "o-spreadsheet-GaugeChartConfigPanel";
20139
20140
  GaugeChartConfigPanel.components = { SelectionInput };
20140
20141
  GaugeChartConfigPanel.props = {
20141
- sheetId: String,
20142
20142
  figureId: String,
20143
20143
  definition: Object,
20144
20144
  updateChart: Function,
@@ -20292,7 +20292,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20292
20292
 
20293
20293
  class LineConfigPanel extends LineBarPieConfigPanel {
20294
20294
  get canTreatLabelsAsText() {
20295
- const chart = this.env.model.getters.getChart(this.props.sheetId, this.props.figureId);
20295
+ const chart = this.env.model.getters.getChart(this.props.figureId);
20296
20296
  if (chart && chart instanceof LineChart) {
20297
20297
  return canChartParseLabels(chart.labelRange, this.env.model.getters);
20298
20298
  }
@@ -20369,7 +20369,6 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20369
20369
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
20370
20370
  ScorecardChartConfigPanel.components = { SelectionInput };
20371
20371
  ScorecardChartConfigPanel.props = {
20372
- sheetId: String,
20373
20372
  figureId: String,
20374
20373
  definition: Object,
20375
20374
  updateChart: Function,
@@ -20501,7 +20500,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20501
20500
  else {
20502
20501
  this.shouldUpdateChart = true;
20503
20502
  }
20504
- if (!this.env.model.getters.isChartDefined(this.sheetId, this.figureId)) {
20503
+ if (!this.env.model.getters.isChartDefined(this.figureId)) {
20505
20504
  this.props.onCloseSidePanel();
20506
20505
  return;
20507
20506
  }
@@ -20522,7 +20521,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20522
20521
  });
20523
20522
  }
20524
20523
  onTypeChange(type) {
20525
- const context = this.env.model.getters.getContextCreationChart(this.sheetId, this.figureId);
20524
+ const context = this.env.model.getters.getContextCreationChart(this.figureId);
20526
20525
  if (!context) {
20527
20526
  throw new Error("Chart not defined.");
20528
20527
  }
@@ -20534,7 +20533,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20534
20533
  });
20535
20534
  }
20536
20535
  get chartPanel() {
20537
- const type = this.env.model.getters.getChartType(this.sheetId, this.figureId);
20536
+ const type = this.env.model.getters.getChartType(this.figureId);
20538
20537
  if (!type) {
20539
20538
  throw new Error("Chart not defined.");
20540
20539
  }
@@ -20544,8 +20543,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
20544
20543
  }
20545
20544
  return chartPanel;
20546
20545
  }
20547
- getChartDefinition() {
20548
- return this.env.model.getters.getChartDefinition(this.sheetId, this.figureId);
20546
+ getChartDefinition(figureId = this.figureId) {
20547
+ return this.env.model.getters.getChartDefinition(figureId);
20549
20548
  }
20550
20549
  get chartTypes() {
20551
20550
  return getChartTypes();
@@ -27104,13 +27103,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27104
27103
  data = migrate(data);
27105
27104
  }
27106
27105
  }
27107
- // sanity check: try to fix missing fields/corrupted state by providing
27108
- // sensible default values
27109
- data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27110
- data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
27111
- if (data.sheets.length === 0) {
27112
- data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27113
- }
27106
+ data = repairData(data);
27114
27107
  return data;
27115
27108
  }
27116
27109
  function migrate(data) {
@@ -27348,6 +27341,48 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27348
27341
  },
27349
27342
  },
27350
27343
  ];
27344
+ /**
27345
+ * This function is used to repair faulty data independently of the migration.
27346
+ */
27347
+ function repairData(data) {
27348
+ data = forceUnicityOfFigure(data);
27349
+ data = setDefaults(data);
27350
+ return data;
27351
+ }
27352
+ /**
27353
+ * Force the unicity of figure ids accross sheets
27354
+ */
27355
+ function forceUnicityOfFigure(data) {
27356
+ if (data.uniqueFigureIds) {
27357
+ return data;
27358
+ }
27359
+ const figureIds = new Set();
27360
+ const uuidGenerator = new UuidGenerator();
27361
+ for (const sheet of data.sheets || []) {
27362
+ for (const figure of sheet.figures || []) {
27363
+ if (figureIds.has(figure.id)) {
27364
+ figure.id += uuidGenerator.uuidv4();
27365
+ }
27366
+ figureIds.add(figure.id);
27367
+ }
27368
+ }
27369
+ data.uniqueFigureIds = true;
27370
+ return data;
27371
+ }
27372
+ /**
27373
+ * sanity check: try to fix missing fields/corrupted state by providing
27374
+ * sensible default values
27375
+ */
27376
+ function setDefaults(data) {
27377
+ data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
27378
+ data.sheets = data.sheets
27379
+ ? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
27380
+ : [];
27381
+ if (data.sheets.length === 0) {
27382
+ data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
27383
+ }
27384
+ return data;
27385
+ }
27351
27386
  /**
27352
27387
  * The goal of this function is to repair corrupted/wrong initial messages caused by
27353
27388
  * a bug.
@@ -27486,6 +27521,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
27486
27521
  formats: {},
27487
27522
  borders: {},
27488
27523
  revisionId: DEFAULT_REVISION_ID,
27524
+ uniqueFigureIds: true,
27489
27525
  };
27490
27526
  return data;
27491
27527
  }
@@ -28483,10 +28519,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28483
28519
  this.validateChartDefinition = (cmd) => validateChartDefinition(this, cmd.definition);
28484
28520
  }
28485
28521
  adaptRanges(applyChange) {
28486
- for (const sheetId of Object.keys(this.charts)) {
28487
- for (const [chartId, chart] of Object.entries(this.charts[sheetId] || {})) {
28488
- this.history.update("charts", sheetId, chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28489
- }
28522
+ for (const [chartId, chart] of Object.entries(this.charts)) {
28523
+ this.history.update("charts", chartId, chart === null || chart === void 0 ? void 0 : chart.updateRanges(applyChange));
28490
28524
  }
28491
28525
  }
28492
28526
  // ---------------------------------------------------------------------------
@@ -28497,20 +28531,20 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28497
28531
  case "CREATE_CHART":
28498
28532
  return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartDuplicate));
28499
28533
  case "UPDATE_CHART":
28500
- return this.validateChartDefinition(cmd);
28534
+ return this.checkValidations(cmd, this.chainValidations(this.validateChartDefinition, this.checkChartExists));
28501
28535
  default:
28502
28536
  return 0 /* CommandResult.Success */;
28503
28537
  }
28504
28538
  }
28505
28539
  handle(cmd) {
28506
- var _a, _b;
28540
+ var _a;
28507
28541
  switch (cmd.type) {
28508
28542
  case "CREATE_CHART":
28509
28543
  this.addFigure(cmd.id, cmd.sheetId, cmd.position, cmd.size);
28510
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28544
+ this.addChart(cmd.id, cmd.definition);
28511
28545
  break;
28512
28546
  case "UPDATE_CHART": {
28513
- this.addChart(cmd.id, cmd.sheetId, cmd.definition);
28547
+ this.addChart(cmd.id, cmd.definition);
28514
28548
  break;
28515
28549
  }
28516
28550
  case "DUPLICATE_SHEET": {
@@ -28519,7 +28553,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28519
28553
  if (fig.tag === "chart") {
28520
28554
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
28521
28555
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
28522
- const chart = (_b = (_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[fig.id]) === null || _b === void 0 ? void 0 : _b.copyForSheetId(cmd.sheetIdTo);
28556
+ const chart = (_a = this.charts[fig.id]) === null || _a === void 0 ? void 0 : _a.copyForSheetId(cmd.sheetIdTo);
28523
28557
  if (chart) {
28524
28558
  this.dispatch("CREATE_CHART", {
28525
28559
  id: duplicatedFigureId,
@@ -28534,41 +28568,44 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28534
28568
  break;
28535
28569
  }
28536
28570
  case "DELETE_FIGURE":
28537
- this.history.update("charts", cmd.sheetId, cmd.id, undefined);
28571
+ this.history.update("charts", cmd.id, undefined);
28538
28572
  break;
28539
28573
  case "DELETE_SHEET":
28540
- this.history.update("charts", cmd.sheetId, undefined);
28574
+ for (let id of this.getChartIds(cmd.sheetId)) {
28575
+ this.history.update("charts", id, undefined);
28576
+ }
28541
28577
  break;
28542
28578
  }
28543
28579
  }
28544
28580
  // ---------------------------------------------------------------------------
28545
28581
  // Getters
28546
28582
  // ---------------------------------------------------------------------------
28547
- getContextCreationChart(sheetId, figureId) {
28548
- var _a, _b;
28549
- return (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getContextCreation();
28550
- }
28551
- getChart(sheetId, figureId) {
28583
+ getContextCreationChart(figureId) {
28552
28584
  var _a;
28553
- return (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
28585
+ return (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getContextCreation();
28554
28586
  }
28555
- getChartType(sheetId, figureId) {
28556
- var _a, _b;
28557
- const type = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.type;
28587
+ getChart(figureId) {
28588
+ return this.charts[figureId];
28589
+ }
28590
+ getChartType(figureId) {
28591
+ var _a;
28592
+ const type = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.type;
28558
28593
  if (!type) {
28559
28594
  throw new Error("Chart not defined.");
28560
28595
  }
28561
28596
  return type;
28562
28597
  }
28563
- isChartDefined(sheetId, figureId) {
28564
- return figureId in (this.charts[sheetId] || {});
28598
+ isChartDefined(figureId) {
28599
+ return figureId in this.charts && this.charts !== undefined;
28565
28600
  }
28566
28601
  getChartIds(sheetId) {
28567
- return Object.keys(this.charts[sheetId] || {});
28602
+ return Object.entries(this.charts)
28603
+ .filter(([, chart]) => (chart === null || chart === void 0 ? void 0 : chart.sheetId) === sheetId)
28604
+ .map(([id]) => id);
28568
28605
  }
28569
- getChartDefinition(sheetId, figureId) {
28570
- var _a, _b;
28571
- const definition = (_b = (_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) === null || _b === void 0 ? void 0 : _b.getDefinition();
28606
+ getChartDefinition(figureId) {
28607
+ var _a;
28608
+ const definition = (_a = this.charts[figureId]) === null || _a === void 0 ? void 0 : _a.getDefinition();
28572
28609
  if (!definition) {
28573
28610
  throw new Error(`There is no chart with the given figureId: ${figureId}`);
28574
28611
  }
@@ -28580,28 +28617,35 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28580
28617
  import(data) {
28581
28618
  for (let sheet of data.sheets) {
28582
28619
  if (sheet.figures) {
28583
- const charts = {};
28584
28620
  for (let figure of sheet.figures) {
28585
28621
  // TODO:
28586
28622
  // figure data should be external IMO => chart should be in sheet.chart
28587
28623
  // instead of in figure.data
28588
28624
  if (figure.tag === "chart") {
28589
- charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28625
+ this.charts[figure.id] = this.createChart(figure.id, figure.data, sheet.id);
28590
28626
  }
28591
28627
  }
28592
- this.charts[sheet.id] = charts;
28593
28628
  }
28594
28629
  }
28595
28630
  }
28596
28631
  export(data) {
28632
+ var _a;
28597
28633
  if (data.sheets) {
28598
28634
  for (let sheet of data.sheets) {
28599
28635
  // TODO This code is false, if two plugins want ot insert figures on the sheet, it will crash !
28600
28636
  const sheetFigures = this.getters.getFigures(sheet.id);
28601
- const figures = sheetFigures;
28602
- for (let figure of figures) {
28637
+ const figures = [];
28638
+ for (let sheetFigure of sheetFigures) {
28639
+ const figure = sheetFigure;
28603
28640
  if (figure && figure.tag === "chart") {
28604
- figure.data = this.getChartDefinition(sheet.id, figure.id);
28641
+ const data = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinition();
28642
+ if (data) {
28643
+ figure.data = data;
28644
+ figures.push(figure);
28645
+ }
28646
+ }
28647
+ else {
28648
+ figures.push(figure);
28605
28649
  }
28606
28650
  }
28607
28651
  sheet.figures = figures;
@@ -28609,13 +28653,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28609
28653
  }
28610
28654
  }
28611
28655
  exportForExcel(data) {
28612
- var _a, _b;
28656
+ var _a;
28613
28657
  for (let sheet of data.sheets) {
28614
28658
  const sheetFigures = this.getters.getFigures(sheet.id);
28615
28659
  const figures = [];
28616
28660
  for (let figure of sheetFigures) {
28617
28661
  if (figure && figure.tag === "chart") {
28618
- const figureData = (_b = (_a = this.charts[sheet.id]) === null || _a === void 0 ? void 0 : _a[figure.id]) === null || _b === void 0 ? void 0 : _b.getDefinitionForExcel();
28662
+ const figureData = (_a = this.charts[figure.id]) === null || _a === void 0 ? void 0 : _a.getDefinitionForExcel();
28619
28663
  if (figureData) {
28620
28664
  figures.push({
28621
28665
  ...figure,
@@ -28654,15 +28698,21 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
28654
28698
  * Add a chart in the local state. If a chart already exists, this chart is
28655
28699
  * replaced
28656
28700
  */
28657
- addChart(id, sheetId, definition) {
28658
- this.history.update("charts", sheetId, id, this.createChart(id, definition, sheetId));
28701
+ addChart(id, definition) {
28702
+ const sheetId = this.getters.getFigureSheetId(id);
28703
+ if (sheetId) {
28704
+ this.history.update("charts", id, this.createChart(id, definition, sheetId));
28705
+ }
28659
28706
  }
28660
28707
  checkChartDuplicate(cmd) {
28661
- var _a;
28662
- if ((_a = this.charts[cmd.sheetId]) === null || _a === void 0 ? void 0 : _a[cmd.id]) {
28663
- return 84 /* CommandResult.DuplicatedChartId */;
28664
- }
28665
- return 0 /* CommandResult.Success */;
28708
+ return this.getters.getFigureSheetId(cmd.id)
28709
+ ? 84 /* CommandResult.DuplicatedChartId */
28710
+ : 0 /* CommandResult.Success */;
28711
+ }
28712
+ checkChartExists(cmd) {
28713
+ return this.getters.getFigureSheetId(cmd.id)
28714
+ ? 0 /* CommandResult.Success */
28715
+ : 85 /* CommandResult.ChartDoesNotExist */;
28666
28716
  }
28667
28717
  }
28668
28718
  ChartPlugin.getters = [
@@ -29043,7 +29093,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29043
29093
  allowDispatch(cmd) {
29044
29094
  switch (cmd.type) {
29045
29095
  case "CREATE_FIGURE":
29046
- return this.checkFigureDuplicate(cmd.sheetId, cmd.figure.id);
29096
+ return this.checkFigureDuplicate(cmd.figure.id);
29047
29097
  case "UPDATE_FIGURE":
29048
29098
  case "DELETE_FIGURE":
29049
29099
  return this.checkFigureExists(cmd.sheetId, cmd.id);
@@ -29109,9 +29159,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29109
29159
  }
29110
29160
  return 0 /* CommandResult.Success */;
29111
29161
  }
29112
- checkFigureDuplicate(sheetId, figureId) {
29113
- var _a;
29114
- if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
29162
+ checkFigureDuplicate(figureId) {
29163
+ if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
29115
29164
  return 82 /* CommandResult.DuplicatedFigureId */;
29116
29165
  }
29117
29166
  return 0 /* CommandResult.Success */;
@@ -29126,6 +29175,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29126
29175
  var _a;
29127
29176
  return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29128
29177
  }
29178
+ getFigureSheetId(figureId) {
29179
+ return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
29180
+ }
29129
29181
  // ---------------------------------------------------------------------------
29130
29182
  // Import/Export
29131
29183
  // ---------------------------------------------------------------------------
@@ -29150,7 +29202,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29150
29202
  this.export(data);
29151
29203
  }
29152
29204
  }
29153
- FigurePlugin.getters = ["getFigures", "getFigure"];
29205
+ FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
29154
29206
 
29155
29207
  class FilterTable {
29156
29208
  constructor(zone) {
@@ -29877,7 +29929,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29877
29929
  switch (cmd.type) {
29878
29930
  case "CREATE_IMAGE":
29879
29931
  if (this.getters.getFigure(cmd.sheetId, cmd.figureId)) {
29880
- return 28 /* CommandResult.DuplicatedImageId */;
29932
+ return 28 /* CommandResult.InvalidFigureId */;
29881
29933
  }
29882
29934
  return 0 /* CommandResult.Success */;
29883
29935
  default:
@@ -29897,7 +29949,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29897
29949
  if (fig.tag === "image") {
29898
29950
  const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
29899
29951
  const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
29900
- const image = this.getImage(cmd.sheetId, fig.id);
29952
+ const image = this.getImage(fig.id);
29901
29953
  if (image) {
29902
29954
  const size = { width: fig.width, height: fig.height };
29903
29955
  this.dispatch("CREATE_IMAGE", {
@@ -29935,13 +29987,19 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29935
29987
  // ---------------------------------------------------------------------------
29936
29988
  // Getters
29937
29989
  // ---------------------------------------------------------------------------
29938
- getImage(sheetId, figureId) {
29939
- var _a;
29940
- const image = (_a = this.images[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
29941
- if (!image) {
29942
- throw new Error(`There is no image with the given figureId: ${figureId}`);
29990
+ getImage(figureId) {
29991
+ for (const sheet of Object.values(this.images)) {
29992
+ if (sheet && sheet[figureId]) {
29993
+ return sheet[figureId];
29994
+ }
29943
29995
  }
29944
- return image;
29996
+ throw new Error(`There is no image with the given figureId: ${figureId}`);
29997
+ }
29998
+ getImagePath(figureId) {
29999
+ return this.getImage(figureId).path;
30000
+ }
30001
+ getImageSize(figureId) {
30002
+ return this.getImage(figureId).size;
29945
30003
  }
29946
30004
  // ---------------------------------------------------------------------------
29947
30005
  // Private
@@ -29983,7 +30041,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
29983
30041
  return images;
29984
30042
  }
29985
30043
  }
29986
- ImagePlugin.getters = ["getImage"];
30044
+ ImagePlugin.getters = ["getImage", "getImagePath", "getImageSize"];
29987
30045
 
29988
30046
  class MergePlugin extends CorePlugin {
29989
30047
  constructor() {
@@ -31784,9 +31842,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
31784
31842
  return formatColors.filter(isDefined$1);
31785
31843
  }
31786
31844
  getChartColors(sheetId) {
31787
- const charts = this.getters
31788
- .getChartIds(sheetId)
31789
- .map((cid) => this.getters.getChart(sheetId, cid));
31845
+ const charts = this.getters.getChartIds(sheetId).map((cid) => this.getters.getChart(cid));
31790
31846
  let chartsColors = new Set();
31791
31847
  for (let chart of charts) {
31792
31848
  if (chart === undefined) {
@@ -32142,37 +32198,34 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32142
32198
  invalidateCFEvaluationCommands.has(cmd.type) ||
32143
32199
  cmd.type === "EVALUATE_CELLS" ||
32144
32200
  cmd.type === "UPDATE_CELL") {
32145
- for (const sheetId in this.charts) {
32146
- for (const chartId in this.charts[sheetId]) {
32147
- this.charts[sheetId][chartId] = undefined;
32148
- }
32201
+ for (const chartId in this.charts) {
32202
+ this.charts[chartId] = undefined;
32149
32203
  }
32150
32204
  }
32151
32205
  switch (cmd.type) {
32152
32206
  case "UPDATE_CHART":
32153
32207
  case "CREATE_CHART":
32154
32208
  case "DELETE_FIGURE":
32155
- if (this.charts[cmd.sheetId]) {
32156
- this.charts[cmd.sheetId][cmd.id] = undefined;
32157
- }
32209
+ this.charts[cmd.id] = undefined;
32158
32210
  break;
32159
32211
  case "DELETE_SHEET":
32160
- delete this.charts[cmd.sheetId];
32212
+ for (let chartId in this.charts) {
32213
+ if (!this.getters.isChartDefined(chartId)) {
32214
+ this.charts[chartId] = undefined;
32215
+ }
32216
+ }
32161
32217
  break;
32162
32218
  }
32163
32219
  }
32164
- getChartRuntime(sheetId, figureId) {
32165
- var _a;
32166
- if (!((_a = this.charts[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId])) {
32167
- const chart = this.getters.getChart(sheetId, figureId);
32220
+ getChartRuntime(figureId) {
32221
+ if (!this.charts[figureId]) {
32222
+ const chart = this.getters.getChart(figureId);
32168
32223
  if (!chart) {
32169
32224
  throw new Error(`No chart for the given id: ${figureId}`);
32170
32225
  }
32171
- if (!this.charts[sheetId])
32172
- this.charts[sheetId] = {};
32173
- this.charts[sheetId][figureId] = this.createRuntimeChart(chart);
32226
+ this.charts[figureId] = this.createRuntimeChart(chart);
32174
32227
  }
32175
- return this.charts[sheetId][figureId];
32228
+ return this.charts[figureId];
32176
32229
  }
32177
32230
  /**
32178
32231
  * Get the background color of a chart based on the color of the first cell of the main range
@@ -32608,6 +32661,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32608
32661
  case "CREATE_SHEET":
32609
32662
  this.filterValues[cmd.sheetId] = {};
32610
32663
  break;
32664
+ case "HIDE_COLUMNS_ROWS":
32665
+ this.updateHiddenRows();
32666
+ break;
32611
32667
  case "UPDATE_FILTER":
32612
32668
  this.updateFilter(cmd);
32613
32669
  this.updateHiddenRows();
@@ -32716,9 +32772,16 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
32716
32772
  updateHiddenRows() {
32717
32773
  var _a, _b;
32718
32774
  const sheetId = this.getters.getActiveSheetId();
32719
- const filters = this.getters.getFilters(sheetId);
32775
+ const filters = this.getters
32776
+ .getFilters(sheetId)
32777
+ .sort((filter1, filter2) => filter1.zoneWithHeaders.top - filter2.zoneWithHeaders.top);
32720
32778
  const hiddenRows = new Set();
32721
32779
  for (let filter of filters) {
32780
+ // Disable filters whose header are hidden
32781
+ if (this.getters.isRowHiddenByUser(sheetId, filter.zoneWithHeaders.top))
32782
+ continue;
32783
+ if (hiddenRows.has(filter.zoneWithHeaders.top))
32784
+ continue;
32722
32785
  const filteredValues = (_b = (_a = this.filterValues[sheetId]) === null || _a === void 0 ? void 0 : _a[filter.id]) === null || _b === void 0 ? void 0 : _b.map(toLowerCase);
32723
32786
  if (!filteredValues || !filter.filteredZone)
32724
32787
  continue;
@@ -37816,7 +37879,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37816
37879
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37817
37880
  this.dispatch = dispatch;
37818
37881
  this.sheetId = sheetId;
37819
- const chart = getters.getChart(sheetId, copiedFigureId);
37882
+ const chart = getters.getChart(copiedFigureId);
37820
37883
  if (!chart) {
37821
37884
  throw new Error(`No chart for the given id: ${copiedFigureId}`);
37822
37885
  }
@@ -37837,7 +37900,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
37837
37900
  constructor(dispatch, getters, sheetId, copiedFigureId) {
37838
37901
  this.dispatch = dispatch;
37839
37902
  this.sheetId = sheetId;
37840
- const image = getters.getImage(sheetId, copiedFigureId);
37903
+ const image = getters.getImage(copiedFigureId);
37841
37904
  this.copiedImage = deepCopy(image);
37842
37905
  }
37843
37906
  paste(sheetId, figureId, position, size) {
@@ -43847,9 +43910,9 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
43847
43910
  Object.defineProperty(exports, '__esModule', { value: true });
43848
43911
 
43849
43912
 
43850
- __info__.version = '16.1.2';
43851
- __info__.date = '2023-03-01T14:43:45.667Z';
43852
- __info__.hash = '59bec2d';
43913
+ __info__.version = '16.1.4';
43914
+ __info__.date = '2023-03-14T09:27:28.837Z';
43915
+ __info__.hash = 'c8882d9';
43853
43916
 
43854
43917
 
43855
43918
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);