diff --git a/config/environment.default.js b/config/environment.default.js
index 0e1e0d03bf..24386d6cf7 100644
--- a/config/environment.default.js
+++ b/config/environment.default.js
@@ -9,11 +9,11 @@ module.exports = {
},
// The REST API server settings.
rest: {
- ssl: true,
+ ssl: true,
host: 'dspace7.4science.cloud',
- port: 443,
+ port: 443,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
- nameSpace: '/server/api'
+ nameSpace: '/server/api'
},
// Caching settings
cache: {
diff --git a/src/app/+search-page/search.component.html b/src/app/+search-page/search.component.html
index a6e83d2b64..f3731607db 100644
--- a/src/app/+search-page/search.component.html
+++ b/src/app/+search-page/search.component.html
@@ -48,7 +48,7 @@
diff --git a/src/app/core/shared/operators.ts b/src/app/core/shared/operators.ts
index 0d1aa74591..308e4f8a2d 100644
--- a/src/app/core/shared/operators.ts
+++ b/src/app/core/shared/operators.ts
@@ -125,9 +125,3 @@ export const getFirstOccurrence = () =>
source.pipe(
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
);
-
-export const obsLog = (logString?: string) =>
- (source: Observable): Observable =>
- source.pipe(
- tap((t) => console.log(logString || '', t))
- );
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts
index 2079f23725..c85ef11e5a 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts
@@ -85,8 +85,7 @@ import { DsDynamicLookupRelationModalComponent } from './relation-lookup-modal/d
import {
getAllSucceededRemoteData,
getRemoteDataPayload,
- getSucceededRemoteData,
- obsLog
+ getSucceededRemoteData
} from '../../../../core/shared/operators';
import { RemoteData } from '../../../../core/data/remote-data';
import { Item } from '../../../../core/shared/item.model';
@@ -100,7 +99,6 @@ import { PaginatedList } from '../../../../core/data/paginated-list';
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
import { MetadataValue } from '../../../../core/shared/metadata.models';
-import * as uuidv4 from 'uuid/v4';
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type | null {
switch (model.type) {
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts
index 241d022dc3..4434684cbb 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts
@@ -24,9 +24,11 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
let item1;
let item2;
let item3;
+ let item4;
let searchResult1;
let searchResult2;
let searchResult3;
+ let searchResult4;
let listID;
let selection$;
@@ -39,9 +41,11 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
item1 = Object.assign(new Item(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' });
item2 = Object.assign(new Item(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' });
item3 = Object.assign(new Item(), { uuid: 'c3bcbff5-ec0c-4831-8e4c-94b9c933ccac' });
+ item4 = Object.assign(new Item(), { uuid: 'f96a385e-de10-45b2-be66-7f10bf52f765' });
searchResult1 = Object.assign(new ItemSearchResult(), { indexableObject: item1 });
searchResult2 = Object.assign(new ItemSearchResult(), { indexableObject: item2 });
searchResult3 = Object.assign(new ItemSearchResult(), { indexableObject: item3 });
+ searchResult4 = Object.assign(new ItemSearchResult(), { indexableObject: item4 });
listID = '6b0c8221-fcb4-47a8-b483-ca32363fffb3';
selection$ = observableOf([searchResult1, searchResult2]);
@@ -93,12 +97,12 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
describe('selectPage', () => {
beforeEach(() => {
spyOn(component.selectObject, 'emit');
- component.selectPage([searchResult1, searchResult2, searchResult3]);
+ component.selectPage([searchResult1, searchResult2, searchResult4]);
});
it('should emit the page filtered from already selected objects and call select on the service for all objects', () => {
- expect(component.selectObject.emit).toHaveBeenCalledWith(searchResult3);
- expect(selectableListService.select).toHaveBeenCalledWith(listID, [searchResult1, searchResult2, searchResult3]);
+ expect(component.selectObject.emit).toHaveBeenCalledWith(searchResult4);
+ expect(selectableListService.select).toHaveBeenCalledWith(listID, [searchResult1, searchResult2, searchResult4]);
});
});
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts
index 32c995ba94..203a4df0b0 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts
@@ -1,46 +1,59 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
-import { RouterTestingModule } from '@angular/router/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { VarDirective } from '../../../../../utils/var.directive';
-import { of as observableOf } from 'rxjs';
+import { Observable, of as observableOf } from 'rxjs';
import { PaginatedSearchOptions } from '../../../../../search/paginated-search-options.model';
import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model';
import { Item } from '../../../../../../core/shared/item.model';
import { DsDynamicLookupRelationSelectionTabComponent } from './dynamic-lookup-relation-selection-tab.component';
import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model';
+import { Router } from '@angular/router';
+import { By } from '@angular/platform-browser';
+import { RemoteData } from '../../../../../../core/data/remote-data';
+import { PaginatedList } from '../../../../../../core/data/paginated-list';
+import { ListableObject } from '../../../../../object-collection/shared/listable-object.model';
+import { createSuccessfulRemoteDataObject$ } from '../../../../../testing/utils';
describe('DsDynamicLookupRelationSelectionTabComponent', () => {
let component: DsDynamicLookupRelationSelectionTabComponent;
let fixture: ComponentFixture;
- let pSearchOptions = new PaginatedSearchOptions({pagination: new PaginationComponentOptions()});
+ let pSearchOptions = new PaginatedSearchOptions({ pagination: new PaginationComponentOptions() });
let item1 = Object.assign(new Item(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' });
let item2 = Object.assign(new Item(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' });
let searchResult1 = Object.assign(new ItemSearchResult(), { indexableObject: item1 });
let searchResult2 = Object.assign(new ItemSearchResult(), { indexableObject: item2 });
let listID = '6b0c8221-fcb4-47a8-b483-ca32363fffb3';
- let selection$ = observableOf([searchResult1, searchResult2]);
+ let selection$;
+ let selectionRD$;
+ let router;
function init() {
- pSearchOptions = new PaginatedSearchOptions({pagination: new PaginationComponentOptions()});
+ pSearchOptions = new PaginatedSearchOptions({ pagination: new PaginationComponentOptions() });
item1 = Object.assign(new Item(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' });
item2 = Object.assign(new Item(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' });
searchResult1 = Object.assign(new ItemSearchResult(), { indexableObject: item1 });
searchResult2 = Object.assign(new ItemSearchResult(), { indexableObject: item2 });
listID = '6b0c8221-fcb4-47a8-b483-ca32363fffb3';
selection$ = observableOf([searchResult1, searchResult2]);
+ selectionRD$ = createSelection([searchResult1, searchResult2]);
+ router = jasmine.createSpyObj('router', ['navigate'])
}
+
beforeEach(async(() => {
init();
TestBed.configureTestingModule({
declarations: [DsDynamicLookupRelationSelectionTabComponent, VarDirective],
- imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
+ imports: [TranslateModule.forRoot()],
providers: [
{
provide: SearchConfigurationService, useValue: {
paginatedSearchOptions: observableOf(pSearchOptions)
- }
+ },
+ },
+ {
+ provide: Router, useValue: router
}
],
schemas: [NO_ERRORS_SCHEMA]
@@ -59,4 +72,26 @@ describe('DsDynamicLookupRelationSelectionTabComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('should call navigate on the router when is called resetRoute', () => {
+ component.resetRoute();
+ expect(router.navigate).toHaveBeenCalled();
+ });
+
+ it('should call navigate on the router when is called resetRoute', () => {
+ component.selectionRD$ = createSelection([]);
+ fixture.detectChanges();
+ const colComponent = fixture.debugElement.query(By.css('ds-viewable-collection'));
+ expect(colComponent).toBe(null);
+ });
+
+ it('should call navigate on the router when is called resetRoute', () => {
+ component.selectionRD$ = selectionRD$;
+ const colComponent = fixture.debugElement.query(By.css('ds-viewable-collection'));
+ expect(colComponent).not.toBe(null);
+ });
});
+
+function createSelection(content: ListableObject[]): Observable>> {
+ return createSuccessfulRemoteDataObject$(new PaginatedList(undefined, content));
+}
diff --git a/src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts b/src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts
index 1d1b47ee78..a7fab782da 100644
--- a/src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts
+++ b/src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts
@@ -5,6 +5,11 @@ export class MockResponseMap extends Map {};
export const MOCK_RESPONSE_MAP: InjectionToken = new InjectionToken('mockResponseMap');
+/**
+ * List of endpoints with their matching mock response
+ * Note that this list is only used in development mode
+ * In production the actual endpoints on the REST server will be called
+ */
export const mockResponseMap: MockResponseMap = new Map([
// [ '/config/submissionforms/traditionalpageone', mockSubmissionResponse ]
]);
diff --git a/src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.ts b/src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.ts
index d1536c56e6..d47e05c8fe 100644
--- a/src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.ts
+++ b/src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.ts
@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
templateUrl: './selectable-list-item-control.component.html'
})
/**
- * Component for determining what component to use depending on the item's relationship type (relationship.type)
+ * Component for rendering list item that has a control (checkbox or radio button) because it's selectable
*/
export class SelectableListItemControlComponent implements OnInit {
/**
diff --git a/src/app/shared/object-list/object-list.component.ts b/src/app/shared/object-list/object-list.component.ts
index 1be0f69106..6ca7adb3f9 100644
--- a/src/app/shared/object-list/object-list.component.ts
+++ b/src/app/shared/object-list/object-list.component.ts
@@ -1,21 +1,11 @@
-import {
- ChangeDetectionStrategy,
- Component,
- EventEmitter,
- Input,
- Output,
- ViewEncapsulation
-} from '@angular/core';
+import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginatedList } from '../../core/data/paginated-list';
import { RemoteData } from '../../core/data/remote-data';
import { fadeIn } from '../animations/fade';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
-import { DSpaceObject } from '../../core/shared/dspace-object.model';
-import { SearchResult } from '../search/search-result.model';
import { SelectableListService } from './selectable-list/selectable-list.service';
-import { map, take, tap } from 'rxjs/operators';
import { ViewMode } from '../../core/shared/view-mode.model';
import { Context } from '../../core/shared/context.model';
import { CollectionElementLinkType } from '../object-collection/collection-element-link.type';
@@ -60,9 +50,6 @@ export class ObjectListComponent {
@Input() hidePagerWhenSinglePage = true;
@Input() selectable = false;
@Input() selectionConfig: { repeatable: boolean, listId: string };
- // @Input() previousSelection: ListableObject[] = [];
- // allSelected = false;
- // selectAllLoading = false;
/**
* The link type of the listable elements
diff --git a/src/app/shared/object-list/selectable-list/selectable-list.actions.ts b/src/app/shared/object-list/selectable-list/selectable-list.actions.ts
index 3dedf7e6a2..010ae5609d 100644
--- a/src/app/shared/object-list/selectable-list/selectable-list.actions.ts
+++ b/src/app/shared/object-list/selectable-list/selectable-list.actions.ts
@@ -55,7 +55,7 @@ export class SelectableListSelectSingleAction extends SelectableListAction {
}
/**
- * Action to deselect objects in a the selectable list
+ * Action to deselect a single object in a the selectable list
*/
export class SelectableListDeselectSingleAction extends SelectableListAction {
payload: ListableObject;
@@ -67,7 +67,7 @@ export class SelectableListDeselectSingleAction extends SelectableListAction {
}
/**
- * Action to deselect a single object in a the selectable list
+ * Action to deselect objects in a the selectable list
*/
export class SelectableListDeselectAction extends SelectableListAction {
payload: ListableObject[];
diff --git a/src/app/shared/page-size-selector/page-size-selector.component.ts b/src/app/shared/page-size-selector/page-size-selector.component.ts
index 799993d35d..b200c337f8 100644
--- a/src/app/shared/page-size-selector/page-size-selector.component.ts
+++ b/src/app/shared/page-size-selector/page-size-selector.component.ts
@@ -14,7 +14,7 @@ import { map } from 'rxjs/operators';
})
/**
- * This component represents the part of the search sidebar that contains the general search settings.
+ * This component represents the part of the search sidebar that contains the page size settings.
*/
export class PageSizeSelectorComponent implements OnInit {
/**
diff --git a/src/app/shared/search/search-filters/search-filters.component.ts b/src/app/shared/search/search-filters/search-filters.component.ts
index e9b5f46fa8..78c40501e6 100644
--- a/src/app/shared/search/search-filters/search-filters.component.ts
+++ b/src/app/shared/search/search-filters/search-filters.component.ts
@@ -8,7 +8,7 @@ import { RemoteData } from '../../../core/data/remote-data';
import { SearchFilterConfig } from '../search-filter-config.model';
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
import { SearchFilterService } from '../../../core/shared/search/search-filter.service';
-import { getSucceededRemoteData, obsLog } from '../../../core/shared/operators';
+import { getSucceededRemoteData } from '../../../core/shared/operators';
import { SEARCH_CONFIG_SERVICE } from '../../../+my-dspace-page/my-dspace-page.component';
import { currentPath } from '../../utils/route.utils';
import { Router } from '@angular/router';
diff --git a/src/app/shared/search/search-labels/search-label/search-label.component.spec.ts b/src/app/shared/search/search-labels/search-label/search-label.component.spec.ts
index 0b382015af..8c6860c2d3 100644
--- a/src/app/shared/search/search-labels/search-label/search-label.component.spec.ts
+++ b/src/app/shared/search/search-labels/search-label/search-label.component.spec.ts
@@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { Observable, of as observableOf } from 'rxjs';
-import { Params } from '@angular/router';
+import { Params, Router } from '@angular/router';
import { SearchLabelComponent } from './search-label.component';
import { ObjectKeysPipe } from '../../../utils/object-keys-pipe';
import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
@@ -39,7 +39,8 @@ describe('SearchLabelComponent', () => {
declarations: [SearchLabelComponent, ObjectKeysPipe],
providers: [
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
- { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() }
+ { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
+ { provide: Router, useValue: {} }
// { provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => observableOf({})} }
],
schemas: [NO_ERRORS_SCHEMA]
diff --git a/src/app/shared/utils/route.utils.ts b/src/app/shared/utils/route.utils.ts
index b0771d4f13..6510fb8894 100644
--- a/src/app/shared/utils/route.utils.ts
+++ b/src/app/shared/utils/route.utils.ts
@@ -1,5 +1,9 @@
import { Router } from '@angular/router';
+/**
+ * Util function to retrieve the current path (without query parameters) the user is on
+ * @param router The router service
+ */
export function currentPath(router: Router) {
const urlTree = router.parseUrl(router.url);
return '/' + urlTree.root.children.primary.segments.map((it) => it.path).join('/')
diff --git a/src/app/submission/sections/form/section-form.component.ts b/src/app/submission/sections/form/section-form.component.ts
index 6c8d7c5468..49dbaea807 100644
--- a/src/app/submission/sections/form/section-form.component.ts
+++ b/src/app/submission/sections/form/section-form.component.ts
@@ -166,8 +166,8 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
.subscribe(([sectionData, workspaceItem]: [WorkspaceitemSectionFormObject, WorkspaceItem]) => {
if (isUndefined(this.formModel)) {
this.sectionData.errors = [];
- // Is the first loading so init form
this.workspaceItem = workspaceItem;
+ // Is the first loading so init form
this.initForm(sectionData);
this.sectionData.data = sectionData;
this.subscriptions();