@odoo/o-spreadsheet 15.0.0 → 15.0.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} +199 -134
- package/dist/{o_spreadsheet.d.ts → o-spreadsheet.d.ts} +19 -16
- package/dist/{o_spreadsheet.esm.js → o-spreadsheet.esm.js} +199 -134
- package/dist/{o_spreadsheet.iife.js → o-spreadsheet.iife.js} +199 -134
- package/dist/{o_spreadsheet.iife.min.js → o-spreadsheet.iife.min.js} +12 -8
- package/package.json +10 -5
|
@@ -1387,6 +1387,7 @@
|
|
|
1387
1387
|
CommandResult[CommandResult["FigureDoesNotExist"] = 55] = "FigureDoesNotExist";
|
|
1388
1388
|
CommandResult[CommandResult["DuplicatedFigureId"] = 56] = "DuplicatedFigureId";
|
|
1389
1389
|
CommandResult[CommandResult["DuplicatedChartId"] = 57] = "DuplicatedChartId";
|
|
1390
|
+
CommandResult[CommandResult["ChartDoesNotExist"] = 58] = "ChartDoesNotExist";
|
|
1390
1391
|
})(exports.CommandResult || (exports.CommandResult = {}));
|
|
1391
1392
|
|
|
1392
1393
|
var ReturnFormatType;
|
|
@@ -2970,6 +2971,9 @@
|
|
|
2970
2971
|
if (isNaN(zone.bottom) || isNaN(zone.top) || isNaN(zone.left) || isNaN(zone.right)) {
|
|
2971
2972
|
return false;
|
|
2972
2973
|
}
|
|
2974
|
+
if (zone.top < 0 || zone.left < 0 || zone.right < 0 || zone.bottom < 0) {
|
|
2975
|
+
return false;
|
|
2976
|
+
}
|
|
2973
2977
|
return zone.bottom >= zone.top && zone.right >= zone.left;
|
|
2974
2978
|
}
|
|
2975
2979
|
/**
|
|
@@ -8474,13 +8478,7 @@
|
|
|
8474
8478
|
data = migrate(data);
|
|
8475
8479
|
}
|
|
8476
8480
|
}
|
|
8477
|
-
|
|
8478
|
-
// sensible default values
|
|
8479
|
-
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8480
|
-
data.sheets = data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s));
|
|
8481
|
-
if (data.sheets.length === 0) {
|
|
8482
|
-
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8483
|
-
}
|
|
8481
|
+
data = repairData(data);
|
|
8484
8482
|
return data;
|
|
8485
8483
|
}
|
|
8486
8484
|
function migrate(data) {
|
|
@@ -8689,6 +8687,48 @@
|
|
|
8689
8687
|
},
|
|
8690
8688
|
},
|
|
8691
8689
|
];
|
|
8690
|
+
/**
|
|
8691
|
+
* This function is used to repair faulty data independently of the migration.
|
|
8692
|
+
*/
|
|
8693
|
+
function repairData(data) {
|
|
8694
|
+
data = forceUnicityOfFigure(data);
|
|
8695
|
+
data = setDefaults(data);
|
|
8696
|
+
return data;
|
|
8697
|
+
}
|
|
8698
|
+
/**
|
|
8699
|
+
* Force the unicity of figure ids accross sheets
|
|
8700
|
+
*/
|
|
8701
|
+
function forceUnicityOfFigure(data) {
|
|
8702
|
+
if (data.uniqueFigureIds) {
|
|
8703
|
+
return data;
|
|
8704
|
+
}
|
|
8705
|
+
const figureIds = new Set();
|
|
8706
|
+
const uuidGenerator = new UuidGenerator();
|
|
8707
|
+
for (const sheet of data.sheets || []) {
|
|
8708
|
+
for (const figure of sheet.figures || []) {
|
|
8709
|
+
if (figureIds.has(figure.id)) {
|
|
8710
|
+
figure.id += uuidGenerator.uuidv4();
|
|
8711
|
+
}
|
|
8712
|
+
figureIds.add(figure.id);
|
|
8713
|
+
}
|
|
8714
|
+
}
|
|
8715
|
+
data.uniqueFigureIds = true;
|
|
8716
|
+
return data;
|
|
8717
|
+
}
|
|
8718
|
+
/**
|
|
8719
|
+
* sanity check: try to fix missing fields/corrupted state by providing
|
|
8720
|
+
* sensible default values
|
|
8721
|
+
*/
|
|
8722
|
+
function setDefaults(data) {
|
|
8723
|
+
data = Object.assign(createEmptyWorkbookData(), data, { version: CURRENT_VERSION });
|
|
8724
|
+
data.sheets = data.sheets
|
|
8725
|
+
? data.sheets.map((s, i) => Object.assign(createEmptySheet(`Sheet${i + 1}`, `Sheet${i + 1}`), s))
|
|
8726
|
+
: [];
|
|
8727
|
+
if (data.sheets.length === 0) {
|
|
8728
|
+
data.sheets.push(createEmptySheet(INITIAL_SHEET_ID, "Sheet1"));
|
|
8729
|
+
}
|
|
8730
|
+
return data;
|
|
8731
|
+
}
|
|
8692
8732
|
/**
|
|
8693
8733
|
* The goal of this function is to repair corrupted/wrong initial messages caused by
|
|
8694
8734
|
* a bug.
|
|
@@ -8775,6 +8815,7 @@
|
|
|
8775
8815
|
styles: {},
|
|
8776
8816
|
borders: {},
|
|
8777
8817
|
revisionId: DEFAULT_REVISION_ID,
|
|
8818
|
+
uniqueFigureIds: true,
|
|
8778
8819
|
};
|
|
8779
8820
|
return data;
|
|
8780
8821
|
}
|
|
@@ -9805,34 +9846,32 @@
|
|
|
9805
9846
|
this.chartFigures = {};
|
|
9806
9847
|
}
|
|
9807
9848
|
adaptRanges(applyChange) {
|
|
9808
|
-
for (
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
this.adaptLabelRanges(sheetId, chart, chartId, applyChange);
|
|
9813
|
-
}
|
|
9849
|
+
for (let [chartId, chart] of Object.entries(this.chartFigures)) {
|
|
9850
|
+
if (chart) {
|
|
9851
|
+
this.adaptDataSetRanges(chart, chartId, applyChange);
|
|
9852
|
+
this.adaptLabelRanges(chart, chartId, applyChange);
|
|
9814
9853
|
}
|
|
9815
9854
|
}
|
|
9816
9855
|
}
|
|
9817
|
-
adaptDataSetRanges(
|
|
9856
|
+
adaptDataSetRanges(chart, chartId, applyChange) {
|
|
9818
9857
|
for (let ds of chart.dataSets) {
|
|
9819
9858
|
if (ds.labelCell) {
|
|
9820
9859
|
const labelCellChange = applyChange(ds.labelCell);
|
|
9821
9860
|
switch (labelCellChange.changeType) {
|
|
9822
9861
|
case "REMOVE":
|
|
9823
|
-
this.history.update("chartFigures",
|
|
9862
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", undefined);
|
|
9824
9863
|
break;
|
|
9825
9864
|
case "RESIZE":
|
|
9826
9865
|
case "MOVE":
|
|
9827
9866
|
case "CHANGE":
|
|
9828
|
-
this.history.update("chartFigures",
|
|
9867
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "labelCell", labelCellChange.range);
|
|
9829
9868
|
}
|
|
9830
9869
|
}
|
|
9831
9870
|
const dataRangeChange = applyChange(ds.dataRange);
|
|
9832
9871
|
switch (dataRangeChange.changeType) {
|
|
9833
9872
|
case "REMOVE":
|
|
9834
9873
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9835
|
-
this.history.update("chartFigures",
|
|
9874
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9836
9875
|
break;
|
|
9837
9876
|
case "RESIZE":
|
|
9838
9877
|
case "MOVE":
|
|
@@ -9840,27 +9879,27 @@
|
|
|
9840
9879
|
// We have to remove the ranges that are #REF
|
|
9841
9880
|
if (this.getters.getRangeString(dataRangeChange.range, dataRangeChange.range.sheetId) !==
|
|
9842
9881
|
INCORRECT_RANGE_STRING) {
|
|
9843
|
-
this.history.update("chartFigures",
|
|
9882
|
+
this.history.update("chartFigures", chartId, "dataSets", chart.dataSets.indexOf(ds), "dataRange", dataRangeChange.range);
|
|
9844
9883
|
}
|
|
9845
9884
|
else {
|
|
9846
9885
|
const newDataSets = chart.dataSets.filter((dataset) => dataset !== ds);
|
|
9847
|
-
this.history.update("chartFigures",
|
|
9886
|
+
this.history.update("chartFigures", chartId, "dataSets", newDataSets);
|
|
9848
9887
|
}
|
|
9849
9888
|
break;
|
|
9850
9889
|
}
|
|
9851
9890
|
}
|
|
9852
9891
|
}
|
|
9853
|
-
adaptLabelRanges(
|
|
9892
|
+
adaptLabelRanges(chart, chartId, applyChange) {
|
|
9854
9893
|
if (chart.labelRange) {
|
|
9855
9894
|
const labelRangeChange = applyChange(chart.labelRange);
|
|
9856
9895
|
switch (labelRangeChange.changeType) {
|
|
9857
9896
|
case "REMOVE":
|
|
9858
|
-
this.history.update("chartFigures",
|
|
9897
|
+
this.history.update("chartFigures", chartId, "labelRange", undefined);
|
|
9859
9898
|
break;
|
|
9860
9899
|
case "RESIZE":
|
|
9861
9900
|
case "MOVE":
|
|
9862
9901
|
case "CHANGE":
|
|
9863
|
-
this.history.update("chartFigures",
|
|
9902
|
+
this.history.update("chartFigures", chartId, "labelRange", labelRangeChange.range);
|
|
9864
9903
|
break;
|
|
9865
9904
|
}
|
|
9866
9905
|
}
|
|
@@ -9871,16 +9910,16 @@
|
|
|
9871
9910
|
allowDispatch(cmd) {
|
|
9872
9911
|
const success = 0 /* Success */;
|
|
9873
9912
|
switch (cmd.type) {
|
|
9874
|
-
case "CREATE_CHART":
|
|
9875
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkChartDuplicate, this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9876
9913
|
case "UPDATE_CHART":
|
|
9877
|
-
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset), this.checkLabelRange);
|
|
9914
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartExists), this.checkLabelRange);
|
|
9915
|
+
case "CREATE_CHART":
|
|
9916
|
+
return this.checkValidations(cmd, this.chainValidations(this.checkEmptyDataset, this.checkDataset, this.checkChartDuplicate), this.checkLabelRange);
|
|
9878
9917
|
default:
|
|
9879
9918
|
return success;
|
|
9880
9919
|
}
|
|
9881
9920
|
}
|
|
9882
9921
|
handle(cmd) {
|
|
9883
|
-
var _a;
|
|
9922
|
+
var _a, _b;
|
|
9884
9923
|
switch (cmd.type) {
|
|
9885
9924
|
case "CREATE_CHART":
|
|
9886
9925
|
const x = cmd.position ? cmd.position.x : 0;
|
|
@@ -9895,7 +9934,7 @@
|
|
|
9895
9934
|
});
|
|
9896
9935
|
break;
|
|
9897
9936
|
case "UPDATE_CHART": {
|
|
9898
|
-
this.updateChartDefinition(cmd.
|
|
9937
|
+
this.updateChartDefinition(cmd.id, cmd.definition);
|
|
9899
9938
|
break;
|
|
9900
9939
|
}
|
|
9901
9940
|
case "DUPLICATE_SHEET": {
|
|
@@ -9905,7 +9944,7 @@
|
|
|
9905
9944
|
const figureIdBase = fig.id.split(FIGURE_ID_SPLITTER).pop();
|
|
9906
9945
|
const duplicatedFigureId = `${cmd.sheetIdTo}${FIGURE_ID_SPLITTER}${figureIdBase}`;
|
|
9907
9946
|
const chartDefinition = {
|
|
9908
|
-
...deepCopy(this.chartFigures[
|
|
9947
|
+
...deepCopy(this.chartFigures[fig.id]),
|
|
9909
9948
|
id: duplicatedFigureId,
|
|
9910
9949
|
};
|
|
9911
9950
|
chartDefinition.sheetId = cmd.sheetIdTo;
|
|
@@ -9935,28 +9974,37 @@
|
|
|
9935
9974
|
break;
|
|
9936
9975
|
}
|
|
9937
9976
|
case "DELETE_FIGURE":
|
|
9938
|
-
this.history.update("chartFigures", cmd.
|
|
9977
|
+
this.history.update("chartFigures", cmd.id, undefined);
|
|
9939
9978
|
break;
|
|
9940
9979
|
case "DELETE_SHEET":
|
|
9941
|
-
this.
|
|
9980
|
+
for (let id of Object.keys(this.chartFigures)) {
|
|
9981
|
+
if (((_b = this.chartFigures[id]) === null || _b === void 0 ? void 0 : _b.sheetId) === cmd.sheetId) {
|
|
9982
|
+
this.history.update("chartFigures", id, undefined);
|
|
9983
|
+
}
|
|
9984
|
+
}
|
|
9942
9985
|
break;
|
|
9943
9986
|
}
|
|
9944
9987
|
}
|
|
9945
9988
|
// ---------------------------------------------------------------------------
|
|
9946
9989
|
// Getters
|
|
9947
9990
|
// ---------------------------------------------------------------------------
|
|
9948
|
-
getChartDefinition(
|
|
9949
|
-
|
|
9950
|
-
return (_a = this.chartFigures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
9991
|
+
getChartDefinition(figureId) {
|
|
9992
|
+
return this.chartFigures[figureId];
|
|
9951
9993
|
}
|
|
9952
|
-
|
|
9953
|
-
return Object.
|
|
9994
|
+
getChartsIdBySheet(sheetId) {
|
|
9995
|
+
return Object.entries(this.chartFigures)
|
|
9996
|
+
.filter((chart) => {
|
|
9997
|
+
return chart[1].sheetId === sheetId;
|
|
9998
|
+
})
|
|
9999
|
+
.map((chart) => chart[0]);
|
|
9954
10000
|
}
|
|
9955
|
-
getChartDefinitionUI(sheetId, figureId
|
|
9956
|
-
const data = this.chartFigures[
|
|
9957
|
-
|
|
10001
|
+
getChartDefinitionUI(sheetId, figureId) {
|
|
10002
|
+
const data = this.chartFigures[figureId];
|
|
10003
|
+
if (!data) {
|
|
10004
|
+
return undefined;
|
|
10005
|
+
}
|
|
9958
10006
|
const dataSets = data.dataSets
|
|
9959
|
-
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange,
|
|
10007
|
+
.map((ds) => (ds ? this.getters.getRangeString(ds.dataRange, sheetId) : ""))
|
|
9960
10008
|
.filter((ds) => {
|
|
9961
10009
|
return ds !== ""; // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9962
10010
|
});
|
|
@@ -9964,7 +10012,7 @@
|
|
|
9964
10012
|
title: data && data.title ? data.title : "",
|
|
9965
10013
|
dataSets,
|
|
9966
10014
|
labelRange: data.labelRange
|
|
9967
|
-
? this.getters.getRangeString(data.labelRange,
|
|
10015
|
+
? this.getters.getRangeString(data.labelRange, sheetId)
|
|
9968
10016
|
: undefined,
|
|
9969
10017
|
type: data ? data.type : "bar",
|
|
9970
10018
|
dataSetsHaveTitle: data && dataSets.length !== 0 ? Boolean(data.dataSets[0].labelCell) : false,
|
|
@@ -9975,12 +10023,16 @@
|
|
|
9975
10023
|
};
|
|
9976
10024
|
}
|
|
9977
10025
|
getChartDefinitionExcel(sheetId, figureId) {
|
|
9978
|
-
const data = this.chartFigures[
|
|
10026
|
+
const data = this.chartFigures[figureId];
|
|
10027
|
+
const dataUI = this.getChartDefinitionUI("forceSheetReference", figureId);
|
|
10028
|
+
if (!data || !dataUI) {
|
|
10029
|
+
return undefined;
|
|
10030
|
+
}
|
|
9979
10031
|
const dataSets = data.dataSets
|
|
9980
10032
|
.map((ds) => this.toExcelDataset(ds))
|
|
9981
10033
|
.filter((ds) => ds.range !== ""); // && range !== INCORRECT_RANGE_STRING ? show incorrect #ref ?
|
|
9982
10034
|
return {
|
|
9983
|
-
...
|
|
10035
|
+
...dataUI,
|
|
9984
10036
|
backgroundColor: data.background,
|
|
9985
10037
|
dataSets,
|
|
9986
10038
|
};
|
|
@@ -10015,17 +10067,15 @@
|
|
|
10015
10067
|
import(data) {
|
|
10016
10068
|
for (let sheet of data.sheets) {
|
|
10017
10069
|
if (sheet.figures) {
|
|
10018
|
-
const charts = {};
|
|
10019
10070
|
for (let figure of sheet.figures) {
|
|
10020
10071
|
if (figure.tag === "chart") {
|
|
10021
10072
|
const figureData = {
|
|
10022
10073
|
...figure.data,
|
|
10023
10074
|
};
|
|
10024
|
-
|
|
10075
|
+
this.chartFigures[figure.id] = this.createChartDefinition(figureData, sheet.id);
|
|
10025
10076
|
delete figure.data;
|
|
10026
10077
|
}
|
|
10027
10078
|
}
|
|
10028
|
-
this.chartFigures[sheet.id] = charts;
|
|
10029
10079
|
}
|
|
10030
10080
|
}
|
|
10031
10081
|
}
|
|
@@ -10033,10 +10083,18 @@
|
|
|
10033
10083
|
if (data.sheets) {
|
|
10034
10084
|
for (let sheet of data.sheets) {
|
|
10035
10085
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10036
|
-
const figures =
|
|
10037
|
-
for (let
|
|
10086
|
+
const figures = [];
|
|
10087
|
+
for (let sheetFigure of sheetFigures) {
|
|
10088
|
+
const figure = sheetFigure;
|
|
10038
10089
|
if (figure && figure.tag === "chart") {
|
|
10039
|
-
|
|
10090
|
+
const data = this.getChartDefinitionUI(sheet.id, figure.id);
|
|
10091
|
+
if (data) {
|
|
10092
|
+
figure.data = data;
|
|
10093
|
+
figures.push(figure);
|
|
10094
|
+
}
|
|
10095
|
+
}
|
|
10096
|
+
else {
|
|
10097
|
+
figures.push(figure);
|
|
10040
10098
|
}
|
|
10041
10099
|
}
|
|
10042
10100
|
sheet.figures = figures;
|
|
@@ -10046,10 +10104,18 @@
|
|
|
10046
10104
|
exportForExcel(data) {
|
|
10047
10105
|
for (let sheet of data.sheets) {
|
|
10048
10106
|
const sheetFigures = this.getters.getFigures(sheet.id);
|
|
10049
|
-
const figures =
|
|
10050
|
-
for (let
|
|
10107
|
+
const figures = [];
|
|
10108
|
+
for (let sheetFigure of sheetFigures) {
|
|
10109
|
+
const figure = sheetFigure;
|
|
10051
10110
|
if (figure && figure.tag === "chart") {
|
|
10052
|
-
|
|
10111
|
+
const data = this.getChartDefinitionExcel(sheet.id, figure.id);
|
|
10112
|
+
if (data) {
|
|
10113
|
+
figure.data = data;
|
|
10114
|
+
figures.push(figure);
|
|
10115
|
+
}
|
|
10116
|
+
}
|
|
10117
|
+
else {
|
|
10118
|
+
figures.push(figure);
|
|
10053
10119
|
}
|
|
10054
10120
|
}
|
|
10055
10121
|
sheet.charts = figures;
|
|
@@ -10075,39 +10141,39 @@
|
|
|
10075
10141
|
* Update the chart definition linked to the given id with the attributes
|
|
10076
10142
|
* given in the partial UI definition
|
|
10077
10143
|
*/
|
|
10078
|
-
updateChartDefinition(
|
|
10079
|
-
const chart = this.chartFigures[
|
|
10144
|
+
updateChartDefinition(id, definition) {
|
|
10145
|
+
const chart = this.chartFigures[id];
|
|
10080
10146
|
if (!chart) {
|
|
10081
10147
|
throw new Error(`There is no chart with the given id: ${id}`);
|
|
10082
10148
|
}
|
|
10083
10149
|
if (definition.title !== undefined) {
|
|
10084
|
-
this.history.update("chartFigures",
|
|
10150
|
+
this.history.update("chartFigures", id, "title", definition.title);
|
|
10085
10151
|
}
|
|
10086
10152
|
if (definition.type) {
|
|
10087
|
-
this.history.update("chartFigures",
|
|
10153
|
+
this.history.update("chartFigures", id, "type", definition.type);
|
|
10088
10154
|
}
|
|
10089
10155
|
if (definition.dataSets) {
|
|
10090
10156
|
const dataSetsHaveTitle = !!definition.dataSetsHaveTitle;
|
|
10091
10157
|
const dataSets = this.createDataSets(definition.dataSets, chart.sheetId, dataSetsHaveTitle);
|
|
10092
|
-
this.history.update("chartFigures",
|
|
10158
|
+
this.history.update("chartFigures", id, "dataSets", dataSets);
|
|
10093
10159
|
}
|
|
10094
10160
|
if (definition.labelRange !== undefined) {
|
|
10095
10161
|
const labelRange = definition.labelRange
|
|
10096
10162
|
? this.getters.getRangeFromSheetXC(chart.sheetId, definition.labelRange)
|
|
10097
10163
|
: undefined;
|
|
10098
|
-
this.history.update("chartFigures",
|
|
10164
|
+
this.history.update("chartFigures", id, "labelRange", labelRange);
|
|
10099
10165
|
}
|
|
10100
10166
|
if (definition.background) {
|
|
10101
|
-
this.history.update("chartFigures",
|
|
10167
|
+
this.history.update("chartFigures", id, "background", definition.background);
|
|
10102
10168
|
}
|
|
10103
10169
|
if (definition.verticalAxisPosition) {
|
|
10104
|
-
this.history.update("chartFigures",
|
|
10170
|
+
this.history.update("chartFigures", id, "verticalAxisPosition", definition.verticalAxisPosition);
|
|
10105
10171
|
}
|
|
10106
10172
|
if (definition.legendPosition) {
|
|
10107
|
-
this.history.update("chartFigures",
|
|
10173
|
+
this.history.update("chartFigures", id, "legendPosition", definition.legendPosition);
|
|
10108
10174
|
}
|
|
10109
10175
|
if (definition.stackedBar !== undefined) {
|
|
10110
|
-
this.history.update("chartFigures",
|
|
10176
|
+
this.history.update("chartFigures", id, "stackedBar", definition.stackedBar);
|
|
10111
10177
|
}
|
|
10112
10178
|
}
|
|
10113
10179
|
createDataSets(dataSetsString, sheetId, dataSetsHaveTitle) {
|
|
@@ -10162,7 +10228,7 @@
|
|
|
10162
10228
|
sheetId,
|
|
10163
10229
|
figure,
|
|
10164
10230
|
});
|
|
10165
|
-
this.history.update("chartFigures",
|
|
10231
|
+
this.history.update("chartFigures", figure.id, data);
|
|
10166
10232
|
}
|
|
10167
10233
|
createDataSet(sheetId, fullZone, titleZone) {
|
|
10168
10234
|
if (fullZone.left !== fullZone.right && fullZone.top !== fullZone.bottom) {
|
|
@@ -10203,14 +10269,20 @@
|
|
|
10203
10269
|
return invalidLabels ? 29 /* InvalidLabelRange */ : 0 /* Success */;
|
|
10204
10270
|
}
|
|
10205
10271
|
checkChartDuplicate(cmd) {
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10272
|
+
for (const sheet of this.getters.getSheets()) {
|
|
10273
|
+
if (this.getters.getFigure(sheet.id, cmd.id)) {
|
|
10274
|
+
return 57 /* DuplicatedChartId */;
|
|
10275
|
+
}
|
|
10209
10276
|
}
|
|
10210
10277
|
return 0 /* Success */;
|
|
10211
10278
|
}
|
|
10279
|
+
checkChartExists(cmd) {
|
|
10280
|
+
return this.getters.getFigure(cmd.sheetId, cmd.id)
|
|
10281
|
+
? 0 /* Success */
|
|
10282
|
+
: 58 /* ChartDoesNotExist */;
|
|
10283
|
+
}
|
|
10212
10284
|
}
|
|
10213
|
-
ChartPlugin.getters = ["getChartDefinition", "getChartDefinitionUI", "
|
|
10285
|
+
ChartPlugin.getters = ["getChartDefinition", "getChartDefinitionUI", "getChartsIdBySheet"];
|
|
10214
10286
|
|
|
10215
10287
|
// -----------------------------------------------------------------------------
|
|
10216
10288
|
// Constants
|
|
@@ -10549,7 +10621,7 @@
|
|
|
10549
10621
|
allowDispatch(cmd) {
|
|
10550
10622
|
switch (cmd.type) {
|
|
10551
10623
|
case "CREATE_FIGURE":
|
|
10552
|
-
return this.checkFigureDuplicate(cmd.
|
|
10624
|
+
return this.checkFigureDuplicate(cmd.figure.id);
|
|
10553
10625
|
case "UPDATE_FIGURE":
|
|
10554
10626
|
case "DELETE_FIGURE":
|
|
10555
10627
|
return this.checkFigureExists(cmd.sheetId, cmd.id);
|
|
@@ -10615,9 +10687,8 @@
|
|
|
10615
10687
|
}
|
|
10616
10688
|
return 0 /* Success */;
|
|
10617
10689
|
}
|
|
10618
|
-
checkFigureDuplicate(
|
|
10619
|
-
|
|
10620
|
-
if ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) {
|
|
10690
|
+
checkFigureDuplicate(figureId) {
|
|
10691
|
+
if (Object.values(this.figures).find((sheet) => sheet === null || sheet === void 0 ? void 0 : sheet[figureId])) {
|
|
10621
10692
|
return 56 /* DuplicatedFigureId */;
|
|
10622
10693
|
}
|
|
10623
10694
|
return 0 /* Success */;
|
|
@@ -10632,6 +10703,9 @@
|
|
|
10632
10703
|
var _a;
|
|
10633
10704
|
return (_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId];
|
|
10634
10705
|
}
|
|
10706
|
+
getFigureSheetId(figureId) {
|
|
10707
|
+
return Object.keys(this.figures).find((sheetId) => { var _a; return ((_a = this.figures[sheetId]) === null || _a === void 0 ? void 0 : _a[figureId]) !== undefined; });
|
|
10708
|
+
}
|
|
10635
10709
|
// ---------------------------------------------------------------------------
|
|
10636
10710
|
// Import/Export
|
|
10637
10711
|
// ---------------------------------------------------------------------------
|
|
@@ -10656,7 +10730,7 @@
|
|
|
10656
10730
|
this.export(data);
|
|
10657
10731
|
}
|
|
10658
10732
|
}
|
|
10659
|
-
FigurePlugin.getters = ["getFigures", "getFigure"];
|
|
10733
|
+
FigurePlugin.getters = ["getFigures", "getFigure", "getFigureSheetId"];
|
|
10660
10734
|
|
|
10661
10735
|
class MergePlugin extends CorePlugin {
|
|
10662
10736
|
constructor() {
|
|
@@ -12818,7 +12892,7 @@
|
|
|
12818
12892
|
},
|
|
12819
12893
|
});
|
|
12820
12894
|
const figure = env.getters.getFigure(sheetId, id);
|
|
12821
|
-
env.openSidePanel("ChartPanel", {
|
|
12895
|
+
env.openSidePanel("ChartPanel", { figure });
|
|
12822
12896
|
};
|
|
12823
12897
|
//------------------------------------------------------------------------------
|
|
12824
12898
|
// Style/Format
|
|
@@ -14315,19 +14389,21 @@
|
|
|
14315
14389
|
constructor() {
|
|
14316
14390
|
super(...arguments);
|
|
14317
14391
|
this.getters = this.env.getters;
|
|
14392
|
+
this.chartSheetId = this.findSheetId(this.props.figure.id);
|
|
14318
14393
|
this.state = owl.useState(this.initialState(this.props.figure));
|
|
14319
14394
|
}
|
|
14320
14395
|
async willUpdateProps(nextProps) {
|
|
14321
|
-
if (!this.getters.getChartDefinition(nextProps.
|
|
14396
|
+
if (!this.getters.getChartDefinition(nextProps.figure.id)) {
|
|
14322
14397
|
this.trigger("close-side-panel");
|
|
14323
14398
|
return;
|
|
14324
14399
|
}
|
|
14325
14400
|
if (nextProps.figure.id !== this.props.figure.id) {
|
|
14401
|
+
this.chartSheetId = this.findSheetId(nextProps.figure.id);
|
|
14326
14402
|
this.state.panel = "configuration";
|
|
14327
14403
|
this.state.fillColorTool = false;
|
|
14328
14404
|
this.state.datasetDispatchResult = undefined;
|
|
14329
14405
|
this.state.labelsDispatchResult = undefined;
|
|
14330
|
-
this.state.chart = this.env.getters.getChartDefinitionUI(this.
|
|
14406
|
+
this.state.chart = this.env.getters.getChartDefinitionUI(this.chartSheetId, nextProps.figure.id);
|
|
14331
14407
|
}
|
|
14332
14408
|
}
|
|
14333
14409
|
get errorMessages() {
|
|
@@ -14374,7 +14450,7 @@
|
|
|
14374
14450
|
updateChart(definition) {
|
|
14375
14451
|
return this.env.dispatch("UPDATE_CHART", {
|
|
14376
14452
|
id: this.props.figure.id,
|
|
14377
|
-
sheetId: this.
|
|
14453
|
+
sheetId: this.chartSheetId,
|
|
14378
14454
|
definition,
|
|
14379
14455
|
});
|
|
14380
14456
|
}
|
|
@@ -14396,12 +14472,16 @@
|
|
|
14396
14472
|
this.state.panel = panel;
|
|
14397
14473
|
}
|
|
14398
14474
|
initialState(figure) {
|
|
14475
|
+
const sheetId = this.findSheetId(figure.id);
|
|
14399
14476
|
return {
|
|
14400
|
-
chart: this.env.getters.getChartDefinitionUI(
|
|
14477
|
+
chart: this.env.getters.getChartDefinitionUI(sheetId, figure.id),
|
|
14401
14478
|
panel: "configuration",
|
|
14402
14479
|
fillColorTool: false,
|
|
14403
14480
|
};
|
|
14404
14481
|
}
|
|
14482
|
+
findSheetId(figureId) {
|
|
14483
|
+
return this.env.getters.getFigureSheetId(figureId) || "";
|
|
14484
|
+
}
|
|
14405
14485
|
}
|
|
14406
14486
|
ChartPanel.template = TEMPLATE$p;
|
|
14407
14487
|
ChartPanel.style = STYLE;
|
|
@@ -18815,60 +18895,51 @@
|
|
|
18815
18895
|
this.outOfDate = new Set();
|
|
18816
18896
|
}
|
|
18817
18897
|
handle(cmd) {
|
|
18818
|
-
var _a;
|
|
18819
18898
|
if (invalidateEvaluationCommands.has(cmd.type) ||
|
|
18820
18899
|
cmd.type === "EVALUATE_CELLS" ||
|
|
18821
18900
|
(cmd.type === "UPDATE_CELL" && "content" in cmd)) {
|
|
18822
|
-
for (
|
|
18823
|
-
|
|
18824
|
-
this.outOfDate.add(chartId);
|
|
18825
|
-
}
|
|
18901
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18902
|
+
this.outOfDate.add(chartId);
|
|
18826
18903
|
}
|
|
18827
18904
|
}
|
|
18828
18905
|
switch (cmd.type) {
|
|
18829
18906
|
case "UPDATE_CHART":
|
|
18830
|
-
case "CREATE_CHART":
|
|
18831
|
-
const chartDefinition = this.getters.getChartDefinition(cmd.
|
|
18832
|
-
|
|
18833
|
-
this.chartRuntime[cmd.sheetId] = {};
|
|
18834
|
-
this.chartRuntime[cmd.sheetId][cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18907
|
+
case "CREATE_CHART":
|
|
18908
|
+
const chartDefinition = this.getters.getChartDefinition(cmd.id);
|
|
18909
|
+
this.chartRuntime[cmd.id] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18835
18910
|
break;
|
|
18836
|
-
}
|
|
18837
18911
|
case "DELETE_FIGURE":
|
|
18838
|
-
|
|
18912
|
+
delete this.chartRuntime[cmd.id];
|
|
18839
18913
|
break;
|
|
18840
|
-
case "REFRESH_CHART":
|
|
18841
|
-
|
|
18842
|
-
this.evaluateUsedSheets([chartDefinition]);
|
|
18914
|
+
case "REFRESH_CHART":
|
|
18915
|
+
this.evaluateUsedSheets([cmd.id]);
|
|
18843
18916
|
this.outOfDate.add(cmd.id);
|
|
18844
18917
|
break;
|
|
18845
|
-
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
this.evaluateUsedSheets(chartsDefinitions);
|
|
18918
|
+
case "ACTIVATE_SHEET":
|
|
18919
|
+
const chartsIds = this.getters.getChartsIdBySheet(cmd.sheetIdTo);
|
|
18920
|
+
this.evaluateUsedSheets(chartsIds);
|
|
18849
18921
|
break;
|
|
18850
|
-
}
|
|
18851
18922
|
case "DELETE_SHEET":
|
|
18852
|
-
|
|
18923
|
+
for (let chartId of Object.keys(this.chartRuntime)) {
|
|
18924
|
+
if (!this.getters.getChartDefinition(chartId)) {
|
|
18925
|
+
delete this.chartRuntime[chartId];
|
|
18926
|
+
}
|
|
18927
|
+
}
|
|
18853
18928
|
break;
|
|
18854
18929
|
}
|
|
18855
18930
|
}
|
|
18856
18931
|
// ---------------------------------------------------------------------------
|
|
18857
18932
|
// Getters
|
|
18858
18933
|
// ---------------------------------------------------------------------------
|
|
18859
|
-
getChartRuntime(
|
|
18860
|
-
if (this.outOfDate.has(figureId) ||
|
|
18861
|
-
|
|
18862
|
-
!(figureId in this.chartRuntime[sheetId])) {
|
|
18863
|
-
const chartDefinition = this.getters.getChartDefinition(sheetId, figureId);
|
|
18934
|
+
getChartRuntime(figureId) {
|
|
18935
|
+
if (this.outOfDate.has(figureId) || !(figureId in this.chartRuntime)) {
|
|
18936
|
+
const chartDefinition = this.getters.getChartDefinition(figureId);
|
|
18864
18937
|
if (chartDefinition === undefined)
|
|
18865
18938
|
return;
|
|
18866
|
-
|
|
18867
|
-
this.chartRuntime[sheetId] = {};
|
|
18868
|
-
this.chartRuntime[sheetId][figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18939
|
+
this.chartRuntime[figureId] = this.mapDefinitionToRuntime(chartDefinition);
|
|
18869
18940
|
this.outOfDate.delete(figureId);
|
|
18870
18941
|
}
|
|
18871
|
-
return this.chartRuntime[
|
|
18942
|
+
return this.chartRuntime[figureId];
|
|
18872
18943
|
}
|
|
18873
18944
|
truncateLabel(label) {
|
|
18874
18945
|
if (!label) {
|
|
@@ -18973,9 +19044,10 @@
|
|
|
18973
19044
|
}
|
|
18974
19045
|
return sheetIds;
|
|
18975
19046
|
}
|
|
18976
|
-
evaluateUsedSheets(
|
|
19047
|
+
evaluateUsedSheets(chartsIds) {
|
|
18977
19048
|
const usedSheetsId = new Set();
|
|
18978
|
-
for (
|
|
19049
|
+
for (let chartId of chartsIds) {
|
|
19050
|
+
const chartDefinition = this.getters.getChartDefinition(chartId);
|
|
18979
19051
|
const sheetsIds = chartDefinition !== undefined ? this.getSheetIdsUsedInChart(chartDefinition) : [];
|
|
18980
19052
|
sheetsIds.forEach((sheetId) => {
|
|
18981
19053
|
if (sheetId !== this.getters.getActiveSheetId()) {
|
|
@@ -23526,6 +23598,7 @@
|
|
|
23526
23598
|
}
|
|
23527
23599
|
else if (range.zone[start] >= min && range.zone[end] <= max) {
|
|
23528
23600
|
changeType = "REMOVE";
|
|
23601
|
+
newRange = this.buildInvalidRange(INCORRECT_RANGE_STRING);
|
|
23529
23602
|
}
|
|
23530
23603
|
else if (range.zone[start] <= max && range.zone[end] >= max) {
|
|
23531
23604
|
const toRemove = max - range.zone[start] + 1;
|
|
@@ -23591,10 +23664,8 @@
|
|
|
23591
23664
|
return { changeType: "NONE" };
|
|
23592
23665
|
}
|
|
23593
23666
|
range = {
|
|
23594
|
-
...
|
|
23595
|
-
zone: { ...range.zone },
|
|
23667
|
+
...this.buildInvalidRange(INCORRECT_RANGE_STRING),
|
|
23596
23668
|
invalidSheetName: this.getters.getSheetName(cmd.sheetId),
|
|
23597
|
-
sheetId: "",
|
|
23598
23669
|
};
|
|
23599
23670
|
return { changeType: "REMOVE", range };
|
|
23600
23671
|
}, cmd.sheetId);
|
|
@@ -26063,7 +26134,7 @@
|
|
|
26063
26134
|
const { xml: xml$l } = owl.tags;
|
|
26064
26135
|
const TEMPLATE$j = xml$l /* xml */ `
|
|
26065
26136
|
<Portal target="'.o-spreadsheet'">
|
|
26066
|
-
<div t-att-style="style">
|
|
26137
|
+
<div class="o-popover" t-att-style="style">
|
|
26067
26138
|
<t t-slot="default"/>
|
|
26068
26139
|
</div>
|
|
26069
26140
|
</Portal>
|
|
@@ -27245,7 +27316,7 @@
|
|
|
27245
27316
|
padding: 0;
|
|
27246
27317
|
margin: 0;
|
|
27247
27318
|
border: 0;
|
|
27248
|
-
z-index:
|
|
27319
|
+
z-index: 6;
|
|
27249
27320
|
flex-grow: 1;
|
|
27250
27321
|
max-height: inherit;
|
|
27251
27322
|
.o-composer {
|
|
@@ -27816,6 +27887,10 @@
|
|
|
27816
27887
|
border-left: 3px solid red;
|
|
27817
27888
|
padding: 10px;
|
|
27818
27889
|
}
|
|
27890
|
+
|
|
27891
|
+
.o-popover:has(.o-error-tooltip) {
|
|
27892
|
+
z-index: 4 !important;
|
|
27893
|
+
}
|
|
27819
27894
|
`;
|
|
27820
27895
|
class ErrorToolTip extends owl.Component {
|
|
27821
27896
|
}
|
|
@@ -27872,7 +27947,7 @@
|
|
|
27872
27947
|
}
|
|
27873
27948
|
mounted() {
|
|
27874
27949
|
const figure = this.props.figure;
|
|
27875
|
-
const chartData = this.env.getters.getChartRuntime(
|
|
27950
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27876
27951
|
if (chartData) {
|
|
27877
27952
|
this.createChart(chartData);
|
|
27878
27953
|
}
|
|
@@ -27880,8 +27955,7 @@
|
|
|
27880
27955
|
patched() {
|
|
27881
27956
|
var _a, _b, _c;
|
|
27882
27957
|
const figure = this.props.figure;
|
|
27883
|
-
const
|
|
27884
|
-
const chartData = this.env.getters.getChartRuntime(sheetId, figure.id);
|
|
27958
|
+
const chartData = this.env.getters.getChartRuntime(figure.id);
|
|
27885
27959
|
if (chartData) {
|
|
27886
27960
|
if (chartData.type !== this.chart.config.type) {
|
|
27887
27961
|
// Updating a chart type requires to update its options accordingly, if feasible at all.
|
|
@@ -27907,7 +27981,7 @@
|
|
|
27907
27981
|
else {
|
|
27908
27982
|
this.chart && this.chart.destroy();
|
|
27909
27983
|
}
|
|
27910
|
-
const def = this.env.getters.getChartDefinition(
|
|
27984
|
+
const def = this.env.getters.getChartDefinition(figure.id);
|
|
27911
27985
|
if (def) {
|
|
27912
27986
|
this.state.background = def.background;
|
|
27913
27987
|
}
|
|
@@ -27916,7 +27990,7 @@
|
|
|
27916
27990
|
const canvas = this.canvas.el;
|
|
27917
27991
|
const ctx = canvas.getContext("2d");
|
|
27918
27992
|
this.chart = new window.Chart(ctx, chartData);
|
|
27919
|
-
const def = this.env.getters.getChartDefinition(this.
|
|
27993
|
+
const def = this.env.getters.getChartDefinition(this.props.figure.id);
|
|
27920
27994
|
if (def) {
|
|
27921
27995
|
this.state.background = def.background;
|
|
27922
27996
|
}
|
|
@@ -27926,10 +28000,8 @@
|
|
|
27926
28000
|
registry.add("edit", {
|
|
27927
28001
|
name: _lt("Edit"),
|
|
27928
28002
|
sequence: 1,
|
|
27929
|
-
action: () => this.env.openSidePanel("ChartPanel", {
|
|
27930
|
-
|
|
27931
|
-
figure: this.props.figure,
|
|
27932
|
-
}),
|
|
28003
|
+
action: () => this.env.openSidePanel("ChartPanel", { figure: this.props.figure }),
|
|
28004
|
+
isVisible: () => !!this.env.getters.getChartDefinition(this.props.figure.id),
|
|
27933
28005
|
});
|
|
27934
28006
|
registry.add("delete", {
|
|
27935
28007
|
name: _lt("Delete"),
|
|
@@ -27940,10 +28012,7 @@
|
|
|
27940
28012
|
id: this.props.figure.id,
|
|
27941
28013
|
});
|
|
27942
28014
|
if (this.props.sidePanelIsOpen) {
|
|
27943
|
-
this.env.toggleSidePanel("ChartPanel", {
|
|
27944
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27945
|
-
figure: this.props.figure,
|
|
27946
|
-
});
|
|
28015
|
+
this.env.toggleSidePanel("ChartPanel", { figure: this.props.figure });
|
|
27947
28016
|
}
|
|
27948
28017
|
this.trigger("figure-deleted");
|
|
27949
28018
|
},
|
|
@@ -27953,7 +28022,6 @@
|
|
|
27953
28022
|
sequence: 11,
|
|
27954
28023
|
action: () => {
|
|
27955
28024
|
this.env.dispatch("REFRESH_CHART", {
|
|
27956
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
27957
28025
|
id: this.props.figure.id,
|
|
27958
28026
|
});
|
|
27959
28027
|
},
|
|
@@ -28197,10 +28265,7 @@
|
|
|
28197
28265
|
return;
|
|
28198
28266
|
}
|
|
28199
28267
|
if (this.props.sidePanelIsOpen) {
|
|
28200
|
-
this.env.openSidePanel("ChartPanel", {
|
|
28201
|
-
sheetId: this.env.getters.getActiveSheetId(),
|
|
28202
|
-
figure,
|
|
28203
|
-
});
|
|
28268
|
+
this.env.openSidePanel("ChartPanel", { figure });
|
|
28204
28269
|
}
|
|
28205
28270
|
const initialX = ev.clientX;
|
|
28206
28271
|
const initialY = ev.clientY;
|
|
@@ -31296,9 +31361,9 @@
|
|
|
31296
31361
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
31297
31362
|
|
|
31298
31363
|
|
|
31299
|
-
__info__.version = '15.0.
|
|
31300
|
-
__info__.date = '2023-
|
|
31301
|
-
__info__.hash = '
|
|
31364
|
+
__info__.version = '15.0.2';
|
|
31365
|
+
__info__.date = '2023-03-14T09:19:34.555Z';
|
|
31366
|
+
__info__.hash = 'c0a25a0';
|
|
31302
31367
|
|
|
31303
31368
|
|
|
31304
31369
|
})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
|