- Added single school page
This commit is contained in:
@@ -11,4 +11,7 @@ export default {
|
|||||||
getSchool(id) {
|
getSchool(id) {
|
||||||
return api.get(`${resource}/${id}`)
|
return api.get(`${resource}/${id}`)
|
||||||
},
|
},
|
||||||
|
getSpellsFromSchool(id) {
|
||||||
|
return api.get(`${resource}/${id}/spells`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<b-modal ref="add_spell_modal">
|
<b-modal
|
||||||
|
ref="add_spell_modal"
|
||||||
|
size="lg"
|
||||||
|
modal-class="b-modal">
|
||||||
|
|
||||||
<template v-slot:modal-header="{ close }">
|
<template v-slot:modal-header="{ close }">
|
||||||
<div class="h1 modal-title font-display font-weight-bold" id="spell_show_edit_modal">
|
<div class="h1 modal-title font-display font-weight-bold" id="spell_show_edit_modal">
|
||||||
<div class="line-height-100">
|
<div class="line-height-100">
|
||||||
@@ -11,6 +15,7 @@
|
|||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:default>
|
<template v-slot:default>
|
||||||
<form id="add-spell" @submit="addSpell">
|
<form id="add-spell" @submit="addSpell">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -21,9 +26,9 @@
|
|||||||
<label for="spell_description" class="font-weight-bold col-form-label">Description :</label>
|
<label for="spell_description" class="font-weight-bold col-form-label">Description :</label>
|
||||||
<textarea class="form-control" name="spell_description" id="spell_description" placeholder="(2048 caractères max.)" v-model="spell.description"></textarea>
|
<textarea class="form-control" name="spell_description" id="spell_description" placeholder="(2048 caractères max.)" v-model="spell.description"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check form-check-inline">
|
||||||
<input type="checkbox" class="form-check-input" id="spell_rituel" v-model="spell.is_ritual">
|
<input type="checkbox" class="form-check-input" id="spell_ritual" name="spell_ritual" v-model="spell.is_ritual">
|
||||||
<label for="spell_ritual" class="font-weight-bold col-form-label">Rituel ? :</label>
|
<label for="spell_ritual" class="font-weight-bold col-form-label">Rituel ? </label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="spell_level" class="font-weight-bold col-form-label">Niveau :</label>
|
<label for="spell_level" class="font-weight-bold col-form-label">Niveau :</label>
|
||||||
@@ -57,10 +62,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:modal-footer="{ close }">
|
<template v-slot:modal-footer="{ close }">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" @click="close()">Fermer</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" @click="close()">Fermer</button>
|
||||||
<input type="submit" class="btn btn-primary" value="Enregistrer" form="add-spell">
|
<input type="submit" class="btn btn-primary" value="Enregistrer" form="add-spell">
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</b-modal>
|
</b-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -82,6 +89,9 @@ export default {
|
|||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
is_ritual: false,
|
is_ritual: false,
|
||||||
|
level: 0,
|
||||||
|
cost: "0",
|
||||||
|
charge: 0,
|
||||||
schools: [],
|
schools: [],
|
||||||
variables: [],
|
variables: [],
|
||||||
ingredients: [],
|
ingredients: [],
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<b-modal ref="edit_spell_modal" :spell="computeSpell">
|
<b-modal
|
||||||
|
ref="edit_spell_modal"
|
||||||
|
size="lg"
|
||||||
|
modal-class="b-modal"
|
||||||
|
:spell="computeSpell">
|
||||||
|
|
||||||
<template v-slot:modal-header="{ close }">
|
<template v-slot:modal-header="{ close }">
|
||||||
<div class="h1 modal-title font-display font-weight-bold" id="spell_show_edit_modal"><div class="line-height-100">{{spell.name}}#{{spell.id}}</div></div>
|
<div class="h1 modal-title font-display font-weight-bold" id="spell_show_edit_modal"><div class="line-height-100">{{spell.name}}#{{spell.id}}</div></div>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" @click="close()">
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close" @click="close()">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:default>
|
<template v-slot:default>
|
||||||
<form id="update-spell" @submit="updateSpell">
|
<form id="update-spell" @submit="updateSpell">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -16,9 +22,9 @@
|
|||||||
<label for="spell_description" class="font-weight-bold col-form-label">Description :</label>
|
<label for="spell_description" class="font-weight-bold col-form-label">Description :</label>
|
||||||
<textarea class="form-control" name="spell_description" id="spell_description" placeholder="(2048 caractères max.)" v-model="spell.description"></textarea>
|
<textarea class="form-control" name="spell_description" id="spell_description" placeholder="(2048 caractères max.)" v-model="spell.description"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check form-check-inline">
|
||||||
<input type="checkbox" class="form-check-input" id="spell_rituel" v-model="spell.is_ritual">
|
<input type="checkbox" class="form-check-input" id="spell_ritual" name="spell_ritual" v-model="spell.is_ritual">
|
||||||
<label for="spell_ritual" class="font-weight-bold col-form-label">Rituel ? :</label>
|
<label for="spell_ritual" class="font-weight-bold col-form-label">Rituel ? </label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="spell_level" class="font-weight-bold col-form-label">Niveau :</label>
|
<label for="spell_level" class="font-weight-bold col-form-label">Niveau :</label>
|
||||||
@@ -52,6 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:modal-footer="{ close }">
|
<template v-slot:modal-footer="{ close }">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" @click="close()">Fermer</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" @click="close()">Fermer</button>
|
||||||
<input type="submit" class="btn btn-primary" value="Enregistrer" form="update-spell">
|
<input type="submit" class="btn btn-primary" value="Enregistrer" form="update-spell">
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import AddSpellCard from "./add-spell-card"
|
|||||||
// API
|
// API
|
||||||
import { RepositoryFactory } from "../../../api/repositories"
|
import { RepositoryFactory } from "../../../api/repositories"
|
||||||
const Spells = RepositoryFactory.get('spells')
|
const Spells = RepositoryFactory.get('spells')
|
||||||
|
const Schools = RepositoryFactory.get('schools')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'spellslist',
|
name: 'spellslist',
|
||||||
@@ -26,6 +27,9 @@ export default {
|
|||||||
'edit-spell-card': EditSpellCard,
|
'edit-spell-card': EditSpellCard,
|
||||||
'add-spell-card': AddSpellCard,
|
'add-spell-card': AddSpellCard,
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
school_id: String
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -39,8 +43,14 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchSpells() {
|
async fetchSpells() {
|
||||||
const { data } = await Spells.getSpells()
|
if (!this.school_id) {
|
||||||
return data
|
const { data } = await Spells.getSpells()
|
||||||
|
return data
|
||||||
|
} else {
|
||||||
|
const { data } = await Schools.getSpellsFromSchool(this.school_id)
|
||||||
|
console.log(data.spells)
|
||||||
|
return data.spells
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async computeSpells() {
|
async computeSpells() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
class Spell {
|
|
||||||
|
|
||||||
private id: number
|
|
||||||
private name: string
|
|
||||||
private description: string
|
|
||||||
private cost: number
|
|
||||||
private charge: number
|
|
||||||
private schools: Array<string>
|
|
||||||
private ingredients: Array<string>
|
|
||||||
private variables: Array<string>
|
|
||||||
|
|
||||||
constructor(id: number) {
|
|
||||||
this.id = id
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Spell;
|
|
||||||
50
client/src/pages/schools/single-school-page.vue
Normal file
50
client/src/pages/schools/single-school-page.vue
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container-fluid p-4" id="spell-container">
|
||||||
|
<h1 class="display-3 font-display mb-3">{{ school.name }}</h1>
|
||||||
|
<spell-list :school_id="id"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import SpellsList from "../../components/spells/spells-list"
|
||||||
|
|
||||||
|
// API
|
||||||
|
import { RepositoryFactory } from "../../../api/repositories"
|
||||||
|
const Schools = RepositoryFactory.get('schools')
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'single-school',
|
||||||
|
components: {
|
||||||
|
'spell-list': SpellsList,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
school: {},
|
||||||
|
id: this.$route.params.id
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.computeSchool()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async fetchSchool(id) {
|
||||||
|
const { data } = await Schools.getSchool(id)
|
||||||
|
return data
|
||||||
|
},
|
||||||
|
async computeSchool() {
|
||||||
|
this.loading = true
|
||||||
|
const displaySchool = await this.fetchSchool(this.id)
|
||||||
|
this.loading = false
|
||||||
|
this.school = displaySchool
|
||||||
|
},
|
||||||
|
console() {
|
||||||
|
console.log(this.school)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
// Pages
|
// Pages
|
||||||
import Index from "./pages/index-page";
|
import Index from "./pages/index-page";
|
||||||
import Spells from "./pages/spells-page";
|
import Spells from "./pages/spells-page";
|
||||||
|
import SchoolSingle from "./pages/schools/single-school-page";
|
||||||
import World from "./pages/world-page";
|
import World from "./pages/world-page";
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
@@ -17,6 +18,9 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: '/spells', component: Spells,
|
path: '/spells', component: Spells,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/school/:id', component: SchoolSingle, props: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/world', component: World,
|
path: '/world', component: World,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class IngredientRepository {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
model.forge()
|
model.forge()
|
||||||
.where({ 'id' : id })
|
.where({ 'id' : id })
|
||||||
.fetch({ withRelated: ['spells']})
|
.fetch({ withRelated: ['spells', 'spells.schools', 'spells.variables', 'spells.ingredients', 'spells.schools.meta_schools']})
|
||||||
.then(v => {
|
.then(v => {
|
||||||
resolve(v.toJSON({ omitPivot: true }))
|
resolve(v.toJSON({ omitPivot: true }))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class SchoolRepository {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
model.forge()
|
model.forge()
|
||||||
.where({ 'id' : id })
|
.where({ 'id' : id })
|
||||||
.fetch({ withRelated: ['spells', 'meta_schools']})
|
.fetch({ withRelated: ['spells', 'spells.schools', 'spells.variables', 'spells.ingredients', 'spells.schools.meta_schools']})
|
||||||
.then(v => {
|
.then(v => {
|
||||||
resolve(v.toJSON({ omitPivot: true }))
|
resolve(v.toJSON({ omitPivot: true }))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class VariableRepository {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
model.forge()
|
model.forge()
|
||||||
.where({ 'id' : id })
|
.where({ 'id' : id })
|
||||||
.fetch({ withRelated: ['spells']})
|
.fetch({ withRelated: ['spells', 'spells.schools', 'spells.variables', 'spells.ingredients', 'spells.schools.meta_schools']})
|
||||||
.then(v => {
|
.then(v => {
|
||||||
resolve(v.toJSON({ omitPivot: true }))
|
resolve(v.toJSON({ omitPivot: true }))
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user