mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
DS-8408: Test cases and some fixes or comcol ordering
This commit is contained in:
@@ -371,6 +371,6 @@ vocabularies:
|
||||
enabled: true
|
||||
|
||||
# Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query.
|
||||
collectionSelectionSort:
|
||||
sortMetadata: "dc.title"
|
||||
sortDirection: "ASC"
|
||||
comcolSelectionSort:
|
||||
sortMetadata: 'dc.title'
|
||||
sortDirection: 'ASC'
|
@@ -11,6 +11,7 @@ import { PaginatedSearchOptions } from '../../search/models/paginated-search-opt
|
||||
import { hasValue } from '../../empty.util';
|
||||
import { createPaginatedList } from '../../testing/utils.test';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
|
||||
describe('DSOSelectorComponent', () => {
|
||||
let component: DSOSelectorComponent;
|
||||
@@ -34,7 +35,7 @@ describe('DSOSelectorComponent', () => {
|
||||
];
|
||||
|
||||
const searchService = {
|
||||
search: (options: PaginatedSearchOptions) => {
|
||||
search: (options: PaginatedSearchOptions, responseMsToLive?: number, useCachedVersionIfAvailable = true) => {
|
||||
if (hasValue(options.query) && options.query.startsWith('search.resourceid')) {
|
||||
return createSuccessfulRemoteDataObject$(createPaginatedList([searchResult]));
|
||||
} else if (options.pagination.currentPage === 1) {
|
||||
@@ -120,6 +121,43 @@ describe('DSOSelectorComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(searchService, 'search').and.callThrough();
|
||||
});
|
||||
|
||||
it('should specify how to sort if no query is given', () => {
|
||||
component.sort = new SortOptions('dc.title', SortDirection.ASC);
|
||||
component.search(undefined, 0);
|
||||
|
||||
expect(searchService.search).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
query: undefined,
|
||||
sort: jasmine.objectContaining({
|
||||
field: 'dc.title',
|
||||
direction: SortDirection.ASC,
|
||||
}),
|
||||
}),
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it('should not specify how to sort if a query is given', () => {
|
||||
component.sort = new SortOptions('dc.title', SortDirection.ASC);
|
||||
component.search('testQuery', 0);
|
||||
|
||||
expect(searchService.search).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
query: 'testQuery',
|
||||
sort: null,
|
||||
}),
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when search returns an error', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(searchService, 'search').and.returnValue(createFailedRemoteDataObject$());
|
||||
|
@@ -8,7 +8,8 @@ import {
|
||||
getCollectionCreateRoute,
|
||||
COLLECTION_PARENT_PARAMETER
|
||||
} from '../../../../collection-page/collection-page-routing-paths';
|
||||
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
/**
|
||||
* Component to wrap a list of existing communities inside a modal
|
||||
* Used to choose a community from to create a new collection in
|
||||
@@ -23,6 +24,7 @@ export class CreateCollectionParentSelectorComponent extends DSOSelectorModalWra
|
||||
selectorTypes = [DSpaceObjectType.COMMUNITY];
|
||||
action = SelectorActionType.CREATE;
|
||||
header = 'dso-selector.create.collection.sub-level';
|
||||
defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection);
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
|
@@ -12,6 +12,8 @@ import {
|
||||
getCommunityCreateRoute,
|
||||
COMMUNITY_PARENT_PARAMETER
|
||||
} from '../../../../community-page/community-page-routing-paths';
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
|
||||
/**
|
||||
* Component to wrap a button - for top communities -
|
||||
@@ -29,7 +31,8 @@ export class CreateCommunityParentSelectorComponent extends DSOSelectorModalWrap
|
||||
objectType = DSpaceObjectType.COMMUNITY;
|
||||
selectorTypes = [DSpaceObjectType.COMMUNITY];
|
||||
action = SelectorActionType.CREATE;
|
||||
|
||||
defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection);
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.mod
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../dso-selector-modal-wrapper.component';
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
|
||||
/**
|
||||
* Component to wrap a list of existing collections inside a modal
|
||||
@@ -21,6 +23,7 @@ export class CreateItemParentSelectorComponent extends DSOSelectorModalWrapperCo
|
||||
selectorTypes = [DSpaceObjectType.COLLECTION];
|
||||
action = SelectorActionType.CREATE;
|
||||
header = 'dso-selector.create.item.sub-level';
|
||||
defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection);
|
||||
|
||||
/**
|
||||
* If present this value is used to filter collection list by entity type
|
||||
|
@@ -5,8 +5,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
import { hasValue, isNotEmpty } from '../../empty.util';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
|
||||
export enum SelectorActionType {
|
||||
CREATE = 'create',
|
||||
@@ -54,7 +53,7 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit {
|
||||
/**
|
||||
* Default DSO ordering
|
||||
*/
|
||||
defaultSort = new SortOptions(environment.collectionSelectionSort.sortMetadata, environment.collectionSelectionSort.sortDirection as SortDirection);
|
||||
defaultSort: SortOptions;
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) {
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import {
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
import { getCollectionEditRoute } from '../../../../collection-page/collection-page-routing-paths';
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
|
||||
/**
|
||||
* Component to wrap a list of existing collections inside a modal
|
||||
@@ -22,7 +24,8 @@ export class EditCollectionSelectorComponent extends DSOSelectorModalWrapperComp
|
||||
objectType = DSpaceObjectType.COLLECTION;
|
||||
selectorTypes = [DSpaceObjectType.COLLECTION];
|
||||
action = SelectorActionType.EDIT;
|
||||
|
||||
defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection);
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@ import {
|
||||
SelectorActionType
|
||||
} from '../dso-selector-modal-wrapper.component';
|
||||
import { getCommunityEditRoute } from '../../../../community-page/community-page-routing-paths';
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
|
||||
/**
|
||||
* Component to wrap a list of existing communities inside a modal
|
||||
@@ -23,7 +25,8 @@ export class EditCommunitySelectorComponent extends DSOSelectorModalWrapperCompo
|
||||
objectType = DSpaceObjectType.COMMUNITY;
|
||||
selectorTypes = [DSpaceObjectType.COMMUNITY];
|
||||
action = SelectorActionType.EDIT;
|
||||
|
||||
defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection);
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../../dso-selector/modal-wrappers/dso-selector-modal-wrapper.component';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
|
||||
/**
|
||||
* Component to wrap a button - to select the entire repository -
|
||||
@@ -33,6 +35,11 @@ export class ScopeSelectorModalComponent extends DSOSelectorModalWrapperComponen
|
||||
*/
|
||||
scopeChange = new EventEmitter<DSpaceObject>();
|
||||
|
||||
/**
|
||||
* Default DSO ordering
|
||||
*/
|
||||
defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection);
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) {
|
||||
super(activeModal, route);
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ interface AppConfig extends Config {
|
||||
info: InfoConfig;
|
||||
markdown: MarkdownConfig;
|
||||
vocabularies: FilterVocabularyConfig[];
|
||||
collectionSelectionSort: DiscoverySortConfig;
|
||||
comcolSelectionSort: DiscoverySortConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -424,8 +424,8 @@ export class DefaultAppConfig implements AppConfig {
|
||||
];
|
||||
|
||||
// Configuration that determines the metadata sorting of community and collection edition and creation when there are not a search query.
|
||||
collectionSelectionSort: DiscoverySortConfig = {
|
||||
sortMetadata:'dc.title',
|
||||
comcolSelectionSort: DiscoverySortConfig = {
|
||||
sortField:'dc.title',
|
||||
sortDirection:'ASC',
|
||||
};
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import { Config } from './config.interface';
|
||||
*/
|
||||
export class DiscoverySortConfig implements Config {
|
||||
|
||||
public sortMetadata: string;
|
||||
public sortField: string;
|
||||
/**
|
||||
* ASC / DESC values expected
|
||||
*/
|
||||
|
@@ -297,8 +297,8 @@ export const environment: BuildConfig = {
|
||||
enabled: false,
|
||||
mathjax: false,
|
||||
},
|
||||
collectionSelectionSort: {
|
||||
sortMetadata:'dc.title',
|
||||
comcolSelectionSort: {
|
||||
sortField:'dc.title',
|
||||
sortDirection:'ASC',
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user