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', () => {
|
describe('when querying the metadata fields returns an error response', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(registryService.queryMetadataFields as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Failed'));
|
(registryService.queryMetadataFields as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Failed'));
|
||||||
|
@@ -43,6 +43,7 @@ import {
|
|||||||
SortDirection,
|
SortDirection,
|
||||||
SortOptions,
|
SortOptions,
|
||||||
} from '../../../core/cache/models/sort-options.model';
|
} from '../../../core/cache/models/sort-options.model';
|
||||||
|
import { FindListOptions } from '../../../core/data/find-list-options.model';
|
||||||
import { RegistryService } from '../../../core/registry/registry.service';
|
import { RegistryService } from '../../../core/registry/registry.service';
|
||||||
import {
|
import {
|
||||||
getAllSucceededRemoteData,
|
getAllSucceededRemoteData,
|
||||||
@@ -153,7 +154,10 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
|
|||||||
/**
|
/**
|
||||||
* Default page option for this feature
|
* 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,
|
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
|
* Upon subscribing to the returned observable, the showInvalid flag is updated accordingly to show the feedback under the input
|
||||||
*/
|
*/
|
||||||
validate(): Observable<boolean> {
|
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(),
|
getFirstCompletedRemoteData(),
|
||||||
switchMap((rd) => {
|
switchMap((rd) => {
|
||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
@@ -263,9 +267,7 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
|
|||||||
* @param useCache Whether or not to use the cache
|
* @param useCache Whether or not to use the cache
|
||||||
*/
|
*/
|
||||||
search(query: string, page: number, useCache: boolean = true) {
|
search(query: string, page: number, useCache: boolean = true) {
|
||||||
return this.registryService.queryMetadataFields(query,{
|
return this.registryService.queryMetadataFields(query, Object.assign({}, this.pageOptions, { currentPage: page }), useCache, false, followLink('schema'))
|
||||||
elementsPerPage: this.pageOptions.elementsPerPage, sort: this.pageOptions.sort,
|
|
||||||
currentPage: page }, useCache, false, followLink('schema'))
|
|
||||||
.pipe(
|
.pipe(
|
||||||
getAllSucceededRemoteData(),
|
getAllSucceededRemoteData(),
|
||||||
metadataFieldsToString(),
|
metadataFieldsToString(),
|
||||||
|
Reference in New Issue
Block a user