add the ability to mix text based metadata fields, authority controlled fields and typed items in the same section

This commit is contained in:
Art Lowel
2019-01-21 18:27:07 +01:00
parent 8ae8498ab1
commit 57999ad382
54 changed files with 833 additions and 98 deletions

View File

@@ -1,5 +1,5 @@
import { Metadatum } from './metadatum.model'
import { isEmpty, isNotEmpty } from '../../shared/empty.util';
import { hasNoValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
import { CacheableObject } from '../cache/object-cache.reducer';
import { RemoteData } from '../data/remote-data';
import { ResourceType } from './resource-type';
@@ -91,4 +91,23 @@ export class DSpaceObject implements CacheableObject, ListableObject {
});
}
/**
* Find metadata on a specific field and order all of them using their "place" property.
* @param key
*/
findMetadataSortedByPlace(key: string): Metadatum[] {
return this.filterMetadata([key]).sort((a: Metadatum, b: Metadatum) => {
if (hasNoValue(a.place) && hasNoValue(b.place)) {
return 0;
}
if (hasNoValue(a.place)) {
return -1;
}
if (hasNoValue(b.place)) {
return 1;
}
return a.place - b.place;
});
}
}