Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1602 Insufficient collection information when submitting an article #3327

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -37,6 +46,52 @@ const parent = Object.assign(new Collection(), {
},
});

describe('JournalIssueSidebarSearchListElementComponent',
createSidebarSearchListElementTests(JournalIssueSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '5 - 7'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('JournalIssueSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(
JournalIssueSidebarSearchListElementComponent,
object,
parent,
hierarchicalTitle,
'title',
'1234, 5678',
);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -40,6 +49,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('JournalVolumeSidebarSearchListElementComponent',
createSidebarSearchListElementTests(JournalVolumeSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'journal title (1) (2)'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('JournalVolumeSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(JournalVolumeSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'journal title (1) (2)');
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import {
catchError,
map,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -35,6 +45,48 @@ const parent = Object.assign(new Collection(), {
},
});

describe('JournalSidebarSearchListElementComponent',
createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '1234, 5678'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
if (remoteData.payload) {
return fetchParentTitles(remoteData.payload);
}
}
return of([]);
}),
catchError(() => of([])),
map(() => titles),
);
}
};

if (fetchParentTitles(currentParent)) {
return fetchParentTitles(currentParent).pipe(
map(() => titles.join(' > ')),
);
}
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('JournalSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', '1234, 5678');
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -37,6 +46,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('OrgUnitSidebarSearchListElementComponent',
createSidebarSearchListElementTests(OrgUnitSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'description'),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('OrgUnitSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(OrgUnitSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'description');
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -42,7 +51,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('PersonSidebarSearchListElementComponent',
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, 'parent title', 'family name, given name', 'job title', [
]),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('PersonSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'family name,given name', 'job title', []);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
catchError,
Observable,
of,
switchMap,
} from 'rxjs';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Community } from 'src/app/core/shared/community.model';

import { Collection } from '../../../../../core/shared/collection.model';
import { Item } from '../../../../../core/shared/item.model';
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
Expand Down Expand Up @@ -27,6 +36,45 @@ const parent = Object.assign(new Collection(), {
},
});

describe('ProjectSidebarSearchListElementComponent',
createSidebarSearchListElementTests(ProjectSidebarSearchListElementComponent, object, parent, 'parent title', 'title', undefined),
);
function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable<string> {
let titles: string[] = [];
if (obj.indexableObject.metadata['dc.title']) {
titles = [obj.indexableObject.metadata['dc.title'][0].value];
}
let currentParent: Collection = parentObj;

const fetchParentTitles = (currParent: Collection | Community): Observable<string[]> => {
if (!currParent) {
return of([]);
}

if (currParent.parentCommunity) {
return currParent.parentCommunity.pipe(
switchMap((remoteData: RemoteData<Community>) => {
if (remoteData.hasSucceeded && remoteData.payload) {
const parentTitle = remoteData.payload.name;
titles.unshift(parentTitle);
return fetchParentTitles(remoteData.payload);
}
return of([]);
}),
catchError(() => of([])),
);
} else {
return of([]);
}
};

return fetchParentTitles(currentParent).pipe(
switchMap(() => titles.join(' > ')),
);
}

const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object);
if (expectedHierarchicalTitle) {
expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => {
describe('ProjectSidebarSearchListElementComponent', () => {
createSidebarSearchListElementTests(ProjectSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', undefined);
});
});
}
Loading
Loading