3634: If a link has the class "force-cache-reload", then on browser-back the page...
authorPhil Hodgson <bitbucket@philhodgson.net>
Fri, 3 Oct 2014 16:42:27 +0000 (12:42 -0400)
committerPhil Hodgson <bitbucket@philhodgson.net>
Fri, 3 Oct 2014 16:42:27 +0000 (12:42 -0400)
(a modal will be shown to the user while the reload is occurring)

apps/workbench/app/assets/javascripts/application.js
apps/workbench/app/views/application/_content_layout.html.erb
apps/workbench/app/views/application/_loading_modal.html.erb [new file with mode: 0644]
apps/workbench/app/views/application/_title_and_buttons.html.erb

index 567a6d12d0a156868d839b449f830e02d20324cc..9fa37c95763cd78cc32e55fc392f5845bfafea87 100644 (file)
@@ -214,4 +214,26 @@ jQuery(function($){
         $(e.target.href).collapse('toggle');
     });
 
+    $(document).on('click', '.force-cache-reload', function(e) {
+        history.replaceState( { nocache: true }, '' );
+    });
 });
+
+window.addEventListener("DOMContentLoaded", function(e) {
+    if(history.state) {
+        if(history.state.nocache) {
+            console.log('no cache!');
+            showLoadingModal();
+            history.replaceState( {}, '' );
+            location.reload(true);
+        }
+    }
+});
+
+function showLoadingModal() {
+    $('#loading-modal').modal('show');
+}
+
+function hideLoadingModal() {
+    $('#loading-modal').modal('hide');
+}
index 4902332a0f75604ba02aed9a2633ba6d5c5bdda9..ff597d9994ad05663f14d443ef7b56ecdba3969f 100644 (file)
@@ -6,3 +6,5 @@
 </div>
 
 <%= content_for :tab_panes %>
+
+<%= render :partial => 'loading_modal' %>
diff --git a/apps/workbench/app/views/application/_loading_modal.html.erb b/apps/workbench/app/views/application/_loading_modal.html.erb
new file mode 100644 (file)
index 0000000..b8f6888
--- /dev/null
@@ -0,0 +1,12 @@
+<div id="loading-modal" class="modal fade">
+  <div class="modal-dialog">
+       <div class="modal-content">
+         <div class="modal-header">
+           <h3>Refreshing...</h3>
+         </div>
+         <div class="modal-body">
+           <p>Content may have changed.</p>
+         </div>
+       </div>
+  </div>
+</div>
index e1ec160ec14bf96aa0701b43898d4d3132cf6d00..1735478043be8a507ab9a401924ebaa388b23298 100644 (file)
@@ -42,7 +42,7 @@
              selection_param: 'uuid',
              success: 'redirect-to-created-object'
            }.to_json),
-          { class: "btn btn-sm btn-primary", remote: true, method: 'get' }) do %>
+          { class: "btn btn-sm btn-primary force-cache-reload", remote: true, method: 'get' }) do %>
         <i class="fa fa-fw fa-truck"></i> Move to project...
       <% end %>
     <% end %>