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

Add unprioritized scope

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