From: Imre Farkas <ifarkas(a)redhat.com>
The order of Pools/Deployments/Instances was messed up after autoupdate
The Properties and Role Assignemt tabs on deployments#show was empty after autoupdate
---
src/app/controllers/instances_controller.rb | 4 ++--
src/app/controllers/pools_controller.rb | 4 ++--
src/app/models/deployment.rb | 2 ++
src/app/models/pool.rb | 2 ++
src/app/views/pools/_pretty_list.html.haml | 2 +-
src/public/javascripts/backbone/routers.js | 2 ++
src/public/javascripts/backbone/views.js | 6 ++++++
7 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/app/controllers/instances_controller.rb b/src/app/controllers/instances_controller.rb
index 5979a1c..3f5917f 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -215,9 +215,9 @@ class InstancesController < ApplicationController
def load_instances
if params[:deployment_id].blank?
- @instances = Instance.includes(:owner).apply_filters(:preset_filter_id => params[:instances_preset_filter], :search_filter => params[:instances_search]).where("instances.pool_id" => @pools)
+ @instances = Instance.includes(:owner).apply_filters(:preset_filter_id => params[:instances_preset_filter], :search_filter => params[:instances_search]).list(sort_column(Instance), sort_direction).where("instances.pool_id" => @pools)
else
- @instances = Instance.includes(:owner).apply_filters(:preset_filter_id => params[:instances_preset_filter], :search_filter => params[:instances_search]).where("instances.pool_id" => @pools, "instances.deployment_id" => params[:deployment_id])
+ @instances = Instance.includes(:owner).apply_filters(:preset_filter_id => params[:instances_preset_filter], :search_filter => params[:instances_search]).list(sort_column(Instance), sort_direction).where("instances.pool_id" => @pools, "instances.deployment_id" => params[:deployment_id])
end
end
diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb
index 272110c..37f238e 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -45,12 +45,12 @@ class PoolsController < ApplicationController
@details_tab = @tabs.find {|t| t[:id] == details_tab_name} || @tabs.first[:name].downcase
case @details_tab[:id]
when 'pools'
- @pools = Pool.list_for_user(current_user, Privilege::VIEW).apply_filters(:preset_filter_id => params[:pools_preset_filter], :search_filter => params[:pools_search])
+ @pools = Pool.list_for_user(current_user, Privilege::VIEW).apply_filters(:preset_filter_id => params[:pools_preset_filter], :search_filter => params[:pools_search]).list(sort_column(Pool), sort_direction)
when 'instances'
params[:instances_preset_filter] = "other_than_stopped" unless params[:instances_preset_filter]
@instances = Instance.apply_filters(:preset_filter_id => params[:instances_preset_filter], :search_filter => params[:instances_search]).list(sort_column(Instance), sort_direction)
when 'deployments'
- @deployments = Deployment.apply_filters(:preset_filter_id => params[:deployments_preset_filter], :search_filter => params[:deployments_search])
+ @deployments = Deployment.apply_filters(:preset_filter_id => params[:deployments_preset_filter], :search_filter => params[:deployments_search]).list(sort_column(Deployment), sort_direction)
end
else
@pools = Pool.list(sort_column(Pool), sort_direction)
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index 7b5ce76..8ebd703 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -57,6 +57,8 @@ class Deployment < ActiveRecord::Base
after_create "assign_owner_roles(owner)"
+ scope :ascending_by_name, :order => 'name ASC'
+
validates_presence_of :pool_id
validates_presence_of :name
validates_uniqueness_of :name, :scope => :pool_id
diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 287bc70..977e61e 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -65,6 +65,8 @@ class Pool < ActiveRecord::Base
before_destroy :destroyable?
+ scope :ascending_by_name, :order => 'name ASC'
+
def cloud_accounts
accounts = []
instances.each do |instance|
diff --git a/src/app/views/pools/_pretty_list.html.haml b/src/app/views/pools/_pretty_list.html.haml
index 555dd6f..ac2af4d 100644
--- a/src/app/views/pools/_pretty_list.html.haml
+++ b/src/app/views/pools/_pretty_list.html.haml
@@ -25,7 +25,7 @@
%a.control{:href => '#'}
%span Expand/Collapse
%div.content
- = render :partial => 'deployments', :locals => {:deployments => pool.deployments}
+ = render :partial => 'deployments', :locals => {:deployments => pool.deployments.ascending_by_name}
%ul.content.actions
%li
= link_to ("#{html_escape(pool.name)} " + "#{t'pools.index.pool_details'}" + " »").html_safe, pool_path(pool), :class =>'pool_details'
diff --git a/src/public/javascripts/backbone/routers.js b/src/public/javascripts/backbone/routers.js
index a766b83..cb55730 100644
--- a/src/public/javascripts/backbone/routers.js
+++ b/src/public/javascripts/backbone/routers.js
@@ -74,6 +74,8 @@ Conductor.Routers.Deployments = Backbone.Router.extend({
var view = new Conductor.Views.DeploymentsShow({ model: deployment,
collection: deployment.instances });
+ if(view.currentTab() !== 'instances') return;
+
deployment.bind('change', function() { view.render() });
deployment.instances.fetch({success: function(instances) {
diff --git a/src/public/javascripts/backbone/views.js b/src/public/javascripts/backbone/views.js
index 3e2776d..dd0cd38 100644
--- a/src/public/javascripts/backbone/views.js
+++ b/src/public/javascripts/backbone/views.js
@@ -102,6 +102,12 @@ Conductor.Views.DeploymentsShow = Backbone.View.extend({
el: '#content',
+ currentTab: function() {
+ if($('#details_instances.active').length > 0) {
+ return 'instances';
+ }
+ },
+
render: function() {
var $instances = this.$('ul.instances-array');
if($instances.length === 0) {
--
1.7.6.4