Merge remote-tracking branch 'alex-upstream/w2p-130424_impossible-to-add-new-values-for-fields-without-qualifiers_contribute-7.6' into w2p-130424_impossible-to-add-new-values-for-fields-without-qualifiers_contribute-8

This commit is contained in:
abhinav
2025-05-23 17:55:55 +02:00
2 changed files with 15 additions and 1 deletions

View File

@@ -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: 10, sort: new SortOptions('fieldName', SortDirection.ASC) }, true, false, followLink('schema'));
});
describe('when querying the metadata fields returns an error response', () => {
beforeEach(() => {
(registryService.queryMetadataFields as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Failed'));

View File

@@ -45,6 +45,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,
@@ -129,6 +130,11 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
*/
showInvalid = false;
searchOptions: FindListOptions = {
elementsPerPage: 10,
sort: new SortOptions('fieldName', SortDirection.ASC),
};
/**
* Subscriptions to unsubscribe from on destroy
*/
@@ -211,7 +217,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, this.searchOptions, true, false, followLink('schema')).pipe(
getFirstCompletedRemoteData(),
switchMap((rd) => {
if (rd.hasSucceeded) {