From: David Gageot Date: Tue, 22 May 2012 17:10:34 +0000 (+0200) Subject: FIX A newly followed dashboard should always come last in the list X-Git-Tag: 3.1~131 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=67356266bd0841cfc525ef11f4350ea6ccf1cd20;p=sonarqube.git FIX A newly followed dashboard should always come last in the list --- 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')