Skip to content

Commit

Permalink
Merge pull request #85 from dsteelma-umd/feature/LIBDRUM-899
Browse files Browse the repository at this point in the history
LIBDRUM-899. Updated UMD components to use DSONameService

https://umd-dit.atlassian.net/browse/LIBDRUM-899
  • Loading branch information
dsteelma-umd authored Jan 14, 2025
2 parents 029268d + 07d73a9 commit 8c48031
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
switchMap,
take,
} from 'rxjs/operators';
import { DSONameService } from 'src/app/core/breadcrumbs/dso-name.service';
import { AuthorizationDataService } from 'src/app/core/data/feature-authorization/authorization-data.service';
import { FeatureID } from 'src/app/core/data/feature-authorization/feature-id';
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
Expand Down Expand Up @@ -168,7 +169,9 @@ export class UnitFormComponent implements OnInit, OnDestroy {
private authorizationService: AuthorizationDataService,
private modalService: NgbModal,
public requestService: RequestService,
protected changeDetectorRef: ChangeDetectorRef) {
protected changeDetectorRef: ChangeDetectorRef,
public dsoNameService: DSONameService,
) {
}

ngOnInit() {
Expand Down Expand Up @@ -324,7 +327,7 @@ export class UnitFormComponent implements OnInit, OnDestroy {
.subscribe((list: PaginatedList<Unit>) => {
if (list.totalElements > 0) {
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.' + notificationSection + '.failure.unitNameInUse', {
name: unit.name,
name: this.dsoNameService.getName(unit),
}));
}
}));
Expand Down Expand Up @@ -357,10 +360,10 @@ export class UnitFormComponent implements OnInit, OnDestroy {
getFirstCompletedRemoteData(),
).subscribe((rd: RemoteData<Unit>) => {
if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.edited.success', { name: rd.payload.name }));
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.edited.success', { name: this.dsoNameService.getName(rd.payload) }));
this.submitForm.emit(rd.payload);
} else {
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.edited.failure', { name: unit.name }));
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.edited.failure', { name: this.dsoNameService.getName(unit) }));
this.cancelForm.emit();
}
});
Expand Down Expand Up @@ -407,7 +410,7 @@ export class UnitFormComponent implements OnInit, OnDestroy {
delete() {
this.unitDataService.getActiveUnit().pipe(take(1)).subscribe((unit: Unit) => {
const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = unit;
modalRef.componentInstance.name = this.dsoNameService.getName(unit);
modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-unit.modal.header';
modalRef.componentInstance.infoLabel = this.messagePrefix + '.delete-unit.modal.info';
modalRef.componentInstance.cancelLabel = this.messagePrefix + '.delete-unit.modal.cancel';
Expand All @@ -420,11 +423,11 @@ export class UnitFormComponent implements OnInit, OnDestroy {
this.unitDataService.delete(unit.id).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<NoContent>) => {
if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: unit.name }));
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: this.dsoNameService.getName(unit) }));
this.onCancel();
} else {
this.notificationsService.error(
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: unit.name }),
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: this.dsoNameService.getName(unit) }),
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.content', { cause: rd.errorMessage }));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
switchMap,
tap,
} from 'rxjs/operators';
import { DSONameService } from 'src/app/core/breadcrumbs/dso-name.service';
import { AuthorizationDataService } from 'src/app/core/data/feature-authorization/authorization-data.service';
import { FeatureID } from 'src/app/core/data/feature-authorization/feature-id';
import {
Expand Down Expand Up @@ -124,7 +125,9 @@ export class UnitsRegistryComponent implements OnInit, OnDestroy {
private notificationsService: NotificationsService,
private formBuilder: FormBuilder,
private authorizationService: AuthorizationDataService,
private paginationService: PaginationService) {
private paginationService: PaginationService,
public dsoNameService: DSONameService,
) {
this.currentSearchQuery = '';
this.searchForm = this.formBuilder.group(({
query: this.currentSearchQuery,
Expand Down Expand Up @@ -223,10 +226,10 @@ export class UnitsRegistryComponent implements OnInit, OnDestroy {
.subscribe((rd: RemoteData<NoContent>) => {
if (rd.hasSucceeded) {
this.deletedUnitsIds = [...this.deletedUnitsIds, unit.unit.id];
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: unit.unit.name }));
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(unit.unit) }));
} else {
this.notificationsService.error(
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: unit.unit.name }),
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: this.dsoNameService.getName(unit.unit) }),
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.content', { cause: rd.errorMessage }));
}
});
Expand Down
9 changes: 6 additions & 3 deletions src/app/etdunit-registry/etdunits-registry.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { NotificationsService } from 'src/app/shared/notifications/notifications
import { PaginationComponentOptions } from 'src/app/shared/pagination/pagination-component-options.model';
import { followLink } from 'src/app/shared/utils/follow-link-config.model';

import { DSONameService } from '../core/breadcrumbs/dso-name.service';
import { ThemedLoadingComponent } from '../shared/loading/themed-loading.component';
import { PaginationComponent } from '../shared/pagination/pagination.component';
import { EtdUnitDataService } from './etdunit-data.service';
Expand Down Expand Up @@ -126,7 +127,9 @@ export class EtdUnitsRegistryComponent implements OnInit, OnDestroy {
private notificationsService: NotificationsService,
private formBuilder: FormBuilder,
private authorizationService: AuthorizationDataService,
private paginationService: PaginationService) {
private paginationService: PaginationService,
public dsoNameService: DSONameService,
) {
this.currentSearchQuery = '';
this.searchForm = this.formBuilder.group(({
query: this.currentSearchQuery,
Expand Down Expand Up @@ -225,10 +228,10 @@ export class EtdUnitsRegistryComponent implements OnInit, OnDestroy {
.subscribe((rd: RemoteData<NoContent>) => {
if (rd.hasSucceeded) {
this.deletedEtdUnitsIds = [...this.deletedEtdUnitsIds, etdunit.etdunit.id];
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: etdunit.etdunit.name }));
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(etdunit.etdunit) }));
} else {
this.notificationsService.error(
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: etdunit.etdunit.name }),
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: this.dsoNameService.getName(etdunit.etdunit) }),
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.content', { cause: rd.errorMessage }));
}
});
Expand Down

0 comments on commit 8c48031

Please sign in to comment.