added ability to revert (#21)

This commit is contained in:
undergroundwires
2020-07-15 19:04:56 +01:00
parent 57028987f1
commit 9c063d59de
58 changed files with 1448 additions and 265 deletions

View File

@@ -32,7 +32,8 @@ import { Component, Prop, Vue } from 'vue-property-decorator';
import { StatefulVue } from '@/presentation/StatefulVue';
import SelectableOption from './SelectableOption.vue';
import { IApplicationState } from '@/application/State/IApplicationState';
import { IScript } from '@/domain/Script';
import { IScript } from '@/domain/IScript';
import { SelectedScript } from '../../../application/State/Selection/SelectedScript';
@Component({
components: {
@@ -79,12 +80,14 @@ export default class TheSelector extends StatefulVue {
private updateSelections(state: IApplicationState) {
this.isNoneSelected = state.selection.totalSelected === 0;
this.isAllSelected = state.selection.totalSelected === state.app.totalScripts;
this.isRecommendedSelected = this.areSame(state.app.getRecommendedScripts(), state.selection.selectedScripts);
this.isRecommendedSelected = this.areAllRecommended(state.app.getRecommendedScripts(),
state.selection.selectedScripts);
}
private areSame(scripts: ReadonlyArray<IScript>, other: ReadonlyArray<IScript>): boolean {
private areAllRecommended(scripts: ReadonlyArray<IScript>, other: ReadonlyArray<SelectedScript>): boolean {
other = other.filter((selected) => !(selected).revert);
return (scripts.length === other.length) &&
scripts.every((script) => other.some((s) => s.id === script.id));
scripts.every((script) => other.some((selected) => selected.id === script.id));
}
}
</script>