Refresh corpus statistic by clicking at statistic button - fixes #107

Change-Id: I2b73529d495028017c789b633f69aa28f74ef16d
diff --git a/dev/js/spec/statSpec.js b/dev/js/spec/statSpec.js
index fbb41a1..d5be4d8 100644
--- a/dev/js/spec/statSpec.js
+++ b/dev/js/spec/statSpec.js
@@ -424,6 +424,29 @@
         expect(checkStatActive(view,show)).toBe(true);
       });
       
+      it ('should refresh a disabled corpus statistic if statistic button is clicked', function(){
+        
+        KorAP.vc = generateCorpusDocGr();  
+        
+        //Show corpus statistic
+        let show = document.createElement('div');
+        show.appendChild(KorAP.vc.element());
+        let panel = show.firstChild.lastChild.firstChild;
+        let statbut =  panel.lastChild.children[0];
+        statbut.click();
+        let view = panel.firstChild.firstChild;
+        
+        //corpus statistic is active
+        expect(checkStatActive(view, show)).toBe(true);
+        
+        //change vc, a line in vc builder is deleted
+        KorAP._delete.apply(KorAP.vc.root().getOperand(0));
+        expect(checkStatDisabled(view,show)).toBe(true);
+        
+        //click at statistic button
+        statbut.click();
+        expect(checkStatActive(view,show)).toBe(true);
+      });
       
       it('should disable corpus statistic if entries in vc builder are deleted', function(){
         KorAP.vc = generateCorpusDocGr();
diff --git a/dev/js/src/panel/vc.js b/dev/js/src/panel/vc.js
index 91fb544..39deef5 100644
--- a/dev/js/src/panel/vc.js
+++ b/dev/js/src/panel/vc.js
@@ -40,12 +40,23 @@
      * Add corpus statistic view to panel
      */
     addCorpStat: function(){
+      
+      //Refreshes corpus statistic
+      if(this.statView !== undefined &&  this.statView.shown()){
+        let statt = this.statView.show();
+        if (statt.classList.contains('stdisabled')){
+          this.reloadCorpStat(); 
+          statt.classList.remove('stdisabled');
+        }
+      }
+      
+      //Add corpus statistic
       if (this.statView === undefined || !this.statView.shown()) {
         this.statView = corpStatVClass.create(this.vc, this);
         this.add(this.statView);
         this.vc.oldvcQuery = KorAP.vc.toQuery();
       }
-
+      
     },
     
     /**