-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vue-router, remote ajax actor search
- Loading branch information
Hidenori Maehara
committed
Nov 16, 2017
1 parent
d388823
commit 0978807
Showing
26 changed files
with
456 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Ajax::ActorsController < ApplicationController | ||
def search | ||
actors = actor_api.staff_search_actors(params[:query]) | ||
render json: actors | ||
end | ||
end |
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,11 @@ | ||
class Ajax::FilmsController < ApplicationController | ||
def index | ||
films = film_api.staff_get_films | ||
render json: films | ||
end | ||
|
||
def show | ||
film = film_api.staff_get_film(params[:id]) | ||
render json: film | ||
end | ||
end |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
class HomeController < ApplicationController | ||
def show | ||
@films = film_api.staff_get_films | ||
end | ||
end | ||
|
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,36 @@ | ||
<template> | ||
<el-container> | ||
<el-header> | ||
kotlin dvd rental 管理画面 | ||
</el-header> | ||
|
||
<el-container> | ||
<el-aside> | ||
<el-menu | ||
class="el-menu-vertical-demo" | ||
router | ||
> | ||
<el-menu-item index="/"> | ||
<i class="el-icon-menu"></i> | ||
<span>映画</span> | ||
</el-menu-item> | ||
<el-menu-item index="/customers"> | ||
<i class="el-icon-setting"></i> | ||
<span>顧客</span> | ||
</el-menu-item> | ||
</el-menu> | ||
</el-aside> | ||
|
||
<el-main> | ||
<router-view></router-view> | ||
</el-main> | ||
</el-container> | ||
</el-container> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
}) | ||
</script> |
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,12 @@ | ||
<template> | ||
<div> | ||
customer index | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
}) | ||
</script> |
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,115 @@ | ||
<template> | ||
<div> | ||
<h1>映画 新規作成</h1> | ||
|
||
<el-form ref="form" :model="form" label-width="120px" size="mini"> | ||
<el-form-item label="タイトル"> | ||
<el-input v-model="form.title"></el-input> | ||
</el-form-item> | ||
|
||
<el-form-item label="説明"> | ||
<el-input v-model="form.description"></el-input> | ||
</el-form-item> | ||
|
||
<el-form-item label="出演者"> | ||
<el-select | ||
v-model="form.actorIds" | ||
multiple | ||
filterable | ||
remote | ||
:reserve-keyword="false" | ||
placeholder="名前で検索してください" | ||
:remote-method="searchActors" | ||
:loading="isSearchActorLoading"> | ||
<el-option | ||
v-for="actor in actors" | ||
:key="actor.id" | ||
:label="actor.fullName" | ||
:value="actor.id"> | ||
</el-option> | ||
</el-select> | ||
</el-form-item> | ||
|
||
<el-form-item label="出版年"> | ||
<el-date-picker | ||
v-model="form.releaseYear" | ||
type="year" | ||
placeholder="出版年を選択してください"> | ||
</el-date-picker> | ||
</el-form-item> | ||
|
||
<el-form-item label="レンタル料金"> | ||
<el-input type="text" v-model.number="form.rentalRate" />$ | ||
</el-form-item> | ||
|
||
<el-form-item label="原価"> | ||
<el-input type="text" v-model.number="form.replacementCost" />$ | ||
</el-form-item> | ||
|
||
<el-form-item label="再生時間"> | ||
<el-input type="text" v-model.number="form.length" />分 | ||
</el-form-item> | ||
|
||
<el-form-item label="言語"> | ||
<el-checkbox-group v-model="form.languageId"> | ||
</el-checkbox-group> | ||
</el-form-item> | ||
|
||
<el-form-item label="カテゴリ"> | ||
<el-checkbox-group v-model="form.categoryIds"> | ||
<el-checkbox label="Online activities" name="type"></el-checkbox> | ||
<el-checkbox label="Promotion activities" name="type"></el-checkbox> | ||
<el-checkbox label="Offline activities" name="type"></el-checkbox> | ||
<el-checkbox label="Simple brand exposure" name="type"></el-checkbox> | ||
</el-checkbox-group> | ||
</el-form-item> | ||
|
||
<el-form-item> | ||
<el-button type="primary" @click="onSubmit">Create</el-button> | ||
</el-form-item> | ||
</el-form> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import axios from 'axios' | ||
export default Vue.extend({ | ||
data() { | ||
return { | ||
form: { | ||
actorIds: [] | ||
}, | ||
actors: [], | ||
isSearchActorLoading: false, | ||
} | ||
}, | ||
methods: { | ||
async onSubmit() { | ||
console.log(this.form) | ||
//try { | ||
// const res = await axios.post("/ajax/films") | ||
// this.$router.push("/") | ||
//} catch (e) { | ||
// alert(e) | ||
//} | ||
}, | ||
async searchActors(query: string) { | ||
if (query == "") { return } | ||
try { | ||
this.isSearchActorLoading = true | ||
const res = await axios.get("/ajax/actors/search", { | ||
params: {query: query} | ||
}) | ||
this.actors = res.data | ||
this.isSearchActorLoading = false | ||
} catch (e) { | ||
this.isSearchActorLoading = false | ||
alert(e) | ||
} | ||
} | ||
} | ||
}) | ||
</script> |
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,67 @@ | ||
<template> | ||
<div> | ||
<el-card> | ||
<h1>{{ film.title }} ({{ film.releaseYear }})</h1> | ||
<table> | ||
<tr> | ||
<th>説明</th> | ||
<td>{{ film.description }}</td> | ||
</tr> | ||
<tr> | ||
<th>言語</th> | ||
<td>{{ film.language.name }}</td> | ||
</tr> | ||
<tr> | ||
<th>レンタル料金</th> | ||
<td>{{ film.rentalRate }}$</td> | ||
</tr> | ||
<tr> | ||
<th>再生時間</th> | ||
<td>{{ film.length }}分</td> | ||
</tr> | ||
<tr> | ||
<th>カテゴリ</th> | ||
<td> | ||
<span v-for="category in film.categories" :key="category.id"> | ||
{{ category.name }} | ||
</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th>主演</th> | ||
<td> | ||
<span v-for="actor in film.actors" :key="actor.id"> | ||
{{ actor.firstName }} | ||
</span> | ||
</td> | ||
</tr> | ||
</table> | ||
</el-card> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import axios from 'axios' | ||
export default Vue.extend({ | ||
data() { | ||
return { | ||
id: this.$route.params.id, | ||
film: { | ||
language: {}, | ||
actors: [], | ||
categories: [] | ||
} | ||
} | ||
}, | ||
async mounted() { | ||
try { | ||
const res = await axios.get(`/ajax/films/${this.id}`) | ||
this.film = res.data | ||
} catch (e) { | ||
alert(e) | ||
} | ||
}, | ||
}) | ||
</script> |
Oops, something went wrong.