Skip to content

Commit

Permalink
feature(publish): #535 show Toast on success or error
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mmaul committed Jan 25, 2024
1 parent 3f480c0 commit 13e6226
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="1000"
[matTooltipDisabled]="roleService.hasAccess(['wip'])"
[matTooltipDisabled]="roleService.hasAccess(['admin'])"
>
<app-button
*ngIf="(allSelectedItems$ | async).length"
Expand Down Expand Up @@ -132,7 +132,7 @@
<app-asset-publisher
[selectedAssets] = "allSelectedItems$ | async"
[isOpen]="isPublisherOpen$"
(submitted)="isPublisherOpen$.next(false)"
(submitted)="isPublisherOpen$.next(false); refreshPartsOnPublish($event);"
></app-asset-publisher>
</app-sidenav-wrapper>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ export class PartsComponent implements OnInit, OnDestroy, AfterViewInit {

}

refreshPartsOnPublish(success: boolean) {
if(!success) {
this.toastService.error("Failed to publish Assets");
} else {
this.toastService.success("Request to publish Assets was successful")
this.partsFacade.setPartsAsBuilt();
this.partsFacade.setPartsAsPlanned();
this.partsTableComponents.map(component => component.clearAllRows())
}
}

private resetFilterAndShowToast() {
let filterIsSet = resetMultiSelectionAutoCompleteComponent(this.partsTableComponents, false);
if (filterIsSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AssetPublisherComponent {
@Input() isOpen: Observable<boolean>;
isOpenSubscription: Subscription;

@Output() submitted = new EventEmitter<void>();
@Output() submitted = new EventEmitter<boolean>();

policiesSubscription: Subscription;
policiesList: Policy[] = [];
Expand Down Expand Up @@ -44,11 +44,15 @@ export class AssetPublisherComponent {
}


publish() {
const selectedAssetIds = this.selectedAssets.map(part => part.id)
this.policyService.publishAssets(selectedAssetIds, this.policyFormControl.value).subscribe(next=> console.log(next));
publish(): void {
const selectedAssetIds = this.selectedAssets.map(part => part.id);
this.policyFormControl.reset();
this.submitted.emit();
this.selectedAssets = [];
this.policyService.publishAssets(selectedAssetIds, this.policyFormControl.value).subscribe({
next: data => {this.submitted.emit(true);},
error: error => {this.submitted.emit(false);}
});

}

private getPolicies() {
Expand Down

0 comments on commit 13e6226

Please sign in to comment.