Merge branch 'master' into w2p-61949_object-factory-refactoring

Conflicts:
	src/app/core/cache/models/normalized-object-factory.ts
	src/app/core/cache/response.models.ts
	src/app/core/core.module.ts
	src/app/core/data/base-response-parsing.service.ts
	src/app/core/shared/resource-type.ts
	src/app/core/submission/submission-response-parsing.service.ts
This commit is contained in:
lotte
2019-05-24 15:42:24 +02:00
490 changed files with 16213 additions and 1195 deletions

View File

@@ -7,6 +7,7 @@ import { CacheableObject, TypedObject } from '../cache/object-cache.reducer';
import { RemoteData } from '../data/remote-data';
import { ResourceType } from './resource-type';
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
import { hasNoValue } from '../../shared/empty.util';
/**
* An abstract model class for a DSpaceObject.
@@ -123,4 +124,23 @@ export class DSpaceObject implements CacheableObject, ListableObject {
return Metadata.has(this.metadata, keyOrKeys, valueFilter);
}
/**
* Find metadata on a specific field and order all of them using their "place" property.
* @param key
*/
findMetadataSortedByPlace(key: string): MetadataValue[] {
return this.allMetadata([key]).sort((a: MetadataValue, b: MetadataValue) => {
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;
});
}
}