This commit is contained in:
2021-11-17 23:44:45 +01:00
parent f2e9a24e88
commit d7b1e51016
2 changed files with 49 additions and 4 deletions

View File

@@ -12,7 +12,7 @@
<b-card-text>
<br>
</b-card-text>
<b-button href="#" variant="success" v-on:click="show" >Ajouter un compte<b-icon-plus-circle-fill style="color:green"></b-icon-plus-circle-fill></b-button>
<b-button href="#" variant="success" v-on:click="show()" >Ajouter un compte<b-icon-plus-circle-fill style="color:green"></b-icon-plus-circle-fill></b-button>
</b-card>
<b-card style="display: inline-block;" v-for="account in accounts" :key="account.id"
@@ -23,12 +23,29 @@
{{account.name}}
</b-card-text>
<b-button href="#" variant="primary" class="see-account" >Voir</b-button>
<b-button href="#" variant="danger" >Supprimer </b-button>
<b-button href="#" variant="danger" v-on:click="validateDeleteAccount(account.id)">Supprimer</b-button>
</b-card>
</b-tab>
</b-tabs>
</b-card>
<b-modal ref="delete-account" size="lg" centered title="">
<template #modal-header="{ }">
</template>
<template #default="{ }">
<p>Etes vous sûr ?</p>
</template>
<template #modal-footer="{ ok, cancel }">
<b-button size="sm" variant="danger" @click="deleteAccount()">
Supprimer
</b-button>
<!-- Button with custom close trigger value -->
<b-button size="sm" variant="outline-secondary" @click="show=cancel()">
Annuler
</b-button>
</template>
</b-modal>
<b-modal ref="create-account" size="lg" centered title="">
<template #modal-header="{ }">
<h5>Ajout d'un compte</h5>
@@ -69,7 +86,7 @@
<script>
import {BCard, BTabs, BButton, BTab, BCardText, BCardTitle, BIconPlusCircleFill, BModal, BFormGroup, BFormSelect, BFormInput} from "bootstrap-vue";
import {createAccount, getAccounts} from "@/config/noscomptes";
import {createAccount, getAccounts, deleteAnAccount} from "@/config/noscomptes";
export default {
name: 'mes_comptes',
data: function () {
@@ -95,6 +112,13 @@ export default {
mounted () {
},
methods: {
deleteAccount(){
let loggedUser = this.$store.state.loggedUser
deleteAnAccount(loggedUser.oauth_token, loggedUser.nosComptesId, this.accountIdToDelete).then(() => {
this.loadAccounts()
this.$refs['delete-account'].hide()
})
},
loadAccounts() {
let loggedUser = this.$store.state.loggedUser
getAccounts(loggedUser.oauth_token, loggedUser.nosComptesId).then(data => {
@@ -120,6 +144,10 @@ export default {
})
},
validateDeleteAccount(accountId) {
this.accountIdToDelete = accountId
this.$refs['delete-account'].show()
},
show() {
this.$refs['create-account'].show()
}