Hello,
I’m trying to cancel any modification, but the reorder of my items keeps modified after the cancelUpdate()
Can you tell me how to achieve this ? Thank you
<ion-header>
<ion-toolbar>
<ion-buttons slot="secondary">
<ion-button color='primary'>
Valider
</ion-button>
</ion-buttons>
<ion-buttons slot="primary">
<ion-button color="danger" (click)="cancelUpdate()">
Annuler
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-reorder-group disabled="false" (ionItemReorder)="onItemReorder($event)">
<ion-item-sliding *ngFor="let contact of newCtc">
<ion-item>
<ion-label class="ion-text-wrap">
<ion-text color="primary">
{{contact.nom}}
</ion-text>
<p *ngIf='contact.qualite'>Qualité: <b>{{contact.qualite}}</b></p>
<p *ngIf='contact.telephone'>Téléphone: <b>{{contact.telephone}}</b></p>
<p *ngIf='contact.telephone1'>Téléphone 1: <b>{{contact.telephone1}}</b></p>
<p *ngIf='contact.email'>Email: <b>{{contact.email}}</b></p>
</ion-label>
<ion-reorder slot="end"></ion-reorder>
</ion-item>
<ion-item-options side="end">
<ion-item-option (click)="updateItm(contact)" color='primary' style="min-width: 105px;">
Modifier
</ion-item-option>
<ion-item-option (click)="removeItm(contact)" color='danger' style="min-width: 105px;">
Supprimer
</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-reorder-group>
</ion-content>
ngOnInit() {
this.newCtc = this.infoSite.contact.map((x) => x);
}
public onItemReorder({ detail }) {
detail.complete(true);
}
removeItm(contact) {
this.myFunctions.confirmationAlert(
"Supprimer le contact ?",
'Voulez-vous vraiment supprimer le contact ' + contact.nom + ' ?',
).then(confirm => {
if (confirm) {
this.newCtc.splice(this.newCtc.indexOf(contact), 1);
}
});
}
cancelUpdate() {
this.myFunctions.confirmationAlert(
"Annuler",
'Voulez-vous vraiment annuler les modifications en cours ?',
).then(confirm => {
if (confirm) {
this.newCtc = this.infoSite.contact.map((x) => x);
}
});
}
1 post - 1 participant