From f65b96412a9c0a81d1f228cff899eeb574e2c03a Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 17 May 2024 14:34:24 +0200 Subject: [PATCH] Fixed multiple edit relationship bugs - Fixed issue making it impossible to add new relationships until the page is refreshed after deleting an existing one (only when you refreshed the page after creating the initial relationship) - Fixed NPE in DsDynamicLookupRelationModalComponent - Grouped buttons on relationship page in order to assure that they always have the same behaviour --- .../abstract-item-update.component.ts | 6 ++ .../item-bitstreams.component.html | 16 ++-- .../edit-item-relationships.service.spec.ts | 2 - .../item-relationships.component.html | 82 +++++++++---------- .../item-relationships.component.spec.ts | 7 +- .../item-relationships.component.ts | 3 + ...namic-lookup-relation-modal.component.html | 2 +- ...dynamic-lookup-relation-modal.component.ts | 7 +- ...ic-lookup-relation-search-tab.component.ts | 6 +- ...ic-lookup-relation-search-tab.component.ts | 4 +- ...lookup-relation-selection-tab.component.ts | 6 +- src/assets/i18n/en.json5 | 2 + 12 files changed, 73 insertions(+), 70 deletions(-) diff --git a/src/app/item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts b/src/app/item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts index 80002f614b6..15ce7dbd53f 100644 --- a/src/app/item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts +++ b/src/app/item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts @@ -35,6 +35,10 @@ export class AbstractItemUpdateComponent extends AbstractTrackableComponent impl */ updates$: Observable; + hasChanges$: Observable; + + isReinstatable$: Observable; + /** * Route to the item's page */ @@ -82,6 +86,8 @@ export class AbstractItemUpdateComponent extends AbstractTrackableComponent impl this.discardTimeOut = environment.item.edit.undoTimeout; this.url = this.router.url; + this.hasChanges$ = this.hasChanges(); + this.isReinstatable$ = this.isReinstatable(); if (this.url.indexOf('?') > 0) { this.url = this.url.substr(0, this.url.indexOf('?')); } diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.html b/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.html index 4cb9577fcb5..32b8288bb99 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.html +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.html @@ -5,18 +5,18 @@ class="fas fa-upload">  {{"item.edit.bitstreams.upload-button" | translate}} - - - - - - - + +
+
@@ -26,36 +10,46 @@ [item]="item" [itemType]="entityType" [relationshipType]="relationshipType" - [hasChanges]="hasChanges()" + [hasChanges]="hasChanges$" >
- - -
-
- - - +
+
-
+ + + + {{ 'item.edit.relationships.no-entity-type' | translate }} + + + + + + + + +
+ + + +
+
diff --git a/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.spec.ts b/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.spec.ts index 24dc86cc3d2..4f7f1a86c6d 100644 --- a/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.spec.ts +++ b/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.spec.ts @@ -2,9 +2,7 @@ import { ChangeDetectorRef, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute, Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { getTestScheduler } from 'jasmine-marbles'; import { combineLatest as observableCombineLatest, of as observableOf } from 'rxjs'; -import { TestScheduler } from 'rxjs/testing'; import { ObjectCacheService } from '../../../core/cache/object-cache.service'; import { RestResponse } from '../../../core/cache/response.models'; import { EntityTypeDataService } from '../../../core/data/entity-type-data.service'; @@ -30,6 +28,7 @@ import { relationshipTypes } from '../../../shared/testing/relationship-types.mo import { ThemeService } from '../../../shared/theme-support/theme.service'; import { getMockThemeService } from '../../../shared/mocks/theme-service.mock'; import { ItemDataServiceStub } from '../../../shared/testing/item-data.service.stub'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; let comp: any; let fixture: ComponentFixture; @@ -58,7 +57,6 @@ let itemService: ItemDataServiceStub; const url = 'http://test-url.com/test-url'; router.url = url; -let scheduler: TestScheduler; let item; let author1; let author2; @@ -206,9 +204,8 @@ describe('ItemRelationshipsComponent', () => { } ); - scheduler = getTestScheduler(); TestBed.configureTestingModule({ - imports: [SharedModule, TranslateModule.forRoot()], + imports: [NoopAnimationsModule, SharedModule, TranslateModule.forRoot()], declarations: [ItemRelationshipsComponent], providers: [ { provide: ThemeService, useValue: getMockThemeService() }, diff --git a/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.ts b/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.ts index 758978f8d86..a405a8b1d28 100644 --- a/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.ts +++ b/src/app/item-page/edit-item-page/item-relationships/item-relationships.component.ts @@ -28,6 +28,7 @@ import { PaginatedList } from '../../../core/data/paginated-list.model'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { EditItemRelationshipsService } from './edit-item-relationships.service'; import { compareArraysUsingIds } from '../../simple/item-types/shared/item-relationships-utils'; +import { AlertType } from '../../../shared/alert/aletr-type'; @Component({ selector: 'ds-item-relationships', @@ -54,6 +55,8 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent { return this.editItemRelationshipsService.isSaving$; } + readonly AlertType = AlertType; + constructor( public itemService: ItemDataService, public objectUpdatesService: ObjectUpdatesService, diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html index 25c35358364..71cc8de0ac4 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html @@ -32,7 +32,7 @@