From cdb2c30bd45e233a5de336cbc67f0ddd0b566361 Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Wed, 10 Jul 2019 11:14:21 +0200 Subject: [PATCH 01/10] 63667: Extract update tracker --- src/app/shared/shared.module.ts | 5 +- .../abstract-trackable.component.spec.ts | 101 ++++++++++++++++++ .../trackable/abstract-trackable.component.ts | 78 ++++++++++++++ 3 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 src/app/shared/trackable/abstract-trackable.component.spec.ts create mode 100644 src/app/shared/trackable/abstract-trackable.component.ts diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 816139c8b9..4654789b90 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -138,6 +138,7 @@ import { RoleDirective } from './roles/role.directive'; import { UserMenuComponent } from './auth-nav-menu/user-menu/user-menu.component'; import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component'; import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component'; +import { AbstractTrackableComponent } from './trackable/abstract-trackable.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -257,7 +258,8 @@ const COMPONENTS = [ ItemSearchResultListElementComponent, TypedItemSearchResultListElementComponent, ItemTypeSwitcherComponent, - BrowseByComponent + BrowseByComponent, + AbstractTrackableComponent ]; const ENTRY_COMPONENTS = [ @@ -311,6 +313,7 @@ const SHARED_ITEM_PAGE_COMPONENTS = [ const PROVIDERS = [ TruncatableService, MockAdminGuard, + AbstractTrackableComponent, { provide: DYNAMIC_FORM_CONTROL_MAP_FN, useValue: dsDynamicFormControlMapFn diff --git a/src/app/shared/trackable/abstract-trackable.component.spec.ts b/src/app/shared/trackable/abstract-trackable.component.spec.ts new file mode 100644 index 0000000000..3755092263 --- /dev/null +++ b/src/app/shared/trackable/abstract-trackable.component.spec.ts @@ -0,0 +1,101 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { AbstractTrackableComponent } from './abstract-trackable.component'; +import { INotification, Notification } from '../notifications/models/notification.model'; +import { NotificationType } from '../notifications/models/notification-type'; +import { of as observableOf } from 'rxjs'; +import { TranslateModule } from '@ngx-translate/core'; +import { ObjectUpdatesService } from '../../core/data/object-updates/object-updates.service'; +import { NotificationsService } from '../notifications/notifications.service'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { TestScheduler } from 'rxjs/testing'; +import { getTestScheduler } from 'jasmine-marbles'; + +describe('AbstractTrackableComponent', () => { + let comp: AbstractTrackableComponent; + let fixture: ComponentFixture; + let objectUpdatesService; + let scheduler: TestScheduler; + + const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info'); + const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning'); + const successNotification: INotification = new Notification('id', NotificationType.Success, 'success'); + + const notificationsService = jasmine.createSpyObj('notificationsService', + { + info: infoNotification, + warning: warningNotification, + success: successNotification + } + ); + + const url = 'http://test-url.com/test-url'; + + beforeEach(async(() => { + objectUpdatesService = jasmine.createSpyObj('objectUpdatesService', + { + saveAddFieldUpdate: {}, + discardFieldUpdates: {}, + reinstateFieldUpdates: observableOf(true), + initialize: {}, + hasUpdates: observableOf(true), + isReinstatable: observableOf(false), // should always return something --> its in ngOnInit + isValidPage: observableOf(true) + } + ); + + scheduler = getTestScheduler(); + + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot()], + declarations: [AbstractTrackableComponent], + providers: [ + {provide: ObjectUpdatesService, useValue: objectUpdatesService}, + {provide: NotificationsService, useValue: notificationsService}, + ], schemas: [ + NO_ERRORS_SCHEMA + ] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AbstractTrackableComponent); + comp = fixture.componentInstance; + comp.url = url; + + fixture.detectChanges(); + }); + + it('should discard object updates', () => { + comp.discard(); + + expect(objectUpdatesService.discardFieldUpdates).toHaveBeenCalledWith(url, infoNotification); + }); + it('should undo the discard of object updates', () => { + comp.reinstate(); + + expect(objectUpdatesService.reinstateFieldUpdates).toHaveBeenCalledWith(url); + }); + + describe('isReinstatable', () => { + beforeEach(() => { + objectUpdatesService.isReinstatable.and.returnValue(observableOf(true)); + }); + + it('should return an observable that emits true', () => { + const expected = '(a|)'; + scheduler.expectObservable(comp.isReinstatable()).toBe(expected, {a: true}); + }); + }); + + describe('hasChanges', () => { + beforeEach(() => { + objectUpdatesService.hasUpdates.and.returnValue(observableOf(true)); + }); + + it('should return an observable that emits true', () => { + const expected = '(a|)'; + scheduler.expectObservable(comp.hasChanges()).toBe(expected, {a: true}); + }); + }); + +}); diff --git a/src/app/shared/trackable/abstract-trackable.component.ts b/src/app/shared/trackable/abstract-trackable.component.ts new file mode 100644 index 0000000000..cd1b425f10 --- /dev/null +++ b/src/app/shared/trackable/abstract-trackable.component.ts @@ -0,0 +1,78 @@ +import { ObjectUpdatesService } from '../../core/data/object-updates/object-updates.service'; +import { NotificationsService } from '../notifications/notifications.service'; +import { TranslateService } from '@ngx-translate/core'; +import { Observable } from 'rxjs'; +import { Component } from '@angular/core'; + +/** + * Abstract Component that is able to track changes made in the inheriting component using the ObjectUpdateService + */ +@Component({ + selector: 'ds-abstract-trackable', + template: '' +}) +export class AbstractTrackableComponent { + + /** + * The time span for being able to undo discarding changes + */ + public discardTimeOut: number; + public message: string; + public url: string; + public notificationsPrefix = 'static-pages.form.notification'; + + constructor( + public objectUpdatesService: ObjectUpdatesService, + public notificationsService: NotificationsService, + public translateService: TranslateService, + ) { + + } + + /** + * Request the object updates service to discard all current changes to this item + * Shows a notification to remind the user that they can undo this + */ + discard() { + const undoNotification = this.notificationsService.info(this.getNotificationTitle('discarded'), this.getNotificationContent('discarded'), {timeOut: this.discardTimeOut}); + this.objectUpdatesService.discardFieldUpdates(this.url, undoNotification); + } + + /** + * Request the object updates service to undo discarding all changes to this item + */ + reinstate() { + this.objectUpdatesService.reinstateFieldUpdates(this.url); + } + + /** + * Checks whether or not the object is currently reinstatable + */ + isReinstatable(): Observable { + return this.objectUpdatesService.isReinstatable(this.url); + } + + /** + * Checks whether or not there are currently updates for this object + */ + hasChanges(): Observable { + return this.objectUpdatesService.hasUpdates(this.url); + } + + /** + * Get translated notification title + * @param key + */ + private getNotificationTitle(key: string) { + return this.translateService.instant(this.notificationsPrefix + key + '.title'); + } + + /** + * Get translated notification content + * @param key + */ + private getNotificationContent(key: string) { + return this.translateService.instant(this.notificationsPrefix + key + '.content'); + + } +} From 3d9af688e775b6de60b1209f4db2ff95ee83770a Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 10 Jul 2019 16:43:20 +0200 Subject: [PATCH 02/10] 63669: Edit Communtiy/Collection Tabs --- resources/i18n/en.json | 38 +++++++++++- .../collection-page-routing.module.ts | 9 +-- .../collection-page.module.ts | 5 +- .../collection-curate.component.html} | 0 .../collection-curate.component.ts | 9 +++ .../collection-metadata.component.html | 4 ++ .../collection-metadata.component.ts | 21 +++++++ .../collection-roles.component.html | 0 .../collection-roles.component.ts | 9 +++ .../collection-source.component.html | 0 .../collection-source.component.ts | 9 +++ .../edit-collection-page.component.html | 11 ---- .../edit-collection-page.component.scss | 1 - .../edit-collection-page.component.ts | 18 ++++-- .../edit-collection-page.module.ts | 32 ++++++++++ .../edit-collection-page.routing.module.ts | 58 +++++++++++++++++++ .../community-page-routing.module.ts | 9 +-- .../+community-page/community-page.module.ts | 5 +- .../community-curate.component.html | 0 .../community-curate.component.ts | 9 +++ .../community-metadata.component.html | 4 ++ .../community-metadata.component.ts | 21 +++++++ .../community-roles.component.html | 0 .../community-roles.component.ts | 9 +++ .../edit-community-page.component.html | 12 ---- .../edit-community-page.component.scss | 1 - .../edit-community-page.component.ts | 18 ++++-- .../edit-community-page.module.ts | 30 ++++++++++ .../edit-community-page.routing.module.ts | 52 +++++++++++++++++ .../comcol-metadata.component.ts | 48 +++++++++++++++ .../edit-comcol-page.component.html | 24 ++++++++ .../edit-comcol-page.component.ts | 41 +++++++------ src/app/shared/shared.module.ts | 4 +- 33 files changed, 436 insertions(+), 75 deletions(-) rename src/app/{shared/mocks/mock-store.ts => +collection-page/edit-collection-page/collection-curate/collection-curate.component.html} (100%) create mode 100644 src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts create mode 100644 src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html create mode 100644 src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts create mode 100644 src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.html create mode 100644 src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts create mode 100644 src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.html create mode 100644 src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts delete mode 100644 src/app/+collection-page/edit-collection-page/edit-collection-page.component.html delete mode 100644 src/app/+collection-page/edit-collection-page/edit-collection-page.component.scss create mode 100644 src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts create mode 100644 src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts create mode 100644 src/app/+community-page/edit-community-page/community-curate/community-curate.component.html create mode 100644 src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts create mode 100644 src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.html create mode 100644 src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts create mode 100644 src/app/+community-page/edit-community-page/community-roles/community-roles.component.html create mode 100644 src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts delete mode 100644 src/app/+community-page/edit-community-page/edit-community-page.component.html delete mode 100644 src/app/+community-page/edit-community-page/edit-community-page.component.scss create mode 100644 src/app/+community-page/edit-community-page/edit-community-page.module.ts create mode 100644 src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts create mode 100644 src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts create mode 100644 src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html diff --git a/resources/i18n/en.json b/resources/i18n/en.json index a066ffe9d0..76e925f1a2 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -30,7 +30,26 @@ }, "edit": { "head": "Edit Collection", - "delete": "Delete this collection" + "delete": "Delete this collection", + "tabs": { + "metadata": { + "title": "Collection Edit - Metadata", + "head": "Edit Metadata" + }, + "roles": { + "title": "Collection Edit - Roles", + "head": "Assign Roles" + }, + "source": { + "title": "Collection Edit - Content Source", + "head": "Content Source" + }, + "curate": { + "title": "Collection Edit - Curate", + "head": "Curate" + } + }, + "return": "Return" }, "create": { "head": "Create a Collection", @@ -72,7 +91,22 @@ }, "edit": { "head": "Edit Community", - "delete": "Delete this community" + "delete": "Delete this community", + "tabs": { + "metadata": { + "title": "Community Edit - Metadata", + "head": "Edit Metadata" + }, + "roles": { + "title": "Community Edit - Roles", + "head": "Assign Roles" + }, + "curate": { + "title": "Community Edit - Curate", + "head": "Curate" + } + }, + "return": "Return" }, "create": { "head": "Create a Community", diff --git a/src/app/+collection-page/collection-page-routing.module.ts b/src/app/+collection-page/collection-page-routing.module.ts index cdbd7650b2..ad142e8fcf 100644 --- a/src/app/+collection-page/collection-page-routing.module.ts +++ b/src/app/+collection-page/collection-page-routing.module.ts @@ -5,7 +5,6 @@ import { CollectionPageComponent } from './collection-page.component'; import { CollectionPageResolver } from './collection-page.resolver'; import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component'; import { AuthenticatedGuard } from '../core/auth/authenticated.guard'; -import { EditCollectionPageComponent } from './edit-collection-page/edit-collection-page.component'; import { CreateCollectionPageGuard } from './create-collection-page/create-collection-page.guard'; import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component'; import { URLCombiner } from '../core/url-combiner/url-combiner'; @@ -38,12 +37,8 @@ const COLLECTION_EDIT_PATH = ':id/edit'; }, { path: COLLECTION_EDIT_PATH, - pathMatch: 'full', - component: EditCollectionPageComponent, - canActivate: [AuthenticatedGuard], - resolve: { - dso: CollectionPageResolver - } + loadChildren: './edit-collection-page/edit-collection-page.module#EditCollectionPageModule', + canActivate: [AuthenticatedGuard] }, { path: ':id/delete', diff --git a/src/app/+collection-page/collection-page.module.ts b/src/app/+collection-page/collection-page.module.ts index bdeffa34f3..f7059deda0 100644 --- a/src/app/+collection-page/collection-page.module.ts +++ b/src/app/+collection-page/collection-page.module.ts @@ -7,7 +7,6 @@ import { CollectionPageComponent } from './collection-page.component'; import { CollectionPageRoutingModule } from './collection-page-routing.module'; import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component'; import { CollectionFormComponent } from './collection-form/collection-form.component'; -import { EditCollectionPageComponent } from './edit-collection-page/edit-collection-page.component'; import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component'; import { SearchService } from '../+search-page/search-service/search.service'; @@ -20,10 +19,12 @@ import { SearchService } from '../+search-page/search-service/search.service'; declarations: [ CollectionPageComponent, CreateCollectionPageComponent, - EditCollectionPageComponent, DeleteCollectionPageComponent, CollectionFormComponent ], + exports: [ + CollectionFormComponent + ], providers: [ SearchService ] diff --git a/src/app/shared/mocks/mock-store.ts b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.html similarity index 100% rename from src/app/shared/mocks/mock-store.ts rename to src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.html diff --git a/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts new file mode 100644 index 0000000000..1445c343fe --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-collection-curate', + templateUrl: './collection-curate.component.html', +}) +export class CollectionCurateComponent { + /* TODO: Implement Collection Edit - Curate */ +} diff --git a/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html new file mode 100644 index 0000000000..cc7a0d5de0 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html @@ -0,0 +1,4 @@ + +{{'collection.edit.delete' + | translate}} diff --git a/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts new file mode 100644 index 0000000000..350ccc0b46 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts @@ -0,0 +1,21 @@ +import { Component } from '@angular/core'; +import { ComcolMetadataComponent } from '../../../shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component'; +import { Collection } from '../../../core/shared/collection.model'; +import { CollectionDataService } from '../../../core/data/collection-data.service'; +import { ActivatedRoute, Router } from '@angular/router'; + +@Component({ + selector: 'ds-collection-metadata', + templateUrl: './collection-metadata.component.html', +}) +export class CollectionMetadataComponent extends ComcolMetadataComponent { + protected frontendURL = '/collections/'; + + public constructor( + protected collectionDataService: CollectionDataService, + protected router: Router, + protected route: ActivatedRoute + ) { + super(collectionDataService, router, route); + } +} diff --git a/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.html b/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts b/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts new file mode 100644 index 0000000000..ffa3f7709c --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-collection-roles', + templateUrl: './collection-roles.component.html', +}) +export class CollectionRolesComponent { + /* TODO: Implement Collection Edit - Roles */ +} diff --git a/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.html b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts new file mode 100644 index 0000000000..a6fc92eec3 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-collection-source', + templateUrl: './collection-source.component.html', +}) +export class CollectionSourceComponent { + /* TODO: Implement Collection Edit - Content Source */ +} diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.html b/src/app/+collection-page/edit-collection-page/edit-collection-page.component.html deleted file mode 100644 index c389c681ce..0000000000 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
- - - {{'collection.edit.delete' - | translate}} -
-
-
diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.scss b/src/app/+collection-page/edit-collection-page/edit-collection-page.component.scss deleted file mode 100644 index 8b13789179..0000000000 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.scss +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.component.ts index ba70bd26c6..21671fe112 100644 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.ts +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.component.ts @@ -2,24 +2,30 @@ import { Component } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { EditComColPageComponent } from '../../shared/comcol-forms/edit-comcol-page/edit-comcol-page.component'; import { Collection } from '../../core/shared/collection.model'; -import { CollectionDataService } from '../../core/data/collection-data.service'; +import { getCollectionPageRoute } from '../collection-page-routing.module'; /** * Component that represents the page where a user can edit an existing Collection */ @Component({ selector: 'ds-edit-collection', - styleUrls: ['./edit-collection-page.component.scss'], - templateUrl: './edit-collection-page.component.html' + templateUrl: '../../shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html' }) export class EditCollectionPageComponent extends EditComColPageComponent { - protected frontendURL = '/collections/'; + protected type = 'collection'; public constructor( - protected collectionDataService: CollectionDataService, protected router: Router, protected route: ActivatedRoute ) { - super(collectionDataService, router, route); + super(router, route); + } + + /** + * Get the collection page url + * @param collection The collection for which the url is requested + */ + getPageUrl(collection: Collection): string { + return getCollectionPageRoute(collection.id) } } diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts new file mode 100644 index 0000000000..f442aae4d6 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.module.ts @@ -0,0 +1,32 @@ +import { NgModule } from '@angular/core'; +import { EditCollectionPageComponent } from './edit-collection-page.component'; +import { CommonModule } from '@angular/common'; +import { SharedModule } from '../../shared/shared.module'; +import { EditCollectionPageRoutingModule } from './edit-collection-page.routing.module'; +import { CollectionMetadataComponent } from './collection-metadata/collection-metadata.component'; +import { CollectionPageModule } from '../collection-page.module'; +import { CollectionRolesComponent } from './collection-roles/collection-roles.component'; +import { CollectionCurateComponent } from './collection-curate/collection-curate.component'; +import { CollectionSourceComponent } from './collection-source/collection-source.component'; + +/** + * Module that contains all components related to the Edit Collection page administrator functionality + */ +@NgModule({ + imports: [ + CommonModule, + SharedModule, + EditCollectionPageRoutingModule, + CollectionPageModule + ], + declarations: [ + EditCollectionPageComponent, + CollectionMetadataComponent, + CollectionRolesComponent, + CollectionCurateComponent, + CollectionSourceComponent + ] +}) +export class EditCollectionPageModule { + +} diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts new file mode 100644 index 0000000000..a3eab30d73 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts @@ -0,0 +1,58 @@ +import { RouterModule } from '@angular/router'; +import { NgModule } from '@angular/core'; +import { EditCollectionPageComponent } from './edit-collection-page.component'; +import { CollectionPageResolver } from '../collection-page.resolver'; +import { CollectionMetadataComponent } from './collection-metadata/collection-metadata.component'; +import { CollectionRolesComponent } from './collection-roles/collection-roles.component'; +import { CollectionSourceComponent } from './collection-source/collection-source.component'; +import { CollectionCurateComponent } from './collection-curate/collection-curate.component'; + +/** + * Routing module that handles the routing for the Edit Collection page administrator functionality + */ +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: '', + component: EditCollectionPageComponent, + resolve: { + dso: CollectionPageResolver + }, + children: [ + { + path: '', + redirectTo: 'metadata', + pathMatch: 'full' + }, + { + path: 'metadata', + component: CollectionMetadataComponent, + data: { title: 'collection.edit.tabs.metadata.title' } + }, + { + path: 'roles', + component: CollectionRolesComponent, + data: { title: 'collection.edit.tabs.roles.title' } + }, + { + path: 'source', + component: CollectionSourceComponent, + data: { title: 'collection.edit.tabs.source.title' } + }, + { + path: 'curate', + component: CollectionCurateComponent, + data: { title: 'collection.edit.tabs.curate.title' } + } + ] + } + ]) + ], + providers: [ + CollectionPageResolver, + ] +}) +export class EditCollectionPageRoutingModule { + +} diff --git a/src/app/+community-page/community-page-routing.module.ts b/src/app/+community-page/community-page-routing.module.ts index cecd17ec10..df548e0617 100644 --- a/src/app/+community-page/community-page-routing.module.ts +++ b/src/app/+community-page/community-page-routing.module.ts @@ -5,7 +5,6 @@ import { CommunityPageComponent } from './community-page.component'; import { CommunityPageResolver } from './community-page.resolver'; import { CreateCommunityPageComponent } from './create-community-page/create-community-page.component'; import { AuthenticatedGuard } from '../core/auth/authenticated.guard'; -import { EditCommunityPageComponent } from './edit-community-page/edit-community-page.component'; import { CreateCommunityPageGuard } from './create-community-page/create-community-page.guard'; import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component'; import { URLCombiner } from '../core/url-combiner/url-combiner'; @@ -38,12 +37,8 @@ const COMMUNITY_EDIT_PATH = ':id/edit'; }, { path: COMMUNITY_EDIT_PATH, - pathMatch: 'full', - component: EditCommunityPageComponent, - canActivate: [AuthenticatedGuard], - resolve: { - dso: CommunityPageResolver - } + loadChildren: './edit-community-page/edit-community-page.module#EditCommunityPageModule', + canActivate: [AuthenticatedGuard] }, { path: ':id/delete', diff --git a/src/app/+community-page/community-page.module.ts b/src/app/+community-page/community-page.module.ts index 6d63cadcc8..534c96989e 100644 --- a/src/app/+community-page/community-page.module.ts +++ b/src/app/+community-page/community-page.module.ts @@ -9,7 +9,6 @@ import { CommunityPageRoutingModule } from './community-page-routing.module'; import {CommunityPageSubCommunityListComponent} from './sub-community-list/community-page-sub-community-list.component'; import { CreateCommunityPageComponent } from './create-community-page/create-community-page.component'; import { CommunityFormComponent } from './community-form/community-form.component'; -import { EditCommunityPageComponent } from './edit-community-page/edit-community-page.component'; import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component'; @NgModule({ @@ -23,9 +22,11 @@ import { DeleteCommunityPageComponent } from './delete-community-page/delete-com CommunityPageSubCollectionListComponent, CommunityPageSubCommunityListComponent, CreateCommunityPageComponent, - EditCommunityPageComponent, DeleteCommunityPageComponent, CommunityFormComponent + ], + exports: [ + CommunityFormComponent ] }) diff --git a/src/app/+community-page/edit-community-page/community-curate/community-curate.component.html b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts new file mode 100644 index 0000000000..cf2d75ba6a --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-community-curate', + templateUrl: './community-curate.component.html', +}) +export class CommunityCurateComponent { + /* TODO: Implement Community Edit - Curate */ +} diff --git a/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.html b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.html new file mode 100644 index 0000000000..9a59be9067 --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.html @@ -0,0 +1,4 @@ + +{{'community.edit.delete' + | translate}} diff --git a/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts new file mode 100644 index 0000000000..feecdf47c8 --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts @@ -0,0 +1,21 @@ +import { Component } from '@angular/core'; +import { ComcolMetadataComponent } from '../../../shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Community } from '../../../core/shared/community.model'; +import { CommunityDataService } from '../../../core/data/community-data.service'; + +@Component({ + selector: 'ds-community-metadata', + templateUrl: './community-metadata.component.html', +}) +export class CommunityMetadataComponent extends ComcolMetadataComponent { + protected frontendURL = '/communities/'; + + public constructor( + protected communityDataService: CommunityDataService, + protected router: Router, + protected route: ActivatedRoute + ) { + super(communityDataService, router, route); + } +} diff --git a/src/app/+community-page/edit-community-page/community-roles/community-roles.component.html b/src/app/+community-page/edit-community-page/community-roles/community-roles.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts b/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts new file mode 100644 index 0000000000..b6f84c8ba6 --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-community-roles', + templateUrl: './community-roles.component.html', +}) +export class CommunityRolesComponent { + /* TODO: Implement Community Edit - Roles */ +} diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.html b/src/app/+community-page/edit-community-page/edit-community-page.component.html deleted file mode 100644 index cedb771c14..0000000000 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
-
- - - {{'community.edit.delete' - | translate}} -
-
-
diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.scss b/src/app/+community-page/edit-community-page/edit-community-page.component.scss deleted file mode 100644 index 8b13789179..0000000000 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.scss +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.ts b/src/app/+community-page/edit-community-page/edit-community-page.component.ts index 9f49ac49dd..a8d4d32b7d 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.ts +++ b/src/app/+community-page/edit-community-page/edit-community-page.component.ts @@ -1,25 +1,31 @@ import { Component } from '@angular/core'; import { Community } from '../../core/shared/community.model'; -import { CommunityDataService } from '../../core/data/community-data.service'; import { ActivatedRoute, Router } from '@angular/router'; import { EditComColPageComponent } from '../../shared/comcol-forms/edit-comcol-page/edit-comcol-page.component'; +import { getCommunityPageRoute } from '../community-page-routing.module'; /** * Component that represents the page where a user can edit an existing Community */ @Component({ selector: 'ds-edit-community', - styleUrls: ['./edit-community-page.component.scss'], - templateUrl: './edit-community-page.component.html' + templateUrl: '../../shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html' }) export class EditCommunityPageComponent extends EditComColPageComponent { - protected frontendURL = '/communities/'; + protected type = 'community'; public constructor( - protected communityDataService: CommunityDataService, protected router: Router, protected route: ActivatedRoute ) { - super(communityDataService, router, route); + super(router, route); + } + + /** + * Get the community page url + * @param community The community for which the url is requested + */ + getPageUrl(community: Community): string { + return getCommunityPageRoute(community.id) } } diff --git a/src/app/+community-page/edit-community-page/edit-community-page.module.ts b/src/app/+community-page/edit-community-page/edit-community-page.module.ts new file mode 100644 index 0000000000..f9a1e11a14 --- /dev/null +++ b/src/app/+community-page/edit-community-page/edit-community-page.module.ts @@ -0,0 +1,30 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { SharedModule } from '../../shared/shared.module'; +import { EditCommunityPageRoutingModule } from './edit-community-page.routing.module'; +import { CommunityPageModule } from '../community-page.module'; +import { EditCommunityPageComponent } from './edit-community-page.component'; +import { CommunityCurateComponent } from './community-curate/community-curate.component'; +import { CommunityMetadataComponent } from './community-metadata/community-metadata.component'; +import { CommunityRolesComponent } from './community-roles/community-roles.component'; + +/** + * Module that contains all components related to the Edit Community page administrator functionality + */ +@NgModule({ + imports: [ + CommonModule, + SharedModule, + EditCommunityPageRoutingModule, + CommunityPageModule + ], + declarations: [ + EditCommunityPageComponent, + CommunityCurateComponent, + CommunityMetadataComponent, + CommunityRolesComponent + ] +}) +export class EditCommunityPageModule { + +} diff --git a/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts b/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts new file mode 100644 index 0000000000..527b3c018f --- /dev/null +++ b/src/app/+community-page/edit-community-page/edit-community-page.routing.module.ts @@ -0,0 +1,52 @@ +import { CommunityPageResolver } from '../community-page.resolver'; +import { EditCommunityPageComponent } from './edit-community-page.component'; +import { RouterModule } from '@angular/router'; +import { NgModule } from '@angular/core'; +import { CommunityMetadataComponent } from './community-metadata/community-metadata.component'; +import { CommunityRolesComponent } from './community-roles/community-roles.component'; +import { CommunityCurateComponent } from './community-curate/community-curate.component'; + +/** + * Routing module that handles the routing for the Edit Community page administrator functionality + */ +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: '', + component: EditCommunityPageComponent, + resolve: { + dso: CommunityPageResolver + }, + children: [ + { + path: '', + redirectTo: 'metadata', + pathMatch: 'full' + }, + { + path: 'metadata', + component: CommunityMetadataComponent, + data: { title: 'community.edit.tabs.metadata.title' } + }, + { + path: 'roles', + component: CommunityRolesComponent, + data: { title: 'community.edit.tabs.roles.title' } + }, + { + path: 'curate', + component: CommunityCurateComponent, + data: { title: 'community.edit.tabs.curate.title' } + } + ] + } + ]) + ], + providers: [ + CommunityPageResolver, + ] +}) +export class EditCommunityPageRoutingModule { + +} diff --git a/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts b/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts new file mode 100644 index 0000000000..3806da5a84 --- /dev/null +++ b/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts @@ -0,0 +1,48 @@ +import { Component, OnInit } from '@angular/core'; +import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; +import { Observable } from 'rxjs/internal/Observable'; +import { RemoteData } from '../../../../core/data/remote-data'; +import { ActivatedRoute, Router } from '@angular/router'; +import { first, map } from 'rxjs/operators'; +import { getSucceededRemoteData } from '../../../../core/shared/operators'; +import { isNotUndefined } from '../../../empty.util'; +import { DataService } from '../../../../core/data/data.service'; + +@Component({ + selector: 'ds-comcol-metadata', + template: '' +}) +export class ComcolMetadataComponent implements OnInit { + /** + * Frontend endpoint for this type of DSO + */ + protected frontendURL: string; + + public dsoRD$: Observable>; + + public constructor( + protected dsoDataService: DataService, + protected router: Router, + protected route: ActivatedRoute + ) { + } + + ngOnInit(): void { + this.dsoRD$ = this.route.parent.data.pipe(first(), map((data) => data.dso)); + } + + /** + * @param {TDomain} dso The updated version of the DSO + * Updates an existing DSO based on the submitted user data and navigates to the edited object's home page + */ + onSubmit(dso: TDomain) { + this.dsoDataService.update(dso) + .pipe(getSucceededRemoteData()) + .subscribe((dsoRD: RemoteData) => { + if (isNotUndefined(dsoRD)) { + const newUUID = dsoRD.payload.uuid; + this.router.navigate([this.frontendURL + newUUID]); + } + }); + } +} diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html new file mode 100644 index 0000000000..964fea35e3 --- /dev/null +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html @@ -0,0 +1,24 @@ +
+
+
+

