From 67356266bd0841cfc525ef11f4350ea6ccf1cd20 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Tue, 22 May 2012 19:10:34 +0200 Subject: [PATCH] FIX A newly followed dashboard should always come last in the list --- .../webapp/WEB-INF/app/controllers/dashboards_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb index b2ee37ba280..587c81fc80f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb @@ -123,7 +123,8 @@ class DashboardsController < ApplicationController if active_dashboard flash[:error]=Api::Utils.message('dashboard.error_follow_existing_name') else - current_user.active_dashboards.create(:dashboard => dashboard, :user => current_user, :order_index => current_user.active_dashboards.size+1) + last_active_dashboard=current_user.active_dashboards.max_by(&:order_index) + current_user.active_dashboards.create(:dashboard => dashboard, :user => current_user, :order_index => (last_active_dashboard ? last_active_dashboard.order_index+1 : 1)) end else bad_request('Unknown dashboard') -- 2.39.5