From bccfa3a4dfbdd373cf60ec011255a916bbb6eda3 Mon Sep 17 00:00:00 2001 From: Avele Date: Tue, 28 May 2019 18:36:40 +0400 Subject: [PATCH] front: code formatting and some todos resolved --- front/build/setupProdServer.ts | 1 - front/client/app.ts | 1 - front/client/components/Categories.vue | 20 ++++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/front/build/setupProdServer.ts b/front/build/setupProdServer.ts index 664e257..0799386 100644 --- a/front/build/setupProdServer.ts +++ b/front/build/setupProdServer.ts @@ -1,4 +1,3 @@ -// TODO move imports here and make no dynamic import path from 'path' import fs from 'fs' import { createBundleRenderer } from 'vue-server-renderer' diff --git a/front/client/app.ts b/front/client/app.ts index cb6a7de..3bf8ae7 100644 --- a/front/client/app.ts +++ b/front/client/app.ts @@ -17,7 +17,6 @@ import AppComponent from './App.vue' import { createRouter } from './router' import { createStore } from './store' - const icons = {} // TODO import and add only used icons for production Object.values(fas).forEach(({ iconName }) => { diff --git a/front/client/components/Categories.vue b/front/client/components/Categories.vue index 8b57f34..540caa5 100644 --- a/front/client/components/Categories.vue +++ b/front/client/components/Categories.vue @@ -114,26 +114,30 @@ export default class Categories extends Vue { async serverPrefetch () { return this.$store.dispatch('category/loadCategoryList') } + get categories () { return this.$store.state.category.categoryList } - // TODO refactor + get groups () { const groupedByGroupName = _groupBy(this.categories, 'group') const groupedEntries = Object.entries(groupedByGroupName) - const groupedAlsoByStatus = groupedEntries.map(([key, value]: [string, ICategoryInfo[]]) => { - const grouppedCategoriesByStatus = _groupBy(value, 'status') - return [key, grouppedCategoriesByStatus] - }) - // Key is groupName, so we sort by groupNames - const entriesKeyIndex = 0 - const sortedAlphabetically = _sortBy(groupedAlsoByStatus, entriesKeyIndex) + const groupedAlsoByStatus = groupedEntries.map( + ([groupName, groupCategories]: [string, ICategoryInfo[]]) => { + const groupedCategoriesByStatus = _groupBy(groupCategories, 'status') + return [groupName, groupedCategoriesByStatus] + }) + // Key 0 is groupName, we sort by groupNames + const entriesGroupNameIndex = 0 + const sortedAlphabetically = _sortBy(groupedAlsoByStatus, entriesGroupNameIndex) return _fromPairs(sortedAlphabetically) } + openAddCategoryDialog (groupName: string) { this.addCategoryGroupName = groupName this.isAddGroupDialogOpen = true } + getCategoryUrl (category: ICategoryInfo): string { return `${_toKebabCase(category.title)}-${category.id}` }