@odoo/o-spreadsheet 17.4.6 → 17.4.7

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 17.4.6
6
- * @date 2024-08-26T13:50:49.623Z
7
- * @hash f5648d9
5
+ * @version 17.4.7
6
+ * @date 2024-09-05T09:32:00.461Z
7
+ * @hash c14a4c9
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -4560,6 +4560,17 @@
4560
4560
  }
4561
4561
  return zone;
4562
4562
  }
4563
+ function aggregatePositionsToZones(positions) {
4564
+ const result = {};
4565
+ for (const position of positions) {
4566
+ result[position.sheetId] ??= [];
4567
+ result[position.sheetId].push(positionToZone(position));
4568
+ }
4569
+ for (const sheetId in result) {
4570
+ result[sheetId] = recomputeZones(result[sheetId]);
4571
+ }
4572
+ return result;
4573
+ }
4563
4574
  /**
4564
4575
  * This function returns a zone with coordinates modified according to the change
4565
4576
  * applied to the zone. It may be possible to change the zone by resizing or moving
@@ -6775,9 +6786,11 @@
6775
6786
  const targetCell = this.getters.getEvaluatedCell(target);
6776
6787
  const originFormat = origin.cell?.format ?? origin.evaluatedCell.format;
6777
6788
  if (clipboardOption?.pasteOption === "asValue") {
6778
- const locale = this.getters.getLocale();
6779
- const content = formatValue(origin.evaluatedCell.value, { locale });
6780
- this.dispatch("UPDATE_CELL", { ...target, content, format: originFormat });
6789
+ this.dispatch("UPDATE_CELL", {
6790
+ ...target,
6791
+ content: origin.evaluatedCell.value?.toString() || "",
6792
+ format: originFormat,
6793
+ });
6781
6794
  return;
6782
6795
  }
6783
6796
  if (clipboardOption?.pasteOption === "onlyFormat") {
@@ -28379,8 +28392,26 @@ stores.inject(MyMetaStore, storeInstance);
28379
28392
  env.openSidePanel("PivotSidePanel", { pivotId });
28380
28393
  }
28381
28394
  };
28382
- const REINSERT_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28383
- id: `reinsert_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28395
+ const REINSERT_DYNAMIC_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28396
+ id: `reinsert_dynamic_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28397
+ name: env.model.getters.getPivotDisplayName(pivotId),
28398
+ sequence: index,
28399
+ execute: (env) => {
28400
+ const zone = env.model.getters.getSelectedZone();
28401
+ const table = env.model.getters.getPivot(pivotId).getTableStructure().export();
28402
+ env.model.dispatch("INSERT_PIVOT_WITH_TABLE", {
28403
+ pivotId,
28404
+ table,
28405
+ col: zone.left,
28406
+ row: zone.top,
28407
+ sheetId: env.model.getters.getActiveSheetId(),
28408
+ pivotMode: "dynamic",
28409
+ });
28410
+ env.model.dispatch("REFRESH_PIVOT", { id: pivotId });
28411
+ },
28412
+ }));
28413
+ const REINSERT_STATIC_PIVOT_CHILDREN = (env) => env.model.getters.getPivotIds().map((pivotId, index) => ({
28414
+ id: `reinsert_static_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
28384
28415
  name: env.model.getters.getPivotDisplayName(pivotId),
28385
28416
  sequence: index,
28386
28417
  execute: (env) => {
@@ -28392,6 +28423,7 @@ stores.inject(MyMetaStore, storeInstance);
28392
28423
  col: zone.left,
28393
28424
  row: zone.top,
28394
28425
  sheetId: env.model.getters.getActiveSheetId(),
28426
+ pivotMode: "static",
28395
28427
  });
28396
28428
  env.model.dispatch("REFRESH_PIVOT", { id: pivotId });
28397
28429
  },
@@ -29260,12 +29292,20 @@ stores.inject(MyMetaStore, storeInstance);
29260
29292
  isEnabled: (env) => env.model.getters.isSingleColSelected(),
29261
29293
  icon: "o-spreadsheet-Icon.SPLIT_TEXT",
29262
29294
  };
29263
- const reinsertPivotMenu = {
29264
- id: "reinsert_pivot",
29265
- name: _t("Re-insert pivot"),
29295
+ const reinsertDynamicPivotMenu = {
29296
+ id: "reinsert_dynamic_pivot",
29297
+ name: _t("Re-insert dynamic pivot"),
29298
+ sequence: 1020,
29299
+ icon: "o-spreadsheet-Icon.INSERT_PIVOT",
29300
+ children: [REINSERT_DYNAMIC_PIVOT_CHILDREN],
29301
+ isVisible: (env) => env.model.getters.getPivotIds().length > 0,
29302
+ };
29303
+ const reinsertStaticPivotMenu = {
29304
+ id: "reinsert_static_pivot",
29305
+ name: _t("Re-insert static pivot"),
29266
29306
  sequence: 1020,
29267
29307
  icon: "o-spreadsheet-Icon.INSERT_PIVOT",
29268
- children: [REINSERT_PIVOT_CHILDREN],
29308
+ children: [REINSERT_STATIC_PIVOT_CHILDREN],
29269
29309
  isVisible: (env) => env.model.getters.getPivotIds().length > 0,
29270
29310
  };
29271
29311
 
@@ -29274,7 +29314,8 @@ stores.inject(MyMetaStore, storeInstance);
29274
29314
  createRemoveFilter: createRemoveFilter,
29275
29315
  createRemoveFilterTool: createRemoveFilterTool,
29276
29316
  dataCleanup: dataCleanup,
29277
- reinsertPivotMenu: reinsertPivotMenu,
29317
+ reinsertDynamicPivotMenu: reinsertDynamicPivotMenu,
29318
+ reinsertStaticPivotMenu: reinsertStaticPivotMenu,
29278
29319
  removeDuplicates: removeDuplicates,
29279
29320
  sortAscending: sortAscending,
29280
29321
  sortDescending: sortDescending,
@@ -30756,7 +30797,8 @@ stores.inject(MyMetaStore, storeInstance);
30756
30797
  };
30757
30798
  });
30758
30799
  })
30759
- .addChild("reinsert_pivot", ["data"], reinsertPivotMenu);
30800
+ .addChild("reinsert_dynamic_pivot", ["data"], reinsertDynamicPivotMenu)
30801
+ .addChild("reinsert_static_pivot", ["data"], reinsertStaticPivotMenu);
30760
30802
 
30761
30803
  class OTRegistry extends Registry {
30762
30804
  /**
@@ -44066,6 +44108,18 @@ stores.inject(MyMetaStore, storeInstance);
44066
44108
  // -------------------------------------
44067
44109
  // WORKSHEET HELPERS
44068
44110
  // -------------------------------------
44111
+ function getCellType(value) {
44112
+ switch (typeof value) {
44113
+ case "boolean":
44114
+ return "b";
44115
+ case "string":
44116
+ return "str";
44117
+ case "number":
44118
+ return "n";
44119
+ default:
44120
+ return undefined;
44121
+ }
44122
+ }
44069
44123
  function convertHeightToExcel(height) {
44070
44124
  return Math.round(HEIGHT_FACTOR * height * 100) / 100;
44071
44125
  }
@@ -54316,8 +54370,9 @@ stores.inject(MyMetaStore, storeInstance);
54316
54370
  }
54317
54371
  getCellsDependingOn(positions) {
54318
54372
  const ranges = [];
54319
- for (const position of positions) {
54320
- ranges.push({ sheetId: position.sheetId, zone: positionToZone(position) });
54373
+ const zonesBySheetIds = aggregatePositionsToZones(positions);
54374
+ for (const sheetId in zonesBySheetIds) {
54375
+ ranges.push(...zonesBySheetIds[sheetId].map((zone) => ({ sheetId, zone })));
54321
54376
  }
54322
54377
  return this.formulaDependencies().getCellsDependingOn(ranges);
54323
54378
  }
@@ -57227,9 +57282,9 @@ stores.inject(MyMetaStore, storeInstance);
57227
57282
  /**
57228
57283
  * Notify the server that the user client left the collaborative session
57229
57284
  */
