Change "grouping" to "view"

1. *Grouping* becomes *view*. Because *view* is more clear and extensible than *grouping*. It increases flexibility to extend by e.g. adding *flat* as a new view as discussed in #50, in this case "flat *view*" would make more sense than "flat *grouping*".
2. *None* becomes *tree*. Because *tree* is more descriptive than *none*.

Updates labels on top menu. As labels are updated, the file structure/names are refactored to follow the same concept. `TheScriptsList` is renamed to `TheScriptsView`. Also refactors `ViewChanger` so view types are presented in same way.
This commit is contained in:
undergroundwires
2021-08-29 11:33:16 +01:00
parent 6dc768817f
commit c0c475ff56
37 changed files with 112 additions and 117 deletions

View File

@@ -1,4 +0,0 @@
export enum Grouping {
Cards = 1,
None = 0,
}

View File

@@ -1,66 +0,0 @@
<template>
<div class="container">
<MenuOptionList
label="Group by"
class="part">
<MenuOptionListItem
label="Cards"
:enabled="!cardsSelected"
@click="groupByCard()"
/>
<MenuOptionListItem
label="None"
:enabled="!noneSelected"
@click="groupByNone()"
/>
</MenuOptionList>
<span class="part">
</span>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { Grouping } from './Grouping';
import MenuOptionList from './../MenuOptionList.vue';
import MenuOptionListItem from './../MenuOptionListItem.vue';
const DefaultGrouping = Grouping.Cards;
@Component({
components: {
MenuOptionList,
MenuOptionListItem,
},
})
export default class TheGrouper extends Vue {
public cardsSelected = false;
public noneSelected = false;
private currentGrouping: Grouping;
public mounted() {
this.changeGrouping(DefaultGrouping);
}
public groupByCard() {
this.changeGrouping(Grouping.Cards);
}
public groupByNone() {
this.changeGrouping(Grouping.None);
}
private changeGrouping(newGrouping: Grouping) {
if (this.currentGrouping === newGrouping) {
return;
}
this.currentGrouping = newGrouping;
this.cardsSelected = newGrouping === Grouping.Cards;
this.noneSelected = newGrouping === Grouping.None;
this.$emit('groupingChanged', this.currentGrouping);
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -9,7 +9,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Prop, Emit, Vue } from 'vue-property-decorator'; import { Component, Prop, Emit, Vue } from 'vue-property-decorator';
import { NonCollapsing } from '@/presentation/components/Scripts/Cards/NonCollapsingDirective'; import { NonCollapsing } from '@/presentation/components/Scripts/View/Cards/NonCollapsingDirective';
@Component({ @Component({
directives: { NonCollapsing }, directives: { NonCollapsing },

View File

@@ -2,9 +2,9 @@
<div id="container"> <div id="container">
<TheSelector class="item" /> <TheSelector class="item" />
<TheOsChanger class="item" /> <TheOsChanger class="item" />
<TheGrouper <TheViewChanger
class="item" class="item"
v-on:groupingChanged="$emit('groupingChanged', $event)" v-on:viewChanged="$emit('viewChanged', $event)"
v-if="!this.isSearching" /> v-if="!this.isSearching" />
</div> </div>
</template> </template>
@@ -13,7 +13,7 @@
import { Component } from 'vue-property-decorator'; import { Component } from 'vue-property-decorator';
import TheOsChanger from './TheOsChanger.vue'; import TheOsChanger from './TheOsChanger.vue';
import TheSelector from './Selector/TheSelector.vue'; import TheSelector from './Selector/TheSelector.vue';
import TheGrouper from './Grouping/TheGrouper.vue'; import TheViewChanger from './View/TheViewChanger.vue';
import { StatefulVue } from '@/presentation/components/Shared/StatefulVue'; import { StatefulVue } from '@/presentation/components/Shared/StatefulVue';
import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState'; import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
import { IEventSubscription } from '@/infrastructure/Events/IEventSource'; import { IEventSubscription } from '@/infrastructure/Events/IEventSource';
@@ -22,7 +22,7 @@ import { IEventSubscription } from '@/infrastructure/Events/IEventSource';
components: { components: {
TheSelector, TheSelector,
TheOsChanger, TheOsChanger,
TheGrouper, TheViewChanger,
}, },
}) })
export default class TheScriptsMenu extends StatefulVue { export default class TheScriptsMenu extends StatefulVue {

View File

@@ -0,0 +1,61 @@
<template>
<MenuOptionList
label="View"
class="part">
<MenuOptionListItem
v-for="view in this.viewOptions" :key="view.type"
:label="view.displayName"
:enabled="currentView !== view.type"
@click="setView(view.type)"
/>
</MenuOptionList>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { ViewType } from './ViewType';
import MenuOptionList from './../MenuOptionList.vue';
import MenuOptionListItem from './../MenuOptionListItem.vue';
const DefaultView = ViewType.Cards;
@Component({
components: {
MenuOptionList,
MenuOptionListItem,
},
})
export default class TheViewChanger extends Vue {
public readonly viewOptions: IViewOption[] = [
{ type: ViewType.Cards, displayName: 'Cards' },
{ type: ViewType.Tree, displayName: 'Tree' },
];
public ViewType = ViewType;
public currentView?: ViewType = null;
public mounted() {
this.setView(DefaultView);
}
public groupBy(type: ViewType) {
this.setView(type);
}
private setView(view: ViewType) {
if (this.currentView === view) {
throw new Error(`View is already "${ViewType[view]}"`);
}
this.currentView = view;
this.$emit('viewChanged', this.currentView);
}
}
interface IViewOption {
readonly type: ViewType;
readonly displayName: string;
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -0,0 +1,4 @@
export enum ViewType {
Cards = 1,
Tree = 0,
}

View File

@@ -1,9 +1,9 @@
<template> <template>
<div class="scripts"> <div class="scripts">
<TheScriptsMenu v-on:groupingChanged="grouping = $event" /> <TheScriptsMenu v-on:viewChanged="currentView = $event" />
<HorizontalResizeSlider class="row"> <HorizontalResizeSlider class="row">
<template v-slot:left> <template v-slot:left>
<TheScriptsList :grouping="grouping" /> <TheScriptsView :currentView="currentView" />
</template> </template>
<template v-slot:right> <template v-slot:right>
<TheCodeArea theme="xcode" /> <TheCodeArea theme="xcode" />
@@ -15,21 +15,21 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator'; import { Component, Vue } from 'vue-property-decorator';
import TheCodeArea from '@/presentation/components/Code/TheCodeArea.vue'; import TheCodeArea from '@/presentation/components/Code/TheCodeArea.vue';
import TheScriptsList from '@/presentation/components/Scripts/TheScriptsList.vue'; import TheScriptsView from '@/presentation/components/Scripts/View/TheScriptsView.vue';
import TheScriptsMenu from '@/presentation/components/Scripts/Menu/TheScriptsMenu.vue'; import TheScriptsMenu from '@/presentation/components/Scripts/Menu/TheScriptsMenu.vue';
import HorizontalResizeSlider from '@/presentation/components/Scripts/Slider/HorizontalResizeSlider.vue'; import HorizontalResizeSlider from '@/presentation/components/Scripts/Slider/HorizontalResizeSlider.vue';
import { Grouping } from '@/presentation/components/Scripts/Menu/Grouping/Grouping'; import { ViewType } from '@/presentation/components/Scripts/Menu/View/ViewType';
@Component({ @Component({
components: { components: {
TheCodeArea, TheCodeArea,
TheScriptsList, TheScriptsView,
TheScriptsMenu, TheScriptsMenu,
HorizontalResizeSlider, HorizontalResizeSlider,
}, },
}) })
export default class TheScriptArea extends Vue { export default class TheScriptArea extends Vue {
public grouping = Grouping.Cards; public currentView = ViewType.Cards;
} }
</script> </script>

View File

@@ -33,7 +33,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Prop, Watch, Emit } from 'vue-property-decorator'; import { Component, Prop, Watch, Emit } from 'vue-property-decorator';
import ScriptsTree from '@/presentation/components/Scripts/ScriptsTree/ScriptsTree.vue'; import ScriptsTree from '@/presentation/components/Scripts/View/ScriptsTree/ScriptsTree.vue';
import { StatefulVue } from '@/presentation/components/Shared/StatefulVue'; import { StatefulVue } from '@/presentation/components/Shared/StatefulVue';
@Component({ @Component({

View File

@@ -1,6 +1,6 @@
import { ILiquorTreeFilter, ILiquorTreeExistingNode } from 'liquor-tree'; import { ILiquorTreeFilter, ILiquorTreeExistingNode } from 'liquor-tree';
import { convertExistingToNode } from './NodeTranslator'; import { convertExistingToNode } from './NodeTranslator';
import { INode } from './../../Node/INode'; import { INode } from '../../Node/INode';
export type FilterPredicate = (node: INode) => boolean; export type FilterPredicate = (node: INode) => boolean;

View File

@@ -1,5 +1,5 @@
import { ILiquorTreeNode, ILiquorTreeNodeState } from 'liquor-tree'; import { ILiquorTreeNode, ILiquorTreeNodeState } from 'liquor-tree';
import { NodeType } from './../../Node/INode'; import { NodeType } from '../../Node/INode';
export function getNewState( export function getNewState(
node: ILiquorTreeNode, node: ILiquorTreeNode,

View File

@@ -1,5 +1,5 @@
import { ILiquorTreeNewNode, ILiquorTreeExistingNode } from 'liquor-tree'; import { ILiquorTreeNewNode, ILiquorTreeExistingNode } from 'liquor-tree';
import { INode } from './../../Node/INode'; import { INode } from '../../Node/INode';
// Functions to translate INode to LiqourTree models and vice versa for anti-corruption // Functions to translate INode to LiqourTree models and vice versa for anti-corruption

View File

@@ -1,8 +1,8 @@
<template> <template>
<div class="scripts"> <div class="scripts">
<div v-if="!isSearching"> <div v-if="!isSearching">
<CardList v-if="grouping === Grouping.Cards"/> <CardList v-if="currentView === ViewType.Cards"/>
<div class="tree" v-if="grouping === Grouping.None"> <div class="tree" v-else-if="currentView === ViewType.Tree">
<ScriptsTree /> <ScriptsTree />
</div> </div>
</div> </div>
@@ -29,12 +29,12 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import TheGrouper from '@/presentation/components/Scripts/Menu/Grouping/TheGrouper.vue'; import TheGrouper from '@/presentation/components/Scripts/Menu/View/TheViewChanger.vue';
import ScriptsTree from '@/presentation/components/Scripts/ScriptsTree/ScriptsTree.vue'; import ScriptsTree from '@/presentation/components/Scripts/View/ScriptsTree/ScriptsTree.vue';
import CardList from '@/presentation/components/Scripts/Cards/CardList.vue'; import CardList from '@/presentation/components/Scripts/View/Cards/CardList.vue';
import { Component, Prop } from 'vue-property-decorator'; import { Component, Prop } from 'vue-property-decorator';
import { StatefulVue } from '@/presentation/components/Shared/StatefulVue'; import { StatefulVue } from '@/presentation/components/Shared/StatefulVue';
import { Grouping } from '@/presentation/components/Scripts/Menu/Grouping/Grouping'; import { ViewType } from '@/presentation/components/Scripts/Menu/View/ViewType';
import { IFilterResult } from '@/application/Context/State/Filter/IFilterResult'; import { IFilterResult } from '@/application/Context/State/Filter/IFilterResult';
import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState'; import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
import { ApplicationFactory } from '@/application/ApplicationFactory'; import { ApplicationFactory } from '@/application/ApplicationFactory';
@@ -56,14 +56,13 @@ filters: {
}, },
}, },
}) })
export default class TheScriptsList extends StatefulVue { export default class TheScriptsView extends StatefulVue {
@Prop() public grouping: Grouping;
public repositoryUrl = ''; public repositoryUrl = '';
public Grouping = Grouping; // Make it accessible from the view
public searchQuery = ''; public searchQuery = '';
public isSearching = false; public isSearching = false;
public searchHasMatches = false; public searchHasMatches = false;
@Prop() public currentView: ViewType;
public ViewType = ViewType; // Make it accessible from the view
public async created() { public async created() {
const app = await ApplicationFactory.Current.getAppAsync(); const app = await ApplicationFactory.Current.getAppAsync();

View File

@@ -12,7 +12,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Watch } from 'vue-property-decorator'; import { Component, Watch } from 'vue-property-decorator';
import { StatefulVue } from '@/presentation/components/Shared/StatefulVue'; import { StatefulVue } from '@/presentation/components/Shared/StatefulVue';
import { NonCollapsing } from '@/presentation/components/Scripts/Cards/NonCollapsingDirective'; import { NonCollapsing } from '@/presentation/components/Scripts/View/Cards/NonCollapsingDirective';
import { IUserFilter } from '@/application/Context/State/Filter/IUserFilter'; import { IUserFilter } from '@/application/Context/State/Filter/IUserFilter';
import { IFilterResult } from '@/application/Context/State/Filter/IFilterResult'; import { IFilterResult } from '@/application/Context/State/Filter/IFilterResult';
import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState'; import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';

View File

@@ -1,7 +1,7 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { NonCollapsing } from '@/presentation/components/Scripts/Cards/NonCollapsingDirective'; import { NonCollapsing } from '@/presentation/components/Scripts/View/Cards/NonCollapsingDirective';
import { hasDirective } from '@/presentation/components/Scripts/Cards/NonCollapsingDirective'; import { hasDirective } from '@/presentation/components/Scripts/View/Cards/NonCollapsingDirective';
const expectedAttributeName = 'data-interaction-does-not-collapse'; const expectedAttributeName = 'data-interaction-does-not-collapse';

View File

@@ -1,9 +1,9 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { getScriptNodeId, getScriptId, getCategoryNodeId, getCategoryId } from '@/presentation/components/Scripts/ScriptsTree/ScriptNodeParser'; import { getScriptNodeId, getScriptId, getCategoryNodeId, getCategoryId } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
import { parseSingleCategory, import { parseSingleCategory,
parseAllCategories } from '@/presentation/components/Scripts/ScriptsTree/ScriptNodeParser'; parseAllCategories } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
import { INode, NodeType } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/INode'; import { INode, NodeType } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INode';
import { IScript } from '@/domain/IScript'; import { IScript } from '@/domain/IScript';
import { ICategory } from '@/domain/ICategory'; import { ICategory } from '@/domain/ICategory';
import { CategoryStub } from '@tests/unit/stubs/CategoryStub'; import { CategoryStub } from '@tests/unit/stubs/CategoryStub';

View File

@@ -1,7 +1,7 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { NodeType, INode } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/INode'; import { NodeType, INode } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INode';
import { NodePredicateFilter } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodePredicateFilter'; import { NodePredicateFilter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodePredicateFilter';
import { ILiquorTreeExistingNode } from 'liquor-tree'; import { ILiquorTreeExistingNode } from 'liquor-tree';
describe('NodePredicateFilter', () => { describe('NodePredicateFilter', () => {

View File

@@ -1,8 +1,8 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { ILiquorTreeNode } from 'liquor-tree'; import { ILiquorTreeNode } from 'liquor-tree';
import { NodeType } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/INode'; import { NodeType } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INode';
import { getNewState } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeStateUpdater'; import { getNewState } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeStateUpdater';
describe('NodeStateUpdater', () => { describe('NodeStateUpdater', () => {
describe('getNewState', () => { describe('getNewState', () => {

View File

@@ -1,8 +1,8 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { NodeType, INode } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/INode'; import { NodeType, INode } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INode';
import { ILiquorTreeExistingNode, ILiquorTreeNewNode, ILiquorTreeNodeData, ICustomLiquorTreeData } from 'liquor-tree'; import { ILiquorTreeExistingNode, ILiquorTreeNewNode, ILiquorTreeNodeData, ICustomLiquorTreeData } from 'liquor-tree';
import { convertExistingToNode, toNewLiquorTreeNode } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeTranslator'; import { convertExistingToNode, toNewLiquorTreeNode } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeTranslator';
describe('NodeTranslator', () => { describe('NodeTranslator', () => {
it('convertExistingToNode', () => { it('convertExistingToNode', () => {

View File

@@ -1,7 +1,7 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { CategoryReverter } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter'; import { CategoryReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter';
import { getCategoryNodeId } from '@/presentation/components/Scripts/ScriptsTree/ScriptNodeParser'; import { getCategoryNodeId } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript'; import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
import { UserSelection } from '@/application/Context/State/Selection/UserSelection'; import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
import { CategoryStub } from '@tests/unit/stubs/CategoryStub'; import { CategoryStub } from '@tests/unit/stubs/CategoryStub';

View File

@@ -1,11 +1,12 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { INode, NodeType } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/INode'; import { INode, NodeType } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INode';
import { // tslint:disable-next-line:max-line-length
getReverter } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ReverterFactory'; import { getReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/ReverterFactory';
import { ScriptReverter } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter'; import { ScriptReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter';
import { CategoryReverter } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter'; import { CategoryReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter';
import { getScriptNodeId, getCategoryNodeId } from '@/presentation/components/Scripts/ScriptsTree/ScriptNodeParser'; // tslint:disable-next-line:max-line-length
import { getScriptNodeId, getCategoryNodeId } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
import { CategoryCollectionStub } from '@tests/unit/stubs/CategoryCollectionStub'; import { CategoryCollectionStub } from '@tests/unit/stubs/CategoryCollectionStub';
import { CategoryStub } from '@tests/unit/stubs/CategoryStub'; import { CategoryStub } from '@tests/unit/stubs/CategoryStub';
import { ScriptStub } from '@tests/unit/stubs/ScriptStub'; import { ScriptStub } from '@tests/unit/stubs/ScriptStub';

View File

@@ -1,7 +1,7 @@
import 'mocha'; import 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import { ScriptReverter } from '@/presentation/components/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter'; import { ScriptReverter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter';
import { getScriptNodeId } from '@/presentation/components/Scripts/ScriptsTree/ScriptNodeParser'; import { getScriptNodeId } from '@/presentation/components/Scripts/View/ScriptsTree/ScriptNodeParser';
import { UserSelection } from '@/application/Context/State/Selection/UserSelection'; import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript'; import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
import { CategoryCollectionStub } from '@tests/unit/stubs/CategoryCollectionStub'; import { CategoryCollectionStub } from '@tests/unit/stubs/CategoryCollectionStub';