diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/assets/javascripts/milestone_select.js | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/assets/javascripts/milestone_select.js')
-rw-r--r-- | app/assets/javascripts/milestone_select.js | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/app/assets/javascripts/milestone_select.js b/app/assets/javascripts/milestone_select.js index 921925e15c5..4cbe0a53307 100644 --- a/app/assets/javascripts/milestone_select.js +++ b/app/assets/javascripts/milestone_select.js @@ -4,16 +4,16 @@ import $ from 'jquery'; import { template, escape } from 'lodash'; -import { __, sprintf } from '~/locale'; -import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import Api from '~/api'; -import axios from './lib/utils/axios_utils'; -import { timeFor, parsePikadayDate, dateInWords } from './lib/utils/datetime_utility'; -import ModalStore from './boards/stores/modal_store'; +import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; +import { __, sprintf } from '~/locale'; import boardsStore, { boardStoreIssueSet, boardStoreIssueDelete, } from './boards/stores/boards_store'; +import ModalStore from './boards/stores/modal_store'; +import axios from './lib/utils/axios_utils'; +import { timeFor, parsePikadayDate, dateInWords } from './lib/utils/datetime_utility'; export default class MilestoneSelect { constructor(currentProject, els, options = {}) { @@ -95,14 +95,19 @@ export default class MilestoneSelect { name: m.title, })) .sort((mA, mB) => { + const dueDateA = mA.due_date ? parsePikadayDate(mA.due_date) : null; + const dueDateB = mB.due_date ? parsePikadayDate(mB.due_date) : null; + // Move all expired milestones to the bottom. - if (mA.expired) { - return 1; - } - if (mB.expired) { - return -1; - } - return 0; + if (mA.expired) return 1; + if (mB.expired) return -1; + + // Move milestones without due dates just above expired milestones. + if (!dueDateA) return 1; + if (!dueDateB) return -1; + + // Sort by due date in ascending order. + return dueDateA - dueDateB; }), ) .then((data) => { |