Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MWPW-147600): stabilize date sorting for cards with identical dates #210

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Chimera UI Libraries - Build 0.23.24 (12/11/2024, 13:58:09)
* Chimera UI Libraries - Build 0.23.25 (12/12/2024, 14:19:59)
*
*/
/******/ (function(modules) { // webpackBootstrap
Expand Down Expand Up @@ -2389,7 +2389,10 @@ var getDateAscSort = exports.getDateAscSort = function getDateAscSort(cards) {
var cardOneDate = (0, _general.getByPath)(cardOne, 'cardDate');
var cardTwoDate = (0, _general.getByPath)(cardTwo, 'cardDate');
if (cardOneDate && cardTwoDate) {
return cardOneDate !== cardTwoDate ? cardOneDate.localeCompare(cardTwoDate) : -1;
if (cardOneDate !== cardTwoDate) {
return cardOneDate.localeCompare(cardTwoDate);
}
return (cardOne.id || '').localeCompare(cardTwo.id || '');
}
return 0;
});
Expand Down
4 changes: 2 additions & 2 deletions dist/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.source.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion react/src/js/components/Consonant/Helpers/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ export const getDateAscSort = cards => cards.sort((cardOne, cardTwo) => {
const cardOneDate = getByPath(cardOne, 'cardDate');
const cardTwoDate = getByPath(cardTwo, 'cardDate');
if (cardOneDate && cardTwoDate) {
return cardOneDate !== cardTwoDate ? cardOneDate.localeCompare(cardTwoDate) : -1;
if (cardOneDate !== cardTwoDate) {
return cardOneDate.localeCompare(cardTwoDate);
}
return (cardOne.id || '').localeCompare(cardTwo.id || '');
}
return 0;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,108 +6,126 @@ const filterCards = helperProps.getFilteredCards;

const cardsToSort = {
1: {
id: '1',
isFeatured: true,
initialTitle: 'c title',
contentArea: { title: 'a title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
2: {
id: '2',
isFeatured: true,
initialTitle: 'c title',
contentArea: { title: 'b title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
3: {
id: '3',
isFeatured: true,
initialTitle: 'c title',
contentArea: { title: 'c title' },
cardDate: null,
},
4: {
id: '4',
isFeatured: true,
initialTitle: 'a title',
contentArea: { title: 'a title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
5: {
id: '5',
isFeatured: true,
initialTitle: 'a title',
contentArea: { title: 'b title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
6: {
id: '6',
isFeatured: true,
initialTitle: 'a title',
contentArea: { title: 'c title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
7: {
id: '7',
isFeatured: false,
initialTitle: 'c title',
contentArea: { title: 'a title' },
cardDate: '2021-10-10T21:00:00.000Z',
},
8: {
id: '8',
isFeatured: false,
initialTitle: 'c title',
contentArea: { title: 'b title' },
cardDate: null,
},
9: {
id: '9',
isFeatured: false,
initialTitle: 'c title',
contentArea: { title: 'c title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
10: {
id: '10',
isFeatured: true,
initialTitle: 'b title',
contentArea: { title: 'a title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
11: {
id: '11',
isFeatured: true,
initialTitle: 'b title',
contentArea: { title: 'b title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
12: {
id: '12',
isFeatured: true,
initialTitle: 'b title',
contentArea: { title: 'c title' },
cardDate: '2021-10-10T21:00:00.000Z',
},
13: {
id: '13',
isFeatured: false,
initialTitle: 'a title',
contentArea: { title: 'a title' },
cardDate: null,
},
14: {
id: '14',
isFeatured: false,
initialTitle: 'a title',
contentArea: { title: 'b title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
15: {
id: '15',
isFeatured: false,
initialTitle: 'a title',
contentArea: { title: 'c title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
16: {
id: '16',
isFeatured: false,
initialTitle: 'b title',
contentArea: { title: 'a title' },
cardDate: '2021-10-12T21:00:00.000Z',
},
17: {
id: '17',
isFeatured: false,
initialTitle: 'b title',
contentArea: { title: 'b title' },
cardDate: '2021-10-10T21:00:00.000Z',
},
18: {
id: '18',
isFeatured: false,
initialTitle: 'b title',
contentArea: { title: 'c title' },
Expand All @@ -125,13 +143,13 @@ const sortCards = [
{
cards: [...cardsWithoutSorting],
sortOption: { sort: SORT_TYPES.DATEASC },
expectedValue: getCards([17, 12, 7, 16, 15, 14, 11, 10, 9, 6, 5, 4, 2, 1, 3, 8, 13, 18]),
expectedValue: getCards([12, 17, 7, 1, 10, 2, 3, 11, 15, 4, 5, 6, 8, 9, 13, 14, 16, 18]),
},
{
cards: [...cardsWithoutSorting],
sortOption: { sort: SORT_TYPES.DATEDESC },
// expectedValue: getCards([18, 16, 15, 14, 17, 13, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 12, 7]),
expectedValue: getCards([18, 13, 8, 3, 1, 2, 4, 5, 6, 9, 10, 11, 14, 15, 16, 7, 12, 17]),
expectedValue: getCards([18, 16, 14, 13, 9, 8, 6, 5, 4, 15, 11, 3, 2, 10, 1, 7, 17, 12]),
},
{
cards: [...cardsWithoutSorting],
Expand Down
Loading