From f0423ca1a597f997d27f976b6d991500359c9597 Mon Sep 17 00:00:00 2001 From: adinlead Date: Fri, 9 Aug 2024 13:08:58 +0800 Subject: [PATCH 1/6] 1. Added undo button after draw button in toolbar 2. Enlarged the delete button icon 3. Added open-source redo and undo icons (from Bootstrap) --- src/code/addButtons.ts | 2 ++ src/code/buttons/undoButton.d.ts | 4 ++++ src/code/buttons/undoButton.js | 30 +++++++++++++++++++++++++ src/code/css/toolbar.css | 8 +++++++ src/code/images/toolbar_quickdelete.svg | 2 +- src/code/images/toolbar_redo.svg | 4 ++++ src/code/images/toolbar_undo.svg | 4 ++++ 7 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/code/buttons/undoButton.d.ts create mode 100644 src/code/buttons/undoButton.js create mode 100644 src/code/images/toolbar_redo.svg create mode 100644 src/code/images/toolbar_undo.svg diff --git a/src/code/addButtons.ts b/src/code/addButtons.ts index 16635974d..595cb1315 100644 --- a/src/code/addButtons.ts +++ b/src/code/addButtons.ts @@ -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"; @@ -24,6 +25,7 @@ export function addButtons() { WasabeeButton, OpButton, QuickdrawButton, + UndoButton, QuickDeleteButton, LinkButton, MarkerButton, diff --git a/src/code/buttons/undoButton.d.ts b/src/code/buttons/undoButton.d.ts new file mode 100644 index 000000000..ddeed7229 --- /dev/null +++ b/src/code/buttons/undoButton.d.ts @@ -0,0 +1,4 @@ +import { WButton } from "../leafletClasses"; + +declare class UndoButton extends WButton {} +export default UndoButton; diff --git a/src/code/buttons/undoButton.js b/src/code/buttons/undoButton.js new file mode 100644 index 000000000..7427da6a8 --- /dev/null +++ b/src/code/buttons/undoButton.js @@ -0,0 +1,30 @@ +import { WButton } from "../leafletClasses"; +import wX from "../wX"; +import { 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: () => { + postToFirebase({ id: "analytics", action: "undo" }); + undo(); + }, + context: this, + title: this.title, + }); + }, +}); + +export default UndoButton; diff --git a/src/code/css/toolbar.css b/src/code/css/toolbar.css index 095514c74..765431b78 100644 --- a/src/code/css/toolbar.css +++ b/src/code/css/toolbar.css @@ -136,6 +136,14 @@ 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-redo { + background-image: url(../images/toolbar_redo.svg); + background-size: 60%; +} .wasabee-toolbar-link { background-image: url(../images/toolbar_addlinks.svg) } diff --git a/src/code/images/toolbar_quickdelete.svg b/src/code/images/toolbar_quickdelete.svg index 15035f468..439a91b76 100644 --- a/src/code/images/toolbar_quickdelete.svg +++ b/src/code/images/toolbar_quickdelete.svg @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/src/code/images/toolbar_redo.svg b/src/code/images/toolbar_redo.svg new file mode 100644 index 000000000..086a3adf5 --- /dev/null +++ b/src/code/images/toolbar_redo.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/code/images/toolbar_undo.svg b/src/code/images/toolbar_undo.svg new file mode 100644 index 000000000..2aa8c2d82 --- /dev/null +++ b/src/code/images/toolbar_undo.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From f816a0bf4763808a96efc176f35712827a31009b Mon Sep 17 00:00:00 2001 From: adinlead Date: Mon, 12 Aug 2024 17:04:36 +0800 Subject: [PATCH 2/6] Fixed the issue where the dialog was not closed when clicking the undo button --- src/code/buttons/undoButton.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/code/buttons/undoButton.js b/src/code/buttons/undoButton.js index 7427da6a8..9a88211a0 100644 --- a/src/code/buttons/undoButton.js +++ b/src/code/buttons/undoButton.js @@ -18,6 +18,8 @@ const UndoButton = WButton.extend({ container: container, className: "wasabee-toolbar-undo", callback: () => { + console.log(this); + this.control.disableAllExcept(); postToFirebase({ id: "analytics", action: "undo" }); undo(); }, From 1602a63ac8effdd8b686f865aa5a45c500f03eb3 Mon Sep 17 00:00:00 2001 From: adinlead Date: Mon, 19 Aug 2024 16:12:42 +0800 Subject: [PATCH 3/6] When unable to undo, disable undo button --- src/code/buttons/undoButton.js | 31 +++++++++++++++++++++++- src/code/css/toolbar.css | 4 +++ src/code/images/toolbar_undo_disable.svg | 4 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/code/images/toolbar_undo_disable.svg diff --git a/src/code/buttons/undoButton.js b/src/code/buttons/undoButton.js index 9a88211a0..5765295e9 100644 --- a/src/code/buttons/undoButton.js +++ b/src/code/buttons/undoButton.js @@ -1,6 +1,6 @@ import { WButton } from "../leafletClasses"; import wX from "../wX"; -import { undo } from "../undo"; +import { undoable, undo } from "../undo"; import { postToFirebase } from "../firebase/logger"; const UndoButton = WButton.extend({ @@ -27,6 +27,35 @@ const UndoButton = WButton.extend({ 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; diff --git a/src/code/css/toolbar.css b/src/code/css/toolbar.css index 765431b78..8000f1edc 100644 --- a/src/code/css/toolbar.css +++ b/src/code/css/toolbar.css @@ -140,6 +140,10 @@ 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%; diff --git a/src/code/images/toolbar_undo_disable.svg b/src/code/images/toolbar_undo_disable.svg new file mode 100644 index 000000000..13705ee38 --- /dev/null +++ b/src/code/images/toolbar_undo_disable.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From f2a7494759c1220ec519cd2a58cf6de4baee4424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E5=B1=9E=E8=A1=8C=E8=80=85?= Date: Mon, 26 Aug 2024 14:36:28 +0800 Subject: [PATCH 4/6] Delete src/code/images/toolbar_redo.svg --- src/code/images/toolbar_redo.svg | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/code/images/toolbar_redo.svg diff --git a/src/code/images/toolbar_redo.svg b/src/code/images/toolbar_redo.svg deleted file mode 100644 index 086a3adf5..000000000 --- a/src/code/images/toolbar_redo.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From d63bf4b7acc1f81548174994040dfcc8744f72af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E5=B1=9E=E8=A1=8C=E8=80=85?= Date: Mon, 26 Aug 2024 14:40:13 +0800 Subject: [PATCH 5/6] change toolbar_undo icon --- src/code/images/toolbar_undo.svg | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/code/images/toolbar_undo.svg b/src/code/images/toolbar_undo.svg index 2aa8c2d82..8b2d06171 100644 --- a/src/code/images/toolbar_undo.svg +++ b/src/code/images/toolbar_undo.svg @@ -1,4 +1 @@ - - - - \ No newline at end of file + From 315f7204df43d2f98312aa7ffb80e78411499a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E5=B1=9E=E8=A1=8C=E8=80=85?= Date: Mon, 26 Aug 2024 14:41:11 +0800 Subject: [PATCH 6/6] Update toolbar_undo_disable.svg --- src/code/images/toolbar_undo_disable.svg | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/code/images/toolbar_undo_disable.svg b/src/code/images/toolbar_undo_disable.svg index 13705ee38..2d88c42e5 100644 --- a/src/code/images/toolbar_undo_disable.svg +++ b/src/code/images/toolbar_undo_disable.svg @@ -1,4 +1 @@ - - - - \ No newline at end of file +