1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-23 21:02:13 +03:00

Renami "uid" to "id" everywhere

This commit is contained in:
Dmitrij Pavluk 2019-01-22 09:04:30 +03:00
parent a86e2f0c82
commit 19241c46ad
9 changed files with 77 additions and 77 deletions

View File

@ -265,7 +265,7 @@ data TraitSite route = TraitSite
deriving (Generic)
-- | Site-wide search
data SearchSite route = SearchSite
newtype SearchSite route = SearchSite
{ _search :: route :-
Summary "Search categories and items"
:> Description "Note: returns at most 100 search results."
@ -344,7 +344,7 @@ instance ToSchema CCreateTrait where
declareNamedSchema = genericDeclareNamedSchema schemaOptions
-- | Client type to move trait or item up or down.
data CMove = CMove
newtype CMove = CMove
{ cmDirection :: CDirection
} deriving (Show, Eq, Generic)
@ -360,7 +360,7 @@ instance ToSchema CMove where
-- | A "light-weight" client type of 'Category', which describes a category
-- but doesn't give the notes or the items.
data CCategoryInfo = CCategoryInfo
{ cciUid :: Uid Category
{ cciId :: Uid Category
, cciTitle :: Text ? "Category title"
, cciCreated :: UTCTime ? "When the category was created"
, cciGroup_ :: Text ? "Category group ('grandcategory')"
@ -377,17 +377,17 @@ instance ToSchema CCategoryInfo where
-- | Factory to create a 'CCategoryInfo' from a 'Category'
toCCategoryInfo :: Category -> CCategoryInfo
toCCategoryInfo Category{..} = CCategoryInfo
{ cciUid = _categoryUid
, cciTitle = H $ _categoryTitle
, cciCreated = H $ _categoryCreated
, cciGroup_ = H $ _categoryGroup_
{ cciId = _categoryUid
, cciTitle = H _categoryTitle
, cciCreated = H _categoryCreated
, cciGroup_ = H _categoryGroup_
, cciStatus = _categoryStatus
}
-- | A "light-weight" client type of 'Category', which gives all available
-- information about a category
data CCategoryFull = CCategoryFull
{ ccfUid :: Uid Category
{ ccfId :: Uid Category
, ccfTitle :: Text ? "Category title"
, ccfGroup :: Text ? "Category group ('grandcategory')"
, ccfStatus :: CategoryStatus
@ -405,9 +405,9 @@ instance ToSchema CCategoryFull where
-- | Factory to create a 'CCategoryFull' from a 'Category'
toCCategoryFull :: Category -> CCategoryFull
toCCategoryFull Category{..} = CCategoryFull
{ ccfUid = _categoryUid
, ccfTitle = H $ _categoryTitle
, ccfGroup = H $ _categoryGroup_
{ ccfId = _categoryUid
, ccfTitle = H _categoryTitle
, ccfGroup = H _categoryGroup_
, ccfDescription = toCMarkdown _categoryNotes
, ccfItems = H $ fmap toCItemFull _categoryItems
, ccfStatus = _categoryStatus
@ -439,7 +439,7 @@ instance ToSchema ItemSection where
--
-- When updating it, don't forget to update 'CItemInfoEdit' and 'setItemInfo'.
data CItemInfo = CItemInfo
{ ciiUid :: Uid Item
{ ciiId :: Uid Item
, ciiCreated :: UTCTime ? "When the item was created"
, ciiName :: Text ? "Item name"
, ciiGroup :: Maybe Text ? "Item group"
@ -488,7 +488,7 @@ instance ToSchema CItemInfoEdit where
-- | Client type of 'Item'
data CItemFull = CItemFull
{ cifUid :: Uid Item
{ cifId :: Uid Item
, cifName :: Text ? "Item name"
, cifCreated :: UTCTime ? "When the item was created"
, cifGroup :: Maybe Text ? "Item group"
@ -511,28 +511,28 @@ instance ToSchema CItemFull where
-- | Factory to create a 'CItemInfo' from an 'Item'
toCItemInfo :: Item -> CItemInfo
toCItemInfo Item{..} = CItemInfo
{ ciiUid = _itemUid
, ciiCreated = H $ _itemCreated
, ciiName = H $ _itemName
, ciiGroup = H $ _itemGroup_
, ciiHackage = H $ _itemHackage
, ciiLink = H $ _itemLink
{ ciiId = _itemUid
, ciiCreated = H _itemCreated
, ciiName = H _itemName
, ciiGroup = H _itemGroup_
, ciiHackage = H _itemHackage
, ciiLink = H _itemLink
}
-- | Factory to create a 'CItemFull' from an 'Item'
toCItemFull :: Item -> CItemFull
toCItemFull Item{..} = CItemFull
{ cifUid = _itemUid
, cifName = H $ _itemName
, cifCreated = H $ _itemCreated
, cifGroup = H $ _itemGroup_
, cifHackage = H $ _itemHackage
{ cifId = _itemUid
, cifName = H _itemName
, cifCreated = H _itemCreated
, cifGroup = H _itemGroup_
, cifHackage = H _itemHackage
, cifSummary = toCMarkdown _itemSummary
, cifPros = H $ fmap toCTrait _itemPros
, cifCons = H $ fmap toCTrait _itemCons
, cifEcosystem = toCMarkdown _itemEcosystem
, cifNotes = toCMarkdown _itemNotes
, cifLink = H $ _itemLink
, cifLink = H _itemLink
, cifToc = H $ map treeToCMD (markdownTreeMdTOC _itemNotes)
}
where
@ -540,7 +540,7 @@ toCItemFull Item{..} = CItemFull
-- | Client type of 'Trait'
data CTrait = CTrait
{ ctUid :: Uid Trait
{ ctId :: Uid Trait
, ctContent :: CMarkdown
} deriving (Show, Generic)
@ -553,7 +553,7 @@ instance ToSchema CTrait where
-- | Factory to create a 'CTrait' from a 'Trait'
toCTrait :: Trait -> CTrait
toCTrait trait = CTrait
{ ctUid = trait ^. uid
{ ctId = trait ^. uid
, ctContent = toCMarkdown $ trait ^. content
}

View File

@ -24,7 +24,7 @@
<router-link
class="category-title"
v-for="category in groupCategories[CategoryStatus.finished]"
:key="category.uid"
:key="category.id"
:to="`/haskell/${getCategoryUrl(category)}`"
>
<h6
@ -43,7 +43,7 @@
<router-link
class="category-title ml-3"
v-for="category in groupCategories[CategoryStatus.inProgress]"
:key="category.uid"
:key="category.id"
:to="`/haskell/${getCategoryUrl(category)}`"
>
<h6
@ -62,7 +62,7 @@
<router-link
class="category-title ml-3"
v-for="category in groupCategories[CategoryStatus.toBeWritten]"
:key="category.uid"
:key="category.id"
:to="`/haskell/${getCategoryUrl(category)}`"
>
<h6
@ -135,7 +135,7 @@ export default class Categories extends Vue {
this.isAddGroupDialogOpen = true
}
getCategoryUrl (category: ICategoryInfo): string {
return `${_toKebabCase(category.title)}-${category.uid}`
return `${_toKebabCase(category.title)}-${category.id}`
}
}
</script>

View File

@ -34,8 +34,8 @@
<template v-if="category">
<category-item
v-for="value in category.items"
:key="value.uid"
:itemUid="value.uid"
:key="value.id"
:itemUid="value.id"
:link="value.link"
:name="value.name"
:group="value.group"
@ -101,7 +101,7 @@ export default class Category extends Vue {
}
get categoryUrl () {
return this.category && `${_toKebabCase(this.category.title)}-${this.category.uid}`
return this.category && `${_toKebabCase(this.category.title)}-${this.category.id}`
}
openAddItemDialog () {

View File

@ -135,7 +135,7 @@ export default class CategoryItemTraits extends Vue {
async saveEdit (trait: any, modifiedText: string) {
await this.$store.dispatch('categoryItem/updateItemTrait', {
itemId: this.itemId,
traitId: trait.uid,
traitId: trait.id,
original: trait.content.text,
modified: modifiedText
})
@ -146,7 +146,7 @@ export default class CategoryItemTraits extends Vue {
async moveTrait (trait: any, direction: string) {
await this.$store.dispatch('categoryItem/moveItemTrait', {
itemId: this.itemId,
traitId: trait.uid,
traitId: trait.id,
direction
})
await this.$store.dispatch('category/reloadCategory')
@ -170,7 +170,7 @@ export default class CategoryItemTraits extends Vue {
async deleteTrait (trait: any) {
await this.$store.dispatch('categoryItem/deleteItemTrait', {
itemId: this.itemId,
traitId: trait.uid
traitId: trait.id
})
await this.$store.dispatch('category/reloadCategory')
}

View File

@ -17,7 +17,7 @@
»
<a-link
openInNewTab
:url="`http://aelve.com:4801/haskell/${result.contents.info.uid}`"
:url="`http://aelve.com:4801/haskell/${result.contents.info.id}`"
>
{{ result.contents.info.title }}
</a-link>
@ -30,7 +30,7 @@
<span class="search-result-title">
<a-link
openInNewTab
:url="`http://aelve.com:4801/haskell/${result.contents.category.uid}`"
:url="`http://aelve.com:4801/haskell/${result.contents.category.id}`"
>
{{ result.contents.category.title }}
</a-link>
@ -38,7 +38,7 @@
<span>
<a-link
openInNewTab
:url="`http://aelve.com:4801/haskell/${result.contents.category.uid}#item-${result.contents.info.uid}`"
:url="`http://aelve.com:4801/haskell/${result.contents.category.id}#item-${result.contents.info.id}`"
>
<!-- Do not format next line to separate lines cause it adds extra space after </a-link>. -->
{{ result.contents.info.name }}</a-link>'s ecosystem

View File

@ -2,7 +2,7 @@ import axios from 'axios'
import { ICategoryItem } from './CategoryItem'
class CategoryService {
async getCategoryById (id: ICategoryInfo['uid']): Promise<ICategoryFull> {
async getCategoryById (id: ICategoryInfo['id']): Promise<ICategoryFull> {
const { data } = await axios.get(`api/category/${id}`, {})
return data
}
@ -14,7 +14,7 @@ class CategoryService {
async createCategory (
{ title, group }: { title: ICategoryInfo['title'], group: ICategoryInfo['group'] }
): Promise<ICategoryInfo['uid']> {
): Promise<ICategoryInfo['id']> {
const { data } = await axios.post('api/category', null, {
params: {
title,
@ -32,7 +32,7 @@ export enum CategoryStatus {
}
export interface ICategoryInfo {
uid: string
id: string
title: string
created: string
group: string
@ -40,7 +40,7 @@ export interface ICategoryInfo {
}
export interface ICategoryFull {
uid: string
id: string
title: string
group: string
status: CategoryStatus

View File

@ -11,19 +11,19 @@ class CategoryItemService {
})
return data
}
async deleteItemById (id: ICategoryItem['uid']): Promise<void> {
async deleteItemById (id: ICategoryItem['id']): Promise<void> {
await axios.delete(`api/item/${id}`)
}
async updateItemInfo (id: ICategoryItem['uid'], body: ICategoryItemInfo): Promise<void> {
async updateItemInfo (id: ICategoryItem['id'], body: ICategoryItemInfo): Promise<void> {
await axios.put(`api/item/${id}/info`, body)
}
async moveItem (id: ICategoryItem['uid'], direction: string): Promise<void> {
async moveItem (id: ICategoryItem['id'], direction: string): Promise<void> {
await axios.post(`api/item/${id}/move`, {
direction
})
}
async updateItemSummary (
id: ICategoryItem['uid'],
id: ICategoryItem['id'],
original: ICategoryItem['summary'],
modified: ICategoryItem['summary']
): Promise<void> {
@ -33,7 +33,7 @@ class CategoryItemService {
})
}
async updateItemEcosystem (
id: ICategoryItem['uid'],
id: ICategoryItem['id'],
original: ICategoryItem['ecosystem'],
modified: ICategoryItem['ecosystem']
): Promise<void> {
@ -43,7 +43,7 @@ class CategoryItemService {
})
}
async updateItemNotes (
id: ICategoryItem['uid'],
id: ICategoryItem['id'],
original: ICategoryItem['notes'],
modified: ICategoryItem['notes']
): Promise<void> {
@ -53,8 +53,8 @@ class CategoryItemService {
})
}
async updateItemTrait (
itemId: ICategoryItem['uid'],
traitId: ITrait['uid'],
itemId: ICategoryItem['id'],
traitId: ITrait['id'],
original: string,
modified: string
): Promise<void> {
@ -64,8 +64,8 @@ class CategoryItemService {
})
}
async moveItemTrait (
itemId: ICategoryItem['uid'],
traitId: ITrait['uid'],
itemId: ICategoryItem['id'],
traitId: ITrait['id'],
direction: string
): Promise<void> {
await axios.post(`api/item/${itemId}/trait/${traitId}/move`, {
@ -73,13 +73,13 @@ class CategoryItemService {
})
}
async deleteItemTrait (
itemId: ICategoryItem['uid'],
traitId: ITrait['uid'],
itemId: ICategoryItem['id'],
traitId: ITrait['id'],
): Promise<void> {
await axios.delete(`api/item/${itemId}/trait/${traitId}`)
}
async createItemTrait (
itemId: ICategoryItem['uid'],
itemId: ICategoryItem['id'],
type: string,
text: string,
): Promise<void> {
@ -97,7 +97,7 @@ export interface ICreateCategoryItem {
}
export interface ICategoryItem {
uid: string
id: string
name: string
created: string
group?: string
@ -113,7 +113,7 @@ export interface ICategoryItem {
}
export interface ICategoryItemInfo {
uid?: string
id?: string
name?: string
created?: string
link?: string
@ -121,7 +121,7 @@ export interface ICategoryItemInfo {
}
export interface ITrait {
uid: string
id: string
content: object
}

View File

@ -19,11 +19,11 @@ const actions: ActionTree<ICategoryState, any> = {
if (!category) {
return
}
dispatch('loadCategory', category.uid)
dispatch('loadCategory', category.id)
},
async loadCategory (
{ commit }: ActionContext<ICategoryState, any>,
categoryId: ICategoryInfo['uid']
categoryId: ICategoryInfo['id']
): Promise<any> {
const data: ICategoryFull = await CategoryService.getCategoryById(categoryId)
// TODO create set function for all the store
@ -36,7 +36,7 @@ const actions: ActionTree<ICategoryState, any> = {
async createCategory (
{ dispatch }: ActionContext<ICategoryState, any>,
{ title, group }: { title: ICategoryInfo['title'], group: ICategoryInfo['group'] }
): Promise<ICategoryInfo['uid']> {
): Promise<ICategoryInfo['id']> {
const createdId = await CategoryService.createCategory({
title,
group

View File

@ -21,7 +21,7 @@ const actions: ActionTree<ICategoryItemState, any> = {
async createItem (
{ dispatch }: ActionContext<ICategoryItemState, any>,
{ category, name }: ICreateCategoryItem
): Promise<ICategoryItem['uid']> {
): Promise<ICategoryItem['id']> {
const createdId = await CategoryItemService.createItem({
category,
name
@ -29,36 +29,36 @@ const actions: ActionTree<ICategoryItemState, any> = {
dispatch('category/reloadCategory', null, { root: true })
return createdId
},
async deleteItemById (context, id: ICategoryItem['uid']) {
async deleteItemById (context, id: ICategoryItem['id']) {
await CategoryItemService.deleteItemById(id)
},
async updateItemInfo (
context: ActionContext<ICategoryItemState, any>,
{ id, body }: { id: ICategoryItem['uid'], body: ICategoryItemInfo }
{ id, body }: { id: ICategoryItem['id'], body: ICategoryItemInfo }
): Promise<void> {
await CategoryItemService.updateItemInfo(id, body)
},
async moveItem (
context: ActionContext<ICategoryItemState, any>,
{ id, direction }: { id: ICategoryItem['uid'], direction: string }
{ id, direction }: { id: ICategoryItem['id'], direction: string }
): Promise<void> {
await CategoryItemService.moveItem(id, direction)
},
async updateItemSummary (
context: ActionContext<ICategoryItemState, any>,
{ id, original, modified }: { id: ICategoryItem['uid'], original: ICategoryItem['summary'], modified: ICategoryItem['summary'] }
{ id, original, modified }: { id: ICategoryItem['id'], original: ICategoryItem['summary'], modified: ICategoryItem['summary'] }
): Promise<void> {
await CategoryItemService.updateItemSummary(id, original, modified)
},
async updateItemEcosystem (
context: ActionContext<ICategoryItemState, any>,
{ id, original, modified }: { id: ICategoryItem['uid'], original: ICategoryItem['ecosystem'], modified: ICategoryItem['ecosystem'] }
{ id, original, modified }: { id: ICategoryItem['id'], original: ICategoryItem['ecosystem'], modified: ICategoryItem['ecosystem'] }
): Promise<void> {
await CategoryItemService.updateItemEcosystem(id, original, modified)
},
async updateItemNotes (
context: ActionContext<ICategoryItemState, any>,
{ id, original, modified }: { id: ICategoryItem['uid'], original: ICategoryItem['notes'], modified: ICategoryItem['notes'] }
{ id, original, modified }: { id: ICategoryItem['id'], original: ICategoryItem['notes'], modified: ICategoryItem['notes'] }
): Promise<void> {
await CategoryItemService.updateItemNotes(id, original, modified)
},
@ -70,8 +70,8 @@ const actions: ActionTree<ICategoryItemState, any> = {
original,
modified
}: {
itemId: ICategoryItem['uid'],
traitId: ITrait['uid'],
itemId: ICategoryItem['id'],
traitId: ITrait['id'],
original: string,
modified: string
}
@ -85,8 +85,8 @@ const actions: ActionTree<ICategoryItemState, any> = {
traitId,
direction
}: {
itemId: ICategoryItem['uid'],
traitId: ITrait['uid'],
itemId: ICategoryItem['id'],
traitId: ITrait['id'],
direction: string
}
): Promise<void> {
@ -98,8 +98,8 @@ const actions: ActionTree<ICategoryItemState, any> = {
itemId,
traitId,
}: {
itemId: ICategoryItem['uid'],
traitId: ITrait['uid']
itemId: ICategoryItem['id'],
traitId: ITrait['id']
}
): Promise<void> {
await CategoryItemService.deleteItemTrait(itemId, traitId)
@ -110,7 +110,7 @@ const actions: ActionTree<ICategoryItemState, any> = {
type,
text
}: {
itemId: ICategoryItem['uid'],
itemId: ICategoryItem['id'],
type: string,
text: string,
}