Merged PR 1217: #3084 Remission Added Loader to WBS on deleting Items

#3084 Remission Added Loader to WBS on deleting Items
This commit is contained in:
Nino Righi
2022-05-09 08:59:59 +00:00
committed by Andreas Schickinger
parent fc3bea28e8
commit d46643cf8c
5 changed files with 17 additions and 3 deletions

View File

@@ -25,7 +25,11 @@
<div class="font-bold col-span-2">Leistung</div>
<div *ngIf="canRemoveItem" class="text-right">
<button class="text-card-sub bg-transparent text-brand border-none font-bold" (click)="removeItem.emit(item)">Entfernen</button>
<button [disabled]="loading" class="text-card-sub bg-transparent text-brand border-none font-bold" (click)="removeItem.emit(item)">
<ui-spinner [show]="loading">
Entfernen
</ui-spinner>
</button>
</div>
</div>
</div>

View File

@@ -15,6 +15,9 @@ export class SharedShippingDocumentDetailsItemComponent implements OnInit {
@Input()
canRemoveItem: boolean = false;
@Input()
loading: boolean = false;
@Output()
removeItem = new EventEmitter<ReceiptItemDTO>();

View File

@@ -66,6 +66,7 @@
*ngFor="let item of firstReceipt.items"
[item]="item?.data"
[canRemoveItem]="canRemoveItems"
[loading]="loading"
(removeItem)="removeItem($event)"
>
</page-shared-shipping-document-details-item>

View File

@@ -16,6 +16,9 @@ export class SharedShippingDocumentDetailsComponent {
@Input()
canRemoveItems: boolean = false;
@Input()
loading: boolean = false;
@Input()
showAddToRemiHint: boolean = false;
@@ -68,6 +71,7 @@ export class SharedShippingDocumentDetailsComponent {
async removeItem(item: ReceiptItemDTO) {
try {
this.loading = true;
await this._remissionService
.removeReturnItemFromReceipt({
returnId: this.return.id,
@@ -75,10 +79,11 @@ export class SharedShippingDocumentDetailsComponent {
receiptItemId: item.id,
})
.toPromise();
this.loading = false;
this.firstReceipt.items = this.firstReceipt.items.filter((i) => i.id !== item.id);
this.itemDeleted.emit(item);
} catch (err) {
this.loading = false;
this._modal.open({ content: UiErrorModalComponent, title: 'Fehler beim Löschen des Artikels', data: err });
}
}

View File

@@ -1,12 +1,13 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ProductImageModule } from '@cdn/product-image';
import { UiSpinnerModule } from '@ui/spinner';
import { RemissionPipeModule } from '../../pipes';
import { SharedShippingDocumentDetailsItemComponent } from './shipping-document-details-item/shipping-document-details-item.component';
import { SharedShippingDocumentDetailsComponent } from './shipping-document-details.component';
@NgModule({
imports: [CommonModule, RemissionPipeModule, ProductImageModule],
imports: [CommonModule, RemissionPipeModule, ProductImageModule, UiSpinnerModule],
exports: [SharedShippingDocumentDetailsComponent, SharedShippingDocumentDetailsItemComponent],
declarations: [SharedShippingDocumentDetailsComponent, SharedShippingDocumentDetailsItemComponent],
providers: [],