diff options
| author | Mehmet Beydogan <mehmet.beydogan@gmail.com> | 2016-03-10 16:26:56 +0200 |
|---|---|---|
| committer | Robert Speicher <rspeicher@gmail.com> | 2016-04-20 15:42:09 -0400 |
| commit | 3afd08170da6f003b4f11ae1a3f737b14dedec40 (patch) | |
| tree | 0e858cd1c275f7862743022e4c2b24bfef3b2148 /app/models | |
| parent | 1e596fef1c42a1dd925636c48fea01be444dc3ab (diff) | |
| download | gitlab-ce-3afd08170da6f003b4f11ae1a3f737b14dedec40.tar.gz | |
Add due_date:time field to Issue model
Add due_date text field to sidebar issue#show
Add ability sorting issues by due date ASC and DESC
Add ability to filtering issues by No Due Date, Any Due Date, Due to tomorrow, Due in this week options
Add handling issue due_date field for MergeRequest
Update CHANGELOG
Fix ambigous match for issues#show sidebar
Fix SCREAMING_SNAKE_CASE offenses for due date contants
Add specs for due date sorting and filtering on issues
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
| -rw-r--r-- | app/models/concerns/sortable.rb | 4 | ||||
| -rw-r--r-- | app/models/issue.rb | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index afa2ca039ae..691b7e104e4 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -39,6 +39,8 @@ module Issuable scope :order_milestone_due_asc, -> { joins(:milestone).reorder('milestones.due_date ASC, milestones.id ASC') } scope :with_label, ->(title) { joins(:labels).where(labels: { title: title }) } scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) } + scope :has_due_date, ->{ where("issues.due_date IS NOT NULL") } + scope :no_due_date, ->{ where("issues.due_date IS NULL")} scope :join_project, -> { joins(:project) } scope :references_project, -> { references(:project) } diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index 8b47b9e0abd..c88a8f5ceb8 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -18,6 +18,8 @@ module Sortable scope :order_updated_asc, -> { reorder(updated_at: :asc) } scope :order_name_asc, -> { reorder(name: :asc) } scope :order_name_desc, -> { reorder(name: :desc) } + scope :due_date_asc, -> { reorder(due_date: :asc) } + scope :due_date_desc, -> { reorder("due_date IS NULL, due_date DESC") } end module ClassMethods @@ -31,6 +33,8 @@ module Sortable when 'created_desc' then order_created_desc when 'id_desc' then order_id_desc when 'id_asc' then order_id_asc + when 'due_date_asc' then due_date_asc + when 'due_date_desc' then due_date_desc else all end diff --git a/app/models/issue.rb b/app/models/issue.rb index a009e235b37..ee5be904330 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -28,6 +28,9 @@ class Issue < ActiveRecord::Base include Sortable include Taskable + NO_DUE_DATE = ['No Due Date', '0'] + ANY_DUE_DATE = ['Any Due Date', ''] + ActsAsTaggableOn.strict_case_match = true belongs_to :project |
