From e380e803a836f33d58f57c9d4cfe0b8614626590 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Wed, 22 Jan 2025 09:31:51 +0100 Subject: [PATCH] Order emoji categories (in admin interface) by name (#33630) --- app/models/custom_emoji_category.rb | 2 ++ app/views/admin/custom_emojis/index.html.haml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/custom_emoji_category.rb b/app/models/custom_emoji_category.rb index f480746517..dfcc156080 100644 --- a/app/models/custom_emoji_category.rb +++ b/app/models/custom_emoji_category.rb @@ -14,4 +14,6 @@ class CustomEmojiCategory < ApplicationRecord has_many :emojis, class_name: 'CustomEmoji', foreign_key: 'category_id', inverse_of: :category, dependent: nil validates :name, presence: true, uniqueness: true + + scope :alphabetic, -> { order(name: :asc) } end diff --git a/app/views/admin/custom_emojis/index.html.haml b/app/views/admin/custom_emojis/index.html.haml index 81b050a047..b9e11a17d1 100644 --- a/app/views/admin/custom_emojis/index.html.haml +++ b/app/views/admin/custom_emojis/index.html.haml @@ -72,7 +72,7 @@ .input.select.optional .label_input = f.select :category_id, - options_from_collection_for_select(CustomEmojiCategory.all, 'id', 'name'), + options_from_collection_for_select(CustomEmojiCategory.alphabetic.all, 'id', 'name'), 'aria-label': t('admin.custom_emojis.assign_category'), class: 'select optional', prompt: t('admin.custom_emojis.assign_category')