Skip to content

Commit

Permalink
[twizzle/edit] Improve UX if you keep changing notation when auto-not…
Browse files Browse the repository at this point in the history
…ation is disabled.
  • Loading branch information
lgarron committed Oct 9, 2024
1 parent 103d05c commit 06e9a79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
40 changes: 19 additions & 21 deletions src/sites/alpha.twizzle.net/edit/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ export class App {
#autofixEnabled: boolean = true;
// TODO: factor this out into a class
async #onSetupOrAlgChange() {
console.log(this.#autofixEnabled);
if (!this.#autofixEnabled) {
return;
}
(async () => {
const [originalPuzzleID, puzzleAlgWithIssue, puzzleSetupAlgWithIssue] =
await Promise.all([
Expand Down Expand Up @@ -195,29 +191,31 @@ export class App {
this.#autoNotationPuzzleOld = originalPuzzleID;
this.#autoNotationPuzzleNew = puzzleID;

for (const elem of this.element.querySelectorAll(
".auto-notation-puzzle-old",
)) {
elem.textContent = puzzles[originalPuzzleID].fullName;
}
for (const elem of this.element.querySelectorAll(
".auto-notation-puzzle-new",
)) {
elem.textContent = puzzleLoader.fullName;
}

this.element.querySelector<HTMLSpanElement>(
".auto-notation",
)!.hidden = false;
this.element.querySelector<HTMLSpanElement>(
".auto-notation-change-back",
)!.hidden = false;
this.element.querySelector<HTMLSpanElement>(
".auto-notation-change-redo",
)!.hidden = true;

this.controlPane.puzzleSelect.value = puzzleID;
this.controlPane.puzzleSelectChanged();
if (this.#autofixEnabled) {
for (const elem of this.element.querySelectorAll(
".auto-notation-puzzle-old",
)) {
elem.textContent = puzzles[originalPuzzleID].fullName;
}
this.element.querySelector<HTMLSpanElement>(
".auto-notation",
)!.hidden = false;
this.element.querySelector<HTMLSpanElement>(
".auto-notation-change-back",
)!.hidden = false;
this.element.querySelector<HTMLSpanElement>(
".auto-notation-change-redo",
)!.hidden = true;

this.controlPane.puzzleSelect.value = puzzleID;
this.controlPane.puzzleSelectChanged();
}
return;
}
} catch {}
Expand Down
2 changes: 1 addition & 1 deletion src/sites/alpha.twizzle.net/edit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
back to <span class="auto-notation-puzzle-old"></span></a>?</span><span
class="auto-notation-change-redo">Auto-detection has been temporarily disabled. Want to <a href="#"
class="auto-notation-redo">re-enable it and change the puzzle to
to <span class="auto-notation-puzzle-new"></span></a> again?</span>)
to <span class="auto-notation-puzzle-new"></span></a>?</span>)
</p>
</div>
<expand-button for="setup" expanded="true" exclusive="false">
Expand Down

0 comments on commit 06e9a79

Please sign in to comment.