mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	Rework query_results/inspect template to load listeners from view listeners.
This commit is contained in:
		@@ -100,20 +100,19 @@ import {
 | 
			
		||||
} from '../../static/js/modules/corpus_analysis/view/ResultsView.js';
 | 
			
		||||
// Import listener which will be registered to the ViewEventListener class.
 | 
			
		||||
import {
 | 
			
		||||
  // listener listening for client dispatched 'notify-vie' custom event.
 | 
			
		||||
  recieveClientNotification,
 | 
			
		||||
} from '../../static/js/modules/corpus_analysis/view/listeners.js';
 | 
			
		||||
import {
 | 
			
		||||
  scrollToTop,
 | 
			
		||||
} from '../../static/js/modules/corpus_analysis/view/scrollToTop.js'
 | 
			
		||||
// vanilla javascript Event listeners which are listening for button clicks etc
 | 
			
		||||
import {
 | 
			
		||||
  // vanilla javascript Event listeners which are listening for button clicks.
 | 
			
		||||
  pageNavigation,
 | 
			
		||||
  expertModeSwitch,
 | 
			
		||||
  actionButtons,
 | 
			
		||||
  displayOptions,
 | 
			
		||||
  showMetaData,
 | 
			
		||||
  showCorpusFiles,
 | 
			
		||||
} from '../../static/js/modules/corpus_analysis/view/eventListeners.js';
 | 
			
		||||
} from '../../static/js/modules/corpus_analysis/view/listeners.js';
 | 
			
		||||
import {
 | 
			
		||||
  scrollToTop,
 | 
			
		||||
} from '../../static/js/modules/corpus_analysis/view/scrollToTop.js'
 | 
			
		||||
/**
 | 
			
		||||
 * Second Phase:
 | 
			
		||||
 * Asynchronus and event driven code.
 | 
			
		||||
@@ -162,9 +161,11 @@ document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
   */
 | 
			
		||||
  const listenForClientNotification = new ViewEventListener('notify-view',
 | 
			
		||||
                                                            recieveClientNotification);
 | 
			
		||||
  resultsList.setViewEventListeners([listenForClientNotification]);
 | 
			
		||||
  resultsList.loadViewEventListeners();
 | 
			
		||||
  // Get all needed HTMLElements for the following event listeners.
 | 
			
		||||
  /**
 | 
			
		||||
   * Register vanilla Javascript events to the resultList listening for button
 | 
			
		||||
   * clicks etc. done by the user.
 | 
			
		||||
   * Get all needed HTMLElements for those event listeners before.
 | 
			
		||||
   */
 | 
			
		||||
  resultsList.getHTMLElements([
 | 
			
		||||
    '.add-btn',
 | 
			
		||||
    '.pagination',
 | 
			
		||||
@@ -196,6 +197,36 @@ document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
    '#sub-results-create',
 | 
			
		||||
    '#sub-results-export',
 | 
			
		||||
  ]);
 | 
			
		||||
  let args = [resultsList, results, client];
 | 
			
		||||
  const listenForPageNavigation = new ViewEventListener('page-navigation',
 | 
			
		||||
                                                         pageNavigation,
 | 
			
		||||
                                                         args);
 | 
			
		||||
  const listenForExpertModeSwitch = new ViewEventListener('expert-mode',
 | 
			
		||||
                                                          expertModeSwitch,
 | 
			
		||||
                                                          args);
 | 
			
		||||
  const listenForActionButtons = new ViewEventListener('action-buttons',
 | 
			
		||||
                                                       actionButtons,
 | 
			
		||||
                                                       args);
 | 
			
		||||
  const listenForDisplayOptions = new ViewEventListener('display-otions',
 | 
			
		||||
                                                         displayOptions,
 | 
			
		||||
                                                         args);
 | 
			
		||||
  const listenForShowMetaData = new ViewEventListener('show-meta-data',
 | 
			
		||||
                                                         showMetaData,
 | 
			
		||||
                                                         args);
 | 
			
		||||
  const listenForShowCorpusFiles = new ViewEventListener('show-corpus-files',
 | 
			
		||||
                                                         showCorpusFiles,
 | 
			
		||||
                                                         args);
 | 
			
		||||
  // Set and load defined listeners
 | 
			
		||||
  resultsList.setViewEventListeners([
 | 
			
		||||
    listenForClientNotification,
 | 
			
		||||
    listenForPageNavigation,
 | 
			
		||||
    listenForExpertModeSwitch,
 | 
			
		||||
    listenForActionButtons,
 | 
			
		||||
    listenForDisplayOptions,
 | 
			
		||||
    listenForShowMetaData,
 | 
			
		||||
    listenForShowCorpusFiles,
 | 
			
		||||
  ]);
 | 
			
		||||
  resultsList.loadViewEventListeners();
 | 
			
		||||
  // Hide buttons which are not needed when just inspecting results
 | 
			
		||||
  resultsList.inspectResultsExport.classList.add('hide');
 | 
			
		||||
  // Execute client event listener callbacks manually because dynamicMode is false
 | 
			
		||||
@@ -203,14 +234,6 @@ document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
  // Save meta data to results after the init callback from line above
 | 
			
		||||
  results.metaData = metaDataJson;
 | 
			
		||||
  client.eventListeners['corpus_analysis_query_results'].executeCallbacks([resultsJson]);
 | 
			
		||||
 | 
			
		||||
  // Call the vanilla event listeners listening for clicks etc. from the user.
 | 
			
		||||
  pageNavigation(resultsList, results, client);
 | 
			
		||||
  expertModeSwitch(resultsList, results);
 | 
			
		||||
  actionButtons(resultsList, results, client);
 | 
			
		||||
  displayOptions(resultsList, results, client);
 | 
			
		||||
  showMetaData(resultsList, results);
 | 
			
		||||
  showCorpusFiles(resultsList, results);
 | 
			
		||||
  // Enable scroll to Top functionality.
 | 
			
		||||
  scrollToTop('#headline', '#menu-scroll-to-top-div');
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user