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