mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
#1243 Status Refresh nach dem Laden
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit, ChangeDetectionStrategy, Input, Inject, Output, EventEmitter } from '@angular/core';
|
||||
import { Component, OnInit, ChangeDetectionStrategy, Input, Inject, Output, EventEmitter, OnDestroy } from '@angular/core';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { CDN_PRODUCT_PICTURES } from 'apps/sales/src/app/tokens';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
@@ -10,7 +10,7 @@ import { map } from 'rxjs/operators';
|
||||
styleUrls: ['search-result-group-item.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class SearchResultGroupItemComponent implements OnInit {
|
||||
export class SearchResultGroupItemComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
item: OrderItemListItemDTO;
|
||||
|
||||
@@ -20,9 +20,14 @@ export class SearchResultGroupItemComponent implements OnInit {
|
||||
@Input()
|
||||
disableSelection: EventEmitter<OrderItemListItemDTO>;
|
||||
|
||||
@Input()
|
||||
setSelection: EventEmitter<OrderItemListItemDTO>;
|
||||
|
||||
@Output()
|
||||
itemSelected = new EventEmitter<{ item: OrderItemListItemDTO; checked: boolean }>();
|
||||
|
||||
setSelectionSubscribtion: Subscription;
|
||||
|
||||
selected: boolean;
|
||||
|
||||
checkboxDisabled$: Observable<boolean>;
|
||||
@@ -30,6 +35,9 @@ export class SearchResultGroupItemComponent implements OnInit {
|
||||
constructor(@Inject(CDN_PRODUCT_PICTURES) public cdnProdutctPictures: string) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.setSelectionSubscribtion = this.setSelection.subscribe((item) => {
|
||||
this.selected = this.item.orderItemSubsetId === item.orderItemSubsetId;
|
||||
});
|
||||
this.checkboxDisabled$ = this.disableSelection.pipe(
|
||||
map((item) => {
|
||||
if (!item) return false;
|
||||
@@ -39,6 +47,12 @@ export class SearchResultGroupItemComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.setSelectionSubscribtion) {
|
||||
this.setSelectionSubscribtion.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
selectionChange() {
|
||||
this.selected = !this.selected;
|
||||
this.itemSelected.emit({ item: this.item, checked: this.selected });
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
(click)="onItemClick({ e: $event, item: item })"
|
||||
(itemSelected)="onItemSelected($event)"
|
||||
[disableSelection]="disableSelection"
|
||||
[setSelection]="setSelection"
|
||||
[displayCompartmentCode]="firstItem | showCompartmentCode: item:group.items"
|
||||
>
|
||||
</app-search-result-group-item>
|
||||
|
||||
@@ -22,6 +22,12 @@ export class SearchResultGroupComponent implements OnInit {
|
||||
@Input()
|
||||
disableSelection: EventEmitter<OrderItemListItemDTO>;
|
||||
|
||||
@Input()
|
||||
setSelection: EventEmitter<OrderItemListItemDTO>;
|
||||
|
||||
@Output()
|
||||
refreshCheckedState = new EventEmitter<void>();
|
||||
|
||||
byOrderNumberFn = (item: OrderItemListItemDTO) => item.orderNumber;
|
||||
|
||||
byProcessingStatusFn = (item: OrderItemListItemDTO) => item.processingStatus;
|
||||
@@ -30,7 +36,9 @@ export class SearchResultGroupComponent implements OnInit {
|
||||
|
||||
constructor(private navigationFacade: ShelfNavigationService) {}
|
||||
|
||||
ngOnInit() {}
|
||||
ngOnInit() {
|
||||
this.refreshCheckedState.emit();
|
||||
}
|
||||
|
||||
navigateToDetails(orderItem: OrderItemListItemDTO) {
|
||||
this.navigationFacade.navigateToDetails(orderItem);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
[group]="group"
|
||||
(selectOrderItemListItem)="navigateToDetails($event)"
|
||||
(orderListItemChecked)="itemChecked($event)"
|
||||
(refreshCheckedState)="refreshCheckedState($event)"
|
||||
[disableSelection]="disableSelection"
|
||||
[setSelection]="setSelection"
|
||||
>
|
||||
</app-search-result-group>
|
||||
<app-loading
|
||||
|
||||
@@ -41,6 +41,7 @@ export class ShelfSearchResultsComponent implements OnInit, OnDestroy {
|
||||
scrollStorageKey = ORDER_DETAILS_PREFIX;
|
||||
|
||||
disableSelection = new EventEmitter<OrderItemListItemDTO>();
|
||||
setSelection = new EventEmitter<OrderItemListItemDTO>();
|
||||
|
||||
checkedItems = new Array<OrderItemListItemDTO>();
|
||||
|
||||
@@ -79,6 +80,15 @@ export class ShelfSearchResultsComponent implements OnInit, OnDestroy {
|
||||
this.initFetch();
|
||||
}
|
||||
|
||||
refreshCheckedState() {
|
||||
setTimeout(() => {
|
||||
this.checkedItems.forEach((i) => {
|
||||
this.setSelection.emit(i);
|
||||
this.disableSelection.emit(i);
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
||||
initFetch() {
|
||||
if (this.isFromSearchPage()) {
|
||||
this.fetch();
|
||||
|
||||
Reference in New Issue
Block a user