From 4241c13e13d5c7519c18c58b021f33b07869d6de Mon Sep 17 00:00:00 2001
From: Stephan Porada <sporada@uni-bielefeld.de>
Date: Wed, 7 Oct 2020 14:48:47 +0200
Subject: [PATCH] Some small fixes

---
 .../modules/corpus_analysis/client/Client.js  |  2 +-
 .../corpus_analysis/client/callbacks.js       |  2 +-
 .../modules/corpus_analysis/model/Results.js  | 12 +++++------
 .../corpus_analysis/view/ResultsView.js       |  9 ---------
 .../modules/corpus_analysis/view/callbacks.js |  2 +-
 .../corpus_analysis/view/eventListeners.js    | 15 +++++++-------
 .../templates/corpora/analyse_corpus.html.j2  |  1 +
 web/app/templates/interactions/infos.html.j2  | 20 +++++++++----------
 8 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/web/app/static/js/modules/corpus_analysis/client/Client.js b/web/app/static/js/modules/corpus_analysis/client/Client.js
index 2d94121f..bd1ac2ee 100644
--- a/web/app/static/js/modules/corpus_analysis/client/Client.js
+++ b/web/app/static/js/modules/corpus_analysis/client/Client.js
@@ -127,7 +127,7 @@ class Client {
       objectKey = 'fullResultsData';
     } else if (resultsType === 'sub-results') {
       objectKey = 'subResultsData';
-    } else if (resultsType = 'inspect-results') {
+    } else if (resultsType === 'inspect-results') {
       objectKey = 'inspectResultsData';
     }
     // Delete old data before new data is coming in.
diff --git a/web/app/static/js/modules/corpus_analysis/client/callbacks.js b/web/app/static/js/modules/corpus_analysis/client/callbacks.js
index 74207478..52d5d61a 100644
--- a/web/app/static/js/modules/corpus_analysis/client/callbacks.js
+++ b/web/app/static/js/modules/corpus_analysis/client/callbacks.js
@@ -123,8 +123,8 @@ function saveResultsData() {
   // Notify view to update progress bar
   client.notifyView('results-data-recieving', {type: type,
     progress: payload.progress})
-  client.isBusy = false;
   if (payload.progress === 100) {
+    client.isBusy = false;
     if (objectKey === 'fullResultsData') {
       // Get match count per text from results.data only for fullResultsData
       results[objectKey].text_lookup = results.data.text_lookup;
diff --git a/web/app/static/js/modules/corpus_analysis/model/Results.js b/web/app/static/js/modules/corpus_analysis/model/Results.js
index 41dc319d..2d1ab7df 100644
--- a/web/app/static/js/modules/corpus_analysis/model/Results.js
+++ b/web/app/static/js/modules/corpus_analysis/model/Results.js
@@ -7,12 +7,12 @@
 // Results class bundleing the different data objects.
 class Results {
   constructor() {
-  this.data = new Data();
-  this.metaData = new MetaData();
-  this.fullResultsData = new Data();
-  this.subResultsData = new Data();
-  this.inspectResultsData = new Data();
-  console.info('Initialized the Results object.');
+    this.data = new Data();
+    this.metaData = new MetaData();
+    this.fullResultsData = new Data();
+    this.subResultsData = new Data();
+    this.inspectResultsData = new Data();
+    console.info('Initialized the Results object.');
   }
 
   // Reset all the data objects in the results class and thus emptying them.
diff --git a/web/app/static/js/modules/corpus_analysis/view/ResultsView.js b/web/app/static/js/modules/corpus_analysis/view/ResultsView.js
index 6fc440f9..b799ff2b 100644
--- a/web/app/static/js/modules/corpus_analysis/view/ResultsView.js
+++ b/web/app/static/js/modules/corpus_analysis/view/ResultsView.js
@@ -58,20 +58,11 @@ class ResultsList extends List {
     this.notificationListeners = {};
     this.knownHTMLElements = new Set();
   }
-
-  /**
-   * // TODO:
-   * Init function that gets all needed HTML Elements. Implement this, or not?
-   * Or build a check into the get HTMLElements function if element already exists.
-   * Also think about saving alle elements in resultsList.es.nameOfElement
-   */
-
   /**
    * Function to clear/reset some class field values. Usefull if a new query
    * hase been issued by the user.
    */
   resetFields() {
-    this.addToSubResultsIdsToShow = new Set();
     this.addToSubResultsStatus = {};
     this.subResultsIndexes = {};
   }
diff --git a/web/app/static/js/modules/corpus_analysis/view/callbacks.js b/web/app/static/js/modules/corpus_analysis/view/callbacks.js
index a29143d7..6090ad49 100644
--- a/web/app/static/js/modules/corpus_analysis/view/callbacks.js
+++ b/web/app/static/js/modules/corpus_analysis/view/callbacks.js
@@ -82,7 +82,7 @@ function queryDataPreparingCallback(resultsList, detail) {
     '#query-results-create',
     '#sub-results-indexes-display',
     '#nr-marked-matches',
-   ]);
+  ]);
   // show or enable some things for the user
   resultsList.interactionsMenu.classList.toggle('hide', false);
   resultsList.queryResultsUserFeedback.classList.toggle('hide', false);
diff --git a/web/app/static/js/modules/corpus_analysis/view/eventListeners.js b/web/app/static/js/modules/corpus_analysis/view/eventListeners.js
index 6c40cafc..23165057 100644
--- a/web/app/static/js/modules/corpus_analysis/view/eventListeners.js
+++ b/web/app/static/js/modules/corpus_analysis/view/eventListeners.js
@@ -181,13 +181,13 @@ function createFullResults(resultsList, results) {
     resultsList.fullResultsCreate.innerText = 'Creating...';
     resultsList.fullResultsCreate.insertAdjacentHTML('afterbegin',
                                                       loadingSpinnerHTML);
+    // .keys() is for a zero based array. I think...
     let dataIndexes = [...Array(results.data.match_count).keys()];
     // Empty fullResultsData so that no previous data is used.
     results.fullResultsData.init();
-    resultsList.notifyClient('get-results', { resultsType: 'full-results',
-                                              dataIndexes: dataIndexes,
-                                              resultsList: resultsList,
-                                            });
+    resultsList.notifyClient('get-results', {resultsType: 'full-results',
+                                             dataIndexes: dataIndexes,
+                                             resultsList: resultsList,});
   }
 }
 
