Order labels by name
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
91c1534e59
commit
2ecc79507a
|
@ -7,7 +7,7 @@ class Projects::LabelsController < Projects::ApplicationController
|
|||
respond_to :js, :html
|
||||
|
||||
def index
|
||||
@labels = @project.labels.order('title ASC').page(params[:page]).per(20)
|
||||
@labels = @project.labels.order_by_name.page(params[:page]).per(20)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -9,6 +9,8 @@ class Label < ActiveRecord::Base
|
|||
# Dont allow '?', '&', and ',' for label titles
|
||||
validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }
|
||||
|
||||
scope :order_by_name, -> { reorder("labels.title ASC") }
|
||||
|
||||
def name
|
||||
title
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
%fieldset
|
||||
%legend Labels
|
||||
%ul.nav.nav-pills.nav-stacked.nav-small.labels-filter
|
||||
- @project.labels.each do |label|
|
||||
- @project.labels.order_by_name.each do |label|
|
||||
%li{class: label_filter_class(label.name)}
|
||||
= link_to labels_filter_path(label.name) do
|
||||
= render_colored_label(label)
|
||||
|
|
Loading…
Reference in New Issue