diff --git a/app/components/submissions-repoid-cell/index.js b/app/components/submissions-repoid-cell/index.js
index 649f04b8..d2261453 100644
--- a/app/components/submissions-repoid-cell/index.js
+++ b/app/components/submissions-repoid-cell/index.js
@@ -9,8 +9,6 @@ export default class SubmissionsRepoidCell extends Component {
@tracked repoCopies = null;
- jscholarshipCheckString = '/handle/';
-
@action
async setUpRepoidCell() {
const publication = await this.args.record.publication;
@@ -50,6 +48,24 @@ export default class SubmissionsRepoidCell extends Component {
}
}
+ /**
+ * Format a repository ID for display.
+ * If the ID includes one of the markers, return the ID after the marker
+ * This deals with DSpace handle and item URLs.
+ */
+ formatId(id) {
+ const markers = ['/handle/', '/items/'];
+
+ for (let marker of markers) {
+ let index = id.indexOf(marker);
+ if (index !== -1) {
+ return id.slice(index + marker.length);
+ }
+ }
+
+ return id;
+ }
+
/**
* Formatted:
* [
@@ -73,14 +89,10 @@ export default class SubmissionsRepoidCell extends Component {
return rc
.filter((repoCopy) => !!repoCopy.externalIds)
.map((repoCopy) => {
- const check = this.jscholarshipCheckString;
-
- // If an ID has the 'check' string, only display the sub-string after the 'check' string
let ids = repoCopy.externalIds.map((id) => {
- // eslint-disable-line
return {
title: id,
- display: id.includes(check) ? id.slice(id.indexOf(check) + check.length) : id,
+ display: this.formatId(id),
};
});
return {
diff --git a/tests/integration/components/submissions-repoid-cell-test.js b/tests/integration/components/submissions-repoid-cell-test.js
index eb37a01a..32ba3325 100644
--- a/tests/integration/components/submissions-repoid-cell-test.js
+++ b/tests/integration/components/submissions-repoid-cell-test.js
@@ -13,7 +13,19 @@ module('Integration | Component | submissions repoid cell', (hooks) => {
// Inject mocked store that on query returns a single user
hooks.beforeEach(function () {
let store = Service.extend({
- query: (type, q) => Promise.resolve([EmberObject.create({ id: 'test' })]),
+ query: (type, q) =>
+ Promise.resolve([
+ EmberObject.create({
+ id: 'test',
+ accessUrl: 'https://dspace.example.com/handle/12345/67890',
+ externalIds: ['https://dspace.example.com/handle/12345/67890'],
+ }),
+ EmberObject.create({
+ id: 'test2',
+ accessUrl: 'https://dspace.example.com/items/abcde-12345',
+ externalIds: ['https://dspace.example.com/items/abcde-12345'],
+ }),
+ ]),
});
run(() => {
@@ -69,4 +81,32 @@ module('Integration | Component | submissions repoid cell', (hooks) => {