mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
split personAction in sub-component
This commit is contained in:
parent
7df753f1cb
commit
a8f55e064d
@ -85,6 +85,7 @@ class AccompanyingCourseController extends Controller
|
|||||||
*/
|
*/
|
||||||
$person = $participation->getPerson();
|
$person = $participation->getPerson();
|
||||||
$persons[$k] = [
|
$persons[$k] = [
|
||||||
|
'id' => $person->getId(),
|
||||||
'firstname' => $person->getFirstName(),
|
'firstname' => $person->getFirstName(),
|
||||||
'lastname' => $person->getLastName(),
|
'lastname' => $person->getLastName(),
|
||||||
'email' => $person->getEmail(),
|
'email' => $person->getEmail(),
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<tr>
|
||||||
|
<td>{{ person.firstname }}</td>
|
||||||
|
<td>{{ person.lastname }}</td>
|
||||||
|
<td>{{ person.startdate }}</td>
|
||||||
|
<td>{{ person.enddate }}</td>
|
||||||
|
<td>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li><button class="sc-button bt-show"></button></li>
|
||||||
|
<li><button class="sc-button bt-update"></button></li>
|
||||||
|
<li><button class="sc-button bt-delete" @click.prevent="$emit('remove', person)"></button></li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'PersonAction',
|
||||||
|
props: {
|
||||||
|
person: { type: Object, required: true }
|
||||||
|
},
|
||||||
|
emits: ['remove']
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h3>Usagers concernés</h3>
|
<h3>Usagers concernés</h3>
|
||||||
|
|
||||||
<label>{{ counter }} usagers</label>
|
<label>{{ counter }} usagers</label>
|
||||||
|
|
||||||
<table class="rounded">
|
<table class="rounded">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -13,40 +15,32 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="person in persons_associated">
|
<person-action v-for="person in persons_associated" :key="person.id" :person="person" @remove="removePerson" />
|
||||||
<td>{{ person.firstname }}</td>
|
|
||||||
<td>{{ person.lastname }}</td>
|
|
||||||
<td>{{ person.startdate }}</td>
|
|
||||||
<td>{{ person.enddate }}</td>
|
|
||||||
<td>
|
|
||||||
<ul class="record_actions">
|
|
||||||
<li><a class="sc-button bt-show"></a></li>
|
|
||||||
<li><a class="sc-button bt-update"></a></li>
|
|
||||||
<li><a class="sc-button bt-delete"></a></li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li><button class="sc-button bt-create" @click="addPerson">Ajouter un usager</button></li>
|
||||||
<button class="sc-button bt-create" @click="addPerson">Add Person</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import PersonAction from "./PersonAction.vue"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PersonsAssociated',
|
name: 'PersonsAssociated',
|
||||||
props: {
|
props: {
|
||||||
'persons_associated': Array
|
persons_associated: Array
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
PersonAction
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
counter() {
|
async counter() {
|
||||||
console.log(typeof(this.persons_associated));
|
|
||||||
// Pourquoi je peux pas compter un tableau avec length ???!!!
|
// Pourquoi je peux pas compter un tableau avec length ???!!!
|
||||||
return this.persons_associated; //.length <= boum !
|
return this.persons_associated.length // <= boum !
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -57,6 +51,9 @@ export default {
|
|||||||
"startdate": "1975-09-15",
|
"startdate": "1975-09-15",
|
||||||
"enddate": "2021-04-20"
|
"enddate": "2021-04-20"
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
removePerson(item) {
|
||||||
|
this.persons_associated = this.persons_associated.filter(person => person !== item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user