@odoo/o-spreadsheet 15.2.0 → 15.2.2
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.
- package/dist/{o_spreadsheet.cjs.js → o-spreadsheet.cjs.js} +192 -135
- package/dist/{o_spreadsheet.d.ts → o-spreadsheet.d.ts} +19 -17
- package/dist/{o_spreadsheet.esm.js → o-spreadsheet.esm.js} +192 -135
- package/dist/{o_spreadsheet.iife.js → o-spreadsheet.iife.js} +192 -135
- package/dist/{o_spreadsheet.iife.min.js → o-spreadsheet.iife.min.js} +31 -31
- package/package.json +10 -5
|
@@ -1392,6 +1392,7 @@ exports.CommandResult = void 0;
|
|
|
1392
1392
|
CommandResult[CommandResult["FigureDoesNotExist"] = 55] = "FigureDoesNotExist";
|
|
1393
1393
|
CommandResult[CommandResult["DuplicatedFigureId"] = 56] = "DuplicatedFigureId";
|
|
1394
1394
|
CommandResult[CommandResult["DuplicatedChartId"] = 57] = "DuplicatedChartId";
|
|
1395
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 58] = "ChartDoesNotExist";
|
|
1395
1396
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
1396
1397
|
|
|
1397
1398
|
var ReturnFormatType;
|
|
@@ -3182,6 +3183,9 @@ function isZoneValid(zone) {
|
|
|
3182
3183
|
if (isNaN(zone.bottom) || isNaN(zone.top) || isNaN(zone.left) || isNaN(zone.right)) {
|
|
3183
3184
|
return false;
|
|
3184
3185
|
}
|
|
3186
|
+
if (zone.top < 0 || zone.left < 0 || zone.right < 0 || zone.bottom < 0) {
|
|
3187
|
+
return false;
|
|
3188
|
+
}
|
|
3185
3189
|
return zone.bottom >= zone.top && zone.right >= zone.left;
|
|
3186
3190
|
}
|
|
3187
3191
|
/**
|
|
@@ -8439,13 +8443,7 @@ function load(data) {
|
|
|
8439
8443
|
data = migrate(data);
|
|
8440
8444
|
}
|
|
8441
8445
|
}
|
|
8442
|
-
|
|
8443
|
-
// sensible default values
|
|
8444
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8445
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
8446
|
-
if (data.sheets.length === 0) {
|
|
8447
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8448
|
-
}
|
|
8446
|
+
data = repairData(data);
|
|
8449
8447
|
return data;
|
|
8450
8448
|
}
|
|
8451
8449
|
function migrate(data) {
|
|
@@ -8672,6 +8670,48 @@ const MIGRATIONS = [
|
|
|
8672
8670
|
},
|
|
8673
8671
|
},
|
|
8674
8672
|
];
|
|
8673
|
+
/**
|
|
8674
|
+
* This function is used to repair faulty data independently of the migration.
|
|
8675
|
+
*/
|
|
8676
|
+
function repairData(data) {
|
|
8677
|
+
data = forceUnicityOfFigure(data);
|
|
8678
|
+
data = setDefaults(data);
|
|
8679
|
+
return data;
|
|
8680
|
+
}
|
|
8681
|
+
/**
|
|
8682
|
+
* Force the unicity of figure ids accross sheets
|
|
8683
|
+
*/
|
|
8684
|
+
function forceUnicityOfFigure(data) {
|
|
8685
|
+
if (data.uniqueFigureIds) {
|
|
8686
|
+
return data;
|
|
8687
|
+
}
|
|
8688
|
+
const figureIds = new Set();
|
|
8689
|
+
const uuidGenerator = new UuidGenerator();
|
|
8690
|
+
for (const sheet of data.sheets || []) {
|
|
8691
|
+
for (const figure of sheet.figures || []) {
|
|
8692
|
+
if (figureIds.has(figure.id)) {
|
|
8693
|
+
figure.id += uuidGenerator.uuidv4();
|
|
8694
|
+
}
|
|
8695
|
+
figureIds.add(figure.id);
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
data.uniqueFigureIds = true;
|
|
8699
|
+
return data;
|
|
8700
|
+
}
|
|
8701
|
+
/**
|
|
8702
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
8703
|
+
* sensible default values
|
|
8704
|
+
*/
|
|
8705
|
+
function setDefaults(data) {
|
|
8706
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8707
|
+
data.sheets = data.sheets
|
|
8708
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
8709
|
+
: [];
|
|
8710
|
+
if (data.sheets.length === 0) {
|
|
8711
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8712
|
+
}
|
|
8713
|
+
return data;
|
|
8714
|
+
}
|
|
8675
8715
|
/**
|
|
8676
8716
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
8677
8717
|
* a bug.
|
|
@@ -8759,6 +8799,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
8759
8799
|
formats: {},
|
|
8760
8800
|
borders: {},
|
|
8761
8801
|
revisionId: DEFAULT_REVISION_ID,
|
|
8802
|
+
uniqueFigureIds: true,
|
|
8762
8803
|
};
|
|
8763
8804
|
return data;
|
|
8764
8805
|
}
|
|
@@ -9799,34 +9840,32 @@ class ChartPlugin extends CorePlugin {
|
|
|
9799
9840
|
this.chartFigures = {};
|
|
9800
9841
|
}
|
|
9801
9842
|
adaptRanges(applyChange) {
|
|
9802
|
-
for (
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
this.adaptLabelRanges(sheetId, chart, chartId, applyChange);
|
|
9807
|
-
}
|
|
9843
|
+
for (let [chartId, chart] of Object.entries(this.chartFigures)) {
|
|
9844
|
+
if (chart) {
|
|
9845
|
+
this.adaptDataSetRanges(chart, chartId, applyChange);
|
|
9846
|
+
this.adaptLabelRanges(chart, chartId, applyChange);
|
|
9808
9847
|
}
|
|
9809
9848
|
}
|
|
9810
9849
|
}
|
|
9811
|
-
adaptDataSetRanges(
|
|
9850
|
+
adaptDataSetRanges(chart, chartId, applyChange) {
|
|
9812
9851
|
for (let ds of chart.dataSets) {
|
|
9813
9852
|
if (ds.labelCell) {
|
|
9814
9853
|
const labelCellChange = applyChange(ds.labelCell);
|
|
9815
9854
|
switch (labelCellChange.changeType) {
|
|
9816
9855
|
case "REMOVE":
|
|
9817
|
-
this.history.update("chartFigures",
|
|
9856
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", undefined);
|
|
9818
9857
|
break;
|
|
9819
9858
|
case "RESIZE":
|
|
9820
9859
|
case "MOVE":
|
|
9821
9860
|
case "CHANGE":
|
|
9822
|
-
this.history.update("chartFigures",
|
|
9861
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", labelCellChange.range);
|
|
9823
9862
|
}
|
|
9824
9863
|
}
|
|
9825
9864
|
const dataRangeChange = applyChange(ds.dataRange);
|
|
9826
9865
|
switch (dataRangeChange.changeType) {
|
|
9827
9866
|
case "REMOVE":
|
|
9828
9867
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9829
|
-
this.history.update("chartFigures",
|
|
9868
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9830
9869
|
break;
|
|
9831
9870
|
case "RESIZE":
|
|
9832
9871
|
case "MOVE":
|
|
@@ -9834,27 +9873,27 @@ class ChartPlugin extends CorePlugin {
|
|
|
9834
9873
|
// We have to remove the ranges that are #REF
|
|
9835
9874
|
if (this.getters.getRangeString(dataRangeChange.range, dataRangeChange.range.sheetId) !==
|
|
9836
9875
|
INCORRECT_RANGE_STRING) {
|
|
9837
|
-
this.history.update("chartFigures",
|
|
9876
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "dataRange", dataRangeChange.range);
|
|
9838
9877
|
}
|
|
9839
9878
|
else {
|
|
9840
9879
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9841
|
-
this.history.update("chartFigures",
|
|
9880
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9842
9881
|
}
|
|
9843
9882
|
break;
|
|
9844
9883
|
}
|
|
9845
9884
|
}
|
|
9846
9885
|
}
|
|
9847
|
-
adaptLabelRanges(
|
|
9886
|
+
adaptLabelRanges(chart, chartId, applyChange) {
|
|
9848
9887
|
if (chart.labelRange) {
|
|
9849
9888
|
const labelRangeChange = applyChange(chart.labelRange);
|
|
9850
9889
|
switch (labelRangeChange.changeType) {
|
|
9851
9890
|
case "REMOVE":
|
|
9852
|
-
this.history.update("chartFigures",
|
|
9891
|
+
this.history.update("chartFigures", chartId, "labelRange", undefined);
|
|
9853
9892
|
break;
|
|
9854
9893
|
case "RESIZE":
|
|
9855
9894
|
case "MOVE":
|
|
9856
9895
|
case "CHANGE":
|
|
9857
|
-
this.history.update("chartFigures",
|
|
9896
|
+
this.history.update("chartFigures", chartId, "labelRange", labelRangeChange.range);
|
|
9858
9897
|
break;
|
|
9859
9898
|
}
|
|
9860
9899
|
}
|
|
@@ -9865,16 +9904,16 @@ class ChartPlugin extends CorePlugin {
|
|
|
9865
9904
|
allowDispatch(cmd) {
|
|
9866
9905
|
const success = 0 /* Success */;
|
|
9867
9906
|
switch (cmd.type) {
|
|
9868
|
-
case "CREATE_CHART":
|
|
9869
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkChartDuplicate, this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9870
9907
|
case "UPDATE_CHART":
|
|
9871
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9908
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartExists), this.checkLabelRange);
|
|
9909
|
+
case "CREATE_CHART":
|
|
9910
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartDuplicate), this.checkLabelRange);
|
|
9872
9911
|
default:
|
|
9873
9912
|
return success;
|
|
9874
9913
|
}
|
|
9875
9914
|
}
|
|
9876
9915
|
handle(cmd) {
|
|
9877
|
-
var _a;
|
|
9916
|
+
var _a, _b;
|
|
9878
9917
|
switch (cmd.type) {
|
|
9879
9918
|
case "CREATE_CHART":
|
|
9880
9919
|
const x = cmd.position ? cmd.position.x : 0;
|
|
@@ -9889,7 +9928,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
9889
9928
|
});
|
|
9890
9929
|
break;
|
|
9891
9930
|
case "UPDATE_CHART": {
|
|
9892
|
-
this.updateChartDefinition(cmd.
|
|
9931
|
+
this.updateChartDefinition(cmd.id, cmd.definition);
|
|
9893
9932
|
break;
|
|
9894
9933
|
}
|
|
9895
9934
|
case "DUPLICATE_SHEET": {
|
|
@@ -9899,7 +9938,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
9899
9938
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
9900
9939
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
9901
9940
|
const chartDefinition = {
|
|
9902
|
-
...deepCopy(this.chartFigures[
|
|
9941
|
+
...deepCopy(this.chartFigures[fig.id]),
|
|
9903
9942
|
id: duplicatedFigureId,
|
|
9904
9943
|
};
|
|
9905
9944
|
chartDefinition.sheetId = cmd.sheetIdTo;
|
|
@@ -9929,28 +9968,37 @@ class ChartPlugin extends CorePlugin {
|
|
|
9929
9968
|
break;
|
|
9930
9969
|
}
|
|
9931
9970
|
case "DELETE_FIGURE":
|
|
9932
|
-
this.history.update("chartFigures", cmd.
|
|
9971
|
+
this.history.update("chartFigures", cmd.id, undefined);
|
|
9933
9972
|
break;
|
|
9934
9973
|
case "DELETE_SHEET":
|
|
9935
|
-
this.
|
|
9974
|
+
for (let id of Object.keys(this.chartFigures)) {
|
|
9975
|
+
if (((_b = this.chartFigures[id]) === null || _b === void 0 ? void 0 : _b.sheetId) === cmd.sheetId) {
|
|
9976
|
+
this.history.update("chartFigures", id, undefined);
|
|
9977
|
+
}
|
|
9978
|
+
}
|
|
9936
9979
|
break;
|
|
9937
9980
|
}
|
|
9938
9981
|
}
|
|
9939
9982
|
// ---------------------------------------------------------------------------
|
|
9940
9983
|
// Getters
|
|
9941
9984
|
// ---------------------------------------------------------------------------
|
|
9942
|
-
getChartDefinition(
|
|
9943
|
-
|
|
9944
|
-
return (_a = this.chartFigures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
9985
|
+
getChartDefinition(figureId) {
|
|
9986
|
+
return this.chartFigures[figureId];
|
|
9945
9987
|
}
|
|
9946
|
-
|
|
9947
|
-
return Object.
|
|
9988
|
+
getChartsIdBySheet(sheetId) {
|
|
9989
|
+
return Object.entries(this.chartFigures)
|
|
9990
|
+
.filter((chart) => {
|
|
9991
|
+
return chart[1].sheetId === sheetId;
|
|
9992
|
+
})
|
|
9993
|
+
.map((chart) => chart[0]);
|
|
9948
9994
|
}
|
|
9949
|
-
getChartDefinitionUI(sheetId, figureId
|
|
9950
|
-
const data = this.chartFigures[
|
|
9951
|
-
|
|
9995
|
+
getChartDefinitionUI(sheetId, figureId) {
|
|
9996
|
+
const data = this.chartFigures[figureId];
|
|
9997
|
+
if (!data) {
|
|
9998
|
+
return undefined;
|
|
9999
|
+
}
|
|
9952
10000
|
const dataSets = data.dataSets
|
|
9953
|
-
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange,
|
|
10001
|
+
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange, sheetId) : ""))
|
|
9954
10002
|
.filter((ds) => {
|
|
9955
10003
|
return ds !== ""; // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9956
10004
|
});
|
|
@@ -9958,7 +10006,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
9958
10006
|
title: data && data.title ? data.title : "",
|
|
9959
10007
|
dataSets,
|
|
9960
10008
|
labelRange: data.labelRange
|
|
9961
|
-
? this.getters.getRangeString(data.labelRange,
|
|
10009
|
+
? this.getters.getRangeString(data.labelRange, sheetId)
|
|
9962
10010
|
: undefined,
|
|
9963
10011
|
type: data ? data.type : "bar",
|
|
9964
10012
|
dataSetsHaveTitle: data && dataSets.length !== 0 ? Boolean(data.dataSets[0].labelCell) : false,
|
|
@@ -9969,12 +10017,16 @@ class ChartPlugin extends CorePlugin {
|
|
|
9969
10017
|
};
|
|
9970
10018
|
}
|
|
9971
10019
|
getChartDefinitionExcel(sheetId, figureId) {
|
|
9972
|
-
const data = this.chartFigures[
|
|
10020
|
+
const data = this.chartFigures[figureId];
|
|
10021
|
+
const dataUI = this.getChartDefinitionUI("forceSheetReference", figureId);
|
|
10022
|
+
if (!data || !dataUI) {
|
|
10023
|
+
return undefined;
|
|
10024
|
+
}
|
|
9973
10025
|
const dataSets = data.dataSets
|
|
9974
10026
|
.map((ds) => this.toExcelDataset(ds))
|
|
9975
10027
|
.filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9976
10028
|
return {
|
|
9977
|
-
...
|
|
10029
|
+
...dataUI,
|
|
9978
10030
|
backgroundColor: data.background,
|
|
9979
10031
|
dataSets,
|
|
9980
10032
|
};
|
|
@@ -10009,17 +10061,15 @@ class ChartPlugin extends CorePlugin {
|
|
|
10009
10061
|
import(data) {
|
|
10010
10062
|
for (let sheet of data.sheets) {
|
|
10011
10063
|
if (sheet.figures) {
|
|
10012
|
-
const charts = {};
|
|
10013
10064
|
for (let figure of sheet.figures) {
|
|
10014
10065
|
if (figure.tag === "chart") {
|
|
10015
10066
|
const figureData = {
|
|
10016
10067
|
...figure.data,
|
|
10017
10068
|
};
|
|
10018
|
-
|
|
10069
|
+
this.chartFigures[figure.id] = this.createChartDefinition(figureData, sheet.id);
|
|
10019
10070
|
delete figure.data;
|
|
10020
10071
|
}
|
|
10021
10072
|
}
|
|
10022
|
-
this.chartFigures[sheet.id] = charts;
|
|
10023
10073
|
}
|
|
10024
10074
|
}
|
|
10025
10075
|
}
|
|
@@ -10027,10 +10077,18 @@ class ChartPlugin extends CorePlugin {
|
|
|
10027
10077
|
if (data.sheets) {
|
|
10028
10078
|
for (let sheet of data.sheets) {
|
|
10029
10079
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10030
|
-
const figures =
|
|
10031
|
-
for (let
|
|
10080
|
+
const figures = [];
|
|
10081
|
+
for (let sheetFigure of sheetFigures) {
|
|
10082
|
+
const figure = sheetFigure;
|
|
10032
10083
|
if (figure && figure.tag === "chart") {
|
|
10033
|
-
|
|
10084
|
+
const data = this.getChartDefinitionUI(sheet.id, figure.id);
|
|
10085
|
+
if (data) {
|
|
10086
|
+
figure.data = data;
|
|
10087
|
+
figures.push(figure);
|
|
10088
|
+
}
|
|
10089
|
+
}
|
|
10090
|
+
else {
|
|
10091
|
+
figures.push(figure);
|
|
10034
10092
|
}
|
|
10035
10093
|
}
|
|
10036
10094
|
sheet.figures = figures;
|
|
@@ -10040,10 +10098,18 @@ class ChartPlugin extends CorePlugin {
|
|
|
10040
10098
|
exportForExcel(data) {
|
|
10041
10099
|
for (let sheet of data.sheets) {
|
|
10042
10100
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10043
|
-
const figures =
|
|
10044
|
-
for (let
|
|
10101
|
+
const figures = [];
|
|
10102
|
+
for (let sheetFigure of sheetFigures) {
|
|
10103
|
+
const figure = sheetFigure;
|
|
10045
10104
|
if (figure && figure.tag === "chart") {
|
|
10046
|
-
|
|
10105
|
+
const data = this.getChartDefinitionExcel(sheet.id, figure.id);
|
|
10106
|
+
if (data) {
|
|
10107
|
+
figure.data = data;
|
|
10108
|
+
figures.push(figure);
|
|
10109
|
+
}
|
|
10110
|
+
}
|
|
10111
|
+
else {
|
|
10112
|
+
figures.push(figure);
|
|
10047
10113
|
}
|
|
10048
10114
|
}
|
|
10049
10115
|
sheet.charts = figures;
|
|
@@ -10069,39 +10135,39 @@ class ChartPlugin extends CorePlugin {
|
|
|
10069
10135
|
* Update the chart definition linked to the given id with the attributes
|
|
10070
10136
|
* given in the partial UI definition
|
|
10071
10137
|
*/
|
|
10072
|
-
updateChartDefinition(
|
|
10073
|
-
const chart = this.chartFigures[
|
|
10138
|
+
updateChartDefinition(id, definition) {
|
|
10139
|
+
const chart = this.chartFigures[id];
|
|
10074
10140
|
if (!chart) {
|
|
10075
10141
|
throw new Error(`There is no chart with the given id: ${id}`);
|
|
10076
10142
|
}
|
|
10077
10143
|
if (definition.title !== undefined) {
|
|
10078
|
-
this.history.update("chartFigures",
|
|
10144
|
+
this.history.update("chartFigures", id, "title", definition.title);
|
|
10079
10145
|
}
|
|
10080
10146
|
if (definition.type) {
|
|
10081
|
-
this.history.update("chartFigures",
|
|
10147
|
+
this.history.update("chartFigures", id, "type", definition.type);
|
|
10082
10148
|
}
|
|
10083
10149
|
if (definition.dataSets) {
|
|
10084
10150
|
const dataSetsHaveTitle = !!definition.dataSetsHaveTitle;
|
|
10085
10151
|
const dataSets = this.createDataSets(definition.dataSets, chart.sheetId, dataSetsHaveTitle);
|
|
10086
|
-
this.history.update("chartFigures",
|
|
10152
|
+
this.history.update("chartFigures", id, "dataSets", dataSets);
|
|
10087
10153
|
}
|
|
10088
10154
|
if (definition.labelRange !== undefined) {
|
|
10089
10155
|
const labelRange = definition.labelRange
|
|
10090
10156
|
? this.getters.getRangeFromSheetXC(chart.sheetId, definition.labelRange)
|
|
10091
10157
|
: undefined;
|
|
10092
|
-
this.history.update("chartFigures",
|
|
10158
|
+
this.history.update("chartFigures", id, "labelRange", labelRange);
|
|
10093
10159
|
}
|
|
10094
10160
|
if (definition.background) {
|
|
10095
|
-
this.history.update("chartFigures",
|
|
10161
|
+
this.history.update("chartFigures", id, "background", definition.background);
|
|
10096
10162
|
}
|
|
10097
10163
|
if (definition.verticalAxisPosition) {
|
|
10098
|
-
this.history.update("chartFigures",
|
|
10164
|
+
this.history.update("chartFigures", id, "verticalAxisPosition", definition.verticalAxisPosition);
|
|
10099
10165
|
}
|
|
10100
10166
|
if (definition.legendPosition) {
|
|
10101
|
-
this.history.update("chartFigures",
|
|
10167
|
+
this.history.update("chartFigures", id, "legendPosition", definition.legendPosition);
|
|
10102
10168
|
}
|
|
10103
10169
|
if (definition.stackedBar !== undefined) {
|
|
10104
|
-
this.history.update("chartFigures",
|
|
10170
|
+
this.history.update("chartFigures", id, "stackedBar", definition.stackedBar);
|
|
10105
10171
|
}
|
|
10106
10172
|
}
|
|
10107
10173
|
createDataSets(dataSetsString, sheetId, dataSetsHaveTitle) {
|
|
@@ -10156,7 +10222,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
10156
10222
|
sheetId,
|
|
10157
10223
|
figure,
|
|
10158
10224
|
});
|
|
10159
|
-
this.history.update("chartFigures",
|
|
10225
|
+
this.history.update("chartFigures", figure.id, data);
|
|
10160
10226
|
}
|
|
10161
10227
|
createDataSet(sheetId, fullZone, titleZone) {
|
|
10162
10228
|
if (fullZone.left !== fullZone.right && fullZone.top !== fullZone.bottom) {
|
|
@@ -10197,18 +10263,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
10197
10263
|
return invalidLabels ? 29 /* InvalidLabelRange */ : 0 /* Success */;
|
|
10198
10264
|
}
|
|
10199
10265
|
checkChartDuplicate(cmd) {
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10266
|
+
for (const sheet of this.getters.getSheets()) {
|
|
10267
|
+
if (this.getters.getFigure(sheet.id, cmd.id)) {
|
|
10268
|
+
return 57 /* DuplicatedChartId */;
|
|
10269
|
+
}
|
|
10203
10270
|
}
|
|
10204
10271
|
return 0 /* Success */;
|
|
10205
10272
|
}
|
|
10273
|
+
checkChartExists(cmd) {
|
|
10274
|
+
return this.getters.getFigure(cmd.sheetId, cmd.id)
|
|
10275
|
+
? 0 /* Success */
|
|
10276
|
+
: 58 /* ChartDoesNotExist */;
|
|
10277
|
+
}
|
|
10206
10278
|
}
|
|
10207
|
-
ChartPlugin.getters = [
|
|
10208
|
-
"getChartDefinition",
|
|
10209
|
-
"getChartDefinitionUI",
|
|
10210
|
-
"getChartDefinitionsBySheet",
|
|
10211
|
-
];
|
|
10279
|
+
ChartPlugin.getters = ["getChartDefinition", "getChartDefinitionUI", "getChartsIdBySheet"];
|
|
10212
10280
|
|
|
10213
10281
|
// -----------------------------------------------------------------------------
|
|
10214
10282
|
// Constants
|
|
@@ -10547,7 +10615,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
10547
10615
|
allowDispatch(cmd) {
|
|
10548
10616
|
switch (cmd.type) {
|
|
10549
10617
|
case "CREATE_FIGURE":
|
|
10550
|
-
return this.checkFigureDuplicate(cmd.
|
|
10618
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
10551
10619
|
case "UPDATE_FIGURE":
|
|
10552
10620
|
case "DELETE_FIGURE":
|
|
10553
10621
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -10613,9 +10681,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
10613
10681
|
}
|
|
10614
10682
|
return 0 /* Success */;
|
|
10615
10683
|
}
|
|
10616
|
-
checkFigureDuplicate(
|
|
10617
|
-
|
|
10618
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
10684
|
+
checkFigureDuplicate(figureId) {
|
|
10685
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
10619
10686
|
return 56 /* DuplicatedFigureId */;
|
|
10620
10687
|
}
|
|
10621
10688
|
return 0 /* Success */;
|
|
@@ -10630,6 +10697,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
10630
10697
|
var _a;
|
|
10631
10698
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
10632
10699
|
}
|
|
10700
|
+
getFigureSheetId(figureId) {
|
|
10701
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
10702
|
+
}
|
|
10633
10703
|
// ---------------------------------------------------------------------------
|
|
10634
10704
|
// Import/Export
|
|
10635
10705
|
// ---------------------------------------------------------------------------
|
|
@@ -10654,7 +10724,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
10654
10724
|
this.export(data);
|
|
10655
10725
|
}
|
|
10656
10726
|
}
|
|
10657
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
10727
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
10658
10728
|
|
|
10659
10729
|
class MergePlugin extends CorePlugin {
|
|
10660
10730
|
constructor() {
|
|
@@ -12957,7 +13027,7 @@ const CREATE_CHART = (env) => {
|
|
|
12957
13027
|
},
|
|
12958
13028
|
});
|
|
12959
13029
|
const figure = env.getters.getFigure(sheetId, id);
|
|
12960
|
-
env.openSidePanel("ChartPanel", {
|
|
13030
|
+
env.openSidePanel("ChartPanel", { figure });
|
|
12961
13031
|
};
|
|
12962
13032
|
//------------------------------------------------------------------------------
|
|
12963
13033
|
// Style/Format
|
|
@@ -14470,15 +14540,17 @@ class ChartPanel extends owl.Component {
|
|
|
14470
14540
|
constructor() {
|
|
14471
14541
|
super(...arguments);
|
|
14472
14542
|
this.getters = this.env.getters;
|
|
14543
|
+
this.chartSheetId = this.findSheetId(this.props.figure.id);
|
|
14473
14544
|
this.state = owl.useState(this.initialState(this.props.figure));
|
|
14474
14545
|
}
|
|
14475
14546
|
setup() {
|
|
14476
14547
|
onWillUpdateProps$6((nextProps) => {
|
|
14477
|
-
if (!this.getters.getChartDefinition(nextProps.
|
|
14548
|
+
if (!this.getters.getChartDefinition(nextProps.figure.id)) {
|
|
14478
14549
|
this.props.onCloseSidePanel();
|
|
14479
14550
|
return;
|
|
14480
14551
|
}
|
|
14481
14552
|
if (nextProps.figure.id !== this.props.figure.id) {
|
|
14553
|
+
this.chartSheetId = this.findSheetId(nextProps.figure.id);
|
|
14482
14554
|
this.state.panel = "configuration";
|
|
14483
14555
|
this.state.fillColorTool = false;
|
|
14484
14556
|
this.state.datasetDispatchResult = undefined;
|
|
@@ -14531,7 +14603,7 @@ class ChartPanel extends owl.Component {
|
|
|
14531
14603
|
updateChart(definition) {
|
|
14532
14604
|
return this.env.dispatch("UPDATE_CHART", {
|
|
14533
14605
|
id: this.props.figure.id,
|
|
14534
|
-
sheetId: this.
|
|
14606
|
+
sheetId: this.chartSheetId,
|
|
14535
14607
|
definition,
|
|
14536
14608
|
});
|
|
14537
14609
|
}
|
|
@@ -14553,12 +14625,16 @@ class ChartPanel extends owl.Component {
|
|
|
14553
14625
|
this.state.panel = panel;
|
|
14554
14626
|
}
|
|
14555
14627
|
initialState(figure) {
|
|
14628
|
+
const sheetId = this.findSheetId(figure.id);
|
|
14556
14629
|
return {
|
|
14557
|
-
chart: this.env.getters.getChartDefinitionUI(
|
|
14630
|
+
chart: this.env.getters.getChartDefinitionUI(sheetId, figure.id),
|
|
14558
14631
|
panel: "configuration",
|
|
14559
14632
|
fillColorTool: false,
|
|
14560
14633
|
};
|
|
14561
14634
|
}
|
|
14635
|
+
findSheetId(figureId) {
|
|
14636
|
+
return this.env.getters.getFigureSheetId(figureId) || "";
|
|
14637
|
+
}
|
|
14562
14638
|
}
|
|
14563
14639
|
ChartPanel.template = TEMPLATE$m;
|
|
14564
14640
|
ChartPanel.style = STYLE;
|
|
@@ -18874,60 +18950,51 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
18874
18950
|
this.outOfDate = new Set();
|
|
18875
18951
|
}
|
|
18876
18952
|
handle(cmd) {
|
|
18877
|
-
var _a;
|
|
18878
18953
|
if (invalidateEvaluationCommands.has(cmd.type) ||
|
|
18879
18954
|
cmd.type === "EVALUATE_CELLS" ||
|
|
18880
18955
|
(cmd.type === "UPDATE_CELL" && "content" in cmd)) {
|
|
18881
|
-
for (
|
|
18882
|
-
|
|
18883
|
-
this.outOfDate.add(chartId);
|
|
18884
|
-
}
|
|
18956
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18957
|
+
this.outOfDate.add(chartId);
|
|
18885
18958
|
}
|
|
18886
18959
|
}
|
|
18887
18960
|
switch (cmd.type) {
|
|
18888
18961
|
case "UPDATE_CHART":
|
|
18889
|
-
case "CREATE_CHART":
|
|
18890
|
-
const chartDefinition = this.getters.getChartDefinition(cmd.
|
|
18891
|
-
|
|
18892
|
-
this.chartRuntime[cmd.sheetId] = {};
|
|
18893
|
-
this.chartRuntime[cmd.sheetId][cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18962
|
+
case "CREATE_CHART":
|
|
18963
|
+
const chartDefinition = this.getters.getChartDefinition(cmd.id);
|
|
18964
|
+
this.chartRuntime[cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18894
18965
|
break;
|
|
18895
|
-
}
|
|
18896
18966
|
case "DELETE_FIGURE":
|
|
18897
|
-
|
|
18967
|
+
delete this.chartRuntime[cmd.id];
|
|
18898
18968
|
break;
|
|
18899
|
-
case "REFRESH_CHART":
|
|
18900
|
-
|
|
18901
|
-
this.evaluateUsedSheets([chartDefinition]);
|
|
18969
|
+
case "REFRESH_CHART":
|
|
18970
|
+
this.evaluateUsedSheets([cmd.id]);
|
|
18902
18971
|
this.outOfDate.add(cmd.id);
|
|
18903
18972
|
break;
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
this.evaluateUsedSheets(chartsDefinitions);
|
|
18973
|
+
case "ACTIVATE_SHEET":
|
|
18974
|
+
const chartsIds = this.getters.getChartsIdBySheet(cmd.sheetIdTo);
|
|
18975
|
+
this.evaluateUsedSheets(chartsIds);
|
|
18908
18976
|
break;
|
|
18909
|
-
}
|
|
18910
18977
|
case "DELETE_SHEET":
|
|
18911
|
-
|
|
18978
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18979
|
+
if (!this.getters.getChartDefinition(chartId)) {
|
|
18980
|
+
delete this.chartRuntime[chartId];
|
|
18981
|
+
}
|
|
18982
|
+
}
|
|
18912
18983
|
break;
|
|
18913
18984
|
}
|
|
18914
18985
|
}
|
|
18915
18986
|
// ---------------------------------------------------------------------------
|
|
18916
18987
|
// Getters
|
|
18917
18988
|
// ---------------------------------------------------------------------------
|
|
18918
|
-
getChartRuntime(
|
|
18919
|
-
if (this.outOfDate.has(figureId) ||
|
|
18920
|
-
|
|
18921
|
-
!(figureId in this.chartRuntime[sheetId])) {
|
|
18922
|
-
const chartDefinition = this.getters.getChartDefinition(sheetId, figureId);
|
|
18989
|
+
getChartRuntime(figureId) {
|
|
18990
|
+
if (this.outOfDate.has(figureId) || !(figureId in this.chartRuntime)) {
|
|
18991
|
+
const chartDefinition = this.getters.getChartDefinition(figureId);
|
|
18923
18992
|
if (chartDefinition === undefined)
|
|
18924
18993
|
return;
|
|
18925
|
-
|
|
18926
|
-
this.chartRuntime[sheetId] = {};
|
|
18927
|
-
this.chartRuntime[sheetId][figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18994
|
+
this.chartRuntime[figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18928
18995
|
this.outOfDate.delete(figureId);
|
|
18929
18996
|
}
|
|
18930
|
-
return this.chartRuntime[
|
|
18997
|
+
return this.chartRuntime[figureId];
|
|
18931
18998
|
}
|
|
18932
18999
|
truncateLabel(label) {
|
|
18933
19000
|
if (!label) {
|
|
@@ -19032,9 +19099,10 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
19032
19099
|
}
|
|
19033
19100
|
return sheetIds;
|
|
19034
19101
|
}
|
|
19035
|
-
evaluateUsedSheets(
|
|
19102
|
+
evaluateUsedSheets(chartsIds) {
|
|
19036
19103
|
const usedSheetsId = new Set();
|
|
19037
|
-
for (
|
|
19104
|
+
for (let chartId of chartsIds) {
|
|
19105
|
+
const chartDefinition = this.getters.getChartDefinition(chartId);
|
|
19038
19106
|
const sheetsIds = chartDefinition !== undefined ? this.getSheetIdsUsedInChart(chartDefinition) : [];
|
|
19039
19107
|
sheetsIds.forEach((sheetId) => {
|
|
19040
19108
|
if (sheetId !== this.getters.getActiveSheetId()) {
|
|
@@ -23444,6 +23512,7 @@ class RangeAdapter {
|
|
|
23444
23512
|
}
|
|
23445
23513
|
else if (range.zone[start] >= min && range.zone[end] <= max) {
|
|
23446
23514
|
changeType = "REMOVE";
|
|
23515
|
+
newRange = this.buildInvalidRange(INCORRECT_RANGE_STRING);
|
|
23447
23516
|
}
|
|
23448
23517
|
else if (range.zone[start] <= max && range.zone[end] >= max) {
|
|
23449
23518
|
const toRemove = max - range.zone[start] + 1;
|
|
@@ -23509,10 +23578,8 @@ class RangeAdapter {
|
|
|
23509
23578
|
return { changeType: "NONE" };
|
|
23510
23579
|
}
|
|
23511
23580
|
range = {
|
|
23512
|
-
...
|
|
23513
|
-
zone: { ...range.zone },
|
|
23581
|
+
...this.buildInvalidRange(INCORRECT_RANGE_STRING),
|
|
23514
23582
|
invalidSheetName: this.getters.getSheetName(cmd.sheetId),
|
|
23515
|
-
sheetId: "",
|
|
23516
23583
|
};
|
|
23517
23584
|
return { changeType: "REMOVE", range };
|
|
23518
23585
|
}, cmd.sheetId);
|
|
@@ -27821,7 +27888,7 @@ class ChartFigure extends owl.Component {
|
|
|
27821
27888
|
setup() {
|
|
27822
27889
|
onMounted$4(() => {
|
|
27823
27890
|
const figure = this.props.figure;
|
|
27824
|
-
const chartData = this.env.getters.getChartRuntime(
|
|
27891
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27825
27892
|
if (chartData) {
|
|
27826
27893
|
this.createChart(chartData);
|
|
27827
27894
|
}
|
|
@@ -27829,8 +27896,7 @@ class ChartFigure extends owl.Component {
|
|
|
27829
27896
|
onPatched$1(() => {
|
|
27830
27897
|
var _a, _b, _c;
|
|
27831
27898
|
const figure = this.props.figure;
|
|
27832
|
-
const
|
|
27833
|
-
const chartData = this.env.getters.getChartRuntime(sheetId, figure.id);
|
|
27899
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27834
27900
|
if (chartData) {
|
|
27835
27901
|
if (chartData.type !== this.chart.config.type) {
|
|
27836
27902
|
// Updating a chart type requires to update its options accordingly, if feasible at all.
|
|
@@ -27856,7 +27922,7 @@ class ChartFigure extends owl.Component {
|
|
|
27856
27922
|
else {
|
|
27857
27923
|
this.chart && this.chart.destroy();
|
|
27858
27924
|
}
|
|
27859
|
-
const def = this.env.getters.getChartDefinition(
|
|
27925
|
+
const def = this.env.getters.getChartDefinition(figure.id);
|
|
27860
27926
|
if (def) {
|
|
27861
27927
|
this.state.background = def.background;
|
|
27862
27928
|
}
|
|
@@ -27866,7 +27932,7 @@ class ChartFigure extends owl.Component {
|
|
|
27866
27932
|
const canvas = this.canvas.el;
|
|
27867
27933
|
const ctx = canvas.getContext("2d");
|
|
27868
27934
|
this.chart = new window.Chart(ctx, chartData);
|
|
27869
|
-
const def = this.env.getters.getChartDefinition(this.
|
|
27935
|
+
const def = this.env.getters.getChartDefinition(this.props.figure.id);
|
|
27870
27936
|
if (def) {
|
|
27871
27937
|
this.state.background = def.background;
|
|
27872
27938
|
}
|
|
@@ -27876,10 +27942,8 @@ class ChartFigure extends owl.Component {
|
|
|
27876
27942
|
registry.add("edit", {
|
|
27877
27943
|
name: _lt("Edit"),
|
|
27878
27944
|
sequence: 1,
|
|
27879
|
-
action: () => this.env.openSidePanel("ChartPanel", {
|
|
27880
|
-
|
|
27881
|
-
figure: this.props.figure,
|
|
27882
|
-
}),
|
|
27945
|
+
action: () => this.env.openSidePanel("ChartPanel", { figure: this.props.figure }),
|
|
27946
|
+
isVisible: () => !!this.env.getters.getChartDefinition(this.props.figure.id),
|
|
27883
27947
|
});
|
|
27884
27948
|
registry.add("delete", {
|
|
27885
27949
|
name: _lt("Delete"),
|
|
@@ -27890,10 +27954,7 @@ class ChartFigure extends owl.Component {
|
|
|
27890
27954
|
id: this.props.figure.id,
|
|
27891
27955
|
});
|
|
27892
27956
|
if (this.props.sidePanelIsOpen) {
|
|
27893
|
-
this.env.toggleSidePanel("ChartPanel", {
|
|
27894
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27895
|
-
figure: this.props.figure,
|
|
27896
|
-
});
|
|
27957
|
+
this.env.toggleSidePanel("ChartPanel", { figure: this.props.figure });
|
|
27897
27958
|
}
|
|
27898
27959
|
this.props.onFigureDeleted();
|
|
27899
27960
|
},
|
|
@@ -27903,7 +27964,6 @@ class ChartFigure extends owl.Component {
|
|
|
27903
27964
|
sequence: 11,
|
|
27904
27965
|
action: () => {
|
|
27905
27966
|
this.env.dispatch("REFRESH_CHART", {
|
|
27906
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27907
27967
|
id: this.props.figure.id,
|
|
27908
27968
|
});
|
|
27909
27969
|
},
|
|
@@ -28151,10 +28211,7 @@ class FiguresContainer extends owl.Component {
|
|
|
28151
28211
|
return;
|
|
28152
28212
|
}
|
|
28153
28213
|
if (this.props.sidePanelIsOpen) {
|
|
28154
|
-
this.env.openSidePanel("ChartPanel", {
|
|
28155
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
28156
|
-
figure,
|
|
28157
|
-
});
|
|
28214
|
+
this.env.openSidePanel("ChartPanel", { figure });
|
|
28158
28215
|
}
|
|
28159
28216
|
const initialX = ev.clientX;
|
|
28160
28217
|
const initialY = ev.clientY;
|
|
@@ -31234,6 +31291,6 @@ exports.registries = registries;
|
|
|
31234
31291
|
exports.setTranslationMethod = setTranslationMethod;
|
|
31235
31292
|
|
|
31236
31293
|
|
|
31237
|
-
__info__.version = '15.2.
|
|
31238
|
-
__info__.date = '2023-
|
|
31239
|
-
__info__.hash = '
|
|
31294
|
+
__info__.version = '15.2.2';
|
|
31295
|
+
__info__.date = '2023-03-14T09:19:31.079Z';
|
|
31296
|
+
__info__.hash = 'a3fcdb7';
|