@odoo/o-spreadsheet 16.2.7 → 16.2.8

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.
@@ -16860,7 +16860,7 @@
16860
16860
  return !!((_a = this.state.labelsDispatchResult) === null || _a === void 0 ? void 0 : _a.isCancelledBecause(33 /* CommandResult.InvalidLabelRange */));
16861
16861
  }
16862
16862
  onUpdateDataSetsHaveTitle(ev) {
16863
- this.props.updateChart({
16863
+ this.props.updateChart(this.props.figureId, {
16864
16864
  dataSetsHaveTitle: ev.target.checked,
16865
16865
  });
16866
16866
  }
@@ -16872,7 +16872,7 @@
16872
16872
  this.dataSeriesRanges = ranges;
16873
16873
  }
16874
16874
  onDataSeriesConfirmed() {
16875
- this.state.datasetDispatchResult = this.props.updateChart({
16875
+ this.state.datasetDispatchResult = this.props.updateChart(this.props.figureId, {
16876
16876
  dataSets: this.dataSeriesRanges,
16877
16877
  });
16878
16878
  }
@@ -16884,12 +16884,12 @@
16884
16884
  this.labelRange = ranges[0];
16885
16885
  }
16886
16886
  onLabelRangeConfirmed() {
16887
- this.state.labelsDispatchResult = this.props.updateChart({
16887
+ this.state.labelsDispatchResult = this.props.updateChart(this.props.figureId, {
16888
16888
  labelRange: this.labelRange,
16889
16889
  });
16890
16890
  }
16891
16891
  onUpdateAggregated(ev) {
16892
- this.props.updateChart({
16892
+ this.props.updateChart(this.props.figureId, {
16893
16893
  aggregated: ev.target.checked,
16894
16894
  });
16895
16895
  }
@@ -16904,12 +16904,12 @@
16904
16904
 
16905
16905
  class BarConfigPanel extends LineBarPieConfigPanel {
16906
16906
  onUpdateStacked(ev) {
16907
- this.props.updateChart({
16907
+ this.props.updateChart(this.props.figureId, {
16908
16908
  stacked: ev.target.checked,
16909
16909
  });
16910
16910
  }
16911
16911
  onUpdateAggregated(ev) {
16912
- this.props.updateChart({
16912
+ this.props.updateChart(this.props.figureId, {
16913
16913
  aggregated: ev.target.checked,
16914
16914
  });
16915
16915
  }
@@ -17252,17 +17252,17 @@
17252
17252
  this.state.fillColorTool = !this.state.fillColorTool;
17253
17253
  }
17254
17254
  updateBackgroundColor(color) {
17255
- this.props.updateChart({
17255
+ this.props.updateChart(this.props.figureId, {
17256
17256
  background: color,
17257
17257
  });
17258
17258
  }
17259
17259
  updateTitle(ev) {
17260
- this.props.updateChart({
17260
+ this.props.updateChart(this.props.figureId, {
17261
17261
  title: ev.target.value,
17262
17262
  });
17263
17263
  }
17264
17264
  updateSelect(attr, ev) {
17265
- this.props.updateChart({
17265
+ this.props.updateChart(this.props.figureId, {
17266
17266
  [attr]: ev.target.value,
17267
17267
  });
17268
17268
  }
@@ -17300,7 +17300,7 @@
17300
17300
  this.dataRange = ranges[0];
17301
17301
  }
17302
17302
  updateDataRange() {
17303
- this.state.dataRangeDispatchResult = this.props.updateChart({
17303
+ this.state.dataRangeDispatchResult = this.props.updateChart(this.props.figureId, {
17304
17304
  dataRange: this.dataRange,
17305
17305
  });
17306
17306
  }
@@ -17362,12 +17362,12 @@
17362
17362
  }
17363
17363
  updateBackgroundColor(color) {
17364
17364
  this.state.openedMenu = undefined;
17365
- this.props.updateChart({
17365
+ this.props.updateChart(this.props.figureId, {
17366
17366
  background: color,
17367
17367
  });
17368
17368
  }
17369
17369
  updateTitle(ev) {
17370
- this.props.updateChart({
17370
+ this.props.updateChart(this.props.figureId, {
17371
17371
  title: ev.target.value,
17372
17372
  });
17373
17373
  }
@@ -17436,7 +17436,7 @@
17436
17436
  }
17437
17437
  }
17438
17438
  updateSectionRule(sectionRule) {
17439
- this.state.sectionRuleDispatchResult = this.props.updateChart({
17439
+ this.state.sectionRuleDispatchResult = this.props.updateChart(this.props.figureId, {
17440
17440
  sectionRule,
17441
17441
  });
17442
17442
  }
@@ -17461,17 +17461,17 @@
17461
17461
  return false;
17462
17462
  }
17463
17463
  onUpdateLabelsAsText(ev) {
17464
- this.props.updateChart({
17464
+ this.props.updateChart(this.props.figureId, {
17465
17465
  labelsAsText: ev.target.checked,
17466
17466
  });
17467
17467
  }
17468
17468
  onUpdateStacked(ev) {
17469
- this.props.updateChart({
17469
+ this.props.updateChart(this.props.figureId, {
17470
17470
  stacked: ev.target.checked,
17471
17471
  });
17472
17472
  }
17473
17473
  onUpdateAggregated(ev) {
17474
- this.props.updateChart({
17474
+ this.props.updateChart(this.props.figureId, {
17475
17475
  aggregated: ev.target.checked,
17476
17476
  });
17477
17477
  }
@@ -17512,7 +17512,7 @@
17512
17512
  this.keyValue = ranges[0];
17513
17513
  }
17514
17514
  updateKeyValueRange() {
17515
- this.state.keyValueDispatchResult = this.props.updateChart({
17515
+ this.state.keyValueDispatchResult = this.props.updateChart(this.props.figureId, {
17516
17516
  keyValue: this.keyValue,
17517
17517
  });
17518
17518
  }
@@ -17520,12 +17520,12 @@
17520
17520
  this.baseline = ranges[0];
17521
17521
  }
17522
17522
  updateBaselineRange() {
17523
- this.state.baselineDispatchResult = this.props.updateChart({
17523
+ this.state.baselineDispatchResult = this.props.updateChart(this.props.figureId, {
17524
17524
  baseline: this.baseline,
17525
17525
  });
17526
17526
  }
17527
17527
  updateBaselineMode(ev) {
17528
- this.props.updateChart({ baselineMode: ev.target.value });
17528
+ this.props.updateChart(this.props.figureId, { baselineMode: ev.target.value });
17529
17529
  }
17530
17530
  }
17531
17531
  ScorecardChartConfigPanel.template = "o-spreadsheet-ScorecardChartConfigPanel";
@@ -17547,12 +17547,12 @@
17547
17547
  owl.useExternalListener(window, "click", this.closeMenus);
17548
17548
  }
17549
17549
  updateTitle(ev) {
17550
- this.props.updateChart({
17550
+ this.props.updateChart(this.props.figureId, {
17551
17551
  title: ev.target.value,
17552
17552
  });
17553
17553
  }
17554
17554
  updateBaselineDescr(ev) {
17555
- this.props.updateChart({ baselineDescr: ev.target.value });
17555
+ this.props.updateChart(this.props.figureId, { baselineDescr: ev.target.value });
17556
17556
  }
17557
17557
  toggleColorPicker(colorPickerId) {
17558
17558
  if (this.state.openedColorPicker === colorPickerId) {
@@ -17565,13 +17565,13 @@
17565
17565
  setColor(color, colorPickerId) {
17566
17566
  switch (colorPickerId) {
17567
17567
  case "backgroundColor":
17568
- this.props.updateChart({ background: color });
17568
+ this.props.updateChart(this.props.figureId, { background: color });
17569
17569
  break;
17570
17570
  case "baselineColorDown":
17571
- this.props.updateChart({ baselineColorDown: color });
17571
+ this.props.updateChart(this.props.figureId, { baselineColorDown: color });
17572
17572
  break;
17573
17573
  case "baselineColorUp":
17574
- this.props.updateChart({ baselineColorUp: color });
17574
+ this.props.updateChart(this.props.figureId, { baselineColorUp: color });
17575
17575
  break;
17576
17576
  }
17577
17577
  this.closeMenus();
@@ -17636,16 +17636,9 @@
17636
17636
  }
17637
17637
  `;
17638
17638
  class ChartPanel extends owl.Component {
17639
- constructor() {
17640
- super(...arguments);
17641
- this.shouldUpdateChart = true;
17642
- }
17643
17639
  get figureId() {
17644
17640
  return this.state.figureId;
17645
17641
  }
17646
- get sheetId() {
17647
- return this.state.sheetId;
17648
- }
17649
17642
  setup() {
17650
17643
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17651
17644
  if (!selectedFigureId) {
@@ -17654,17 +17647,11 @@
17654
17647
  this.state = owl.useState({
17655
17648
  panel: "configuration",
17656
17649
  figureId: selectedFigureId,
17657
- sheetId: this.env.model.getters.getActiveSheetId(),
17658
17650
  });
17659
17651
  owl.onWillUpdateProps(() => {
17660
17652
  const selectedFigureId = this.env.model.getters.getSelectedFigureId();
17661
17653
  if (selectedFigureId && selectedFigureId !== this.state.figureId) {
17662
17654
  this.state.figureId = selectedFigureId;
17663
- this.state.sheetId = this.env.model.getters.getActiveSheetId();
17664
- this.shouldUpdateChart = false;
17665
- }
17666
- else {
17667
- this.shouldUpdateChart = true;
17668
17655
  }
17669
17656
  if (!this.env.model.getters.isChartDefined(this.figureId)) {
17670
17657
  this.props.onCloseSidePanel();
@@ -17672,8 +17659,8 @@
17672
17659
  }
17673
17660
  });
17674
17661
  }
17675
- updateChart(updateDefinition) {
17676
- if (!this.shouldUpdateChart) {
17662
+ updateChart(figureId, updateDefinition) {
17663
+ if (figureId !== this.figureId) {
17677
17664
  return;
17678
17665
  }
17679
17666
  const definition = {
@@ -17682,8 +17669,8 @@
17682
17669
  };
17683
17670
  return this.env.model.dispatch("UPDATE_CHART", {
17684
17671
  definition,
17685
- id: this.figureId,
17686
- sheetId: this.sheetId,
17672
+ id: figureId,
17673
+ sheetId: this.env.model.getters.getFigureSheetId(figureId),
17687
17674
  });
17688
17675
  }
17689
17676
  onTypeChange(type) {
@@ -17695,7 +17682,7 @@
17695
17682
  this.env.model.dispatch("UPDATE_CHART", {
17696
17683
  definition,
17697
17684
  id: this.figureId,
17698
- sheetId: this.sheetId,
17685
+ sheetId: this.env.model.getters.getFigureSheetId(this.figureId),
17699
17686
  });
17700
17687
  }
17701
17688
  get chartPanel() {
@@ -23065,6 +23052,16 @@
23065
23052
  63: "333333",
23066
23053
  64: "000000",
23067
23054
  65: "FFFFFF", // system background
23055
+ };
23056
+ const IMAGE_MIMETYPE_EXTENSION_MAPPING = {
23057
+ "image/avif": "avif",
23058
+ "image/bmp": "bmp",
23059
+ "image/gif": "gif",
23060
+ "image/vnd.microsoft.icon": "ico",
23061
+ "image/jpeg": "jpeg",
23062
+ "image/png": "png",
23063
+ "image/tiff": "tiff",
23064
+ "image/webp": "webp",
23068
23065
  };
23069
23066
 
23070
23067
  /**
@@ -25501,6 +25498,11 @@
25501
25498
  <Override ContentType="${contentType}" PartName="${partName}" />
25502
25499
  `;
25503
25500
  }
25501
+ function createDefaultXMLElement(extension, contentType) {
25502
+ return escapeXml /*xml*/ `
25503
+ <Default Extension="${extension}" ContentType="${contentType}" />
25504
+ `;
25505
+ }
25504
25506
  function joinXmlNodes(xmlNodes) {
25505
25507
  return new XMLString(xmlNodes.join("\n"));
25506
25508
  }
@@ -39562,7 +39564,7 @@
39562
39564
  const file = await this.getImageFromUser();
39563
39565
  const path = await this.fileStore.upload(file);
39564
39566
  const size = await this.getImageSize(path);
39565
- return { path, size };
39567
+ return { path, size, mimetype: file.type };
39566
39568
  }
39567
39569
  getImageFromUser() {
39568
39570
  return new Promise((resolve, reject) => {
@@ -44628,8 +44630,7 @@
44628
44630
  // Figures and Charts
44629
44631
  let drawingNode = escapeXml ``;
44630
44632
  const drawingRelIds = [];
44631
- const charts = sheet.charts;
44632
- for (const chart of charts) {
44633
+ for (const chart of sheet.charts) {
44633
44634
  const xlsxChartId = convertChartId(chart.id);
44634
44635
  const chartRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44635
44636
  target: `../charts/chart${xlsxChartId}.xml`,
@@ -44638,20 +44639,27 @@
44638
44639
  drawingRelIds.push(chartRelId);
44639
44640
  files.push(createXMLFile(createChart(chart, sheetIndex, data), `xl/charts/chart${xlsxChartId}.xml`, "chart"));
44640
44641
  }
44641
- const images = sheet.images;
44642
- for (const image of images) {
44642
+ for (const image of sheet.images) {
44643
+ const mimeType = image.data.mimetype;
44644
+ if (mimeType === undefined)
44645
+ continue;
44646
+ const extension = IMAGE_MIMETYPE_EXTENSION_MAPPING[mimeType];
44647
+ // only support exporting images with mimetypes specified in the mapping
44648
+ if (extension === undefined)
44649
+ continue;
44643
44650
  const xlsxImageId = convertImageId(image.id);
44651
+ let imageFileName = `image${xlsxImageId}.${extension}`;
44644
44652
  const imageRelId = addRelsToFile(construct.relsFiles, `xl/drawings/_rels/drawing${sheetIndex}.xml.rels`, {
44645
- target: `../media/image${xlsxImageId}`,
44653
+ target: `../media/${imageFileName}`,
44646
44654
  type: XLSX_RELATION_TYPE.image,
44647
44655
  });
44648
44656
  drawingRelIds.push(imageRelId);
44649
44657
  files.push({
44650
- path: `xl/media/image${xlsxImageId}`,
44651
- imagePath: image.data.path,
44658
+ path: `xl/media/${imageFileName}`,
44659
+ imageSrc: image.data.path,
44652
44660
  });
44653
44661
  }
44654
- const drawings = [...charts, ...images];
44662
+ const drawings = [...sheet.charts, ...sheet.images];
44655
44663
  if (drawings.length) {
44656
44664
  const drawingRelId = addRelsToFile(construct.relsFiles, `xl/worksheets/_rels/sheet${sheetIndex}.xml.rels`, {
44657
44665
  target: `../drawings/drawing${sheetIndex}.xml`,
@@ -44770,6 +44778,8 @@
44770
44778
  }
44771
44779
  function createContentTypes(files) {
44772
44780
  const overrideNodes = [];
44781
+ // hard-code supported image mimetypes
44782
+ const imageDefaultNodes = Object.entries(IMAGE_MIMETYPE_EXTENSION_MAPPING).map(([mimetype, extension]) => createDefaultXMLElement(extension, mimetype));
44773
44783
  for (const file of files) {
44774
44784
  if ("contentType" in file && file.contentType) {
44775
44785
  overrideNodes.push(createOverride("/" + file.path, CONTENT_TYPES[file.contentType]));
@@ -44777,6 +44787,7 @@
44777
44787
  }
44778
44788
  const xml = escapeXml /*xml*/ `
44779
44789
  <Types xmlns="${NAMESPACE["Types"]}">
44790
+ ${joinXmlNodes(Object.values(imageDefaultNodes))}
44780
44791
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
44781
44792
  <Default Extension="xml" ContentType="application/xml" />
44782
44793
  ${joinXmlNodes(overrideNodes)}
@@ -45338,9 +45349,9 @@
45338
45349
  Object.defineProperty(exports, '__esModule', { value: true });
45339
45350
 
45340
45351
 
45341
- __info__.version = '16.2.7';
45342
- __info__.date = '2023-05-25T12:56:32.163Z';
45343
- __info__.hash = '047a6d5';
45352
+ __info__.version = '16.2.8';
45353
+ __info__.date = '2023-06-02T10:12:43.068Z';
45354
+ __info__.hash = 'b474e62';
45344
45355
 
45345
45356
 
45346
45357
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);