Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/381' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
le-jeu committed Aug 19, 2024
2 parents 9895eb8 + 1602a63 commit c15603e
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/code/addButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import QuickdrawButton from "./buttons/quickdrawButton";
import WasabeeButton from "./buttons/wasabeeButton";
import SyncButton from "./buttons/syncButton";
import OpButton from "./buttons/opButton";
import UndoButton from "./buttons/undoButton";
import LinkButton from "./buttons/linkButton";
import MarkerButton from "./buttons/markerButton";
import UploadButton from "./buttons/uploadButton";
Expand All @@ -24,6 +25,7 @@ export function addButtons() {
WasabeeButton,
OpButton,
QuickdrawButton,
UndoButton,
QuickDeleteButton,
LinkButton,
MarkerButton,
Expand Down
4 changes: 4 additions & 0 deletions src/code/buttons/undoButton.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { WButton } from "../leafletClasses";

declare class UndoButton extends WButton {}
export default UndoButton;
61 changes: 61 additions & 0 deletions src/code/buttons/undoButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { WButton } from "../leafletClasses";
import wX from "../wX";
import { undoable, undo } from "../undo";
import { postToFirebase } from "../firebase/logger";

const UndoButton = WButton.extend({
statics: {
TYPE: "UndoButton",
},

needWritePermission: true,

initialize: function (container) {
this.type = UndoButton.TYPE;
this.title = wX("toolbar.op.undo");

this.button = this._createButton({
container: container,
className: "wasabee-toolbar-undo",
callback: () => {
console.log(this);
this.control.disableAllExcept();
postToFirebase({ id: "analytics", action: "undo" });
undo();
},
context: this,
title: this.title,
});
},
update: function () {
WButton.prototype.update.call(this);
console.log("UndoButton.update >> ", this);
if (undoable()) {
console.log(">> is undoable");
this.enable();
} else {
console.log(">> no undoable");
this.disable();
}
},
disable: function () {
console.log("do disable:", this);
let btn = this.button;
console.log(btn);
btn.style.pointerEvents = "none";
btn.style.cursor = "not-allowed";

btn.className = "wasabee-toolbar-undo-disable";
},
enable: function () {
console.log("do enable:", this);
let btn = this.button;
console.log(btn);
btn.style.pointerEvents = "auto";
btn.style.cursor = "pointer";

btn.className = "wasabee-toolbar-undo";
},
});

export default UndoButton;
12 changes: 12 additions & 0 deletions src/code/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@
background-image: url(../images/toolbar_quickdelete.svg);
background-size: 60%;
}
.wasabee-toolbar-undo {
background-image: url(../images/toolbar_undo.svg);
background-size: 60%;
}
.wasabee-toolbar-undo-disable {
background-image: url(../images/toolbar_undo_disable.svg);
background-size: 60%;
}
.wasabee-toolbar-redo {
background-image: url(../images/toolbar_redo.svg);
background-size: 60%;
}
.wasabee-toolbar-link {
background-image: url(../images/toolbar_addlinks.svg)
}
Expand Down
2 changes: 1 addition & 1 deletion src/code/images/toolbar_quickdelete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/code/images/toolbar_redo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/code/images/toolbar_undo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/code/images/toolbar_undo_disable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c15603e

Please sign in to comment.