From fe174793b992144c2480d3300ad919b6ccab2564 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Sun, 22 Aug 2021 15:26:05 +0100 Subject: [PATCH] Add revert all toggle - Also aligns items on top menu vertically - Renames SelectionStatus to RecommentationLevel in the top menu to make it more clear. - In App.vue it renames row class to `app__row` to avoid misusage as styles are not scoped in it. - In ScriptsArea, remove unintended row class refering to global style, make styling menu class more verbose and lower bottom margin. - Change category toggle so its status become reverted when all of its reversible scripts are reverted, before it did not care about reversible scripts but required all scripts to be reverted. If a category has no reversible scripts, revert toggle returns false. --- .github/ISSUE_TEMPLATE/3-feature-request.md | 11 ++ .../Context/State/Selection/IUserSelection.ts | 1 + .../Context/State/Selection/UserSelection.ts | 32 +++-- src/domain/UserScriptPosition.ts | 8 ++ src/presentation/components/App.vue | 10 +- .../components/Scripts/Menu/MenuOption.vue | 6 +- .../RecommendationStatusHandler.ts} | 29 ++--- .../RecommendationStatusType.ts | 7 ++ .../TheRecommendationSelector.vue} | 39 +++--- .../Menu/Revert/RevertStatusHandler.ts | 29 +++++ .../Scripts/Menu/Revert/RevertStatusType.ts | 6 + .../Scripts/Menu/Revert/TheRevertSelector.vue | 72 +++++++++++ .../Scripts/Menu/TheScriptsMenu.vue | 26 ++-- .../components/Scripts/TheScriptArea.vue | 6 +- .../Node/Reverter/CategoryReverter.ts | 8 +- .../State/Selection/SelectedScript.spec.ts | 1 - .../State/Selection/UserSelection.spec.ts | 103 ++++++++++++++++ .../RecommendationStatusHandler.spec.ts} | 59 ++++----- .../RecommendationStatusTestScenario.ts} | 2 +- .../Menu/Revert/RevertStatusHandler.spec.ts | 106 +++++++++++++++++ .../Node/Reverter/CategoryReverter.spec.ts | 112 +++++++++++++++--- tests/unit/stubs/ScriptStub.ts | 13 +- tests/unit/stubs/UserSelectionStub.ts | 3 + 23 files changed, 566 insertions(+), 123 deletions(-) create mode 100644 src/domain/UserScriptPosition.ts rename src/presentation/components/Scripts/Menu/{Selector/SelectionTypeHandler.ts => Recommendation/RecommendationStatusHandler.ts} (77%) create mode 100644 src/presentation/components/Scripts/Menu/Recommendation/RecommendationStatusType.ts rename src/presentation/components/Scripts/Menu/{Selector/TheSelector.vue => Recommendation/TheRecommendationSelector.vue} (60%) create mode 100644 src/presentation/components/Scripts/Menu/Revert/RevertStatusHandler.ts create mode 100644 src/presentation/components/Scripts/Menu/Revert/RevertStatusType.ts create mode 100644 src/presentation/components/Scripts/Menu/Revert/TheRevertSelector.vue rename tests/unit/presentation/components/Scripts/Menu/{Selector/SelectionTypeHandler.spec.ts => Recommendation/RecommendationStatusHandler.spec.ts} (66%) rename tests/unit/presentation/components/Scripts/Menu/{Selector/SelectionStateTestScenario.ts => Recommendation/RecommendationStatusTestScenario.ts} (97%) create mode 100644 tests/unit/presentation/components/Scripts/Menu/Revert/RevertStatusHandler.spec.ts diff --git a/.github/ISSUE_TEMPLATE/3-feature-request.md b/.github/ISSUE_TEMPLATE/3-feature-request.md index 99a34742b..d9c1aebe5 100644 --- a/.github/ISSUE_TEMPLATE/3-feature-request.md +++ b/.github/ISSUE_TEMPLATE/3-feature-request.md @@ -5,6 +5,7 @@ labels: enhancement --- @@ -15,6 +16,16 @@ Please fill in as much of the template below as you're able. What are we trying to solve? Please add a clear and concise description of the problem you are seeking to solve with this feature request. E.g. I'm always frustrated when [...] +======= +Thank you for suggesting an idea to make privacy better. 🤗 +Please fill in as much of the template below as you're able. +--> + +### Problem Description + + ### Proposed solution diff --git a/src/application/Context/State/Selection/IUserSelection.ts b/src/application/Context/State/Selection/IUserSelection.ts index 0cc991b88..134c71dca 100644 --- a/src/application/Context/State/Selection/IUserSelection.ts +++ b/src/application/Context/State/Selection/IUserSelection.ts @@ -12,6 +12,7 @@ export interface IUserSelection { addOrUpdateAllInCategory(categoryId: number, revert: boolean): void; addSelectedScript(scriptId: string, revert: boolean): void; addOrUpdateSelectedScript(scriptId: string, revert: boolean): void; + addOrUpdateAll(scripts: readonly ISelectedScript[]): void; removeSelectedScript(scriptId: string): void; selectOnly(scripts: ReadonlyArray): void; isSelected(scriptId: string): boolean; diff --git a/src/application/Context/State/Selection/UserSelection.ts b/src/application/Context/State/Selection/UserSelection.ts index 3aab3d0e7..adca71b59 100644 --- a/src/application/Context/State/Selection/UserSelection.ts +++ b/src/application/Context/State/Selection/UserSelection.ts @@ -57,18 +57,8 @@ export class UserSelection implements IUserSelection { public addOrUpdateAllInCategory(categoryId: number, revert: boolean = false): void { const category = this.collection.findCategory(categoryId); const scriptsToAddOrUpdate = category.getAllScriptsRecursively() - .filter((script) => - !this.scripts.exists(script.id) - || this.scripts.getById(script.id).revert !== revert, - ); - if (!scriptsToAddOrUpdate.length) { - return; - } - for (const script of scriptsToAddOrUpdate) { - const selectedScript = new SelectedScript(script, revert); - this.scripts.addOrUpdateItem(selectedScript); - } - this.changed.notify(this.scripts.getItems()); + .map((script) => new SelectedScript(script, revert)); + this.addOrUpdateAll(scriptsToAddOrUpdate); } public addSelectedScript(scriptId: string, revert: boolean): void { @@ -139,4 +129,22 @@ export class UserSelection implements IUserSelection { } this.changed.notify(this.scripts.getItems()); } + + public addOrUpdateAll(scripts: readonly SelectedScript[]): void { + if (!scripts.length) { + return; + } + const scriptsToAddOrUpdate = scripts + .filter((script) => + !this.scripts.exists(script.id) + || this.scripts.getById(script.id).revert !== script.revert, + ); + if (!scriptsToAddOrUpdate.length) { + return; + } + for (const script of scriptsToAddOrUpdate) { + this.scripts.addOrUpdateItem(script); + } + this.changed.notify(this.scripts.getItems()); + } } diff --git a/src/domain/UserScriptPosition.ts b/src/domain/UserScriptPosition.ts new file mode 100644 index 000000000..8538a1a8e --- /dev/null +++ b/src/domain/UserScriptPosition.ts @@ -0,0 +1,8 @@ +/* Represents preferred position in generated user script */ +export class ScriptPosition { + constructor( + public readonly positionInFile: number, + public readonly positionInCategory: number) { + + } +} diff --git a/src/presentation/components/App.vue b/src/presentation/components/App.vue index a0cd601a1..531b69187 100644 --- a/src/presentation/components/App.vue +++ b/src/presentation/components/App.vue @@ -1,10 +1,10 @@