Question 2,4,5,6 finies, question 3 à revoir

master
dohodin 2 years ago
parent 665f8b3e68
commit 056d386d0c

@ -1,3 +1,10 @@
/* Global */
.pointer {
cursor: pointer;
}
/* Onglet */ /* Onglet */
.menu-pannel { .menu-pannel {
@ -20,24 +27,6 @@
display: none; display: none;
} }
.team{
position: absolute;
border: 0;
height: 1px;
width: 1px;
padding: 0;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6 & IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
.team:target{
position: relative;
height: auto;
padding: initial;
clip: initial;
}
/* Formulaire */ /* Formulaire */
@ -50,7 +39,7 @@ form input {
/* CARD */ /* CARD */
.team-card { .team-card {
border: #000000 1px; border: #000000 1px solid;
border-radius: 5px; border-radius: 5px;
} }

@ -12,9 +12,14 @@
<div id="app"> <div id="app">
<navbar></navbar> <navbar></navbar>
<div class="team" style="display: none;"> <div class="team">
<team-card></team-card> <team-add @add-team="addTeam"></team-add>
</div> </div>
<teamcard v-for="team in allTeam"
:id="team.id"
:name="team.name"
:description="team.description">
</teamcard>
</div> </div>
<script src="/src/misc/constant.js"></script> <script src="/src/misc/constant.js"></script>
@ -23,21 +28,25 @@
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 TeamCard from '/src/view/team_add.js'; import TeamAdd from '/src/view/team_add.js';
import Teamcard from '/src/view/teamcard.js';
const app = createApp({ const app = createApp({
data() { data() {
return { return {
links: [ allTeam: []
'#', }
'./src/viewhtml/team.html', },
'https://www.github.com', methods:{
] addTeam: function(team){
console.log('index.addTeam',team);
this.allTeam.push(team);
} }
} }
}) })
app.component('Navbar', Navbar) app.component('Navbar', Navbar)
.component('TeamCard', TeamCard); .component('TeamAdd', TeamAdd)
.component('Teamcard',Teamcard);
app.mount('#app'); app.mount('#app');
</script> </script>
</body> </body>

@ -3,7 +3,7 @@ export default class LinkService{
getLinks(){ getLinks(){
return [ return [
'#', '#',
'./src/viewhtml/team.html', '#',
'https://www.github.com', 'https://www.github.com',
]; ];
} }

@ -1,14 +1,34 @@
export default { export default {
props: { props: {
linkHome: String, linkHome: {
linkTeam: String, type: String,
linkResults: String default: '#'
},
linkTeam:{
type: String,
default: ''
},
linkResults: {
type: String,
default: 'https://www.github.com'
}
},
methods:{
toggleDiv: function(){
let div = document.getElementById("team");
if (div.classList.contains("hide")) {
div.classList.remove("hide");
} else {
div.classList.add("hide");
}
}
}, },
template:` template:`
<ul> <ul>
<li><a href="#">Home</a></li> <li><a :href="linkHome">Home</a></li>
<li><a href="#team">Teams</a></li> <li @click="toggleDiv"><a :href="linkTeam">Team</a></li>
<li><a href="https://www.github.com">Results</a></li> <li><a target="_blank" :href="linkResults">Results</a></li>
</ul> </ul>
` `
}; };

@ -3,6 +3,7 @@ export default {
return { return {
id: '', id: '',
name: '', name: '',
description: '',
errorMessage: '', errorMessage: '',
errorColor: ERROR_COLOR errorColor: ERROR_COLOR
} }
@ -10,18 +11,25 @@ export default {
methods: { methods: {
addTeam: function() { addTeam: function() {
this.errorMessage = ''; this.errorMessage = '';
if (!this.id || !this.name) { if (!this.id ){
this.errorMessage = 'ID and Name are required !'; this.errorMessage = 'ID is required !';
return;
}else if (!this.name){
this.errorMessage = 'Name is required !';
return
}else if(!this.description) {
this.errorMessage = 'Description is required !';
return; return;
} }
const team = { id: this.id, name: this.name}; 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('addTeam', team);
this.id = ''; this.id = '';
this.name = ''; this.name = '';
this.description = '';
} }
}, },
template: `<section> template: `<section>
@ -36,6 +44,10 @@ export default {
<label>Name</label><br/> <label>Name</label><br/>
<input type="text" v-model="name"/> <input type="text" v-model="name"/>
</div> </div>
<div>
<label>Description</label><br/>
<textarea v-model="description"></textarea>
</div>
<input type="submit" value="Create Team" @click="addTeam"/> <input type="submit" value="Create Team" @click="addTeam"/>
</form> </form>
</section>` </section>`

@ -0,0 +1,32 @@
export default {
props: {
id: {
type :String,
require : true
},
name: {
type :String,
require : true
},
description: {
type :String,
require : true
}
},
computed: {
description20(){
if (this.description.length > 20) {
return this.description.substring(0, 20) + '...';
} else {
return this.description;
}
}
},
template: `
<div class="team-card">
<span>ID of the Team : {{ id }}</span>
<p>Name : {{ name }}</p>
<p>Description : {{ description20 }}</p>
</div>
`
}
Loading…
Cancel
Save