Commit 8f0bf297 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Add unprioritized scope

parent bf0c4426
......@@ -11,8 +11,8 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to :js, :html
def index
@labels = @project.labels.prioritized(false).page(params[:page])
@prioritized = @project.labels.prioritized
@labels = @project.labels.unprioritized.page(params[:page])
@prioritized_labels = @project.labels.prioritized
respond_to do |format|
format.html
......
......@@ -32,10 +32,12 @@ class Label < ActiveRecord::Base
scope :templates, -> { where(template: true) }
def self.prioritized(bool = true)
query = bool ? where.not(priority: nil) : where(priority: nil)
def self.prioritized
where.not(priority: nil).reorder(Gitlab::Database.nulls_last_order(:priority), :title)
end
query.reorder(Gitlab::Database.nulls_last_order(:priority), :title)
def self.unprioritized
where(priority: nil).reorder(Gitlab::Database.nulls_last_order(:priority), :title)
end
alias_attribute :name, :title
......
......@@ -14,8 +14,8 @@
.prioritized-labels{ class: hide_class }
%h5 Prioritized Label
%ul.content-list.manage-labels-list.js-prioritized-labels{ "data-url" => set_sorting_namespace_project_labels_path(@project.namespace, @project) }
- if @prioritized.present?
= render @prioritized
- if @prioritized_labels.present?
= render @prioritized_labels
- else
%p.empty-message No prioritized labels yet
.other-labels
......
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