@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
|
@@ -1389,6 +1389,7 @@
|
|
|
1389
1389
|
CommandResult[CommandResult["FigureDoesNotExist"] = 55] = "FigureDoesNotExist";
|
|
1390
1390
|
CommandResult[CommandResult["DuplicatedFigureId"] = 56] = "DuplicatedFigureId";
|
|
1391
1391
|
CommandResult[CommandResult["DuplicatedChartId"] = 57] = "DuplicatedChartId";
|
|
1392
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 58] = "ChartDoesNotExist";
|
|
1392
1393
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
1393
1394
|
|
|
1394
1395
|
var ReturnFormatType;
|
|
@@ -8436,13 +8437,7 @@
|
|
|
8436
8437
|
data = migrate(data);
|
|
8437
8438
|
}
|
|
8438
8439
|
}
|
|
8439
|
-
|
|
8440
|
-
// sensible default values
|
|
8441
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8442
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
8443
|
-
if (data.sheets.length === 0) {
|
|
8444
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8445
|
-
}
|
|
8440
|
+
data = repairData(data);
|
|
8446
8441
|
return data;
|
|
8447
8442
|
}
|
|
8448
8443
|
function migrate(data) {
|
|
@@ -8669,6 +8664,48 @@
|
|
|
8669
8664
|
},
|
|
8670
8665
|
},
|
|
8671
8666
|
];
|
|
8667
|
+
/**
|
|
8668
|
+
* This function is used to repair faulty data independently of the migration.
|
|
8669
|
+
*/
|
|
8670
|
+
function repairData(data) {
|
|
8671
|
+
data = forceUnicityOfFigure(data);
|
|
8672
|
+
data = setDefaults(data);
|
|
8673
|
+
return data;
|
|
8674
|
+
}
|
|
8675
|
+
/**
|
|
8676
|
+
* Force the unicity of figure ids accross sheets
|
|
8677
|
+
*/
|
|
8678
|
+
function forceUnicityOfFigure(data) {
|
|
8679
|
+
if (data.uniqueFigureIds) {
|
|
8680
|
+
return data;
|
|
8681
|
+
}
|
|
8682
|
+
const figureIds = new Set();
|
|
8683
|
+
const uuidGenerator = new UuidGenerator();
|
|
8684
|
+
for (const sheet of data.sheets || []) {
|
|
8685
|
+
for (const figure of sheet.figures || []) {
|
|
8686
|
+
if (figureIds.has(figure.id)) {
|
|
8687
|
+
figure.id += uuidGenerator.uuidv4();
|
|
8688
|
+
}
|
|
8689
|
+
figureIds.add(figure.id);
|
|
8690
|
+
}
|
|
8691
|
+
}
|
|
8692
|
+
data.uniqueFigureIds = true;
|
|
8693
|
+
return data;
|
|
8694
|
+
}
|
|
8695
|
+
/**
|
|
8696
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
8697
|
+
* sensible default values
|
|
8698
|
+
*/
|
|
8699
|
+
function setDefaults(data) {
|
|
8700
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8701
|
+
data.sheets = data.sheets
|
|
8702
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
8703
|
+
: [];
|
|
8704
|
+
if (data.sheets.length === 0) {
|
|
8705
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8706
|
+
}
|
|
8707
|
+
return data;
|
|
8708
|
+
}
|
|
8672
8709
|
/**
|
|
8673
8710
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
8674
8711
|
* a bug.
|
|
@@ -8756,6 +8793,7 @@
|
|
|
8756
8793
|
formats: {},
|
|
8757
8794
|
borders: {},
|
|
8758
8795
|
revisionId: DEFAULT_REVISION_ID,
|
|
8796
|
+
uniqueFigureIds: true,
|
|
8759
8797
|
};
|
|
8760
8798
|
return data;
|
|
8761
8799
|
}
|
|
@@ -9796,34 +9834,32 @@
|
|
|
9796
9834
|
this.chartFigures = {};
|
|
9797
9835
|
}
|
|
9798
9836
|
adaptRanges(applyChange) {
|
|
9799
|
-
for (
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
this.adaptLabelRanges(sheetId, chart, chartId, applyChange);
|
|
9804
|
-
}
|
|
9837
|
+
for (let [chartId, chart] of Object.entries(this.chartFigures)) {
|
|
9838
|
+
if (chart) {
|
|
9839
|
+
this.adaptDataSetRanges(chart, chartId, applyChange);
|
|
9840
|
+
this.adaptLabelRanges(chart, chartId, applyChange);
|
|
9805
9841
|
}
|
|
9806
9842
|
}
|
|
9807
9843
|
}
|
|
9808
|
-
adaptDataSetRanges(
|
|
9844
|
+
adaptDataSetRanges(chart, chartId, applyChange) {
|
|
9809
9845
|
for (let ds of chart.dataSets) {
|
|
9810
9846
|
if (ds.labelCell) {
|
|
9811
9847
|
const labelCellChange = applyChange(ds.labelCell);
|
|
9812
9848
|
switch (labelCellChange.changeType) {
|
|
9813
9849
|
case "REMOVE":
|
|
9814
|
-
this.history.update("chartFigures",
|
|
9850
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", undefined);
|
|
9815
9851
|
break;
|
|
9816
9852
|
case "RESIZE":
|
|
9817
9853
|
case "MOVE":
|
|
9818
9854
|
case "CHANGE":
|
|
9819
|
-
this.history.update("chartFigures",
|
|
9855
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", labelCellChange.range);
|
|
9820
9856
|
}
|
|
9821
9857
|
}
|
|
9822
9858
|
const dataRangeChange = applyChange(ds.dataRange);
|
|
9823
9859
|
switch (dataRangeChange.changeType) {
|
|
9824
9860
|
case "REMOVE":
|
|
9825
9861
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9826
|
-
this.history.update("chartFigures",
|
|
9862
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9827
9863
|
break;
|
|
9828
9864
|
case "RESIZE":
|
|
9829
9865
|
case "MOVE":
|
|
@@ -9831,27 +9867,27 @@
|
|
|
9831
9867
|
// We have to remove the ranges that are #REF
|
|
9832
9868
|
if (this.getters.getRangeString(dataRangeChange.range, dataRangeChange.range.sheetId) !==
|
|
9833
9869
|
INCORRECT_RANGE_STRING) {
|
|
9834
|
-
this.history.update("chartFigures",
|
|
9870
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "dataRange", dataRangeChange.range);
|
|
9835
9871
|
}
|
|
9836
9872
|
else {
|
|
9837
9873
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9838
|
-
this.history.update("chartFigures",
|
|
9874
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9839
9875
|
}
|
|
9840
9876
|
break;
|
|
9841
9877
|
}
|
|
9842
9878
|
}
|
|
9843
9879
|
}
|
|
9844
|
-
adaptLabelRanges(
|
|
9880
|
+
adaptLabelRanges(chart, chartId, applyChange) {
|
|
9845
9881
|
if (chart.labelRange) {
|
|
9846
9882
|
const labelRangeChange = applyChange(chart.labelRange);
|
|
9847
9883
|
switch (labelRangeChange.changeType) {
|
|
9848
9884
|
case "REMOVE":
|
|
9849
|
-
this.history.update("chartFigures",
|
|
9885
|
+
this.history.update("chartFigures", chartId, "labelRange", undefined);
|
|
9850
9886
|
break;
|
|
9851
9887
|
case "RESIZE":
|
|
9852
9888
|
case "MOVE":
|
|
9853
9889
|
case "CHANGE":
|
|
9854
|
-
this.history.update("chartFigures",
|
|
9890
|
+
this.history.update("chartFigures", chartId, "labelRange", labelRangeChange.range);
|
|
9855
9891
|
break;
|
|
9856
9892
|
}
|
|
9857
9893
|
}
|
|
@@ -9862,16 +9898,16 @@
|
|
|
9862
9898
|
allowDispatch(cmd) {
|
|
9863
9899
|
const success = 0 /* Success */;
|
|
9864
9900
|
switch (cmd.type) {
|
|
9865
|
-
case "CREATE_CHART":
|
|
9866
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkChartDuplicate, this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9867
9901
|
case "UPDATE_CHART":
|
|
9868
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9902
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartExists), this.checkLabelRange);
|
|
9903
|
+
case "CREATE_CHART":
|
|
9904
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartDuplicate), this.checkLabelRange);
|
|
9869
9905
|
default:
|
|
9870
9906
|
return success;
|
|
9871
9907
|
}
|
|
9872
9908
|
}
|
|
9873
9909
|
handle(cmd) {
|
|
9874
|
-
var _a;
|
|
9910
|
+
var _a, _b;
|
|
9875
9911
|
switch (cmd.type) {
|
|
9876
9912
|
case "CREATE_CHART":
|
|
9877
9913
|
const x = cmd.position ? cmd.position.x : 0;
|
|
@@ -9886,7 +9922,7 @@
|
|
|
9886
9922
|
});
|
|
9887
9923
|
break;
|
|
9888
9924
|
case "UPDATE_CHART": {
|
|
9889
|
-
this.updateChartDefinition(cmd.
|
|
9925
|
+
this.updateChartDefinition(cmd.id, cmd.definition);
|
|
9890
9926
|
break;
|
|
9891
9927
|
}
|
|
9892
9928
|
case "DUPLICATE_SHEET": {
|
|
@@ -9896,7 +9932,7 @@
|
|
|
9896
9932
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
9897
9933
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
9898
9934
|
const chartDefinition = {
|
|
9899
|
-
...deepCopy(this.chartFigures[
|
|
9935
|
+
...deepCopy(this.chartFigures[fig.id]),
|
|
9900
9936
|
id: duplicatedFigureId,
|
|
9901
9937
|
};
|
|
9902
9938
|
chartDefinition.sheetId = cmd.sheetIdTo;
|
|
@@ -9926,28 +9962,37 @@
|
|
|
9926
9962
|
break;
|
|
9927
9963
|
}
|
|
9928
9964
|
case "DELETE_FIGURE":
|
|
9929
|
-
this.history.update("chartFigures", cmd.
|
|
9965
|
+
this.history.update("chartFigures", cmd.id, undefined);
|
|
9930
9966
|
break;
|
|
9931
9967
|
case "DELETE_SHEET":
|
|
9932
|
-
this.
|
|
9968
|
+
for (let id of Object.keys(this.chartFigures)) {
|
|
9969
|
+
if (((_b = this.chartFigures[id]) === null || _b === void 0 ? void 0 : _b.sheetId) === cmd.sheetId) {
|
|
9970
|
+
this.history.update("chartFigures", id, undefined);
|
|
9971
|
+
}
|
|
9972
|
+
}
|
|
9933
9973
|
break;
|
|
9934
9974
|
}
|
|
9935
9975
|
}
|
|
9936
9976
|
// ---------------------------------------------------------------------------
|
|
9937
9977
|
// Getters
|
|
9938
9978
|
// ---------------------------------------------------------------------------
|
|
9939
|
-
getChartDefinition(
|
|
9940
|
-
|
|
9941
|
-
return (_a = this.chartFigures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
9979
|
+
getChartDefinition(figureId) {
|
|
9980
|
+
return this.chartFigures[figureId];
|
|
9942
9981
|
}
|
|
9943
|
-
|
|
9944
|
-
return Object.
|
|
9982
|
+
getChartsIdBySheet(sheetId) {
|
|
9983
|
+
return Object.entries(this.chartFigures)
|
|
9984
|
+
.filter((chart) => {
|
|
9985
|
+
return chart[1].sheetId === sheetId;
|
|
9986
|
+
})
|
|
9987
|
+
.map((chart) => chart[0]);
|
|
9945
9988
|
}
|
|
9946
|
-
getChartDefinitionUI(sheetId, figureId
|
|
9947
|
-
const data = this.chartFigures[
|
|
9948
|
-
|
|
9989
|
+
getChartDefinitionUI(sheetId, figureId) {
|
|
9990
|
+
const data = this.chartFigures[figureId];
|
|
9991
|
+
if (!data) {
|
|
9992
|
+
return undefined;
|
|
9993
|
+
}
|
|
9949
9994
|
const dataSets = data.dataSets
|
|
9950
|
-
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange,
|
|
9995
|
+
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange, sheetId) : ""))
|
|
9951
9996
|
.filter((ds) => {
|
|
9952
9997
|
return ds !== ""; // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9953
9998
|
});
|
|
@@ -9955,7 +10000,7 @@
|
|
|
9955
10000
|
title: data && data.title ? data.title : "",
|
|
9956
10001
|
dataSets,
|
|
9957
10002
|
labelRange: data.labelRange
|
|
9958
|
-
? this.getters.getRangeString(data.labelRange,
|
|
10003
|
+
? this.getters.getRangeString(data.labelRange, sheetId)
|
|
9959
10004
|
: undefined,
|
|
9960
10005
|
type: data ? data.type : "bar",
|
|
9961
10006
|
dataSetsHaveTitle: data && dataSets.length !== 0 ? Boolean(data.dataSets[0].labelCell) : false,
|
|
@@ -9966,12 +10011,16 @@
|
|
|
9966
10011
|
};
|
|
9967
10012
|
}
|
|
9968
10013
|
getChartDefinitionExcel(sheetId, figureId) {
|
|
9969
|
-
const data = this.chartFigures[
|
|
10014
|
+
const data = this.chartFigures[figureId];
|
|
10015
|
+
const dataUI = this.getChartDefinitionUI("forceSheetReference", figureId);
|
|
10016
|
+
if (!data || !dataUI) {
|
|
10017
|
+
return undefined;
|
|
10018
|
+
}
|
|
9970
10019
|
const dataSets = data.dataSets
|
|
9971
10020
|
.map((ds) => this.toExcelDataset(ds))
|
|
9972
10021
|
.filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9973
10022
|
return {
|
|
9974
|
-
...
|
|
10023
|
+
...dataUI,
|
|
9975
10024
|
backgroundColor: data.background,
|
|
9976
10025
|
dataSets,
|
|
9977
10026
|
};
|
|
@@ -10006,17 +10055,15 @@
|
|
|
10006
10055
|
import(data) {
|
|
10007
10056
|
for (let sheet of data.sheets) {
|
|
10008
10057
|
if (sheet.figures) {
|
|
10009
|
-
const charts = {};
|
|
10010
10058
|
for (let figure of sheet.figures) {
|
|
10011
10059
|
if (figure.tag === "chart") {
|
|
10012
10060
|
const figureData = {
|
|
10013
10061
|
...figure.data,
|
|
10014
10062
|
};
|
|
10015
|
-
|
|
10063
|
+
this.chartFigures[figure.id] = this.createChartDefinition(figureData, sheet.id);
|
|
10016
10064
|
delete figure.data;
|
|
10017
10065
|
}
|
|
10018
10066
|
}
|
|
10019
|
-
this.chartFigures[sheet.id] = charts;
|
|
10020
10067
|
}
|
|
10021
10068
|
}
|
|
10022
10069
|
}
|
|
@@ -10024,10 +10071,18 @@
|
|
|
10024
10071
|
if (data.sheets) {
|
|
10025
10072
|
for (let sheet of data.sheets) {
|
|
10026
10073
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10027
|
-
const figures =
|
|
10028
|
-
for (let
|
|
10074
|
+
const figures = [];
|
|
10075
|
+
for (let sheetFigure of sheetFigures) {
|
|
10076
|
+
const figure = sheetFigure;
|
|
10029
10077
|
if (figure && figure.tag === "chart") {
|
|
10030
|
-
|
|
10078
|
+
const data = this.getChartDefinitionUI(sheet.id, figure.id);
|
|
10079
|
+
if (data) {
|
|
10080
|
+
figure.data = data;
|
|
10081
|
+
figures.push(figure);
|
|
10082
|
+
}
|
|
10083
|
+
}
|
|
10084
|
+
else {
|
|
10085
|
+
figures.push(figure);
|
|
10031
10086
|
}
|
|
10032
10087
|
}
|
|
10033
10088
|
sheet.figures = figures;
|
|
@@ -10037,10 +10092,18 @@
|
|
|
10037
10092
|
exportForExcel(data) {
|
|
10038
10093
|
for (let sheet of data.sheets) {
|
|
10039
10094
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10040
|
-
const figures =
|
|
10041
|
-
for (let
|
|
10095
|
+
const figures = [];
|
|
10096
|
+
for (let sheetFigure of sheetFigures) {
|
|
10097
|
+
const figure = sheetFigure;
|
|
10042
10098
|
if (figure && figure.tag === "chart") {
|
|
10043
|
-
|
|
10099
|
+
const data = this.getChartDefinitionExcel(sheet.id, figure.id);
|
|
10100
|
+
if (data) {
|
|
10101
|
+
figure.data = data;
|
|
10102
|
+
figures.push(figure);
|
|
10103
|
+
}
|
|
10104
|
+
}
|
|
10105
|
+
else {
|
|
10106
|
+
figures.push(figure);
|
|
10044
10107
|
}
|
|
10045
10108
|
}
|
|
10046
10109
|
sheet.charts = figures;
|
|
@@ -10066,39 +10129,39 @@
|
|
|
10066
10129
|
* Update the chart definition linked to the given id with the attributes
|
|
10067
10130
|
* given in the partial UI definition
|
|
10068
10131
|
*/
|
|
10069
|
-
updateChartDefinition(
|
|
10070
|
-
const chart = this.chartFigures[
|
|
10132
|
+
updateChartDefinition(id, definition) {
|
|
10133
|
+
const chart = this.chartFigures[id];
|
|
10071
10134
|
if (!chart) {
|
|
10072
10135
|
throw new Error(`There is no chart with the given id: ${id}`);
|
|
10073
10136
|
}
|
|
10074
10137
|
if (definition.title !== undefined) {
|
|
10075
|
-
this.history.update("chartFigures",
|
|
10138
|
+
this.history.update("chartFigures", id, "title", definition.title);
|
|
10076
10139
|
}
|
|
10077
10140
|
if (definition.type) {
|
|
10078
|
-
this.history.update("chartFigures",
|
|
10141
|
+
this.history.update("chartFigures", id, "type", definition.type);
|
|
10079
10142
|
}
|
|
10080
10143
|
if (definition.dataSets) {
|
|
10081
10144
|
const dataSetsHaveTitle = !!definition.dataSetsHaveTitle;
|
|
10082
10145
|
const dataSets = this.createDataSets(definition.dataSets, chart.sheetId, dataSetsHaveTitle);
|
|
10083
|
-
this.history.update("chartFigures",
|
|
10146
|
+
this.history.update("chartFigures", id, "dataSets", dataSets);
|
|
10084
10147
|
}
|
|
10085
10148
|
if (definition.labelRange !== undefined) {
|
|
10086
10149
|
const labelRange = definition.labelRange
|
|
10087
10150
|
? this.getters.getRangeFromSheetXC(chart.sheetId, definition.labelRange)
|
|
10088
10151
|
: undefined;
|
|
10089
|
-
this.history.update("chartFigures",
|
|
10152
|
+
this.history.update("chartFigures", id, "labelRange", labelRange);
|
|
10090
10153
|
}
|
|
10091
10154
|
if (definition.background) {
|
|
10092
|
-
this.history.update("chartFigures",
|
|
10155
|
+
this.history.update("chartFigures", id, "background", definition.background);
|
|
10093
10156
|
}
|
|
10094
10157
|
if (definition.verticalAxisPosition) {
|
|
10095
|
-
this.history.update("chartFigures",
|
|
10158
|
+
this.history.update("chartFigures", id, "verticalAxisPosition", definition.verticalAxisPosition);
|
|
10096
10159
|
}
|
|
10097
10160
|
if (definition.legendPosition) {
|
|
10098
|
-
this.history.update("chartFigures",
|
|
10161
|
+
this.history.update("chartFigures", id, "legendPosition", definition.legendPosition);
|
|
10099
10162
|
}
|
|
10100
10163
|
if (definition.stackedBar !== undefined) {
|
|
10101
|
-
this.history.update("chartFigures",
|
|
10164
|
+
this.history.update("chartFigures", id, "stackedBar", definition.stackedBar);
|
|
10102
10165
|
}
|
|
10103
10166
|
}
|
|
10104
10167
|
createDataSets(dataSetsString, sheetId, dataSetsHaveTitle) {
|
|
@@ -10153,7 +10216,7 @@
|
|
|
10153
10216
|
sheetId,
|
|
10154
10217
|
figure,
|
|
10155
10218
|
});
|
|
10156
|
-
this.history.update("chartFigures",
|
|
10219
|
+
this.history.update("chartFigures", figure.id, data);
|
|
10157
10220
|
}
|
|
10158
10221
|
createDataSet(sheetId, fullZone, titleZone) {
|
|
10159
10222
|
if (fullZone.left !== fullZone.right && fullZone.top !== fullZone.bottom) {
|
|
@@ -10194,18 +10257,20 @@
|
|
|
10194
10257
|
return invalidLabels ? 29 /* InvalidLabelRange */ : 0 /* Success */;
|
|
10195
10258
|
}
|
|
10196
10259
|
checkChartDuplicate(cmd) {
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10260
|
+
for (const sheet of this.getters.getSheets()) {
|
|
10261
|
+
if (this.getters.getFigure(sheet.id, cmd.id)) {
|
|
10262
|
+
return 57 /* DuplicatedChartId */;
|
|
10263
|
+
}
|
|
10200
10264
|
}
|
|
10201
10265
|
return 0 /* Success */;
|
|
10202
10266
|
}
|
|
10267
|
+
checkChartExists(cmd) {
|
|
10268
|
+
return this.getters.getFigure(cmd.sheetId, cmd.id)
|
|
10269
|
+
? 0 /* Success */
|
|
10270
|
+
: 58 /* ChartDoesNotExist */;
|
|
10271
|
+
}
|
|
10203
10272
|
}
|
|
10204
|
-
ChartPlugin.getters = [
|
|
10205
|
-
"getChartDefinition",
|
|
10206
|
-
"getChartDefinitionUI",
|
|
10207
|
-
"getChartDefinitionsBySheet",
|
|
10208
|
-
];
|
|
10273
|
+
ChartPlugin.getters = ["getChartDefinition", "getChartDefinitionUI", "getChartsIdBySheet"];
|
|
10209
10274
|
|
|
10210
10275
|
// -----------------------------------------------------------------------------
|
|
10211
10276
|
// Constants
|
|
@@ -10544,7 +10609,7 @@
|
|
|
10544
10609
|
allowDispatch(cmd) {
|
|
10545
10610
|
switch (cmd.type) {
|
|
10546
10611
|
case "CREATE_FIGURE":
|
|
10547
|
-
return this.checkFigureDuplicate(cmd.
|
|
10612
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
10548
10613
|
case "UPDATE_FIGURE":
|
|
10549
10614
|
case "DELETE_FIGURE":
|
|
10550
10615
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -10610,9 +10675,8 @@
|
|
|
10610
10675
|
}
|
|
10611
10676
|
return 0 /* Success */;
|
|
10612
10677
|
}
|
|
10613
|
-
checkFigureDuplicate(
|
|
10614
|
-
|
|
10615
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
10678
|
+
checkFigureDuplicate(figureId) {
|
|
10679
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
10616
10680
|
return 56 /* DuplicatedFigureId */;
|
|
10617
10681
|
}
|
|
10618
10682
|
return 0 /* Success */;
|
|
@@ -10627,6 +10691,9 @@
|
|
|
10627
10691
|
var _a;
|
|
10628
10692
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
10629
10693
|
}
|
|
10694
|
+
getFigureSheetId(figureId) {
|
|
10695
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
10696
|
+
}
|
|
10630
10697
|
// ---------------------------------------------------------------------------
|
|
10631
10698
|
// Import/Export
|
|
10632
10699
|
// ---------------------------------------------------------------------------
|
|
@@ -10651,7 +10718,7 @@
|
|
|
10651
10718
|
this.export(data);
|
|
10652
10719
|
}
|
|
10653
10720
|
}
|
|
10654
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
10721
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
10655
10722
|
|
|
10656
10723
|
class MergePlugin extends CorePlugin {
|
|
10657
10724
|
constructor() {
|
|
@@ -12954,7 +13021,7 @@
|
|
|
12954
13021
|
},
|
|
12955
13022
|
});
|
|
12956
13023
|
const figure = env.getters.getFigure(sheetId, id);
|
|
12957
|
-
env.openSidePanel("ChartPanel", {
|
|
13024
|
+
env.openSidePanel("ChartPanel", { figure });
|
|
12958
13025
|
};
|
|
12959
13026
|
//------------------------------------------------------------------------------
|
|
12960
13027
|
// Style/Format
|
|
@@ -14467,15 +14534,17 @@
|
|
|
14467
14534
|
constructor() {
|
|
14468
14535
|
super(...arguments);
|
|
14469
14536
|
this.getters = this.env.getters;
|
|
14537
|
+
this.chartSheetId = this.findSheetId(this.props.figure.id);
|
|
14470
14538
|
this.state = owl.useState(this.initialState(this.props.figure));
|
|
14471
14539
|
}
|
|
14472
14540
|
setup() {
|
|
14473
14541
|
onWillUpdateProps$6((nextProps) => {
|
|
14474
|
-
if (!this.getters.getChartDefinition(nextProps.
|
|
14542
|
+
if (!this.getters.getChartDefinition(nextProps.figure.id)) {
|
|
14475
14543
|
this.props.onCloseSidePanel();
|
|
14476
14544
|
return;
|
|
14477
14545
|
}
|
|
14478
14546
|
if (nextProps.figure.id !== this.props.figure.id) {
|
|
14547
|
+
this.chartSheetId = this.findSheetId(nextProps.figure.id);
|
|
14479
14548
|
this.state.panel = "configuration";
|
|
14480
14549
|
this.state.fillColorTool = false;
|
|
14481
14550
|
this.state.datasetDispatchResult = undefined;
|
|
@@ -14528,7 +14597,7 @@
|
|
|
14528
14597
|
updateChart(definition) {
|
|
14529
14598
|
return this.env.dispatch("UPDATE_CHART", {
|
|
14530
14599
|
id: this.props.figure.id,
|
|
14531
|
-
sheetId: this.
|
|
14600
|
+
sheetId: this.chartSheetId,
|
|
14532
14601
|
definition,
|
|
14533
14602
|
});
|
|
14534
14603
|
}
|
|
@@ -14550,12 +14619,16 @@
|
|
|
14550
14619
|
this.state.panel = panel;
|
|
14551
14620
|
}
|
|
14552
14621
|
initialState(figure) {
|
|
14622
|
+
const sheetId = this.findSheetId(figure.id);
|
|
14553
14623
|
return {
|
|
14554
|
-
chart: this.env.getters.getChartDefinitionUI(
|
|
14624
|
+
chart: this.env.getters.getChartDefinitionUI(sheetId, figure.id),
|
|
14555
14625
|
panel: "configuration",
|
|
14556
14626
|
fillColorTool: false,
|
|
14557
14627
|
};
|
|
14558
14628
|
}
|
|
14629
|
+
findSheetId(figureId) {
|
|
14630
|
+
return this.env.getters.getFigureSheetId(figureId) || "";
|
|
14631
|
+
}
|
|
14559
14632
|
}
|
|
14560
14633
|
ChartPanel.template = TEMPLATE$m;
|
|
14561
14634
|
ChartPanel.style = STYLE;
|
|
@@ -18871,60 +18944,51 @@
|
|
|
18871
18944
|
this.outOfDate = new Set();
|
|
18872
18945
|
}
|
|
18873
18946
|
handle(cmd) {
|
|
18874
|
-
var _a;
|
|
18875
18947
|
if (invalidateEvaluationCommands.has(cmd.type) ||
|
|
18876
18948
|
cmd.type === "EVALUATE_CELLS" ||
|
|
18877
18949
|
(cmd.type === "UPDATE_CELL" && "content" in cmd)) {
|
|
18878
|
-
for (
|
|
18879
|
-
|
|
18880
|
-
this.outOfDate.add(chartId);
|
|
18881
|
-
}
|
|
18950
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18951
|
+
this.outOfDate.add(chartId);
|
|
18882
18952
|
}
|
|
18883
18953
|
}
|
|
18884
18954
|
switch (cmd.type) {
|
|
18885
18955
|
case "UPDATE_CHART":
|
|
18886
|
-
case "CREATE_CHART":
|
|
18887
|
-
const chartDefinition = this.getters.getChartDefinition(cmd.
|
|
18888
|
-
|
|
18889
|
-
this.chartRuntime[cmd.sheetId] = {};
|
|
18890
|
-
this.chartRuntime[cmd.sheetId][cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18956
|
+
case "CREATE_CHART":
|
|
18957
|
+
const chartDefinition = this.getters.getChartDefinition(cmd.id);
|
|
18958
|
+
this.chartRuntime[cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18891
18959
|
break;
|
|
18892
|
-
}
|
|
18893
18960
|
case "DELETE_FIGURE":
|
|
18894
|
-
|
|
18961
|
+
delete this.chartRuntime[cmd.id];
|
|
18895
18962
|
break;
|
|
18896
|
-
case "REFRESH_CHART":
|
|
18897
|
-
|
|
18898
|
-
this.evaluateUsedSheets([chartDefinition]);
|
|
18963
|
+
case "REFRESH_CHART":
|
|
18964
|
+
this.evaluateUsedSheets([cmd.id]);
|
|
18899
18965
|
this.outOfDate.add(cmd.id);
|
|
18900
18966
|
break;
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
this.evaluateUsedSheets(chartsDefinitions);
|
|
18967
|
+
case "ACTIVATE_SHEET":
|
|
18968
|
+
const chartsIds = this.getters.getChartsIdBySheet(cmd.sheetIdTo);
|
|
18969
|
+
this.evaluateUsedSheets(chartsIds);
|
|
18905
18970
|
break;
|
|
18906
|
-
}
|
|
18907
18971
|
case "DELETE_SHEET":
|
|
18908
|
-
|
|
18972
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18973
|
+
if (!this.getters.getChartDefinition(chartId)) {
|
|
18974
|
+
delete this.chartRuntime[chartId];
|
|
18975
|
+
}
|
|
18976
|
+
}
|
|
18909
18977
|
break;
|
|
18910
18978
|
}
|
|
18911
18979
|
}
|
|
18912
18980
|
// ---------------------------------------------------------------------------
|
|
18913
18981
|
// Getters
|
|
18914
18982
|
// ---------------------------------------------------------------------------
|
|
18915
|
-
getChartRuntime(
|
|
18916
|
-
if (this.outOfDate.has(figureId) ||
|
|
18917
|
-
|
|
18918
|
-
!(figureId in this.chartRuntime[sheetId])) {
|
|
18919
|
-
const chartDefinition = this.getters.getChartDefinition(sheetId, figureId);
|
|
18983
|
+
getChartRuntime(figureId) {
|
|
18984
|
+
if (this.outOfDate.has(figureId) || !(figureId in this.chartRuntime)) {
|
|
18985
|
+
const chartDefinition = this.getters.getChartDefinition(figureId);
|
|
18920
18986
|
if (chartDefinition === undefined)
|
|
18921
18987
|
return;
|
|
18922
|
-
|
|
18923
|
-
this.chartRuntime[sheetId] = {};
|
|
18924
|
-
this.chartRuntime[sheetId][figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18988
|
+
this.chartRuntime[figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18925
18989
|
this.outOfDate.delete(figureId);
|
|
18926
18990
|
}
|
|
18927
|
-
return this.chartRuntime[
|
|
18991
|
+
return this.chartRuntime[figureId];
|
|
18928
18992
|
}
|
|
18929
18993
|
truncateLabel(label) {
|
|
18930
18994
|
if (!label) {
|
|
@@ -19029,9 +19093,10 @@
|
|
|
19029
19093
|
}
|
|
19030
19094
|
return sheetIds;
|
|
19031
19095
|
}
|
|
19032
|
-
evaluateUsedSheets(
|
|
19096
|
+
evaluateUsedSheets(chartsIds) {
|
|
19033
19097
|
const usedSheetsId = new Set();
|
|
19034
|
-
for (
|
|
19098
|
+
for (let chartId of chartsIds) {
|
|
19099
|
+
const chartDefinition = this.getters.getChartDefinition(chartId);
|
|
19035
19100
|
const sheetsIds = chartDefinition !== undefined ? this.getSheetIdsUsedInChart(chartDefinition) : [];
|
|
19036
19101
|
sheetsIds.forEach((sheetId) => {
|
|
19037
19102
|
if (sheetId !== this.getters.getActiveSheetId()) {
|
|
@@ -27818,7 +27883,7 @@
|
|
|
27818
27883
|
setup() {
|
|
27819
27884
|
onMounted$4(() => {
|
|
27820
27885
|
const figure = this.props.figure;
|
|
27821
|
-
const chartData = this.env.getters.getChartRuntime(
|
|
27886
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27822
27887
|
if (chartData) {
|
|
27823
27888
|
this.createChart(chartData);
|
|
27824
27889
|
}
|
|
@@ -27826,8 +27891,7 @@
|
|
|
27826
27891
|
onPatched$1(() => {
|
|
27827
27892
|
var _a, _b, _c;
|
|
27828
27893
|
const figure = this.props.figure;
|
|
27829
|
-
const
|
|
27830
|
-
const chartData = this.env.getters.getChartRuntime(sheetId, figure.id);
|
|
27894
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27831
27895
|
if (chartData) {
|
|
27832
27896
|
if (chartData.type !== this.chart.config.type) {
|
|
27833
27897
|
// Updating a chart type requires to update its options accordingly, if feasible at all.
|
|
@@ -27853,7 +27917,7 @@
|
|
|
27853
27917
|
else {
|
|
27854
27918
|
this.chart && this.chart.destroy();
|
|
27855
27919
|
}
|
|
27856
|
-
const def = this.env.getters.getChartDefinition(
|
|
27920
|
+
const def = this.env.getters.getChartDefinition(figure.id);
|
|
27857
27921
|
if (def) {
|
|
27858
27922
|
this.state.background = def.background;
|
|
27859
27923
|
}
|
|
@@ -27863,7 +27927,7 @@
|
|
|
27863
27927
|
const canvas = this.canvas.el;
|
|
27864
27928
|
const ctx = canvas.getContext("2d");
|
|
27865
27929
|
this.chart = new window.Chart(ctx, chartData);
|
|
27866
|
-
const def = this.env.getters.getChartDefinition(this.
|
|
27930
|
+
const def = this.env.getters.getChartDefinition(this.props.figure.id);
|
|
27867
27931
|
if (def) {
|
|
27868
27932
|
this.state.background = def.background;
|
|
27869
27933
|
}
|
|
@@ -27873,10 +27937,8 @@
|
|
|
27873
27937
|
registry.add("edit", {
|
|
27874
27938
|
name: _lt("Edit"),
|
|
27875
27939
|
sequence: 1,
|
|
27876
|
-
action: () => this.env.openSidePanel("ChartPanel", {
|
|
27877
|
-
|
|
27878
|
-
figure: this.props.figure,
|
|
27879
|
-
}),
|
|
27940
|
+
action: () => this.env.openSidePanel("ChartPanel", { figure: this.props.figure }),
|
|
27941
|
+
isVisible: () => !!this.env.getters.getChartDefinition(this.props.figure.id),
|
|
27880
27942
|
});
|
|
27881
27943
|
registry.add("delete", {
|
|
27882
27944
|
name: _lt("Delete"),
|
|
@@ -27887,10 +27949,7 @@
|
|
|
27887
27949
|
id: this.props.figure.id,
|
|
27888
27950
|
});
|
|
27889
27951
|
if (this.props.sidePanelIsOpen) {
|
|
27890
|
-
this.env.toggleSidePanel("ChartPanel", {
|
|
27891
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27892
|
-
figure: this.props.figure,
|
|
27893
|
-
});
|
|
27952
|
+
this.env.toggleSidePanel("ChartPanel", { figure: this.props.figure });
|
|
27894
27953
|
}
|
|
27895
27954
|
this.props.onFigureDeleted();
|
|
27896
27955
|
},
|
|
@@ -27900,7 +27959,6 @@
|
|
|
27900
27959
|
sequence: 11,
|
|
27901
27960
|
action: () => {
|
|
27902
27961
|
this.env.dispatch("REFRESH_CHART", {
|
|
27903
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27904
27962
|
id: this.props.figure.id,
|
|
27905
27963
|
});
|
|
27906
27964
|
},
|
|
@@ -28148,10 +28206,7 @@
|
|
|
28148
28206
|
return;
|
|
28149
28207
|
}
|
|
28150
28208
|
if (this.props.sidePanelIsOpen) {
|
|
28151
|
-
this.env.openSidePanel("ChartPanel", {
|
|
28152
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
28153
|
-
figure,
|
|
28154
|
-
});
|
|
28209
|
+
this.env.openSidePanel("ChartPanel", { figure });
|
|
28155
28210
|
}
|
|
28156
28211
|
const initialX = ev.clientX;
|
|
28157
28212
|
const initialY = ev.clientY;
|
|
@@ -31233,9 +31288,9 @@
|
|
|
31233
31288
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
31234
31289
|
|
|
31235
31290
|
|
|
31236
|
-
__info__.version = '15.2.
|
|
31237
|
-
__info__.date = '2023-
|
|
31238
|
-
__info__.hash = '
|
|
31291
|
+
__info__.version = '15.2.1';
|
|
31292
|
+
__info__.date = '2023-03-06T07:16:45.196Z';
|
|
31293
|
+
__info__.hash = 'baeea23';
|
|
31239
31294
|
|
|
31240
31295
|
|
|
31241
31296
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|