mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge branch 'w2p-130424_impossible-to-add-new-values-for-fields-without-qualifiers_contribute-7.6'
This commit is contained in:
@@ -116,6 +116,14 @@ describe('MetadataFieldSelectorComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should sort the fields by name to ensure the one without a qualifier is first', () => {
|
||||
component.mdField = 'dc.relation';
|
||||
|
||||
component.validate();
|
||||
|
||||
expect(registryService.queryMetadataFields).toHaveBeenCalledWith('dc.relation', { elementsPerPage: 20, sort: new SortOptions('fieldName', SortDirection.ASC), currentPage: 1 }, true, false, followLink('schema'));
|
||||
});
|
||||
|
||||
describe('when querying the metadata fields returns an error response', () => {
|
||||
beforeEach(() => {
|
||||
(registryService.queryMetadataFields as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Failed'));
|
||||
|
@@ -43,6 +43,7 @@ import {
|
||||
SortDirection,
|
||||
SortOptions,
|
||||
} from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/find-list-options.model';
|
||||
import { RegistryService } from '../../../core/registry/registry.service';
|
||||
import {
|
||||
getAllSucceededRemoteData,
|
||||
@@ -153,7 +154,10 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
|
||||
/**
|
||||
* Default page option for this feature
|
||||
*/
|
||||
pageOptions = { elementsPerPage: 20, sort: new SortOptions('fieldName', SortDirection.ASC) };
|
||||
pageOptions: FindListOptions = {
|
||||
elementsPerPage: 20,
|
||||
sort: new SortOptions('fieldName', SortDirection.ASC),
|
||||
};
|
||||
|
||||
|
||||
constructor(protected registryService: RegistryService,
|
||||
@@ -209,7 +213,7 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
|
||||
* Upon subscribing to the returned observable, the showInvalid flag is updated accordingly to show the feedback under the input
|
||||
*/
|
||||
validate(): Observable<boolean> {
|
||||
return this.registryService.queryMetadataFields(this.mdField, null, true, false, followLink('schema')).pipe(
|
||||
return this.registryService.queryMetadataFields(this.mdField, Object.assign({}, this.pageOptions, { currentPage: 1 }), true, false, followLink('schema')).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
switchMap((rd) => {
|
||||
if (rd.hasSucceeded) {
|
||||
@@ -263,9 +267,7 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
|
||||
* @param useCache Whether or not to use the cache
|
||||
*/
|
||||
search(query: string, page: number, useCache: boolean = true) {
|
||||
return this.registryService.queryMetadataFields(query,{
|
||||
elementsPerPage: this.pageOptions.elementsPerPage, sort: this.pageOptions.sort,
|
||||
currentPage: page }, useCache, false, followLink('schema'))
|
||||
return this.registryService.queryMetadataFields(query, Object.assign({}, this.pageOptions, { currentPage: page }), useCache, false, followLink('schema'))
|
||||
.pipe(
|
||||
getAllSucceededRemoteData(),
|
||||
metadataFieldsToString(),
|
||||
|
Reference in New Issue
Block a user