1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-23 04:07:14 +03:00

front: code formatting and some todos resolved

This commit is contained in:
Avele 2019-05-28 18:36:40 +04:00
parent b320838b0f
commit bccfa3a4df
3 changed files with 12 additions and 10 deletions

View File

@ -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'

View File

@ -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 }) => {

View File

@ -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}`
}