Modification majeur des composants

master
Raphael LACOTE 2 years ago
parent d95677ab57
commit 5021d71f4d

@ -12,14 +12,15 @@
<div id="app"> <div id="app">
<navbar></navbar> <navbar></navbar>
<div class="team"> <team></team>
<!--<div class="team">
<team-add @add-team="addTeam"></team-add> <team-add @add-team="addTeam"></team-add>
</div> </div>
<teamcard v-for="team in allTeam" <teamcard v-for="team in allTeam"
:id="team.id" :id="team.id"
:name="team.name" :name="team.name"
:description="team.description"> :description="team.description">
</teamcard> </teamcard>-->
</div> </div>
<script src="./src/misc/constant.js"></script> <script src="./src/misc/constant.js"></script>
@ -31,27 +32,16 @@
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'; import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js';
import Navbar from './src/view/navbar.js'; import Navbar from './src/view/navbar.js';
import TeamAdd from './src/view/team_add.js'; import Team from './src/view/team.js'
import Teamcard from './src/view/teamcard.js';
const app = createApp();
const app = createApp({
data() {
return {
allTeam: []
}
},
methods: {
addTeam: function (team) {
console.log('index.addTeam', team);
this.allTeam.push(team);
}
}
})
app.component('Navbar', Navbar) app.component('Navbar', Navbar)
.component('TeamAdd', TeamAdd) .component('Team', Team)
.component('Teamcard', Teamcard);
app.mount('#app'); app.mount('#app');
</script> </script>
</body> </body>
</html> </html>
<!--Ctrl Maj R-->

@ -1,3 +1,3 @@
const ERROR_COLOR = 'red'; const ERROR_COLOR = 'red';
const DESCRIPTION_MINIMAL_SIZE = 20; const DESCRIPTION_MINIMAL_SIZE = 1;
const NAME_MINIMAL_SIZE = 5; const NAME_MINIMAL_SIZE = 1;

@ -30,5 +30,4 @@ export default {
<li><a target="_blank" :href="linkResults">Results</a></li> <li><a target="_blank" :href="linkResults">Results</a></li>
</ul> </ul>
` `
}; };

@ -1,3 +1,5 @@
export default { export default {
data: function() { data: function() {
return { return {
@ -31,11 +33,10 @@ export default {
throw new StringSize("Name", NAME_MINIMAL_SIZE) throw new StringSize("Name", NAME_MINIMAL_SIZE)
} }
console.log(this.description.length)
const team = { id: this.id, name: this.name, description: this.description}; const team = { id: this.id, name: this.name, description: this.description};
console.log('form.addTeam', team); console.log('form.addTeam', team);
this.$emit('addTeam', team); this.$emit('teamAjoute', team);
this.id = ''; this.id = '';
this.name = ''; this.name = '';
@ -53,7 +54,6 @@ export default {
} }
}, },
template: `<section> template: `<section>
<h2>News form</h2>
<form @submit.prevent> <form @submit.prevent>
<div v-bind:style="{ color: errorColor}">{{ errorMessage }}</div> <div v-bind:style="{ color: errorColor}">{{ errorMessage }}</div>
<div> <div>

@ -0,0 +1,34 @@
import teamAdd from './team-add.js';
import teamCard from './teamcard.js';
export default {
data: function() {
return {
allTeam: []
}
},
methods: {
recupTeam: function (team) {
console.log('team.addTeam', team);
this.allTeam.push(team);
}
},
components: {
teamCard,
teamAdd
},
template: `
<section>
<h2>News form</h2>
<div class="team">
<teamAdd v-on:teamAjoute="recupTeam"></teamAdd>
</div>
<teamCard v-for="team in allTeam"
:id="team.id"
:name="team.name"
:description="team.description">
</teamCard>
</section>
`
}

@ -13,6 +13,16 @@ export default {
require : true require : true
} }
}, },
data: function () {
return {
isEdit: false
}
},
methods: {
editTeam: function () {
this.isEdit = !this.isEdit;
}
},
computed: { computed: {
description20(){ description20(){
if (this.description.length > 20) { if (this.description.length > 20) {
@ -27,6 +37,7 @@ export default {
<span>ID of the Team : {{ id }}</span> <span>ID of the Team : {{ id }}</span>
<p>Name : {{ name }}</p> <p>Name : {{ name }}</p>
<p>Description : {{ description20 }}</p> <p>Description : {{ description20 }}</p>
<button name="button" @click="editTeam">Editer</button>
</div> </div>
` `
} }
Loading…
Cancel
Save