Merge branch 'master' into 3634-tab-state
authorPhil Hodgson <bitbucket@philhodgson.net>
Mon, 6 Oct 2014 18:53:08 +0000 (14:53 -0400)
committerPhil Hodgson <bitbucket@philhodgson.net>
Mon, 6 Oct 2014 18:53:08 +0000 (14:53 -0400)
Conflicts (resolved):
apps/workbench/app/views/application/_title_and_buttons.html.erb

apps/workbench/Gemfile
apps/workbench/Gemfile.lock
apps/workbench/app/assets/javascripts/application.js
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/views/application/_content.html.erb
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 46d017e1840b5d22b3c47b84c1ef3e504433d9c0..a20e4e6ccf79dfea4c64669b4715ef6b08cbf28f 100644 (file)
@@ -49,6 +49,7 @@ end
 gem 'jquery-rails'
 gem 'bootstrap-sass', '~> 3.1.0'
 gem 'bootstrap-x-editable-rails'
+gem 'bootstrap-tab-history-rails'
 
 gem 'less'
 gem 'less-rails'
index a676e54f631c4755e5395dfa38c9f20c6389d159..301ef926669ad9f6f00e15a7a581570b96c0121e 100644 (file)
@@ -51,6 +51,8 @@ GEM
       multi_json (>= 1.0.0)
     bootstrap-sass (3.1.0.1)
       sass (~> 3.2)
+    bootstrap-tab-history-rails (0.1.0)
+      railties (>= 3.1)
     bootstrap-x-editable-rails (1.5.1.1)
       railties (>= 3.0)
     builder (3.2.2)
@@ -234,6 +236,7 @@ DEPENDENCIES
   andand
   arvados (>= 0.1.20140917180103)
   bootstrap-sass (~> 3.1.0)
+  bootstrap-tab-history-rails
   bootstrap-x-editable-rails
   capybara
   coffee-rails
index 39e8cf96eac5b9e8cfbb886451931f45eb545bac..a23a6d488045be7bc297aa217626e9d60cf23c02 100644 (file)
@@ -21,6 +21,7 @@
 //= require bootstrap/modal
 //= require bootstrap/button
 //= require bootstrap3-editable/bootstrap-editable
+//= require bootstrap-tab-history
 //= require wiselinks
 //= require_tree .
 
@@ -213,4 +214,25 @@ 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) {
+            showLoadingModal();
+            history.replaceState( {}, '' );
+            location.reload(true);
+        }
+    }
+});
+
+function showLoadingModal() {
+    $('#loading-modal').modal('show');
+}
+
+function hideLoadingModal() {
+    $('#loading-modal').modal('hide');
+}
index 0313111ab9e1f34e75b530b396846111fcc9f568..4f5d8fdcd20d8776643bfbc8f1902b876a8df0ba 100644 (file)
@@ -12,6 +12,7 @@ class ApplicationController < ActionController::Base
   # Methods that don't require login should
   #   skip_around_filter :require_thread_api_token
   around_filter :require_thread_api_token, except: ERROR_ACTIONS
+  before_filter :set_cache_buster
   before_filter :accept_uuid_as_id_param, except: ERROR_ACTIONS
   before_filter :check_user_agreements, except: ERROR_ACTIONS
   before_filter :check_user_profile, except: ERROR_ACTIONS
@@ -31,6 +32,12 @@ class ApplicationController < ActionController::Base
                 with: :render_exception)
   end
 
+  def set_cache_buster
+    response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
+    response.headers["Pragma"] = "no-cache"
+    response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
+  end
+
   def unprocessable(message=nil)
     @errors ||= []
 
index e37225ce80c6082fe13e40367282f710795508af..e9fec776de337ec588584c5715c99ef4c9bfa8d5 100644 (file)
@@ -2,30 +2,34 @@
 
   <% comparable = controller.respond_to? :compare %>
 
-<ul class="nav nav-tabs" data-tab-counts-url="<%= url_for(action: :tab_counts) rescue '' %>">
-  <% pane_list.each_with_index do |pane, i| %>
-    <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
-    <li class="<%= 'active' if i==0 %>">
-      <a href="#<%= pane_name %>" data-toggle="tab"
-         class="pane-anchor"
-         id="<%= pane_name %>-tab"
-         data-pane-content-url="<%= url_for(params.merge(tab_pane: pane)) %>">
-        <%= pane_name.gsub('_', ' ') %> <span id="<%= pane_name %>-count"></span>
-      </a>
-    </li>
-  <% end %>
-</ul>
-<div class="tab-content">
-<% pane_list.each_with_index do |pane, i| %>
+  <ul class="nav nav-tabs" data-tab-counts-url="<%= url_for(action: :tab_counts) rescue '' %>">
+    <% pane_list.each_with_index do |pane, i| %>
       <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
-  <div id="<%= pane_name %>"
-       class="tab-pane fade <%= 'in active loaded' if i==0 %> arv-log-event-listener"
-<% if controller.action_name == "index" %>
-       data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
-<% else %>
-       data-object-uuid="<%= @object.uuid %>"
-<% end %>
-  >
+      <li class="<%= 'active' if i==0 %>">
+        <a href="#<%= pane_name %>"
+           class="pane-anchor"
+           id="<%= pane_name %>-tab"
+           data-toggle="tab"
+           data-tab-history=true
+           data-tab-history-update-url=true
+           data-pane-content-url="<%= url_for(params.merge(tab_pane: pane_name)) %>">
+          <%= pane_name.gsub('_', ' ') %> <span id="<%= pane_name %>-count"></span>
+        </a>
+      </li>
+    <% end %>
+  </ul>
+
+  <div class="tab-content">
+    <% pane_list.each_with_index do |pane, i| %>
+      <% pane_name = (pane.is_a?(Hash) ? pane[:name] : pane) %>
+      <div id="<%= pane_name %>"
+           class="tab-pane fade <%= 'in active loaded' if i==0 %> arv-log-event-listener"
+           <% if controller.action_name == "index" %>
+             data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
+           <% else %>
+             data-object-uuid="<%= @object.uuid %>"
+           <% end %>
+      >
         <div id="<%= pane_name %>-scroll" style="margin-top:0.5em;">
           <div class="pane-content">
             <% if i == 0 %>
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 822c9048579487366ef2591a7a055454b7dd586e..4d54fd08ba0ce0464d561fcb4ed26d16b5ffaeaf 100644 (file)
@@ -44,7 +44,7 @@
              selection_param: 'uuid',
              success: 'redirect-to-created-object'
            }.to_json),
-          { class: "btn btn-sm btn-primary", remote: true, method: 'get',
+          { class: "btn btn-sm btn-primary force-cache-reload", remote: true, method: 'get',
             title: "Move this #{object_class} to a different project"}) do %>
         <i class="fa fa-fw fa-truck"></i> Move <%=object_class%>...
       <% end %>
@@ -53,7 +53,7 @@
 <% end %>
 
 <%
-  # Display any flash messages in an alert. If there is any entry with "error" key, alert-danger is used. 
+  # Display any flash messages in an alert. If there is any entry with "error" key, alert-danger is used.
   flash_msg = ''
   flash_msg_is_error = false
   flash.each do |msg|