community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1864627 - in /comdev/reporter.apache.org/trunk/site/wizard: css/wizard.css index.html js/source/drafts.js js/source/stepper.js js/source/unified.js js/wizard.js
Date Wed, 07 Aug 2019 15:02:33 GMT
Author: humbedooh
Date: Wed Aug  7 15:02:33 2019
New Revision: 1864627

URL: http://svn.apache.org/viewvc?rev=1864627&view=rev
Log:
Add a 'save checker' that reminds you to save when you have unsaved changes to your report.

At the same time, rework the stepper a bit, to cut down on the number of times we redraw the
helper panel.

Modified:
    comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css
    comdev/reporter.apache.org/trunk/site/wizard/index.html
    comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js
    comdev/reporter.apache.org/trunk/site/wizard/js/source/stepper.js
    comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
    comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js

Modified: comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css?rev=1864627&r1=1864626&r2=1864627&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css Wed Aug  7 15:02:33 2019
@@ -16,6 +16,21 @@ body {
     vertical-align:top;
 }
 
+#unified-saver {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ left: 0;
+ width: 100%;
+ height: 32px;
+ padding: 4px;
+ z-index: 1000;
+ background: #333B;
+ color: #FFF;
+ font-weight: 600;
+ line-height: 24px;
+}
+
 .wizard-step {
     width: 64px !important;
     height: 64px;
@@ -172,6 +187,7 @@ body {
  
 
 #unified-helper {
+  position: relative;
   border-top-right-radius: 5px;
   border-bottom-right-radius: 5px;
   display: inline-block;

Modified: comdev/reporter.apache.org/trunk/site/wizard/index.html
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/index.html?rev=1864627&r1=1864626&r2=1864627&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/index.html (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/index.html Wed Aug  7 15:02:33 2019
@@ -13,8 +13,8 @@
 
 <title>ASF Board Report Wizard</title>
 <link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/selawik" type="text/css"/>

-<link rel="stylesheet" href="css/wizard.css?unified-1.0"/>
-<link rel="stylesheet" href="highlighter/highlighter.css?unified-1.0"/>
+<link rel="stylesheet" href="css/wizard.css?unified-1.1"/>
+<link rel="stylesheet" href="highlighter/highlighter.css?unified-1.1"/>
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
 </head>
 <body onload="init_wizard(false);">
@@ -62,7 +62,7 @@
 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
 <script src="highlighter/highlighter.js" type="text/javascript"></script>
-<script src="js/wizard.js" type="text/javascript"></script>
+<script src="js/wizard.js?unified-1.1" type="text/javascript"></script>
 </body>
 </html>
 

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js?rev=1864627&r1=1864626&r2=1864627&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js Wed Aug  7 15:02:33 2019
@@ -31,6 +31,7 @@ function draft_saved(state, json) {
     document.getElementById("pname").style.display = 'block';
     
     if (json.filename) {
+        draft_stepper.editor.check_changes(true);
         modal("Draft was saved in the reporter database as <kbd>%s</kbd>. You
can revisit this draft at any time by loading it from the base data tab. Drafts are kept for
up to two months.".format(json.filename));
         let obj = {
           yours: true,
@@ -55,6 +56,7 @@ function read_draft(state, json) {
         draft_stepper.editor.report = json.report;
         window.setTimeout(() => { draft_stepper.editor.highlight() }, 250);
         draft_stepper.build(0, false, false);
+        draft_stepper.editor.check_changes(true);
         modal("Draft was successfully loaded and is ready.");
     } else {
         modal("Could not load report draft :/");
@@ -159,6 +161,7 @@ function report_published(state, json) {
   
   if (json && json.okay) {
     modal("Your report was successfully posted to the board agenda!");
+    draft_stepper.editor.check_changes(true);
   } else {
     modal("Something went wrong, and we couldn't publish your report.<br/>Please check
with the Whimsy tool to see if there is already a report posted!");
   }

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/stepper.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/stepper.js?rev=1864627&r1=1864626&r2=1864627&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/stepper.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/stepper.js Wed Aug  7 15:02:33
2019
@@ -29,10 +29,14 @@ function ReportStepper(div, editor, layo
         
         if (start) {
             this.editor.reset();
+            this.editor.report_saved = this.editor.report;
         }
         
         
         if (this.changed) this.editor.highlight();
+        // skip building if nothing changed
+        if (!this.changed && !start && this.editor.report == this.editor.last_cursor_report)
return;
+        this.editor.last_cursor_report = this.editor.report;
         
         // build the step div
         this.object.innerHTML = '';

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js?rev=1864627&r1=1864626&r2=1864627&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js Wed Aug  7 15:02:33
2019
@@ -65,6 +65,7 @@ function UnifiedEditor_highlight_section
             );
         $(this.object).focus();
     }
+    
 }
 
 
@@ -158,6 +159,8 @@ function UnifiedEditor_parse_report(quie
       }
       
     }
+    
+    this.check_changes();
 }
 
 
@@ -269,6 +272,27 @@ function UnifiedEditor_compile() {
     return text;
 }
 
+function UnifiedEditor_check_changes(force) {
+    if (force) {
+        this.report_saved = this.report;
+    }
+    let saver = document.getElementById('unified-saver');
+    if (!saver && this.stepper && this.stepper.helper) {
+        saver = new HTML('div', {id: 'unified-saver'});
+        this.stepper.helper.inject(saver);
+    }
+    if (this.report != this.report_saved) {
+        if (saver) {
+            saver.innerText = "Current changes not saved yet - ";
+            let btn = new HTML('button', { onclick: 'save_draft();', class: 'btn btn-warning
btn-sm'}, 'Save draft');
+            saver.inject(btn);
+            saver.style.display = 'inline-block';
+        }
+    } else if (saver) {
+        saver.style.display = 'none';
+    }
+}
+
 
 // This is the Unfied Editor for reports.
 function UnifiedEditor(div, layout) {
@@ -294,6 +318,7 @@ function UnifiedEditor(div, layout) {
     this.reset = UnifiedEditor_reset;
     this.find_section = UnifiedEditor_find_section;
     this.compile = UnifiedEditor_compile;
+    this.check_changes = UnifiedEditor_check_changes;
     
     // set div events
     this.object.addEventListener('keyup', () => { this.find_section(true); });

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js?rev=1864627&r1=1864626&r2=1864627&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js Wed Aug  7 15:02:33 2019
@@ -1046,6 +1046,7 @@ function draft_saved(state, json) {
     document.getElementById("pname").style.display = 'block';
     
     if (json.filename) {
+        draft_stepper.editor.check_changes(true);
         modal("Draft was saved in the reporter database as <kbd>%s</kbd>. You
can revisit this draft at any time by loading it from the base data tab. Drafts are kept for
up to two months.".format(json.filename));
         let obj = {
           yours: true,
@@ -1070,6 +1071,7 @@ function read_draft(state, json) {
         draft_stepper.editor.report = json.report;
         window.setTimeout(() => { draft_stepper.editor.highlight() }, 250);
         draft_stepper.build(0, false, false);
+        draft_stepper.editor.check_changes(true);
         modal("Draft was successfully loaded and is ready.");
     } else {
         modal("Could not load report draft :/");
@@ -1174,6 +1176,7 @@ function report_published(state, json) {
   
   if (json && json.okay) {
     modal("Your report was successfully posted to the board agenda!");
+    draft_stepper.editor.check_changes(true);
   } else {
     modal("Something went wrong, and we couldn't publish your report.<br/>Please check
with the Whimsy tool to see if there is already a report posted!");
   }
@@ -3141,10 +3144,14 @@ function ReportStepper(div, editor, layo
         
         if (start) {
             this.editor.reset();
+            this.editor.report_saved = this.editor.report;
         }
         
         
         if (this.changed) this.editor.highlight();
+        // skip building if nothing changed
+        if (!this.changed && !start && this.editor.report == this.editor.last_cursor_report)
return;
+        this.editor.last_cursor_report = this.editor.report;
         
         // build the step div
         this.object.innerHTML = '';
@@ -3308,6 +3315,7 @@ function UnifiedEditor_highlight_section
             );
         $(this.object).focus();
     }
+    
 }
 
 
@@ -3401,6 +3409,8 @@ function UnifiedEditor_parse_report(quie
       }
       
     }
+    
+    this.check_changes();
 }
 
 
@@ -3512,6 +3522,27 @@ function UnifiedEditor_compile() {
     return text;
 }
 
+function UnifiedEditor_check_changes(force) {
+    if (force) {
+        this.report_saved = this.report;
+    }
+    let saver = document.getElementById('unified-saver');
+    if (!saver && this.stepper && this.stepper.helper) {
+        saver = new HTML('div', {id: 'unified-saver'});
+        this.stepper.helper.inject(saver);
+    }
+    if (this.report != this.report_saved) {
+        if (saver) {
+            saver.innerText = "Current changes not saved yet - ";
+            let btn = new HTML('button', { onclick: 'save_draft();', class: 'btn btn-warning
btn-sm'}, 'Save draft');
+            saver.inject(btn);
+            saver.style.display = 'inline-block';
+        }
+    } else if (saver) {
+        saver.style.display = 'none';
+    }
+}
+
 
 // This is the Unfied Editor for reports.
 function UnifiedEditor(div, layout) {
@@ -3537,6 +3568,7 @@ function UnifiedEditor(div, layout) {
     this.reset = UnifiedEditor_reset;
     this.find_section = UnifiedEditor_find_section;
     this.compile = UnifiedEditor_compile;
+    this.check_changes = UnifiedEditor_check_changes;
     
     // set div events
     this.object.addEventListener('keyup', () => { this.find_section(true); });



Mime
View raw message