Skip to content

Commit 4f79574

Browse files
authored
Merge pull request #4383 from atmire/w2p-130424_impossible-to-add-new-values-for-fields-without-qualifiers_contribute-7.6
[Port dspace-7_x] Fix unqualified metadata field validation in Edit Metadata tab by sorting fields in validation request
2 parents 1aaa20e + cb0ac0c commit 4f79574

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
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
@@ -106,6 +106,14 @@ describe('MetadataFieldSelectorComponent', () => {
106106
});
107107
});
108108

109+
it('should sort the fields by name to ensure the one without a qualifier is first', () => {
110+
component.mdField = 'dc.relation';
111+
112+
component.validate();
113+
114+
expect(registryService.queryMetadataFields).toHaveBeenCalledWith('dc.relation', { elementsPerPage: 10, sort: new SortOptions('fieldName', SortDirection.ASC) }, true, false, followLink('schema'));
115+
});
116+
109117
describe('when querying the metadata fields returns an error response', () => {
110118
beforeEach(() => {
111119
(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
@@ -29,6 +29,7 @@ import { hasValue } from '../../../shared/empty.util';
2929
import { NotificationsService } from '../../../shared/notifications/notifications.service';
3030
import { TranslateService } from '@ngx-translate/core';
3131
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
32+
import { FindListOptions } from '../../../core/data/find-list-options.model';
3233

3334
@Component({
3435
selector: 'ds-metadata-field-selector',
@@ -100,6 +101,11 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
100101
*/
101102
showInvalid = false;
102103

104+
searchOptions: FindListOptions = {
105+
elementsPerPage: 10,
106+
sort: new SortOptions('fieldName', SortDirection.ASC),
107+
};
108+
103109
/**
104110
* Subscriptions to unsubscribe from on destroy
105111
*/
@@ -182,7 +188,7 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
182188
* Upon subscribing to the returned observable, the showInvalid flag is updated accordingly to show the feedback under the input
183189
*/
184190
validate(): Observable<boolean> {
185-
return this.registryService.queryMetadataFields(this.mdField, null, true, false, followLink('schema')).pipe(
191+
return this.registryService.queryMetadataFields(this.mdField, this.searchOptions, true, false, followLink('schema')).pipe(
186192
getFirstCompletedRemoteData(),
187193
switchMap((rd) => {
188194
if (rd.hasSucceeded) {

src/app/item-page/edit-item-page/edit-item-page.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="col-12">
44
<h1 class="border-bottom">{{'item.edit.head' | translate}}</h1>
55
<div class="pt-2">
6-
<ul class="nav nav-tabs justify-content-start" role="tablist">
6+
<ul *ngIf="pages.length > 0" class="nav nav-tabs justify-content-start" role="tablist">
77
<li *ngFor="let page of pages" class="nav-item" role="presentation">
88
<a *ngIf="(page.enabled | async)"
99
[attr.aria-selected]="page.page === currentPage"

0 commit comments

Comments
 (0)