Skip to content

Commit c8e7950

Browse files
committed
Fix public gallery link for records
The public gallery links were not generating correctly, because the endpoint for getting the record has changed and the property used to create it, ParentFolderVOs, is not present anymore. In order to create the record links, parent properties present on the record object can be used. One exception is, the link for records that are in the root folder will have 2 extra parameters, but they will work. Issue: PER-10348 Get public gallery link not working for individual records
1 parent fa260c0 commit c8e7950

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/app/models/record-vo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export class RecordVO
103103
public parentFolder_linkId;
104104
public ParentFolderVOs;
105105
public parentArchiveNbr: string;
106+
public parentFolderArchiveNumber: string;
106107
public parentDisplayName: string;
107108
public pathAsArchiveNbr;
108109
public files: PermanentFile[];
@@ -217,6 +218,7 @@ export interface RecordVOData extends BaseVOData {
217218
pathAsFolder_linkId?: any;
218219
pathAsText?: any;
219220
parentFolder_linkId?: any;
221+
parentFolderArchiveNumber?: any;
220222
ParentFolderVOs?: any;
221223
parentArchiveNbr?: any;
222224
parentDisplayName?: string;

src/app/shared/pipes/public-route.pipe.spec.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ describe('PublicRoutePipe', () => {
5454
]);
5555
});
5656

57+
it('returns correct link for record with no ParentFolderVOs defined', () => {
58+
const record = new RecordVO({
59+
parentFolder_linkId: 1234,
60+
parentFolderArchiveNumber: '0001-meow',
61+
folder_linkId: 1001,
62+
archiveNbr: '0001-00gp',
63+
});
64+
const route = pipe.transform(record);
65+
66+
expect(route).toBeDefined();
67+
expect(route).toEqual([
68+
'/p',
69+
'archive',
70+
'0001-0000',
71+
'0001-meow',
72+
1234,
73+
'record',
74+
record.archiveNbr,
75+
]);
76+
});
77+
5778
it('returns correct link for record in the public root folder', () => {
5879
const record = new RecordVO({
5980
ParentFolderVOs: [
@@ -78,6 +99,34 @@ describe('PublicRoutePipe', () => {
7899
]);
79100
});
80101

102+
it('returns link for record in the public root folder, even if there is no ParentFolderVOs defined', () => {
103+
const record = new RecordVO({
104+
ParentFolderVOs: [
105+
new FolderVO({
106+
archiveNbr: 'do-not-use',
107+
folder_linkId: -1,
108+
folder_linkType: 'type.folder_link.root.public',
109+
type: 'type.folder.root.public',
110+
}),
111+
],
112+
parentFolderArchiveNumber: '1234-000d',
113+
parentFolder_linkId: 987,
114+
folder_linkId: 1001,
115+
archiveNbr: '1234-5678',
116+
});
117+
const route = pipe.transform(record);
118+
119+
expect(route).toEqual([
120+
'/p',
121+
'archive',
122+
'1234-0000',
123+
'1234-000d',
124+
987,
125+
'record',
126+
'1234-5678',
127+
]);
128+
});
129+
81130
it('uses the archiveArchiveNbr field to get the archive an item is located in', () => {
82131
const route = pipe.transform(
83132
new FolderVO({

src/app/shared/pipes/public-route.pipe.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export class PublicRoutePipe implements PipeTransform {
1616
parentFolder.archiveNbr,
1717
parentFolder.folder_linkId.toString(),
1818
);
19+
} else if (
20+
value.parentFolderArchiveNumber &&
21+
value.parentFolder_linkId &&
22+
rootArchive !== value.parentFolderArchiveNumber
23+
) {
24+
route.push(value.parentFolderArchiveNumber, value.parentFolder_linkId);
1925
}
2026
route.push('record', value.archiveNbr);
2127
return route;

0 commit comments

Comments
 (0)