57230
- leave(data) {
57285
+ async leave(data) {
57231
57286
  if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
57232
- this.snapshot(data());
57287
+ await this.snapshot(data());
57233
57288
  }
57234
57289
  delete this.clients[this.clientId];
57235
57290
  this.transportService.leave(this.clientId);
@@ -57242,12 +57297,12 @@ stores.inject(MyMetaStore, storeInstance);
57242
57297
  /**
57243
57298
  * Send a snapshot of the spreadsheet to the collaboration server
57244
57299
  */
57245
- snapshot(data) {
57300
+ async snapshot(data) {
57246
57301
  if (this.pendingMessages.length !== 0) {
57247
57302
  return;
57248
57303
  }
57249
57304
  const snapshotId = this.uuidGenerator.uuidv4();
57250
- this.transportService.sendMessage({
57305
+ await this.transportService.sendMessage({
57251
57306
  type: "SNAPSHOT",
57252
57307
  nextRevisionId: snapshotId,
57253
57308
  serverRevisionId: this.serverRevisionId,
@@ -57931,7 +57986,7 @@ stores.inject(MyMetaStore, storeInstance);
57931
57986
  this.duplicatePivotInNewSheet(cmd.pivotId, cmd.newPivotId, cmd.newSheetId);
57932
57987
  break;
57933
57988
  case "INSERT_PIVOT_WITH_TABLE":
57934
- this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table);
57989
+ this.insertPivotWithTable(cmd.sheetId, cmd.col, cmd.row, cmd.pivotId, cmd.table, cmd.pivotMode);
57935
57990
  break;
57936
57991
  }
57937
57992
  }
@@ -58007,26 +58062,44 @@ stores.inject(MyMetaStore, storeInstance);
58007
58062
  }
58008
58063
  return name;
58009
58064
  }
58010
- insertPivotWithTable(sheetId, col, row, pivotId, table) {
58065
+ insertPivotWithTable(sheetId, col, row, pivotId, table, mode) {
58011
58066
  const { cols, rows, measures, fieldsType } = table;
58012
58067
  const pivotTable = new SpreadsheetPivotTable(cols, rows, measures, fieldsType || {});
58068
+ const numberOfHeaders = pivotTable.columns.length - 1;
58013
58069
  this.resizeSheet(sheetId, col, row, pivotTable);
58014
58070
  const pivotFormulaId = this.getters.getPivotFormulaId(pivotId);
58015
- this.dispatch("UPDATE_CELL", {
58016
- sheetId,
58017
- col,
58018
- row,
58019
- content: `=PIVOT(${pivotFormulaId})`,
58020
- });
58021
- const zone = {
58022
- left: col,
58023
- right: col,
58024
- top: row,
58025
- bottom: row,
58026
- };
58027
- const numberOfHeaders = pivotTable.columns.length - 1;
58071
+ let zone;
58072
+ if (mode === "dynamic") {
58073
+ this.dispatch("UPDATE_CELL", {
58074
+ sheetId,
58075
+ col,
58076
+ row,
58077
+ content: `=PIVOT(${pivotFormulaId})`,
58078
+ });
58079
+ zone = {
58080
+ left: col,
58081
+ right: col,
58082
+ top: row,
58083
+ bottom: row,
58084
+ };
58085
+ }
58086
+ else {
58087
+ this.dispatch("INSERT_PIVOT", {
58088
+ sheetId,
58089
+ col,
58090
+ row,
58091
+ pivotId,
58092
+ table: pivotTable.export(),
58093
+ });
58094
+ zone = {
58095
+ left: col,
58096
+ right: col + pivotTable.getNumberOfDataColumns(),
58097
+ top: row,
58098
+ bottom: row + numberOfHeaders + pivotTable.rows.length,
58099
+ };
58100
+ }
58028
58101
  this.dispatch("CREATE_TABLE", {
58029
- tableType: "dynamic",
58102
+ tableType: mode,
58030
58103
  sheetId,
58031
58104
  ranges: [this.getters.getRangeDataFromZone(sheetId, zone)],
58032
58105
  config: { ...PIVOT_TABLE_CONFIG, numberOfHeaders },
@@ -60228,6 +60301,8 @@ stores.inject(MyMetaStore, storeInstance);
60228
60301
  this.selectedFigureId = null;
60229
60302
  break;
60230
60303
  }
60304
+ }
60305
+ finalize() {
60231
60306
  /** Any change to the selection has to be reflected in the selection processor. */
60232
60307
  this.selection.resetDefaultAnchor(this, deepCopy(this.gridSelection.anchor));
60233
60308
  }
@@ -61009,7 +61084,6 @@ stores.inject(MyMetaStore, storeInstance);
61009
61084
  }
61010
61085
  }
61011
61086
  handle(cmd) {
61012
- this.cleanViewports();
61013
61087
  // changing the evaluation can hide/show rows because of data filters
61014
61088
  if (invalidateEvaluationCommands.has(cmd.type)) {
61015
61089
  for (const sheetId of this.getters.getSheetIds()) {
@@ -61025,6 +61099,7 @@ stores.inject(MyMetaStore, storeInstance);
61025
61099
  break;
61026
61100
  case "UNDO":
61027
61101
  case "REDO":
61102
+ this.cleanViewports();
61028
61103
  for (const sheetId of this.getters.getSheetIds()) {
61029
61104
  this.sheetsWithDirtyViewports.add(sheetId);
61030
61105
  }
@@ -61079,6 +61154,9 @@ stores.inject(MyMetaStore, storeInstance);
61079
61154
  }
61080
61155
  }
61081
61156
  break;
61157
+ case "DELETE_SHEET":
61158
+ this.cleanViewports();
61159
+ break;
61082
61160
  case "ACTIVATE_SHEET":
61083
61161
  this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
61084
61162
  break;
@@ -62366,6 +62444,17 @@ stores.inject(MyMetaStore, storeInstance);
62366
62444
  .o-bottom-bar-fade-in {
62367
62445
  background-image: linear-gradient(90deg, #cfcfcf, transparent 1%);
62368
62446
  }
62447
+
62448
+ .o-sheet-list {
62449
+ overflow-y: hidden;
62450
+ overflow-x: auto;
62451
+
62452
+ &::-webkit-scrollbar {
62453
+ display: none; /* Chrome */
62454
+ }
62455
+ -ms-overflow-style: none; /* IE and Edge */
62456
+ scrollbar-width: none; /* Firefox */
62457
+ }
62369
62458
  }
62370
62459
 
62371
62460
  .o-bottom-bar-arrows {
@@ -64339,7 +64428,7 @@ stores.inject(MyMetaStore, storeInstance);
64339
64428
 
64340
64429
  class LocalTransportService {
64341
64430
  listeners = [];
64342
- sendMessage(message) {
64431
+ async sendMessage(message) {
64343
64432
  for (const { callback } of this.listeners) {
64344
64433
  callback(message);
64345
64434
  }
@@ -66432,17 +66521,13 @@ stores.inject(MyMetaStore, storeInstance);
66432
66521
  if (!formula) {
66433
66522
  return { attrs: [], node: escapeXml `` };
66434
66523
  }
66435
- const attrs = [];
66436
- let node = escapeXml ``;
66437
- let cycle = escapeXml ``;
66438
- const XlsxFormula = adaptFormulaToExcel(formula);
66439
- // hack for cycles : if we don't set a value (be it 0 or #VALUE!), it will appear as invisible on excel,
66440
- // Making it very hard for the client to find where the recursion is.
66441
- if (cell.value === CellErrorType.CircularDependency) {
66442
- attrs.push(["t", "str"]);
66443
- cycle = escapeXml /*xml*/ `<v>${cell.value}</v>`;
66524
+ const type = getCellType(cell.value);
66525
+ if (type === undefined) {
66526
+ return { attrs: [], node: escapeXml `` };
66444
66527
  }
66445
- node = escapeXml /*xml*/ `<f>${XlsxFormula}</f>${cycle}`;
66528
+ const attrs = [["t", type]];
66529
+ const XlsxFormula = adaptFormulaToExcel(formula);
66530
+ const node = escapeXml /*xml*/ `<f>${XlsxFormula}</f><v>${cell.value}</v>`;
66446
66531
  return { attrs, node };
66447
66532
  }
66448
66533
  function addContent(content, sharedStrings, forceString = false) {
@@ -67856,8 +67941,8 @@ stores.inject(MyMetaStore, storeInstance);
67856
67941
  joinSession() {
67857
67942
  this.session.join(this.config.client);
67858
67943
  }
67859
- leaveSession() {
67860
- this.session.leave(lazy(() => this.exportData()));
67944
+ async leaveSession() {
67945
+ await this.session.leave(lazy(() => this.exportData()));
67861
67946
  }
67862
67947
  setupUiPlugin(Plugin) {
67863
67948
  const plugin = new Plugin(this.uiPluginConfig);
@@ -68459,9 +68544,9 @@ stores.inject(MyMetaStore, storeInstance);
68459
68544
  exports.tokenize = tokenize;
68460
68545
 
68461
68546
 
68462
- __info__.version = "17.4.6";
68463
- __info__.date = "2024-08-26T13:50:49.623Z";
68464
- __info__.hash = "f5648d9";
68547
+ __info__.version = "17.4.7";
68548
+ __info__.date = "2024-09-05T09:32:00.461Z";
68549
+ __info__.hash = "c14a4c9";
68465
68550
 
68466
68551
 
68467
68552
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);