This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
forked from ku-suke/flightbooks-front
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
296 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<template> | ||
<div class="wrapper"> | ||
<div class="header"> | ||
<div class="title">書籍設定</div> | ||
</div> | ||
<div class="content" v-if="presenter.book"> | ||
<FormBlock label="書籍名"> | ||
<Input v-model="presenter.book.name" placeholder="猫でもわかるflightbooks" :disabled="isLoading"/> | ||
</FormBlock> | ||
<FormBlock label="コピーライト"> | ||
<Input v-model="presenter.book.copyright" placeholder="(c)2015 neko" :disabled="isLoading"/> | ||
</FormBlock> | ||
<FormBlock> | ||
<Button text="保存" @click="save" :loading="isLoading" :disabled="isLoading"/> | ||
</FormBlock> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue"; | ||
import moment from "moment"; | ||
import Presenter, { IPresenter } from "./presenter"; | ||
import FetchBookUseCase from "@/usecases/Book/FetchBookUseCase"; | ||
import SaveBookUseCase from "@/usecases/Book/SaveBookUseCase"; | ||
import BookEntity from "@/entities/Book"; | ||
import BookRepository from "@/repositories/BookRepository"; | ||
import ErrorService from "@/services/ErrorService"; | ||
import Input from "@/components/Base/Input.vue"; | ||
import Select from "@/components/Base/Select.vue"; | ||
import FormBlock from "@/components/Base/FormBlock.vue"; | ||
import Button, { | ||
Type as ButtonType, | ||
Size as ButtonSize | ||
} from "@/components/Base/Button.vue"; | ||
interface IData { | ||
isLoading: boolean; | ||
} | ||
export default Vue.extend({ | ||
components: { | ||
FormBlock, | ||
Input, | ||
Button | ||
}, | ||
props: { | ||
id: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
data(): IData { | ||
return { | ||
isLoading: false | ||
}; | ||
}, | ||
computed: { | ||
presenter(): IPresenter { | ||
let p = Presenter({ | ||
bookRepository: new BookRepository() | ||
}); | ||
return p; | ||
} | ||
}, | ||
methods: { | ||
async fetchBook() { | ||
const usecase = new FetchBookUseCase({ | ||
bookRepository: new BookRepository(), | ||
errorService: new ErrorService({ context: "LoadContainer UseCase" }) | ||
}); | ||
await usecase.execute(this.id); | ||
}, | ||
async save() { | ||
this.isLoading = true; | ||
// Bookを保存する | ||
const saveBookUseCase = new SaveBookUseCase({ | ||
BookRepository: new BookRepository(), | ||
errorService: new ErrorService({ context: "saveBookJob UseCase" }) | ||
}); | ||
const item = new BookEntity({ | ||
...this.presenter.Book, | ||
identifier: this.id | ||
}); | ||
await saveBookUseCase.execute(item); | ||
this.isLoading = false; | ||
alert("Bookを保存しました"); | ||
} | ||
}, | ||
async mounted() { | ||
await this.fetchBook(); | ||
} | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.title { | ||
padding: 24px; | ||
font-size: 24px; | ||
} | ||
.content { | ||
width: 640px; | ||
margin: 0 auto; | ||
} | ||
.select { | ||
box-sizing: border-box; | ||
font-size: 14px; | ||
min-height: 50px; | ||
padding: 10px 18px; | ||
line-height: 30px; | ||
color: #070707; | ||
background-color: #f6f6f6; | ||
outline: none; | ||
border: 1px solid #dadbe3; | ||
border-radius: 4px; | ||
transition: 0.3s; | ||
appearance: none; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import UserRepository from "@/repositories/UserRepository"; | ||
import BookRepository from "@/repositories/BookRepository"; | ||
import BookEntity from "@/entities/Book"; | ||
import { IBook } from "@/entities/Book"; | ||
|
||
export interface PresenterParams { | ||
bookRepository: BookRepository; | ||
} | ||
|
||
export interface IPresenter { | ||
book: IBook; | ||
} | ||
|
||
export default ({ bookRepository }: PresenterParams): IPresenter => { | ||
const item = bookRepository.getItem(); | ||
return { | ||
book: item ? new BookEntity(item).props : null | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import firebase from "firebase"; | ||
import uuid from "uuid/v4"; | ||
|
||
export interface IAuthor { | ||
identifier: string; | ||
name: string; | ||
role?: string; | ||
profile?: string; | ||
link?: string; | ||
createdAt: firebase.firestore.Timestamp; | ||
updatedAt: firebase.firestore.Timestamp; | ||
} | ||
|
||
export default class AuthorEntity { | ||
private _props: IAuthor; | ||
|
||
constructor(params: IAuthor) { | ||
this._props = { ...params }; | ||
} | ||
|
||
static newAuthor({ | ||
name, | ||
role, | ||
profile, | ||
link | ||
}: { | ||
name: string; | ||
role: string; | ||
profile: string; | ||
link: string; | ||
}): AuthorEntity { | ||
return new AuthorEntity({ | ||
identifier: uuid(), | ||
name, | ||
role, | ||
profile, | ||
link, | ||
createdAt: firebase.firestore.FieldValue.serverTimestamp() as firebase.firestore.Timestamp, | ||
updatedAt: firebase.firestore.FieldValue.serverTimestamp() as firebase.firestore.Timestamp | ||
}); | ||
} | ||
|
||
get props(): IAuthor { | ||
return this._props; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<template> | ||
<main class="BookSetting"> | ||
<BookSettingContainer :id="$route.params.id" /> | ||
</main> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue"; | ||
import BookSettingContainer from "@/containers/BookSetting/index.vue"; | ||
export default Vue.extend({ | ||
name: "build", | ||
components: { | ||
BookSettingContainer | ||
} | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.BookSetting { | ||
padding: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.