From 422576fcd63ec60e37bab9cab08bf1da91202749 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:36:30 +0100 Subject: [PATCH] Sort rent periods in organisation details page --- app/models/organisation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/organisation.rb b/app/models/organisation.rb index e769f7b3d..bee597b11 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -115,7 +115,9 @@ class Organisation < ApplicationRecord mappings = RentPeriod.rent_period_mappings return %w[All] if (mappings.keys.map(&:to_i) - rent_period_ids).empty? - rent_period_ids.map { |id| mappings.dig(id.to_s, "value") }.compact + rent_period_ids.map { |id| mappings.dig(id.to_s, "value") }.compact.sort_by do |label| + mappings.keys.index { |key| mappings[key]["value"] == label } + end end def data_protection_confirmed?