mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Merge branch 'master' into w2p-68346_Bundles-in-edit-item-Updates
Conflicts: package.json resources/i18n/en.json5 src/app/+item-page/item-page.module.ts src/app/core/core.module.ts src/app/core/data/bundle-data.service.ts src/app/core/data/data.service.spec.ts src/app/core/data/data.service.ts src/app/core/data/item-data.service.ts src/app/core/data/object-updates/object-updates.service.ts src/app/core/shared/hal-endpoint.service.ts src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts src/app/shared/mocks/mock-request.service.ts src/app/shared/shared.module.ts src/app/shared/trackable/abstract-trackable.component.ts yarn.lock
This commit is contained in:
@@ -10,7 +10,7 @@ export class ObjectKeysPipe implements PipeTransform {
|
||||
* @param value An object
|
||||
* @returns {any} Array with all keys the input object
|
||||
*/
|
||||
transform(value, args:string[]): any {
|
||||
transform(value, args: string[]): any {
|
||||
const keys = [];
|
||||
Object.keys(value).forEach((k) => keys.push(k));
|
||||
return keys;
|
||||
|
@@ -14,7 +14,7 @@ export class ObjectValuesPipe implements PipeTransform {
|
||||
* @param value An object
|
||||
* @returns {any} Array with all values of the input object
|
||||
*/
|
||||
transform(value, args:string[]): any {
|
||||
transform(value, args: string[]): any {
|
||||
const values = [];
|
||||
if (isNotEmpty(value)) {
|
||||
Object.values(value).forEach((v) => values.push(v));
|
||||
|
18
src/app/shared/utils/relation-query.utils.spec.ts
Normal file
18
src/app/shared/utils/relation-query.utils.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getFilterByRelation, getQueryByRelations } from './relation-query.utils';
|
||||
|
||||
describe('Relation Query Utils', () => {
|
||||
const relationtype = 'isAuthorOfPublication';
|
||||
const itemUUID = 'a7939af0-36ad-430d-af09-7be8b0a4dadd';
|
||||
describe('getQueryByRelations', () => {
|
||||
it('Should return the correct query based on relationtype and uuid', () => {
|
||||
const result = getQueryByRelations(relationtype, itemUUID);
|
||||
expect(result).toEqual('query=relation.isAuthorOfPublication:a7939af0-36ad-430d-af09-7be8b0a4dadd');
|
||||
});
|
||||
});
|
||||
describe('getFilterByRelation', () => {
|
||||
it('Should return the correct query based on relationtype and uuid', () => {
|
||||
const result = getFilterByRelation(relationtype, itemUUID);
|
||||
expect(result).toEqual('f.isAuthorOfPublication=a7939af0-36ad-430d-af09-7be8b0a4dadd');
|
||||
});
|
||||
});
|
||||
});
|
18
src/app/shared/utils/relation-query.utils.ts
Normal file
18
src/app/shared/utils/relation-query.utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Get the query for looking up items by relation type
|
||||
* @param {string} relationType Relation type
|
||||
* @param {string} itemUUID Item UUID
|
||||
* @returns {string} Query
|
||||
*/
|
||||
export function getQueryByRelations(relationType: string, itemUUID: string): string {
|
||||
return `query=relation.${relationType}:${itemUUID}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filter for a relation with the item's UUID
|
||||
* @param relationType The type of relation e.g. 'isAuthorOfPublication'
|
||||
* @param itemUUID The item's UUID
|
||||
*/
|
||||
export function getFilterByRelation(relationType: string, itemUUID: string): string {
|
||||
return `f.${relationType}=${itemUUID}`;
|
||||
}
|
22
src/app/shared/utils/route.utils.spec.ts
Normal file
22
src/app/shared/utils/route.utils.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { currentPath } from './route.utils';
|
||||
|
||||
describe('Route Utils', () => {
|
||||
const urlTree = {
|
||||
root: {
|
||||
children: {
|
||||
primary: {
|
||||
segments: [
|
||||
{ path: 'test' },
|
||||
{ path: 'path' }
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
const router = { parseUrl: () => urlTree } as any;
|
||||
it('Should return the correct current path based on the router', () => {
|
||||
const result = currentPath(router);
|
||||
expect(result).toEqual('/test/path');
|
||||
});
|
||||
});
|
10
src/app/shared/utils/route.utils.ts
Normal file
10
src/app/shared/utils/route.utils.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Util function to retrieve the current path (without query parameters) the user is on
|
||||
* @param router The router service
|
||||
*/
|
||||
export function currentPath(router: Router) {
|
||||
const urlTree = router.parseUrl(router.url);
|
||||
return '/' + urlTree.root.children.primary.segments.map((it) => it.path).join('/')
|
||||
}
|
Reference in New Issue
Block a user