Skip to content

Commit 4faae44

Browse files
committed
[spalenque] - #13384 * change order of user stories
1 parent cfab6d9 commit 4faae44

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

user-stories/code/infrastructure/repositories/SapphireUserStoryRepository.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ public function __construct(){
2222
parent::__construct(new UserStoryDO());
2323
}
2424

25-
public function getAllStories($sort_by = 'LastEdited') {
26-
return UserStoryDO::get()->sort($sort_by);
25+
public function getAllStories($sort_by = 'LastEdited', $sort_dir = 'DESC') {
26+
return UserStoryDO::get()->sort($sort_by, $sort_dir);
2727
}
2828

29-
public function getAllActive($sort_by = 'LastEdited') {
30-
return UserStoryDO::get()->filter('Active',1)->sort($sort_by);
29+
public function getAllActive($sort_by = 'LastEdited', $sort_dir = 'DESC') {
30+
return UserStoryDO::get()->filter('Active',1)->sort($sort_by, $sort_dir);
3131
}
3232

3333
public function findAllActive($search_term) {
3434
return UserStoryDO::get()->filter('Active',1)
3535
->where("Name LIKE '%$search_term%' OR Description LIKE '%$search_term%'")
36-
->sort('LastEdited');
36+
->sort('LastEdited', 'DESC');
3737
}
3838

3939
public function findAllActiveByTag($tag) {
4040
return UserStoryDO::get()
4141
->filter(['Active' => 1, 'Tags.Tag' => $tag])
42-
->sort('LastEdited');
42+
->sort('LastEdited', 'DESC');
4343
}
4444

4545
}

user-stories/code/model/IUserStoryRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
**/
1515
interface IUserStoryRepository
1616
{
17-
public function getAllStories($sort_by = 'LastEdited');
17+
public function getAllStories($sort_by = 'LastEdited', $sort_dir = 'DESC');
1818

19-
public function getAllActive($sort_by = 'LastEdited');
19+
public function getAllActive($sort_by = 'LastEdited', $sort_dir = 'DESC');
2020

2121
public function findAllActive($search_term);
2222

user-stories/ui/source/js/components/views/StoryUnGroupedView.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ export default ({
2929
}
3030

3131
const sortStories = function(stories, compareProp) {
32+
compareProp = (compareProp == 'search') ? 'date' : compareProp;
33+
3234
let sorted_stories = stories.sort((a,b) => {
3335
const aName = a[compareProp];
3436
const bName = b[compareProp];
3537

36-
return aName > bName ? 1 : (aName < bName ? -1 : 0)
38+
if (compareProp == 'date') { // date must be DESC
39+
return aName < bName ? 1 : (aName > bName ? -1 : 0)
40+
} else {
41+
return aName > bName ? 1 : (aName < bName ? -1 : 0)
42+
}
3743
});
3844

3945
return sorted_stories;

0 commit comments

Comments
 (0)