Commit 2ecc7950 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Order labels by name

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 91c1534e
...@@ -7,7 +7,7 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -7,7 +7,7 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to :js, :html respond_to :js, :html
def index 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 end
def new def new
......
...@@ -9,6 +9,8 @@ class Label < ActiveRecord::Base ...@@ -9,6 +9,8 @@ class Label < ActiveRecord::Base
# Dont allow '?', '&', and ',' for label titles # Dont allow '?', '&', and ',' for label titles
validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ } validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }
scope :order_by_name, -> { reorder("labels.title ASC") }
def name def name
title title
end end
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
%fieldset %fieldset
%legend Labels %legend Labels
%ul.nav.nav-pills.nav-stacked.nav-small.labels-filter %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)} %li{class: label_filter_class(label.name)}
= link_to labels_filter_path(label.name) do = link_to labels_filter_path(label.name) do
= render_colored_label(label) = render_colored_label(label)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment