Add more old functionality

This commit is contained in:
Stephan Porada
2020-08-28 15:54:48 +02:00
parent 73160c8210
commit 0eda40d0e7
8 changed files with 146 additions and 120 deletions

View File

@ -217,8 +217,24 @@ document.addEventListener("DOMContentLoaded", () => {
'#sub-results-create',
'#full-results-export',
'#sub-results-export',
'#download-results-json'
'#download-results-json',
'#query-results-download-modal',
'#query-results-table'
]);
/**
* The following event Listener handles the add-btn and the inspect-btn
* onclick events via bubbleing.
*/
resultsList.queryResultsTable.addEventListener('click', (event) => {
let dataIndex;
if (event.target.classList.contains('inspect-btn')) {
dataIndex = parseInt(event.target.closest('tr').dataset.index);
resultsList.inspect([dataIndex], 'inspect');
} else if (event.target.classList.contains('add-btn')) {
dataIndex = parseInt(event.target.closest('tr').dataset.index);
resultsList.addToSubResults(dataIndex);
}
})
/**
* Display events: Following event listeners are handleing the
* live update of hits per page if hits per page value is changed and the
@ -234,15 +250,11 @@ document.addEventListener("DOMContentLoaded", () => {
* The following event listener handel the Show metadata button and its
* functionality. Before the needed modal is initialized.
*/
let deleteOverlay = () => {
let overlay = document.querySelector(".modal-overlay");
overlay.remove();
};
resultsList.metaDataModal= M.Modal.init(resultsList.metaDataModal, {
'preventScrolling': false,
'opacity': 0.0,
'dismissible': false,
'onOpenEnd': deleteOverlay
'onOpenEnd': (() => {document.querySelector(".modal-overlay").remove()})
});
resultsList.showMetaData.onclick = () => {
resultsList.metaDataModalContent.textContent = '';
@ -287,27 +299,29 @@ document.addEventListener("DOMContentLoaded", () => {
resultsList.notifyClient('get-results', { resultsType: 'sub-results',
dataIndexes: dataIndexes});
}
/**
* Before the downland events are added the needed modal is initialized.
*/
resultsList.queryResultsDownloadModal = M.Modal.init(resultsList.queryResultsDownloadModal);
// Open download modal when full results export button is pressed
resultsList.fullResultsExport.onclick = () => {
exportModal.open();
resultsList.queryResultsDownloadModal.open();
// add onclick to download JSON button and download the file
let downloadResultsJSONElement = document.querySelector('#download-results-json')
downloadResultsJSONElement.onclick = () => {
let filename = results.fullResultsData.createDownloadFilename('matches-results');
resultsList.downloadResultsJson.onclick = () => {
let filename = results.fullResultsData.createDownloadFilename('full-results');
results.fullResultsData.addData(results.metaData);
results.fullResultsData.downloadJSONRessource(filename, results.resultsData,
downloadResultsJSONElement)};
results.fullResultsData.downloadJSONRessource(filename, results.fullResultsData,
resultsList.downloadResultsJson)};
}
// Open download modal when sub results export button is pressed
resultsList.fullResultsExport.onclick = () => {
exportModal.open();
resultsList.subResultsExport.onclick = () => {
resultsList.queryResultsDownloadModal.open();
// add onclick to download JSON button and download the file
let downloadResultsJSONElement = document.querySelector('#download-results-json')
downloadResultsJSONElement.onclick = () => {
let filename = results.subResultsData.createDownloadFilename('matches-results');
resultsList.downloadResultsJson.onclick = () => {
let filename = results.subResultsData.createDownloadFilename('sub-results');
results.subResultsData.addData(results.metaData);
results.subResultsData.downloadJSONRessource(filename, results.resultsData,
downloadResultsJSONElement)};
results.subResultsData.downloadJSONRessource(filename, results.subResultsData,
resultsList.downloadResultsJson)};
}
// enable scroll to Top