mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
add the ability to mix text based metadata fields, authority controlled fields and typed items in the same section
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user