-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
function collapseNode(node) { | ||
const event = new CustomEvent('click', { | ||
view: window, | ||
bubbles: true, | ||
detail: { system: true }, | ||
}) | ||
setTimeout(() => { | ||
node.dispatchEvent(event) | ||
}, 1) | ||
} | ||
|
||
function updateNodeStatus() { | ||
const buttons = document.querySelectorAll('a.collapse') | ||
buttons.forEach((button) => { | ||
button.addEventListener('click', (event) => { | ||
if (event.detail.system) { | ||
return | ||
} | ||
const buttonId = event.currentTarget.parentElement.parentElement.id | ||
setTimeout(() => { | ||
if (button.classList.contains('expanded')) { | ||
window.localStorage.setItem(`${buttonId}-open`, true) | ||
} else { | ||
window.localStorage.removeItem(`${buttonId}-open`) | ||
} | ||
}, 100) | ||
}) | ||
}) | ||
} | ||
|
||
function expandOpenNodes() { | ||
const rows = document.querySelectorAll('#result_list tr') | ||
rows.forEach((row) => { | ||
const currentRowOpen = window.localStorage.getItem(`${row.id}-open`) | ||
if (currentRowOpen) { | ||
const button = row.querySelector('.collapse') | ||
const event = new MouseEvent('click', { | ||
view: window, | ||
bubbles: true, | ||
}) | ||
setTimeout(() => { | ||
button.dispatchEvent(event) | ||
}, 1) | ||
} | ||
}) | ||
} | ||
|
||
function main() { | ||
const questionnairePage = document.querySelector( | ||
' .app-questionnaire, .model-questionnairestep, .change-list' | ||
) | ||
|
||
if (questionnairePage) { | ||
// Collapse all expanded nodes when the page is loaded | ||
;[...document.querySelectorAll('a.collapse')] | ||
.reverse() | ||
.forEach(collapseNode) | ||
|
||
// Update local storage when the node is expanded | ||
updateNodeStatus() | ||
|
||
// Expand all nodes which are saved as open in the local storage | ||
expandOpenNodes() | ||
} | ||
} | ||
|
||
window.addEventListener('load', main) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './admin/ckeditor' | ||
import './admin/treebeard' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters