mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
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
This commit is contained in:
@@ -106,6 +106,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', () => {
|
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'));
|
||||||
|
@@ -29,6 +29,7 @@ import { hasValue } from '../../../shared/empty.util';
|
|||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||||
|
import { FindListOptions } from '../../../core/data/find-list-options.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-metadata-field-selector',
|
selector: 'ds-metadata-field-selector',
|
||||||
@@ -100,6 +101,11 @@ export class MetadataFieldSelectorComponent implements OnInit, OnDestroy, AfterV
|
|||||||
*/
|
*/
|
||||||
showInvalid = false;
|
showInvalid = false;
|
||||||
|
|
||||||
|
searchOptions: FindListOptions = {
|
||||||
|
elementsPerPage: 10,
|
||||||
|
sort: new SortOptions('fieldName', SortDirection.ASC),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscriptions to unsubscribe from on destroy
|
* Subscriptions to unsubscribe from on destroy
|
||||||
*/
|
*/
|
||||||
@@ -182,7 +188,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, this.searchOptions, true, false, followLink('schema')).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
switchMap((rd) => {
|
switchMap((rd) => {
|
||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h1 class="border-bottom">{{'item.edit.head' | translate}}</h1>
|
<h1 class="border-bottom">{{'item.edit.head' | translate}}</h1>
|
||||||
<div class="pt-2">
|
<div class="pt-2">
|
||||||
<ul class="nav nav-tabs justify-content-start" role="tablist">
|
<ul *ngIf="pages.length > 0" class="nav nav-tabs justify-content-start" role="tablist">
|
||||||
<li *ngFor="let page of pages" class="nav-item" role="presentation">
|
<li *ngFor="let page of pages" class="nav-item" role="presentation">
|
||||||
<a *ngIf="(page.enabled | async)"
|
<a *ngIf="(page.enabled | async)"
|
||||||
[attr.aria-selected]="page.page === currentPage"
|
[attr.aria-selected]="page.page === currentPage"
|
||||||
|
Reference in New Issue
Block a user