@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
|
@@ -1369,6 +1369,7 @@ var CommandResult;
|
|
|
1369
1369
|
CommandResult[CommandResult["FigureDoesNotExist"] = 55] = "FigureDoesNotExist";
|
|
1370
1370
|
CommandResult[CommandResult["DuplicatedFigureId"] = 56] = "DuplicatedFigureId";
|
|
1371
1371
|
CommandResult[CommandResult["DuplicatedChartId"] = 57] = "DuplicatedChartId";
|
|
1372
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 58] = "ChartDoesNotExist";
|
|
1372
1373
|
})(CommandResult || (CommandResult = {}));
|
|
1373
1374
|
|
|
1374
1375
|
var ReturnFormatType;
|
|
@@ -3159,6 +3160,9 @@ function isZoneValid(zone) {
|
|
|
3159
3160
|
if (isNaN(zone.bottom) || isNaN(zone.top) || isNaN(zone.left) || isNaN(zone.right)) {
|
|
3160
3161
|
return false;
|
|
3161
3162
|
}
|
|
3163
|
+
if (zone.top < 0 || zone.left < 0 || zone.right < 0 || zone.bottom < 0) {
|
|
3164
|
+
return false;
|
|
3165
|
+
}
|
|
3162
3166
|
return zone.bottom >= zone.top && zone.right >= zone.left;
|
|
3163
3167
|
}
|
|
3164
3168
|
/**
|
|
@@ -8416,13 +8420,7 @@ function load(data) {
|
|
|
8416
8420
|
data = migrate(data);
|
|
8417
8421
|
}
|
|
8418
8422
|
}
|
|
8419
|
-
|
|
8420
|
-
// sensible default values
|
|
8421
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8422
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
8423
|
-
if (data.sheets.length === 0) {
|
|
8424
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8425
|
-
}
|
|
8423
|
+
data = repairData(data);
|
|
8426
8424
|
return data;
|
|
8427
8425
|
}
|
|
8428
8426
|
function migrate(data) {
|
|
@@ -8649,6 +8647,48 @@ const MIGRATIONS = [
|
|
|
8649
8647
|
},
|
|
8650
8648
|
},
|
|
8651
8649
|
];
|
|
8650
|
+
/**
|
|
8651
|
+
* This function is used to repair faulty data independently of the migration.
|
|
8652
|
+
*/
|
|
8653
|
+
function repairData(data) {
|
|
8654
|
+
data = forceUnicityOfFigure(data);
|
|
8655
|
+
data = setDefaults(data);
|
|
8656
|
+
return data;
|
|
8657
|
+
}
|
|
8658
|
+
/**
|
|
8659
|
+
* Force the unicity of figure ids accross sheets
|
|
8660
|
+
*/
|
|
8661
|
+
function forceUnicityOfFigure(data) {
|
|
8662
|
+
if (data.uniqueFigureIds) {
|
|
8663
|
+
return data;
|
|
8664
|
+
}
|
|
8665
|
+
const figureIds = new Set();
|
|
8666
|
+
const uuidGenerator = new UuidGenerator();
|
|
8667
|
+
for (const sheet of data.sheets || []) {
|
|
8668
|
+
for (const figure of sheet.figures || []) {
|
|
8669
|
+
if (figureIds.has(figure.id)) {
|
|
8670
|
+
figure.id += uuidGenerator.uuidv4();
|
|
8671
|
+
}
|
|
8672
|
+
figureIds.add(figure.id);
|
|
8673
|
+
}
|
|
8674
|
+
}
|
|
8675
|
+
data.uniqueFigureIds = true;
|
|
8676
|
+
return data;
|
|
8677
|
+
}
|
|
8678
|
+
/**
|
|
8679
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
8680
|
+
* sensible default values
|
|
8681
|
+
*/
|
|
8682
|
+
function setDefaults(data) {
|
|
8683
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8684
|
+
data.sheets = data.sheets
|
|
8685
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
8686
|
+
: [];
|
|
8687
|
+
if (data.sheets.length === 0) {
|
|
8688
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8689
|
+
}
|
|
8690
|
+
return data;
|
|
8691
|
+
}
|
|
8652
8692
|
/**
|
|
8653
8693
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
8654
8694
|
* a bug.
|
|
@@ -8736,6 +8776,7 @@ function createEmptyWorkbookData(sheetName = "Sheet1") {
|
|
|
8736
8776
|
formats: {},
|
|
8737
8777
|
borders: {},
|
|
8738
8778
|
revisionId: DEFAULT_REVISION_ID,
|
|
8779
|
+
uniqueFigureIds: true,
|
|
8739
8780
|
};
|
|
8740
8781
|
return data;
|
|
8741
8782
|
}
|
|
@@ -9776,34 +9817,32 @@ class ChartPlugin extends CorePlugin {
|
|
|
9776
9817
|
this.chartFigures = {};
|
|
9777
9818
|
}
|
|
9778
9819
|
adaptRanges(applyChange) {
|
|
9779
|
-
for (
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
this.adaptLabelRanges(sheetId, chart, chartId, applyChange);
|
|
9784
|
-
}
|
|
9820
|
+
for (let [chartId, chart] of Object.entries(this.chartFigures)) {
|
|
9821
|
+
if (chart) {
|
|
9822
|
+
this.adaptDataSetRanges(chart, chartId, applyChange);
|
|
9823
|
+
this.adaptLabelRanges(chart, chartId, applyChange);
|
|
9785
9824
|
}
|
|
9786
9825
|
}
|
|
9787
9826
|
}
|
|
9788
|
-
adaptDataSetRanges(
|
|
9827
|
+
adaptDataSetRanges(chart, chartId, applyChange) {
|
|
9789
9828
|
for (let ds of chart.dataSets) {
|
|
9790
9829
|
if (ds.labelCell) {
|
|
9791
9830
|
const labelCellChange = applyChange(ds.labelCell);
|
|
9792
9831
|
switch (labelCellChange.changeType) {
|
|
9793
9832
|
case "REMOVE":
|
|
9794
|
-
this.history.update("chartFigures",
|
|
9833
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", undefined);
|
|
9795
9834
|
break;
|
|
9796
9835
|
case "RESIZE":
|
|
9797
9836
|
case "MOVE":
|
|
9798
9837
|
case "CHANGE":
|
|
9799
|
-
this.history.update("chartFigures",
|
|
9838
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", labelCellChange.range);
|
|
9800
9839
|
}
|
|
9801
9840
|
}
|
|
9802
9841
|
const dataRangeChange = applyChange(ds.dataRange);
|
|
9803
9842
|
switch (dataRangeChange.changeType) {
|
|
9804
9843
|
case "REMOVE":
|
|
9805
9844
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9806
|
-
this.history.update("chartFigures",
|
|
9845
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9807
9846
|
break;
|
|
9808
9847
|
case "RESIZE":
|
|
9809
9848
|
case "MOVE":
|
|
@@ -9811,27 +9850,27 @@ class ChartPlugin extends CorePlugin {
|
|
|
9811
9850
|
// We have to remove the ranges that are #REF
|
|
9812
9851
|
if (this.getters.getRangeString(dataRangeChange.range, dataRangeChange.range.sheetId) !==
|
|
9813
9852
|
INCORRECT_RANGE_STRING) {
|
|
9814
|
-
this.history.update("chartFigures",
|
|
9853
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "dataRange", dataRangeChange.range);
|
|
9815
9854
|
}
|
|
9816
9855
|
else {
|
|
9817
9856
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9818
|
-
this.history.update("chartFigures",
|
|
9857
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9819
9858
|
}
|
|
9820
9859
|
break;
|
|
9821
9860
|
}
|
|
9822
9861
|
}
|
|
9823
9862
|
}
|
|
9824
|
-
adaptLabelRanges(
|
|
9863
|
+
adaptLabelRanges(chart, chartId, applyChange) {
|
|
9825
9864
|
if (chart.labelRange) {
|
|
9826
9865
|
const labelRangeChange = applyChange(chart.labelRange);
|
|
9827
9866
|
switch (labelRangeChange.changeType) {
|
|
9828
9867
|
case "REMOVE":
|
|
9829
|
-
this.history.update("chartFigures",
|
|
9868
|
+
this.history.update("chartFigures", chartId, "labelRange", undefined);
|
|
9830
9869
|
break;
|
|
9831
9870
|
case "RESIZE":
|
|
9832
9871
|
case "MOVE":
|
|
9833
9872
|
case "CHANGE":
|
|
9834
|
-
this.history.update("chartFigures",
|
|
9873
|
+
this.history.update("chartFigures", chartId, "labelRange", labelRangeChange.range);
|
|
9835
9874
|
break;
|
|
9836
9875
|
}
|
|
9837
9876
|
}
|
|
@@ -9842,16 +9881,16 @@ class ChartPlugin extends CorePlugin {
|
|
|
9842
9881
|
allowDispatch(cmd) {
|
|
9843
9882
|
const success = 0 /* Success */;
|
|
9844
9883
|
switch (cmd.type) {
|
|
9845
|
-
case "CREATE_CHART":
|
|
9846
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkChartDuplicate, this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9847
9884
|
case "UPDATE_CHART":
|
|
9848
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9885
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartExists), this.checkLabelRange);
|
|
9886
|
+
case "CREATE_CHART":
|
|
9887
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartDuplicate), this.checkLabelRange);
|
|
9849
9888
|
default:
|
|
9850
9889
|
return success;
|
|
9851
9890
|
}
|
|
9852
9891
|
}
|
|
9853
9892
|
handle(cmd) {
|
|
9854
|
-
var _a;
|
|
9893
|
+
var _a, _b;
|
|
9855
9894
|
switch (cmd.type) {
|
|
9856
9895
|
case "CREATE_CHART":
|
|
9857
9896
|
const x = cmd.position ? cmd.position.x : 0;
|
|
@@ -9866,7 +9905,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
9866
9905
|
});
|
|
9867
9906
|
break;
|
|
9868
9907
|
case "UPDATE_CHART": {
|
|
9869
|
-
this.updateChartDefinition(cmd.
|
|
9908
|
+
this.updateChartDefinition(cmd.id, cmd.definition);
|
|
9870
9909
|
break;
|
|
9871
9910
|
}
|
|
9872
9911
|
case "DUPLICATE_SHEET": {
|
|
@@ -9876,7 +9915,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
9876
9915
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
9877
9916
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
9878
9917
|
const chartDefinition = {
|
|
9879
|
-
...deepCopy(this.chartFigures[
|
|
9918
|
+
...deepCopy(this.chartFigures[fig.id]),
|
|
9880
9919
|
id: duplicatedFigureId,
|
|
9881
9920
|
};
|
|
9882
9921
|
chartDefinition.sheetId = cmd.sheetIdTo;
|
|
@@ -9906,28 +9945,37 @@ class ChartPlugin extends CorePlugin {
|
|
|
9906
9945
|
break;
|
|
9907
9946
|
}
|
|
9908
9947
|
case "DELETE_FIGURE":
|
|
9909
|
-
this.history.update("chartFigures", cmd.
|
|
9948
|
+
this.history.update("chartFigures", cmd.id, undefined);
|
|
9910
9949
|
break;
|
|
9911
9950
|
case "DELETE_SHEET":
|
|
9912
|
-
this.
|
|
9951
|
+
for (let id of Object.keys(this.chartFigures)) {
|
|
9952
|
+
if (((_b = this.chartFigures[id]) === null || _b === void 0 ? void 0 : _b.sheetId) === cmd.sheetId) {
|
|
9953
|
+
this.history.update("chartFigures", id, undefined);
|
|
9954
|
+
}
|
|
9955
|
+
}
|
|
9913
9956
|
break;
|
|
9914
9957
|
}
|
|
9915
9958
|
}
|
|
9916
9959
|
// ---------------------------------------------------------------------------
|
|
9917
9960
|
// Getters
|
|
9918
9961
|
// ---------------------------------------------------------------------------
|
|
9919
|
-
getChartDefinition(
|
|
9920
|
-
|
|
9921
|
-
return (_a = this.chartFigures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
9962
|
+
getChartDefinition(figureId) {
|
|
9963
|
+
return this.chartFigures[figureId];
|
|
9922
9964
|
}
|
|
9923
|
-
|
|
9924
|
-
return Object.
|
|
9965
|
+
getChartsIdBySheet(sheetId) {
|
|
9966
|
+
return Object.entries(this.chartFigures)
|
|
9967
|
+
.filter((chart) => {
|
|
9968
|
+
return chart[1].sheetId === sheetId;
|
|
9969
|
+
})
|
|
9970
|
+
.map((chart) => chart[0]);
|
|
9925
9971
|
}
|
|
9926
|
-
getChartDefinitionUI(sheetId, figureId
|
|
9927
|
-
const data = this.chartFigures[
|
|
9928
|
-
|
|
9972
|
+
getChartDefinitionUI(sheetId, figureId) {
|
|
9973
|
+
const data = this.chartFigures[figureId];
|
|
9974
|
+
if (!data) {
|
|
9975
|
+
return undefined;
|
|
9976
|
+
}
|
|
9929
9977
|
const dataSets = data.dataSets
|
|
9930
|
-
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange,
|
|
9978
|
+
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange, sheetId) : ""))
|
|
9931
9979
|
.filter((ds) => {
|
|
9932
9980
|
return ds !== ""; // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9933
9981
|
});
|
|
@@ -9935,7 +9983,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
9935
9983
|
title: data && data.title ? data.title : "",
|
|
9936
9984
|
dataSets,
|
|
9937
9985
|
labelRange: data.labelRange
|
|
9938
|
-
? this.getters.getRangeString(data.labelRange,
|
|
9986
|
+
? this.getters.getRangeString(data.labelRange, sheetId)
|
|
9939
9987
|
: undefined,
|
|
9940
9988
|
type: data ? data.type : "bar",
|
|
9941
9989
|
dataSetsHaveTitle: data && dataSets.length !== 0 ? Boolean(data.dataSets[0].labelCell) : false,
|
|
@@ -9946,12 +9994,16 @@ class ChartPlugin extends CorePlugin {
|
|
|
9946
9994
|
};
|
|
9947
9995
|
}
|
|
9948
9996
|
getChartDefinitionExcel(sheetId, figureId) {
|
|
9949
|
-
const data = this.chartFigures[
|
|
9997
|
+
const data = this.chartFigures[figureId];
|
|
9998
|
+
const dataUI = this.getChartDefinitionUI("forceSheetReference", figureId);
|
|
9999
|
+
if (!data || !dataUI) {
|
|
10000
|
+
return undefined;
|
|
10001
|
+
}
|
|
9950
10002
|
const dataSets = data.dataSets
|
|
9951
10003
|
.map((ds) => this.toExcelDataset(ds))
|
|
9952
10004
|
.filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9953
10005
|
return {
|
|
9954
|
-
...
|
|
10006
|
+
...dataUI,
|
|
9955
10007
|
backgroundColor: data.background,
|
|
9956
10008
|
dataSets,
|
|
9957
10009
|
};
|
|
@@ -9986,17 +10038,15 @@ class ChartPlugin extends CorePlugin {
|
|
|
9986
10038
|
import(data) {
|
|
9987
10039
|
for (let sheet of data.sheets) {
|
|
9988
10040
|
if (sheet.figures) {
|
|
9989
|
-
const charts = {};
|
|
9990
10041
|
for (let figure of sheet.figures) {
|
|
9991
10042
|
if (figure.tag === "chart") {
|
|
9992
10043
|
const figureData = {
|
|
9993
10044
|
...figure.data,
|
|
9994
10045
|
};
|
|
9995
|
-
|
|
10046
|
+
this.chartFigures[figure.id] = this.createChartDefinition(figureData, sheet.id);
|
|
9996
10047
|
delete figure.data;
|
|
9997
10048
|
}
|
|
9998
10049
|
}
|
|
9999
|
-
this.chartFigures[sheet.id] = charts;
|
|
10000
10050
|
}
|
|
10001
10051
|
}
|
|
10002
10052
|
}
|
|
@@ -10004,10 +10054,18 @@ class ChartPlugin extends CorePlugin {
|
|
|
10004
10054
|
if (data.sheets) {
|
|
10005
10055
|
for (let sheet of data.sheets) {
|
|
10006
10056
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10007
|
-
const figures =
|
|
10008
|
-
for (let
|
|
10057
|
+
const figures = [];
|
|
10058
|
+
for (let sheetFigure of sheetFigures) {
|
|
10059
|
+
const figure = sheetFigure;
|
|
10009
10060
|
if (figure && figure.tag === "chart") {
|
|
10010
|
-
|
|
10061
|
+
const data = this.getChartDefinitionUI(sheet.id, figure.id);
|
|
10062
|
+
if (data) {
|
|
10063
|
+
figure.data = data;
|
|
10064
|
+
figures.push(figure);
|
|
10065
|
+
}
|
|
10066
|
+
}
|
|
10067
|
+
else {
|
|
10068
|
+
figures.push(figure);
|
|
10011
10069
|
}
|
|
10012
10070
|
}
|
|
10013
10071
|
sheet.figures = figures;
|
|
@@ -10017,10 +10075,18 @@ class ChartPlugin extends CorePlugin {
|
|
|
10017
10075
|
exportForExcel(data) {
|
|
10018
10076
|
for (let sheet of data.sheets) {
|
|
10019
10077
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10020
|
-
const figures =
|
|
10021
|
-
for (let
|
|
10078
|
+
const figures = [];
|
|
10079
|
+
for (let sheetFigure of sheetFigures) {
|
|
10080
|
+
const figure = sheetFigure;
|
|
10022
10081
|
if (figure && figure.tag === "chart") {
|
|
10023
|
-
|
|
10082
|
+
const data = this.getChartDefinitionExcel(sheet.id, figure.id);
|
|
10083
|
+
if (data) {
|
|
10084
|
+
figure.data = data;
|
|
10085
|
+
figures.push(figure);
|
|
10086
|
+
}
|
|
10087
|
+
}
|
|
10088
|
+
else {
|
|
10089
|
+
figures.push(figure);
|
|
10024
10090
|
}
|
|
10025
10091
|
}
|
|
10026
10092
|
sheet.charts = figures;
|
|
@@ -10046,39 +10112,39 @@ class ChartPlugin extends CorePlugin {
|
|
|
10046
10112
|
* Update the chart definition linked to the given id with the attributes
|
|
10047
10113
|
* given in the partial UI definition
|
|
10048
10114
|
*/
|
|
10049
|
-
updateChartDefinition(
|
|
10050
|
-
const chart = this.chartFigures[
|
|
10115
|
+
updateChartDefinition(id, definition) {
|
|
10116
|
+
const chart = this.chartFigures[id];
|
|
10051
10117
|
if (!chart) {
|
|
10052
10118
|
throw new Error(`There is no chart with the given id: ${id}`);
|
|
10053
10119
|
}
|
|
10054
10120
|
if (definition.title !== undefined) {
|
|
10055
|
-
this.history.update("chartFigures",
|
|
10121
|
+
this.history.update("chartFigures", id, "title", definition.title);
|
|
10056
10122
|
}
|
|
10057
10123
|
if (definition.type) {
|
|
10058
|
-
this.history.update("chartFigures",
|
|
10124
|
+
this.history.update("chartFigures", id, "type", definition.type);
|
|
10059
10125
|
}
|
|
10060
10126
|
if (definition.dataSets) {
|
|
10061
10127
|
const dataSetsHaveTitle = !!definition.dataSetsHaveTitle;
|
|
10062
10128
|
const dataSets = this.createDataSets(definition.dataSets, chart.sheetId, dataSetsHaveTitle);
|
|
10063
|
-
this.history.update("chartFigures",
|
|
10129
|
+
this.history.update("chartFigures", id, "dataSets", dataSets);
|
|
10064
10130
|
}
|
|
10065
10131
|
if (definition.labelRange !== undefined) {
|
|
10066
10132
|
const labelRange = definition.labelRange
|
|
10067
10133
|
? this.getters.getRangeFromSheetXC(chart.sheetId, definition.labelRange)
|
|
10068
10134
|
: undefined;
|
|
10069
|
-
this.history.update("chartFigures",
|
|
10135
|
+
this.history.update("chartFigures", id, "labelRange", labelRange);
|
|
10070
10136
|
}
|
|
10071
10137
|
if (definition.background) {
|
|
10072
|
-
this.history.update("chartFigures",
|
|
10138
|
+
this.history.update("chartFigures", id, "background", definition.background);
|
|
10073
10139
|
}
|
|
10074
10140
|
if (definition.verticalAxisPosition) {
|
|
10075
|
-
this.history.update("chartFigures",
|
|
10141
|
+
this.history.update("chartFigures", id, "verticalAxisPosition", definition.verticalAxisPosition);
|
|
10076
10142
|
}
|
|
10077
10143
|
if (definition.legendPosition) {
|
|
10078
|
-
this.history.update("chartFigures",
|
|
10144
|
+
this.history.update("chartFigures", id, "legendPosition", definition.legendPosition);
|
|
10079
10145
|
}
|
|
10080
10146
|
if (definition.stackedBar !== undefined) {
|
|
10081
|
-
this.history.update("chartFigures",
|
|
10147
|
+
this.history.update("chartFigures", id, "stackedBar", definition.stackedBar);
|
|
10082
10148
|
}
|
|
10083
10149
|
}
|
|
10084
10150
|
createDataSets(dataSetsString, sheetId, dataSetsHaveTitle) {
|
|
@@ -10133,7 +10199,7 @@ class ChartPlugin extends CorePlugin {
|
|
|
10133
10199
|
sheetId,
|
|
10134
10200
|
figure,
|
|
10135
10201
|
});
|
|
10136
|
-
this.history.update("chartFigures",
|
|
10202
|
+
this.history.update("chartFigures", figure.id, data);
|
|
10137
10203
|
}
|
|
10138
10204
|
createDataSet(sheetId, fullZone, titleZone) {
|
|
10139
10205
|
if (fullZone.left !== fullZone.right && fullZone.top !== fullZone.bottom) {
|
|
@@ -10174,18 +10240,20 @@ class ChartPlugin extends CorePlugin {
|
|
|
10174
10240
|
return invalidLabels ? 29 /* InvalidLabelRange */ : 0 /* Success */;
|
|
10175
10241
|
}
|
|
10176
10242
|
checkChartDuplicate(cmd) {
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10243
|
+
for (const sheet of this.getters.getSheets()) {
|
|
10244
|
+
if (this.getters.getFigure(sheet.id, cmd.id)) {
|
|
10245
|
+
return 57 /* DuplicatedChartId */;
|
|
10246
|
+
}
|
|
10180
10247
|
}
|
|
10181
10248
|
return 0 /* Success */;
|
|
10182
10249
|
}
|
|
10250
|
+
checkChartExists(cmd) {
|
|
10251
|
+
return this.getters.getFigure(cmd.sheetId, cmd.id)
|
|
10252
|
+
? 0 /* Success */
|
|
10253
|
+
: 58 /* ChartDoesNotExist */;
|
|
10254
|
+
}
|
|
10183
10255
|
}
|
|
10184
|
-
ChartPlugin.getters = [
|
|
10185
|
-
"getChartDefinition",
|
|
10186
|
-
"getChartDefinitionUI",
|
|
10187
|
-
"getChartDefinitionsBySheet",
|
|
10188
|
-
];
|
|
10256
|
+
ChartPlugin.getters = ["getChartDefinition", "getChartDefinitionUI", "getChartsIdBySheet"];
|
|
10189
10257
|
|
|
10190
10258
|
// -----------------------------------------------------------------------------
|
|
10191
10259
|
// Constants
|
|
@@ -10524,7 +10592,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
10524
10592
|
allowDispatch(cmd) {
|
|
10525
10593
|
switch (cmd.type) {
|
|
10526
10594
|
case "CREATE_FIGURE":
|
|
10527
|
-
return this.checkFigureDuplicate(cmd.
|
|
10595
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
10528
10596
|
case "UPDATE_FIGURE":
|
|
10529
10597
|
case "DELETE_FIGURE":
|
|
10530
10598
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -10590,9 +10658,8 @@ class FigurePlugin extends CorePlugin {
|
|
|
10590
10658
|
}
|
|
10591
10659
|
return 0 /* Success */;
|
|
10592
10660
|
}
|
|
10593
|
-
checkFigureDuplicate(
|
|
10594
|
-
|
|
10595
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
10661
|
+
checkFigureDuplicate(figureId) {
|
|
10662
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
10596
10663
|
return 56 /* DuplicatedFigureId */;
|
|
10597
10664
|
}
|
|
10598
10665
|
return 0 /* Success */;
|
|
@@ -10607,6 +10674,9 @@ class FigurePlugin extends CorePlugin {
|
|
|
10607
10674
|
var _a;
|
|
10608
10675
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
10609
10676
|
}
|
|
10677
|
+
getFigureSheetId(figureId) {
|
|
10678
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
10679
|
+
}
|
|
10610
10680
|
// ---------------------------------------------------------------------------
|
|
10611
10681
|
// Import/Export
|
|
10612
10682
|
// ---------------------------------------------------------------------------
|
|
@@ -10631,7 +10701,7 @@ class FigurePlugin extends CorePlugin {
|
|
|
10631
10701
|
this.export(data);
|
|
10632
10702
|
}
|
|
10633
10703
|
}
|
|
10634
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
10704
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
10635
10705
|
|
|
10636
10706
|
class MergePlugin extends CorePlugin {
|
|
10637
10707
|
constructor() {
|
|
@@ -12934,7 +13004,7 @@ const CREATE_CHART = (env) => {
|
|
|
12934
13004
|
},
|
|
12935
13005
|
});
|
|
12936
13006
|
const figure = env.getters.getFigure(sheetId, id);
|
|
12937
|
-
env.openSidePanel("ChartPanel", {
|
|
13007
|
+
env.openSidePanel("ChartPanel", { figure });
|
|
12938
13008
|
};
|
|
12939
13009
|
//------------------------------------------------------------------------------
|
|
12940
13010
|
// Style/Format
|
|
@@ -14447,15 +14517,17 @@ class ChartPanel extends Component {
|
|
|
14447
14517
|
constructor() {
|
|
14448
14518
|
super(...arguments);
|
|
14449
14519
|
this.getters = this.env.getters;
|
|
14520
|
+
this.chartSheetId = this.findSheetId(this.props.figure.id);
|
|
14450
14521
|
this.state = useState$b(this.initialState(this.props.figure));
|
|
14451
14522
|
}
|
|
14452
14523
|
setup() {
|
|
14453
14524
|
onWillUpdateProps$6((nextProps) => {
|
|
14454
|
-
if (!this.getters.getChartDefinition(nextProps.
|
|
14525
|
+
if (!this.getters.getChartDefinition(nextProps.figure.id)) {
|
|
14455
14526
|
this.props.onCloseSidePanel();
|
|
14456
14527
|
return;
|
|
14457
14528
|
}
|
|
14458
14529
|
if (nextProps.figure.id !== this.props.figure.id) {
|
|
14530
|
+
this.chartSheetId = this.findSheetId(nextProps.figure.id);
|
|
14459
14531
|
this.state.panel = "configuration";
|
|
14460
14532
|
this.state.fillColorTool = false;
|
|
14461
14533
|
this.state.datasetDispatchResult = undefined;
|
|
@@ -14508,7 +14580,7 @@ class ChartPanel extends Component {
|
|
|
14508
14580
|
updateChart(definition) {
|
|
14509
14581
|
return this.env.dispatch("UPDATE_CHART", {
|
|
14510
14582
|
id: this.props.figure.id,
|
|
14511
|
-
sheetId: this.
|
|
14583
|
+
sheetId: this.chartSheetId,
|
|
14512
14584
|
definition,
|
|
14513
14585
|
});
|
|
14514
14586
|
}
|
|
@@ -14530,12 +14602,16 @@ class ChartPanel extends Component {
|
|
|
14530
14602
|
this.state.panel = panel;
|
|
14531
14603
|
}
|
|
14532
14604
|
initialState(figure) {
|
|
14605
|
+
const sheetId = this.findSheetId(figure.id);
|
|
14533
14606
|
return {
|
|
14534
|
-
chart: this.env.getters.getChartDefinitionUI(
|
|
14607
|
+
chart: this.env.getters.getChartDefinitionUI(sheetId, figure.id),
|
|
14535
14608
|
panel: "configuration",
|
|
14536
14609
|
fillColorTool: false,
|
|
14537
14610
|
};
|
|
14538
14611
|
}
|
|
14612
|
+
findSheetId(figureId) {
|
|
14613
|
+
return this.env.getters.getFigureSheetId(figureId) || "";
|
|
14614
|
+
}
|
|
14539
14615
|
}
|
|
14540
14616
|
ChartPanel.template = TEMPLATE$m;
|
|
14541
14617
|
ChartPanel.style = STYLE;
|
|
@@ -18851,60 +18927,51 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
18851
18927
|
this.outOfDate = new Set();
|
|
18852
18928
|
}
|
|
18853
18929
|
handle(cmd) {
|
|
18854
|
-
var _a;
|
|
18855
18930
|
if (invalidateEvaluationCommands.has(cmd.type) ||
|
|
18856
18931
|
cmd.type === "EVALUATE_CELLS" ||
|
|
18857
18932
|
(cmd.type === "UPDATE_CELL" && "content" in cmd)) {
|
|
18858
|
-
for (
|
|
18859
|
-
|
|
18860
|
-
this.outOfDate.add(chartId);
|
|
18861
|
-
}
|
|
18933
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18934
|
+
this.outOfDate.add(chartId);
|
|
18862
18935
|
}
|
|
18863
18936
|
}
|
|
18864
18937
|
switch (cmd.type) {
|
|
18865
18938
|
case "UPDATE_CHART":
|
|
18866
|
-
case "CREATE_CHART":
|
|
18867
|
-
const chartDefinition = this.getters.getChartDefinition(cmd.
|
|
18868
|
-
|
|
18869
|
-
this.chartRuntime[cmd.sheetId] = {};
|
|
18870
|
-
this.chartRuntime[cmd.sheetId][cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18939
|
+
case "CREATE_CHART":
|
|
18940
|
+
const chartDefinition = this.getters.getChartDefinition(cmd.id);
|
|
18941
|
+
this.chartRuntime[cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18871
18942
|
break;
|
|
18872
|
-
}
|
|
18873
18943
|
case "DELETE_FIGURE":
|
|
18874
|
-
|
|
18944
|
+
delete this.chartRuntime[cmd.id];
|
|
18875
18945
|
break;
|
|
18876
|
-
case "REFRESH_CHART":
|
|
18877
|
-
|
|
18878
|
-
this.evaluateUsedSheets([chartDefinition]);
|
|
18946
|
+
case "REFRESH_CHART":
|
|
18947
|
+
this.evaluateUsedSheets([cmd.id]);
|
|
18879
18948
|
this.outOfDate.add(cmd.id);
|
|
18880
18949
|
break;
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
this.evaluateUsedSheets(chartsDefinitions);
|
|
18950
|
+
case "ACTIVATE_SHEET":
|
|
18951
|
+
const chartsIds = this.getters.getChartsIdBySheet(cmd.sheetIdTo);
|
|
18952
|
+
this.evaluateUsedSheets(chartsIds);
|
|
18885
18953
|
break;
|
|
18886
|
-
}
|
|
18887
18954
|
case "DELETE_SHEET":
|
|
18888
|
-
|
|
18955
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18956
|
+
if (!this.getters.getChartDefinition(chartId)) {
|
|
18957
|
+
delete this.chartRuntime[chartId];
|
|
18958
|
+
}
|
|
18959
|
+
}
|
|
18889
18960
|
break;
|
|
18890
18961
|
}
|
|
18891
18962
|
}
|
|
18892
18963
|
// ---------------------------------------------------------------------------
|
|
18893
18964
|
// Getters
|
|
18894
18965
|
// ---------------------------------------------------------------------------
|
|
18895
|
-
getChartRuntime(
|
|
18896
|
-
if (this.outOfDate.has(figureId) ||
|
|
18897
|
-
|
|
18898
|
-
!(figureId in this.chartRuntime[sheetId])) {
|
|
18899
|
-
const chartDefinition = this.getters.getChartDefinition(sheetId, figureId);
|
|
18966
|
+
getChartRuntime(figureId) {
|
|
18967
|
+
if (this.outOfDate.has(figureId) || !(figureId in this.chartRuntime)) {
|
|
18968
|
+
const chartDefinition = this.getters.getChartDefinition(figureId);
|
|
18900
18969
|
if (chartDefinition === undefined)
|
|
18901
18970
|
return;
|
|
18902
|
-
|
|
18903
|
-
this.chartRuntime[sheetId] = {};
|
|
18904
|
-
this.chartRuntime[sheetId][figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18971
|
+
this.chartRuntime[figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18905
18972
|
this.outOfDate.delete(figureId);
|
|
18906
18973
|
}
|
|
18907
|
-
return this.chartRuntime[
|
|
18974
|
+
return this.chartRuntime[figureId];
|
|
18908
18975
|
}
|
|
18909
18976
|
truncateLabel(label) {
|
|
18910
18977
|
if (!label) {
|
|
@@ -19009,9 +19076,10 @@ class EvaluationChartPlugin extends UIPlugin {
|
|
|
19009
19076
|
}
|
|
19010
19077
|
return sheetIds;
|
|
19011
19078
|
}
|
|
19012
|
-
evaluateUsedSheets(
|
|
19079
|
+
evaluateUsedSheets(chartsIds) {
|
|
19013
19080
|
const usedSheetsId = new Set();
|
|
19014
|
-
for (
|
|
19081
|
+
for (let chartId of chartsIds) {
|
|
19082
|
+
const chartDefinition = this.getters.getChartDefinition(chartId);
|
|
19015
19083
|
const sheetsIds = chartDefinition !== undefined ? this.getSheetIdsUsedInChart(chartDefinition) : [];
|
|
19016
19084
|
sheetsIds.forEach((sheetId) => {
|
|
19017
19085
|
if (sheetId !== this.getters.getActiveSheetId()) {
|
|
@@ -23421,6 +23489,7 @@ class RangeAdapter {
|
|
|
23421
23489
|
}
|
|
23422
23490
|
else if (range.zone[start] >= min && range.zone[end] <= max) {
|
|
23423
23491
|
changeType = "REMOVE";
|
|
23492
|
+
newRange = this.buildInvalidRange(INCORRECT_RANGE_STRING);
|
|
23424
23493
|
}
|
|
23425
23494
|
else if (range.zone[start] <= max && range.zone[end] >= max) {
|
|
23426
23495
|
const toRemove = max - range.zone[start] + 1;
|
|
@@ -23486,10 +23555,8 @@ class RangeAdapter {
|
|
|
23486
23555
|
return { changeType: "NONE" };
|
|
23487
23556
|
}
|
|
23488
23557
|
range = {
|
|
23489
|
-
...
|
|
23490
|
-
zone: { ...range.zone },
|
|
23558
|
+
...this.buildInvalidRange(INCORRECT_RANGE_STRING),
|
|
23491
23559
|
invalidSheetName: this.getters.getSheetName(cmd.sheetId),
|
|
23492
|
-
sheetId: "",
|
|
23493
23560
|
};
|
|
23494
23561
|
return { changeType: "REMOVE", range };
|
|
23495
23562
|
}, cmd.sheetId);
|
|
@@ -27798,7 +27865,7 @@ class ChartFigure extends Component {
|
|
|
27798
27865
|
setup() {
|
|
27799
27866
|
onMounted$4(() => {
|
|
27800
27867
|
const figure = this.props.figure;
|
|
27801
|
-
const chartData = this.env.getters.getChartRuntime(
|
|
27868
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27802
27869
|
if (chartData) {
|
|
27803
27870
|
this.createChart(chartData);
|
|
27804
27871
|
}
|
|
@@ -27806,8 +27873,7 @@ class ChartFigure extends Component {
|
|
|
27806
27873
|
onPatched$1(() => {
|
|
27807
27874
|
var _a, _b, _c;
|
|
27808
27875
|
const figure = this.props.figure;
|
|
27809
|
-
const
|
|
27810
|
-
const chartData = this.env.getters.getChartRuntime(sheetId, figure.id);
|
|
27876
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27811
27877
|
if (chartData) {
|
|
27812
27878
|
if (chartData.type !== this.chart.config.type) {
|
|
27813
27879
|
// Updating a chart type requires to update its options accordingly, if feasible at all.
|
|
@@ -27833,7 +27899,7 @@ class ChartFigure extends Component {
|
|
|
27833
27899
|
else {
|
|
27834
27900
|
this.chart && this.chart.destroy();
|
|
27835
27901
|
}
|
|
27836
|
-
const def = this.env.getters.getChartDefinition(
|
|
27902
|
+
const def = this.env.getters.getChartDefinition(figure.id);
|
|
27837
27903
|
if (def) {
|
|
27838
27904
|
this.state.background = def.background;
|
|
27839
27905
|
}
|
|
@@ -27843,7 +27909,7 @@ class ChartFigure extends Component {
|
|
|
27843
27909
|
const canvas = this.canvas.el;
|
|
27844
27910
|
const ctx = canvas.getContext("2d");
|
|
27845
27911
|
this.chart = new window.Chart(ctx, chartData);
|
|
27846
|
-
const def = this.env.getters.getChartDefinition(this.
|
|
27912
|
+
const def = this.env.getters.getChartDefinition(this.props.figure.id);
|
|
27847
27913
|
if (def) {
|
|
27848
27914
|
this.state.background = def.background;
|
|
27849
27915
|
}
|
|
@@ -27853,10 +27919,8 @@ class ChartFigure extends Component {
|
|
|
27853
27919
|
registry.add("edit", {
|
|
27854
27920
|
name: _lt("Edit"),
|
|
27855
27921
|
sequence: 1,
|
|
27856
|
-
action: () => this.env.openSidePanel("ChartPanel", {
|
|
27857
|
-
|
|
27858
|
-
figure: this.props.figure,
|
|
27859
|
-
}),
|
|
27922
|
+
action: () => this.env.openSidePanel("ChartPanel", { figure: this.props.figure }),
|
|
27923
|
+
isVisible: () => !!this.env.getters.getChartDefinition(this.props.figure.id),
|
|
27860
27924
|
});
|
|
27861
27925
|
registry.add("delete", {
|
|
27862
27926
|
name: _lt("Delete"),
|
|
@@ -27867,10 +27931,7 @@ class ChartFigure extends Component {
|
|
|
27867
27931
|
id: this.props.figure.id,
|
|
27868
27932
|
});
|
|
27869
27933
|
if (this.props.sidePanelIsOpen) {
|
|
27870
|
-
this.env.toggleSidePanel("ChartPanel", {
|
|
27871
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27872
|
-
figure: this.props.figure,
|
|
27873
|
-
});
|
|
27934
|
+
this.env.toggleSidePanel("ChartPanel", { figure: this.props.figure });
|
|
27874
27935
|
}
|
|
27875
27936
|
this.props.onFigureDeleted();
|
|
27876
27937
|
},
|
|
@@ -27880,7 +27941,6 @@ class ChartFigure extends Component {
|
|
|
27880
27941
|
sequence: 11,
|
|
27881
27942
|
action: () => {
|
|
27882
27943
|
this.env.dispatch("REFRESH_CHART", {
|
|
27883
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27884
27944
|
id: this.props.figure.id,
|
|
27885
27945
|
});
|
|
27886
27946
|
},
|
|
@@ -28128,10 +28188,7 @@ class FiguresContainer extends Component {
|
|
|
28128
28188
|
return;
|
|
28129
28189
|
}
|
|
28130
28190
|
if (this.props.sidePanelIsOpen) {
|
|
28131
|
-
this.env.openSidePanel("ChartPanel", {
|
|
28132
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
28133
|
-
figure,
|
|
28134
|
-
});
|
|
28191
|
+
this.env.openSidePanel("ChartPanel", { figure });
|
|
28135
28192
|
}
|
|
28136
28193
|
const initialX = ev.clientX;
|
|
28137
28194
|
const initialY = ev.clientY;
|
|
@@ -31188,6 +31245,6 @@ const helpers = {
|
|
|
31188
31245
|
export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
|
|
31189
31246
|
|
|
31190
31247
|
|
|
31191
|
-
__info__.version = '15.2.
|
|
31192
|
-
__info__.date = '2023-
|
|
31193
|
-
__info__.hash = '
|
|
31248
|
+
__info__.version = '15.2.2';
|
|
31249
|
+
__info__.date = '2023-03-14T09:19:31.079Z';
|
|
31250
|
+
__info__.hash = 'a3fcdb7';
|