Skip to content

Commit 26e50f6

Browse files
[BUGFIX] Fix npe when multiViewAddSource class does not exist (kitodo#1759)
Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
1 parent 4b405d0 commit 26e50f6

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

Configuration/TypoScript/setup.typoscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ page {
6767
kitodo-pageView-searchInDocument = EXT:dlf/Resources/Public/JavaScript/PageView/SearchInDocument.js
6868
kitodo-pageView-pageView = EXT:dlf/Resources/Public/JavaScript/PageView/PageView.js
6969
kitodo-pageView-teiParser = EXT:dlf/Resources/Public/JavaScript/PageView/TeiParser.js
70-
kitodo-pageview-multiViewAddSource = EXT:dlf/Resources/Public/JavaScript/MultiView/MultViewAddSource.js
70+
kitodo-pageview-multiViewAddSource = EXT:dlf/Resources/Public/JavaScript/MultiView/MultiViewAddSource.js
7171
kitodo-search-suggest = EXT:dlf/Resources/Public/JavaScript/Search/Suggester.js
7272
}
7373
}

Resources/Public/JavaScript/MultiView/MultViewAddSource.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
3+
*
4+
* This file is part of the Kitodo and TYPO3 projects.
5+
*
6+
* @license GNU General Public License version 3 or later.
7+
* For the full copyright and license information, please read the
8+
* LICENSE.txt file that was distributed with this source code.
9+
*/
10+
11+
const multiViewAddSource = document.querySelector('.multiViewAddSource');
12+
if (multiViewAddSource) {
13+
document.querySelector('.multiViewAddSource').addEventListener('submit', function (e) {
14+
e.preventDefault();
15+
const url = new URL(window.location.href);
16+
const params = [...url.searchParams.keys()];
17+
const multiview = params.filter(p => p.startsWith("tx_dlf[multiview]"));
18+
if (multiview.length === 0) {
19+
url.searchParams.append("tx_dlf[multiview]", 1);
20+
}
21+
const multiViewSources = params.filter(p => p.startsWith("tx_dlf[multiViewSource]["));
22+
const nextIndex = multiViewSources.length;
23+
const urlValue = document.getElementById('location-field').value.trim();
24+
url.searchParams.append(`tx_dlf[multiViewSource][${nextIndex}]`, urlValue);
25+
// eslint-disable-next-line
26+
window.location.href = url.toString();
27+
});
28+
}

0 commit comments

Comments
 (0)