Merge branch 'clean-relationships-in-submission' into reorder-name-variants

This commit is contained in:
lotte
2019-12-20 15:26:46 +01:00
13 changed files with 72 additions and 41 deletions

View File

@@ -9,10 +9,11 @@ module.exports = {
},
// The REST API server settings.
rest: {
ssl: true,
host: 'dspace7-entities.atmire.com',
port: 443,
nameSpace: '/server/api'
ssl: true,
host: 'dspace7.4science.cloud',
port: 443,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
nameSpace: '/server/api'
},
// Caching settings
cache: {

View File

@@ -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) =>
<T>(source: Observable<T>): Observable<T> =>
source.pipe(
tap((t) => console.log(logString || '', t))
);

View File

@@ -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]);
});
});

View File

@@ -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<DsDynamicLookupRelationSelectionTabComponent>;
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<RemoteData<PaginatedList<ListableObject>>> {
return createSuccessfulRemoteDataObject$(new PaginatedList(undefined, content));
}

View File

@@ -5,6 +5,11 @@ export class MockResponseMap extends Map<string, any> {};
export const MOCK_RESPONSE_MAP: InjectionToken<MockResponseMap> = new InjectionToken<MockResponseMap>('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 ]
]);

View File

@@ -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 {
/**

View File

@@ -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

View File

@@ -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[];

View File

@@ -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 {
/**

View File

@@ -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';

View File

@@ -26,7 +26,8 @@ export class SearchLabelComponent implements OnInit {
* Initialize the instance variable
*/
constructor(
private searchService: SearchService, private router: Router) {
private searchService: SearchService,
private router: Router) {
}
ngOnInit(): void {

View File

@@ -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('/')

View File

@@ -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();