Skip to content

Commit

Permalink
[FIX] spreadsheet: update o_spreadsheet to latest version
Browse files Browse the repository at this point in the history
### Contains the following commits:

odoo/o-spreadsheet@6c89e266 [FIX] collaborative: don't endlessly dispatch new revision
odoo/o-spreadsheet@1de19d7d [FIX] GridOverlay: Only react to self targeted double clicks
odoo/o-spreadsheet@40fc6151 [FIX] figure: apply dragging style on actual drag, not on mousedown
odoo/o-spreadsheet@aee5f929 [FIX] figure: Avoid scroll on a focused figure
odoo/o-spreadsheet@37b97b18 [FIX] dashboard: click cells to close filter menu

closes odoo#107644

Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
  • Loading branch information
LucasLefevre committed Dec 9, 2022
1 parent fbedc97 commit 59e44ad
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
42 changes: 31 additions & 11 deletions addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,6 @@
"SET_FORMATTING",
"CLEAR_FORMATTING",
"SET_BORDER",
"SET_DECIMAL",
/** CHART */
"CREATE_CHART",
"UPDATE_CHART",
Expand Down Expand Up @@ -20711,7 +20710,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
setup() {
owl.useEffect((selectedFigureId, thisFigureId, el) => {
if (selectedFigureId === thisFigureId) {
el === null || el === void 0 ? void 0 : el.focus();
/** Scrolling on a newly inserted figure that overflows outside the viewport
* will break the whole layout.
* NOTE: `preventScroll`does not work on mobile but then again,
* mobile is not really supported ATM.
*
* TODO: When implementing proper mobile, we will need to scroll the viewport
* correctly (and render?) before focusing the element.
*/
el === null || el === void 0 ? void 0 : el.focus({ preventScroll: true });
}
}, () => [this.env.model.getters.getSelectedFigureId(), this.props.figure.id, this.figureRef.el]);
}
Expand All @@ -20720,12 +20727,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
ev.stopPropagation();
const initialX = ev.clientX;
const initialY = ev.clientY;
this.dnd.isActive = true;
this.dnd.x = figure.x;
this.dnd.y = figure.y;
this.dnd.width = figure.width;
this.dnd.height = figure.height;
const onMouseMove = (ev) => {
this.dnd.isActive = true;
const deltaX = Math.max(dirX * (ev.clientX - initialX), MIN_FIG_SIZE - figure.width);
const deltaY = Math.max(dirY * (ev.clientY - initialY), MIN_FIG_SIZE - figure.height);
this.dnd.width = figure.width + deltaX;
Expand Down Expand Up @@ -20775,12 +20782,12 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
const { offsetX, offsetY } = this.env.model.getters.getActiveSheetScrollInfo();
const initialX = ev.clientX - position.left;
const initialY = ev.clientY - position.top;
this.dnd.isActive = true;
this.dnd.x = figure.x;
this.dnd.y = figure.y;
this.dnd.width = figure.width;
this.dnd.height = figure.height;
const onMouseMove = (ev) => {
this.dnd.isActive = true;
const newX = ev.clientX - position.left;
let deltaX = newX - initialX;
if (newX > offsetCorrectionX && initialX < offsetCorrectionX) {
Expand Down Expand Up @@ -26344,7 +26351,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
*/
function repairInitialMessages(data, initialMessages) {
initialMessages = fixTranslatedSheetIds(data, initialMessages);
initialMessages = dropSortCommands(data, initialMessages);
initialMessages = dropCommands(initialMessages, "SORT_CELLS");
initialMessages = dropCommands(initialMessages, "SET_DECIMAL");
return initialMessages;
}
/**
Expand Down Expand Up @@ -26382,14 +26390,13 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
}
return messages;
}
function dropSortCommands(data, initialMessages) {
function dropCommands(initialMessages, commandType) {
const messages = [];
for (const message of initialMessages) {
if (message.type === "REMOTE_REVISION") {
messages.push({
...message,
// @ts-ignore
commands: message.commands.filter((command) => command.type !== "SORT_CELLS"),
commands: message.commands.filter((command) => command.type !== commandType),
});
}
else {
Expand Down Expand Up @@ -34725,6 +34732,7 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
this.clientId = "local";
this.pendingMessages = [];
this.waitingAck = false;
this.isReplayingInitialRevisions = false;
this.processedRevisions = new Set();
this.uuidGenerator = new UuidGenerator();
this.debouncedMove = debounce(this._move.bind(this), DEBOUNCE_TIME);
Expand Down Expand Up @@ -34784,13 +34792,15 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
this.transportService.onNewMessage(this.clientId, this.onMessageReceived.bind(this));
}
loadInitialMessages(messages) {
this.isReplayingInitialRevisions = true;
this.on("unexpected-revision-id", this, ({ revisionId }) => {
throw new Error(`The spreadsheet could not be loaded. Revision ${revisionId} is corrupted.`);
});
for (const message of messages) {
this.onMessageReceived(message);
}
this.off("unexpected-revision-id", this);
this.isReplayingInitialRevisions = false;
}
/**
* Notify the server that the user client left the collaborative session
Expand Down Expand Up @@ -34979,6 +34989,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
commands: revision.commands,
};
}
if (this.isReplayingInitialRevisions) {
throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.
${JSON.stringify(message)}`);
}
this.transportService.sendMessage({
...message,
serverRevisionId: this.serverRevisionId,
Expand Down Expand Up @@ -41668,7 +41682,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
case 3 /* Status.Finalizing */:
throw new Error("Cannot dispatch commands in the finalize state");
case 2 /* Status.RunningCore */:
throw new Error("A UI plugin cannot dispatch while handling a core command");
if (isCoreCommand(command)) {
throw new Error(`A UI plugin cannot dispatch ${type} while handling a core command`);
}
this.dispatchToHandlers(this.handlers, command);
}
return DispatchResult.Success;
};
Expand Down Expand Up @@ -41790,7 +41807,10 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
}
onRemoteRevisionReceived({ commands }) {
for (let command of commands) {
const previousStatus = this.status;
this.status = 2 /* Status.RunningCore */;
this.dispatchToHandlers(this.uiPlugins, command);
this.status = previousStatus;
}
this.finalize();
}
Expand Down Expand Up @@ -42056,8 +42076,8 @@ day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} ) ${_lt("A
Object.defineProperty(exports, '__esModule', { value: true });

exports.__info__.version = '2.0.0';
exports.__info__.date = '2022-12-07T09:24:07.747Z';
exports.__info__.hash = '31d0590';
exports.__info__.date = '2022-12-09T14:58:12.180Z';
exports.__info__.hash = '6c89e26';

})(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
//# sourceMappingURL=o_spreadsheet.js.map
11 changes: 8 additions & 3 deletions addons/spreadsheet/static/src/o_spreadsheet/o_spreadsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@
</t>

<t t-name="o-spreadsheet-SpreadsheetDashboard" owl="1">
<div class="o-grid o-two-columns" tabindex="-1" t-on-wheel="onMouseWheel" t-on-copy="copy">
<div
class="o-grid o-two-columns"
tabindex="-1"
t-on-wheel="onMouseWheel"
t-on-copy="copy"
t-on-click="onClosePopover">
<div class="mx-auto h-100 position-relative" t-ref="grid" t-att-style="gridContainer">
<GridOverlay
onCellHovered.bind="onCellHovered"
Expand Down Expand Up @@ -465,7 +470,7 @@
</t>

<t t-name="o-spreadsheet-FilterIcon" owl="1">
<div class="o-filter-icon" t-att-style="style" t-on-click="props.onClick">
<div class="o-filter-icon" t-att-style="style" t-on-click.stop="props.onClick">
<t t-if="props.isActive" t-call="o-spreadsheet-Icon.FILTER_ICON_ACTIVE"/>
<t t-else="" t-call="o-spreadsheet-Icon.FILTER_ICON"/>
</div>
Expand Down Expand Up @@ -650,7 +655,7 @@
class="o-grid-overlay"
t-att-style="props.gridOverlayDimensions"
t-on-mousedown="onMouseDown"
t-on-dblclick="onDoubleClick"
t-on-dblclick.self="onDoubleClick"
t-on-contextmenu="onContextMenu">
<!-- TODO remove sidePanelIsOpen props. It is wrong.
If you have a CF sidepanel open, selecting a figure should
Expand Down

0 comments on commit 59e44ad

Please sign in to comment.