{{ type + '.edit.head' | translate }}

+ +
+
+
diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts index 24181b5e61..7e3b9957e2 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../../core/data/remote-data'; -import { isNotUndefined } from '../../empty.util'; +import { isNotEmpty, isNotUndefined } from '../../empty.util'; import { first, map } from 'rxjs/operators'; import { getSucceededRemoteData } from '../../../core/shared/operators'; import { DataService } from '../../../core/data/data.service'; @@ -13,41 +13,48 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; */ @Component({ selector: 'ds-edit-comcol', - template: '' + templateUrl: './edit-comcol-page.component.html' }) export class EditComColPageComponent implements OnInit { /** - * Frontend endpoint for this type of DSO + * The type of DSpaceObject (used to create i18n messages) */ - protected frontendURL: string; + protected type: string; + /** - * The initial DSO object + * The current page outlet string */ + public currentPage: string; + + /** + * All possible page outlet strings + */ + public pages: string[]; + public dsoRD$: Observable>; public constructor( - protected dsoDataService: DataService, protected router: Router, protected route: ActivatedRoute ) { + this.router.events.subscribe(() => { + this.currentPage = this.route.snapshot.firstChild.routeConfig.path; + }); } ngOnInit(): void { + this.pages = this.route.routeConfig.children + .map((child: any) => child.path) + .filter((path: string) => isNotEmpty(path)); // ignore reroutes this.dsoRD$ = this.route.data.pipe(first(), map((data) => data.dso)); } /** - * @param {TDomain} dso The updated version of the DSO - * Updates an existing DSO based on the submitted user data and navigates to the edited object's home page + * Get the dso's page url + * This method is expected to be overridden in the edit community/collection page components + * @param dso The DSpaceObject for which the url is requested */ - onSubmit(dso: TDomain) { - this.dsoDataService.update(dso) - .pipe(getSucceededRemoteData()) - .subscribe((dsoRD: RemoteData) => { - if (isNotUndefined(dsoRD)) { - const newUUID = dsoRD.payload.uuid; - this.router.navigate([this.frontendURL + newUUID]); - } - }); + getPageUrl(dso: TDomain): string { + return this.router.url; } } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 4654789b90..c134b89718 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -139,6 +139,7 @@ import { UserMenuComponent } from './auth-nav-menu/user-menu/user-menu.component import { ClaimedTaskActionsReturnToPoolComponent } from './mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component'; import { ItemDetailPreviewFieldComponent } from './object-detail/my-dspace-result-detail-element/item-detail-preview/item-detail-preview-field/item-detail-preview-field.component'; import { AbstractTrackableComponent } from './trackable/abstract-trackable.component'; +import { ComcolMetadataComponent } from './comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -259,7 +260,8 @@ const COMPONENTS = [ TypedItemSearchResultListElementComponent, ItemTypeSwitcherComponent, BrowseByComponent, - AbstractTrackableComponent + AbstractTrackableComponent, + ComcolMetadataComponent ]; const ENTRY_COMPONENTS = [ From 09c6a167fb4edeca85fded87a694fd272645f989 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 10 Jul 2019 17:43:01 +0200 Subject: [PATCH 03/10] 63669: Edit Col/Com Tabs Tests + JSDocs --- .../collection-metadata.component.spec.ts | 39 +++++++ .../edit-collection-page.component.spec.ts | 24 +++- .../community-metadata.component.spec.ts | 39 +++++++ .../edit-community-page.component.spec.ts | 24 +++- .../comcol-metadata.component.spec.ts | 108 ++++++++++++++++++ .../edit-comcol-page.component.spec.ts | 65 ++++------- .../edit-comcol-page.component.ts | 5 +- 7 files changed, 251 insertions(+), 53 deletions(-) create mode 100644 src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.spec.ts create mode 100644 src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.spec.ts create mode 100644 src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts diff --git a/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.spec.ts b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.spec.ts new file mode 100644 index 0000000000..67eab669d5 --- /dev/null +++ b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.spec.ts @@ -0,0 +1,39 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { TranslateModule } from '@ngx-translate/core'; +import { SharedModule } from '../../../shared/shared.module'; +import { CommonModule } from '@angular/common'; +import { RouterTestingModule } from '@angular/router/testing'; +import { CollectionDataService } from '../../../core/data/collection-data.service'; +import { ActivatedRoute } from '@angular/router'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { CollectionMetadataComponent } from './collection-metadata.component'; + +describe('CollectionMetadataComponent', () => { + let comp: CollectionMetadataComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], + declarations: [CollectionMetadataComponent], + providers: [ + { provide: CollectionDataService, useValue: {} }, + { provide: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: { payload: {} } }) } } }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CollectionMetadataComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + }); + + describe('frontendURL', () => { + it('should have the right frontendURL set', () => { + expect((comp as any).frontendURL).toEqual('/collections/'); + }) + }); +}); diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.spec.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.component.spec.ts index 193cb293e4..9f915d2d7a 100644 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.component.spec.ts +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.component.spec.ts @@ -13,13 +13,29 @@ describe('EditCollectionPageComponent', () => { let comp: EditCollectionPageComponent; let fixture: ComponentFixture; + const routeStub = { + data: observableOf({ + dso: { payload: {} } + }), + routeConfig: { + children: [] + }, + snapshot: { + firstChild: { + routeConfig: { + path: 'mockUrl' + } + } + } + }; + beforeEach(async(() => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], declarations: [EditCollectionPageComponent], providers: [ { provide: CollectionDataService, useValue: {} }, - { provide: ActivatedRoute, useValue: { data: observableOf({ dso: { payload: {} } }) } }, + { provide: ActivatedRoute, useValue: routeStub }, ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); @@ -31,9 +47,9 @@ describe('EditCollectionPageComponent', () => { fixture.detectChanges(); }); - describe('frontendURL', () => { - it('should have the right frontendURL set', () => { - expect((comp as any).frontendURL).toEqual('/collections/'); + describe('type', () => { + it('should have the right type set', () => { + expect((comp as any).type).toEqual('collection'); }) }); }); diff --git a/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.spec.ts b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.spec.ts new file mode 100644 index 0000000000..52ee73bfab --- /dev/null +++ b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.spec.ts @@ -0,0 +1,39 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { TranslateModule } from '@ngx-translate/core'; +import { SharedModule } from '../../../shared/shared.module'; +import { CommonModule } from '@angular/common'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { CommunityMetadataComponent } from './community-metadata.component'; +import { CommunityDataService } from '../../../core/data/community-data.service'; + +describe('CommunityMetadataComponent', () => { + let comp: CommunityMetadataComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], + declarations: [CommunityMetadataComponent], + providers: [ + { provide: CommunityDataService, useValue: {} }, + { provide: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: { payload: {} } }) } } }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CommunityMetadataComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + }); + + describe('frontendURL', () => { + it('should have the right frontendURL set', () => { + expect((comp as any).frontendURL).toEqual('/communities/'); + }) + }); +}); diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts b/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts index 54f2133ce7..b61924dd00 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts +++ b/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts @@ -13,13 +13,29 @@ describe('EditCommunityPageComponent', () => { let comp: EditCommunityPageComponent; let fixture: ComponentFixture; + const routeStub = { + data: observableOf({ + dso: { payload: {} } + }), + routeConfig: { + children: [] + }, + snapshot: { + firstChild: { + routeConfig: { + path: 'mockUrl' + } + } + } + }; + beforeEach(async(() => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], declarations: [EditCommunityPageComponent], providers: [ { provide: CommunityDataService, useValue: {} }, - { provide: ActivatedRoute, useValue: { data: observableOf({ dso: { payload: {} } }) } }, + { provide: ActivatedRoute, useValue: routeStub }, ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); @@ -31,9 +47,9 @@ describe('EditCommunityPageComponent', () => { fixture.detectChanges(); }); - describe('frontendURL', () => { - it('should have the right frontendURL set', () => { - expect((comp as any).frontendURL).toEqual('/communities/'); + describe('type', () => { + it('should have the right type set', () => { + expect((comp as any).type).toEqual('community'); }) }); }); diff --git a/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts b/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts new file mode 100644 index 0000000000..26002d555d --- /dev/null +++ b/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts @@ -0,0 +1,108 @@ +import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { CommunityDataService } from '../../../../core/data/community-data.service'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Community } from '../../../../core/shared/community.model'; +import { of as observableOf } from 'rxjs/internal/observable/of'; +import { RemoteData } from '../../../../core/data/remote-data'; +import { TranslateModule } from '@ngx-translate/core'; +import { SharedModule } from '../../../shared.module'; +import { CommonModule } from '@angular/common'; +import { RouterTestingModule } from '@angular/router/testing'; +import { DataService } from '../../../../core/data/data.service'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { ComcolMetadataComponent } from './comcol-metadata.component'; + +describe('ComColMetadataComponent', () => { + let comp: ComcolMetadataComponent; + let fixture: ComponentFixture>; + let dsoDataService: CommunityDataService; + let router: Router; + + let community; + let newCommunity; + let communityDataServiceStub; + let routerStub; + let routeStub; + + function initializeVars() { + community = Object.assign(new Community(), { + uuid: 'a20da287-e174-466a-9926-f66b9300d347', + metadata: [{ + key: 'dc.title', + value: 'test community' + }] + }); + + newCommunity = Object.assign(new Community(), { + uuid: '1ff59938-a69a-4e62-b9a4-718569c55d48', + metadata: [{ + key: 'dc.title', + value: 'new community' + }] + }); + + communityDataServiceStub = { + update: (com, uuid?) => observableOf(new RemoteData(false, false, true, undefined, newCommunity)) + + }; + + routerStub = { + navigate: (commands) => commands + }; + + routeStub = { + parent: { + data: observableOf(community) + } + }; + + } + + beforeEach(async(() => { + initializeVars(); + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], + providers: [ + { provide: DataService, useValue: communityDataServiceStub }, + { provide: Router, useValue: routerStub }, + { provide: ActivatedRoute, useValue: routeStub }, + ], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ComcolMetadataComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + dsoDataService = (comp as any).dsoDataService; + router = (comp as any).router; + }); + + describe('onSubmit', () => { + let data; + beforeEach(() => { + data = Object.assign(new Community(), { + metadata: [{ + key: 'dc.title', + value: 'test' + }] + }); + }); + it('should navigate when successful', () => { + spyOn(router, 'navigate'); + comp.onSubmit(data); + fixture.detectChanges(); + expect(router.navigate).toHaveBeenCalled(); + }); + + it('should not navigate on failure', () => { + spyOn(router, 'navigate'); + spyOn(dsoDataService, 'update').and.returnValue(observableOf(new RemoteData(true, true, false, undefined, newCommunity))); + comp.onSubmit(data); + fixture.detectChanges(); + expect(router.navigate).not.toHaveBeenCalled(); + }); + }); +}); diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts index 75b7fe40e7..8d1023e66d 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts @@ -1,9 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { CommunityDataService } from '../../../core/data/community-data.service'; import { ActivatedRoute, Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; import { of as observableOf } from 'rxjs'; -import { RemoteData } from '../../../core/data/remote-data'; import { Community } from '../../../core/shared/community.model'; import { SharedModule } from '../../shared.module'; import { CommonModule } from '@angular/common'; @@ -11,17 +9,13 @@ import { RouterTestingModule } from '@angular/router/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { EditComColPageComponent } from './edit-comcol-page.component'; -import { DataService } from '../../../core/data/data.service'; describe('EditComColPageComponent', () => { let comp: EditComColPageComponent; let fixture: ComponentFixture>; - let dsoDataService: CommunityDataService; let router: Router; let community; - let newCommunity; - let communityDataServiceStub; let routerStub; let routeStub; @@ -34,25 +28,26 @@ describe('EditComColPageComponent', () => { }] }); - newCommunity = Object.assign(new Community(), { - uuid: '1ff59938-a69a-4e62-b9a4-718569c55d48', - metadata: [{ - key: 'dc.title', - value: 'new community' - }] - }); - - communityDataServiceStub = { - update: (com, uuid?) => observableOf(new RemoteData(false, false, true, undefined, newCommunity)) - - }; - routerStub = { - navigate: (commands) => commands + navigate: (commands) => commands, + events: observableOf({}), + url: 'mockUrl' }; routeStub = { - data: observableOf(community) + data: observableOf({ + dso: community + }), + routeConfig: { + children: [] + }, + snapshot: { + firstChild: { + routeConfig: { + path: 'mockUrl' + } + } + } }; } @@ -62,7 +57,6 @@ describe('EditComColPageComponent', () => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], providers: [ - { provide: DataService, useValue: communityDataServiceStub }, { provide: Router, useValue: routerStub }, { provide: ActivatedRoute, useValue: routeStub }, ], @@ -74,33 +68,16 @@ describe('EditComColPageComponent', () => { fixture = TestBed.createComponent(EditComColPageComponent); comp = fixture.componentInstance; fixture.detectChanges(); - dsoDataService = (comp as any).dsoDataService; router = (comp as any).router; }); - describe('onSubmit', () => { - let data; + describe('getPageUrl', () => { + let url; beforeEach(() => { - data = Object.assign(new Community(), { - metadata: [{ - key: 'dc.title', - value: 'test' - }] - }); + url = comp.getPageUrl(community); }); - it('should navigate when successful', () => { - spyOn(router, 'navigate'); - comp.onSubmit(data); - fixture.detectChanges(); - expect(router.navigate).toHaveBeenCalled(); - }); - - it('should not navigate on failure', () => { - spyOn(router, 'navigate'); - spyOn(dsoDataService, 'update').and.returnValue(observableOf(new RemoteData(true, true, false, undefined, newCommunity))); - comp.onSubmit(data); - fixture.detectChanges(); - expect(router.navigate).not.toHaveBeenCalled(); + it('should return the current url as a fallback', () => { + expect(url).toEqual(routerStub.url); }); }); }); diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts index 7e3b9957e2..9face94abd 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts @@ -13,7 +13,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; */ @Component({ selector: 'ds-edit-comcol', - templateUrl: './edit-comcol-page.component.html' + template: '' }) export class EditComColPageComponent implements OnInit { /** @@ -31,6 +31,9 @@ export class EditComColPageComponent implements On */ public pages: string[]; + /** + * The DSO to render the edit page for + */ public dsoRD$: Observable>; public constructor( From 12f57e397533cfdb7e713f04bc8376eaaffd1a4f Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 11 Jul 2019 12:05:28 +0200 Subject: [PATCH 04/10] 63669: Missing JSDocs --- .../collection-curate/collection-curate.component.ts | 3 +++ .../collection-metadata/collection-metadata.component.ts | 3 +++ .../collection-roles/collection-roles.component.ts | 3 +++ .../collection-source/collection-source.component.ts | 3 +++ .../community-curate/community-curate.component.ts | 3 +++ .../community-metadata/community-metadata.component.ts | 3 +++ .../community-roles/community-roles.component.ts | 3 +++ 7 files changed, 21 insertions(+) diff --git a/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts index 1445c343fe..d7deaea982 100644 --- a/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts +++ b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.ts @@ -1,5 +1,8 @@ import { Component } from '@angular/core'; +/** + * Component for managing a collection's curation tasks + */ @Component({ selector: 'ds-collection-curate', templateUrl: './collection-curate.component.html', diff --git a/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts index 350ccc0b46..3a9d9c8af5 100644 --- a/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts +++ b/src/app/+collection-page/edit-collection-page/collection-metadata/collection-metadata.component.ts @@ -4,6 +4,9 @@ import { Collection } from '../../../core/shared/collection.model'; import { CollectionDataService } from '../../../core/data/collection-data.service'; import { ActivatedRoute, Router } from '@angular/router'; +/** + * Component for editing a collection's metadata + */ @Component({ selector: 'ds-collection-metadata', templateUrl: './collection-metadata.component.html', diff --git a/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts b/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts index ffa3f7709c..39f72fd2ce 100644 --- a/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts +++ b/src/app/+collection-page/edit-collection-page/collection-roles/collection-roles.component.ts @@ -1,5 +1,8 @@ import { Component } from '@angular/core'; +/** + * Component for managing a collection's roles + */ @Component({ selector: 'ds-collection-roles', templateUrl: './collection-roles.component.html', diff --git a/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts index a6fc92eec3..6ec5be884d 100644 --- a/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts +++ b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.ts @@ -1,5 +1,8 @@ import { Component } from '@angular/core'; +/** + * Component for managing the content source of the collection + */ @Component({ selector: 'ds-collection-source', templateUrl: './collection-source.component.html', diff --git a/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts index cf2d75ba6a..6151d3fe9a 100644 --- a/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts +++ b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.ts @@ -1,5 +1,8 @@ import { Component } from '@angular/core'; +/** + * Component for managing a community's curation tasks + */ @Component({ selector: 'ds-community-curate', templateUrl: './community-curate.component.html', diff --git a/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts index feecdf47c8..c57c74175d 100644 --- a/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts +++ b/src/app/+community-page/edit-community-page/community-metadata/community-metadata.component.ts @@ -4,6 +4,9 @@ import { ActivatedRoute, Router } from '@angular/router'; import { Community } from '../../../core/shared/community.model'; import { CommunityDataService } from '../../../core/data/community-data.service'; +/** + * Component for editing a community's metadata + */ @Component({ selector: 'ds-community-metadata', templateUrl: './community-metadata.component.html', diff --git a/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts b/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts index b6f84c8ba6..afa1fe14d1 100644 --- a/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts +++ b/src/app/+community-page/edit-community-page/community-roles/community-roles.component.ts @@ -1,5 +1,8 @@ import { Component } from '@angular/core'; +/** + * Component for managing a community's roles + */ @Component({ selector: 'ds-community-roles', templateUrl: './community-roles.component.html', From 1008bd16e2e338daf40cdbb3fc5824a2299eeac7 Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Wed, 21 Aug 2019 17:35:16 +0200 Subject: [PATCH 05/10] 64424: Angular impact of changes to relationship type changes --- .../simple/item-types/shared/item-relationships-utils.ts | 8 ++++---- .../models/items/normalized-relationship-type.model.ts | 4 ++-- .../shared/item-relationships/relationship-type.model.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts b/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts index 65ad743245..091bd4f406 100644 --- a/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts +++ b/src/app/+item-page/simple/item-types/shared/item-relationships-utils.ts @@ -58,10 +58,10 @@ export const filterRelationsByTypeLabel = (label: string, thisId?: string) => return relatedItems$.pipe( map((arr) => relsCurrentPage.filter((rel: Relationship, idx: number) => hasValue(relTypesCurrentPage[idx]) && ( - (hasNoValue(thisId) && (relTypesCurrentPage[idx].leftLabel === label || - relTypesCurrentPage[idx].rightLabel === label)) || - (thisId === arr[idx][0].id && relTypesCurrentPage[idx].leftLabel === label) || - (thisId === arr[idx][1].id && relTypesCurrentPage[idx].rightLabel === label) + (hasNoValue(thisId) && (relTypesCurrentPage[idx].leftwardType === label || + relTypesCurrentPage[idx].rightwardType === label)) || + (thisId === arr[idx][0].id && relTypesCurrentPage[idx].leftwardType === label) || + (thisId === arr[idx][1].id && relTypesCurrentPage[idx].rightwardType === label) ) )) ); diff --git a/src/app/core/cache/models/items/normalized-relationship-type.model.ts b/src/app/core/cache/models/items/normalized-relationship-type.model.ts index 800b27cd7e..23c3333a9b 100644 --- a/src/app/core/cache/models/items/normalized-relationship-type.model.ts +++ b/src/app/core/cache/models/items/normalized-relationship-type.model.ts @@ -23,7 +23,7 @@ export class NormalizedRelationshipType extends NormalizedObject Date: Thu, 3 Oct 2019 13:55:57 +0200 Subject: [PATCH 06/10] leftLabel/rightLabel renaming to leftwardType/rightwardType --- src/app/core/data/relationship.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/core/data/relationship.service.ts b/src/app/core/data/relationship.service.ts index 1699b6a27d..b07e4b714c 100644 --- a/src/app/core/data/relationship.service.ts +++ b/src/app/core/data/relationship.service.ts @@ -182,9 +182,9 @@ export class RelationshipService { map(([leftItems, rightItems, relTypesCurrentPage]) => { return relTypesCurrentPage.map((type, index) => { if (leftItems[index].uuid === item.uuid) { - return type.leftLabel; + return type.leftwardType; } else { - return type.rightLabel; + return type.rightwardType; } }); }), From e10a5bb8f81e5a780de51650d152dd8f8b8bae30 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 3 Oct 2019 14:39:46 +0200 Subject: [PATCH 07/10] 63669: Hide return button for metadata edit on com/col --- .../edit-collection-page.routing.module.ts | 5 ++++- .../edit-comcol-page/edit-comcol-page.component.html | 2 +- .../edit-comcol-page/edit-comcol-page.component.ts | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts b/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts index a3eab30d73..fcfced9d81 100644 --- a/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts +++ b/src/app/+collection-page/edit-collection-page/edit-collection-page.routing.module.ts @@ -28,7 +28,10 @@ import { CollectionCurateComponent } from './collection-curate/collection-curate { path: 'metadata', component: CollectionMetadataComponent, - data: { title: 'collection.edit.tabs.metadata.title' } + data: { + title: 'collection.edit.tabs.metadata.title', + hideReturnButton: true + } }, { path: 'roles', diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html index 964fea35e3..aa6290ea9f 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.html @@ -16,7 +16,7 @@
- {{ type + '.edit.return' | translate }} + {{ type + '.edit.return' | translate }} diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts index 9face94abd..b1b37f265e 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.ts @@ -36,12 +36,19 @@ export class EditComColPageComponent implements On */ public dsoRD$: Observable>; + /** + * Hide the default return button? + */ + public hideReturnButton: boolean; + public constructor( protected router: Router, protected route: ActivatedRoute ) { this.router.events.subscribe(() => { this.currentPage = this.route.snapshot.firstChild.routeConfig.path; + this.hideReturnButton = this.route.routeConfig.children + .find((child: any) => child.path === this.currentPage).data.hideReturnButton; }); } From a1fea1d6a2ecc7a79e800964da437ead9e6e4902 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 3 Oct 2019 14:53:00 +0200 Subject: [PATCH 08/10] leftLabel/rightLabel renaming to leftwardType/rightwardType in test case --- src/app/core/data/relationship.service.spec.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/core/data/relationship.service.spec.ts b/src/app/core/data/relationship.service.spec.ts index 0ced517d74..75e0a856fa 100644 --- a/src/app/core/data/relationship.service.spec.ts +++ b/src/app/core/data/relationship.service.spec.ts @@ -5,7 +5,6 @@ import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-da import { of as observableOf } from 'rxjs/internal/observable/of'; import { RequestEntry } from './request.reducer'; import { RelationshipType } from '../shared/item-relationships/relationship-type.model'; -import { ResourceType } from '../shared/resource-type'; import { Relationship } from '../shared/item-relationships/relationship.model'; import { RemoteData } from './remote-data'; import { getMockRequestService } from '../../shared/mocks/mock-request.service'; @@ -33,8 +32,8 @@ describe('RelationshipService', () => { const relationshipType = Object.assign(new RelationshipType(), { id: '1', uuid: '1', - leftLabel: 'isAuthorOfPublication', - rightLabel: 'isPublicationOfAuthor' + leftwardType: 'isAuthorOfPublication', + rightwardType: 'isPublicationOfAuthor' }); const relationship1 = Object.assign(new Relationship(), { @@ -129,7 +128,7 @@ describe('RelationshipService', () => { describe('getItemRelationshipLabels', () => { it('should return the correct labels', () => { service.getItemRelationshipLabels(item).subscribe((result) => { - expect(result).toEqual([relationshipType.rightLabel]); + expect(result).toEqual([relationshipType.rightwardType]); }); }); }); From 556475318dac77ec28043846527a9dd14f296b4e Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Thu, 3 Oct 2019 15:22:45 +0200 Subject: [PATCH 09/10] Fixed remaining left/right-labels --- .../edit-relationship-list.component.spec.ts | 6 +++--- .../edit-relationship/edit-relationship.component.spec.ts | 4 ++-- .../item-relationships/item-relationships.component.spec.ts | 4 ++-- src/app/core/data/relationship.service.spec.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts index 3748ebca9d..3293711d73 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts @@ -38,8 +38,8 @@ describe('EditRelationshipListComponent', () => { relationshipType = Object.assign(new RelationshipType(), { id: '1', uuid: '1', - leftLabel: 'isAuthorOfPublication', - rightLabel: 'isPublicationOfAuthor' + leftwardType: 'isAuthorOfPublication', + rightwardType: 'isPublicationOfAuthor' }); relationships = [ @@ -119,7 +119,7 @@ describe('EditRelationshipListComponent', () => { de = fixture.debugElement; comp.item = item; comp.url = url; - comp.relationshipLabel = relationshipType.leftLabel; + comp.relationshipLabel = relationshipType.leftwardType; fixture.detectChanges(); }); diff --git a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts index 3306d8eb01..e98da94c9d 100644 --- a/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-relationships/edit-relationship/edit-relationship.component.spec.ts @@ -34,8 +34,8 @@ describe('EditRelationshipComponent', () => { relationshipType = Object.assign(new RelationshipType(), { id: '1', uuid: '1', - leftLabel: 'isAuthorOfPublication', - rightLabel: 'isPublicationOfAuthor' + leftwardType: 'isAuthorOfPublication', + rightwardType: 'isPublicationOfAuthor' }); relationships = [ 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 b1a4e11371..48bc28a1b9 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 @@ -68,8 +68,8 @@ describe('ItemRelationshipsComponent', () => { relationshipType = Object.assign(new RelationshipType(), { id: '1', uuid: '1', - leftLabel: 'isAuthorOfPublication', - rightLabel: 'isPublicationOfAuthor' + leftwardType: 'isAuthorOfPublication', + rightwardType: 'isPublicationOfAuthor' }); relationships = [ diff --git a/src/app/core/data/relationship.service.spec.ts b/src/app/core/data/relationship.service.spec.ts index 75e0a856fa..31513bb779 100644 --- a/src/app/core/data/relationship.service.spec.ts +++ b/src/app/core/data/relationship.service.spec.ts @@ -143,7 +143,7 @@ describe('RelationshipService', () => { describe('getRelatedItemsByLabel', () => { it('should return the related items by label', () => { - service.getRelatedItemsByLabel(item, relationshipType.rightLabel).subscribe((result) => { + service.getRelatedItemsByLabel(item, relationshipType.rightwardType).subscribe((result) => { expect(result).toEqual(relatedItems); }); }); From ac68893f6e2c7c667b040ae56518734bcc10fe56 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Fri, 4 Oct 2019 15:47:52 +0200 Subject: [PATCH 10/10] 63669: Test fix --- .../edit-comcol-page/edit-comcol-page.component.spec.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts index 8d1023e66d..d1b87db7ae 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts +++ b/src/app/shared/comcol-forms/edit-comcol-page/edit-comcol-page.component.spec.ts @@ -39,7 +39,14 @@ describe('EditComColPageComponent', () => { dso: community }), routeConfig: { - children: [] + children: [ + { + path: 'mockUrl', + data: { + hideReturnButton: false + } + } + ] }, snapshot: { firstChild: {