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.
62 lines
1.5 KiB
Vue
62 lines
1.5 KiB
Vue
<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>
|