@@ -204,10 +204,9 @@ function createSubResults(resultsList, results) {
                                                      loadingSpinnerHTML);
     // Empty subResultsData so that no previous data is used.
     results.subResultsData.init();
-    resultsList.notifyClient('get-results', { resultsType: 'sub-results',
-                                              dataIndexes: dataIndexes,
-                                              resultsList: resultsList,
-                                            });
+    resultsList.notifyClient('get-results', {resultsType: 'sub-results',
+                                             dataIndexes: dataIndexes,
+                                             resultsList: resultsList,});
   }
 }
 // 3. Open download modal when full results export button is pressed
diff --git a/web/app/templates/corpora/analyse_corpus.html.j2 b/web/app/templates/corpora/analyse_corpus.html.j2
index 1ee776d4..7681495d 100644
--- a/web/app/templates/corpora/analyse_corpus.html.j2
+++ b/web/app/templates/corpora/analyse_corpus.html.j2
@@ -43,6 +43,7 @@
     <div class="card-content" id="result-list" style="overflow: hidden;">
       <div id="interactions-menu" class="row hide"
            style="margin-bottom: 0px;">
+        {# Importing menus for query settings, export etc. #}
         {% include 'interactions/infos.html.j2' %}
         {% include 'interactions/export.html.j2' %}
         {% include 'interactions/create.html.j2' %}
diff --git a/web/app/templates/interactions/infos.html.j2 b/web/app/templates/interactions/infos.html.j2
index 47e94d8f..7a9eafe8 100644
--- a/web/app/templates/interactions/infos.html.j2
+++ b/web/app/templates/interactions/infos.html.j2
@@ -6,16 +6,6 @@ result.-->
   <h6 style="margin-top: 0px;">Infos</h6>
   <div class="divider" style="margin-bottom: 10px;"></div>
   <div class="row">
-    <div class="col s12">
-      <button id="show-meta-data"
-              class="waves-effect
-                     waves-light
-                     btn-flat
-                     flat-interaction"
-              type="submit">Corpus Meta Data
-        <i class="material-icons left">info_outline</i>
-      </button>
-    </div>
     <div class="col s12">
       <button id="loading-matches"
               class="waves-effect
@@ -36,6 +26,16 @@ result.-->
         <div class="determinate"></div>
       </div>
     </div>
+    <div class="col s12">
+      <button id="show-meta-data"
+              class="waves-effect
+                     waves-light
+                     btn-flat
+                     flat-interaction"
+              type="submit">Corpus Meta Data
+        <i class="material-icons left">info_outline</i>
+      </button>
+    </div>
     <div class="col s12">
       <button id="show-corpus-files"
               class="waves-effect
-- 
GitLab