Skip to content

Commit 7c45c78

Browse files
authored
Merge pull request #4370 from atmire/w2p-130424_impossible-to-add-new-values-for-fields-without-qualifiers_contribute-8
[Port dspace-8_x] Fix unqualified metadata field validation in Edit Metadata tab by sorting fields in validation request
2 parents eb67598 + 65c47fb commit 7c45c78

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/app/dso-shared/dso-edit-metadata/metadata-field-selector/metadata-field-selector.component.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ describe('MetadataFieldSelectorComponent', () => {
116116
});
117117
});
118118

119+
it('should sort the fields by name to ensure the one without a qualifier is first', () => {
120+
component.mdField = 'dc.relation';
121+
122+
component.validate();
123+
124+
expect(registryService.queryMetadataFields).toHaveBeenCalledWith('dc.relation', { elementsPerPage: 10, sort: new SortOptions('fieldName', SortDirection.ASC) }, true, false, followLink('schema'));
125+
});
126+
119127
describe('when querying the metadata fields returns an error response', () => {
120128
beforeEach(() => {
121129
(registryService.queryMetadataFields as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Failed'));

src/app/dso-shared/dso-edit-metadata/metadata-field-selector/metadata-field-selector.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
SortDirection,
4646
SortOptions,
4747
} from '../../../core/cache/models/sort-options.model';
48+
import { FindListOptions } from '../../../core/data/find-list-options.model';
4849
import { RegistryService } from '../../../core/registry/registry.service';
4950
import {
5051
getAllSucceededRemoteData,
@@ -129,6 +130,11 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
129130
*/
130131
showInvalid = false;
131132

133+
searchOptions: FindListOptions = {
134+
elementsPerPage: 10,
135+
sort: new SortOptions('fieldName', SortDirection.ASC),
136+
};
137+
132138
/**
133139
* Subscriptions to unsubscribe from on destroy
134140
*/
@@ -211,7 +217,7 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
211217
* Upon subscribing to the returned observable, the showInvalid flag is updated accordingly to show the feedback under the input
212218
*/
213219
validate(): Observable<boolean> {
214-
return this.registryService.queryMetadataFields(this.mdField, null, true, false, followLink('schema')).pipe(
220+
return this.registryService.queryMetadataFields(this.mdField, this.searchOptions, true, false, followLink('schema')).pipe(
215221
getFirstCompletedRemoteData(),
216222
switchMap((rd) => {
217223
if (rd.hasSucceeded) {

0 commit comments

Comments
 (0)