-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
297 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
|
||
2024-04-02 Line 1 rec:1d due:2024-04-03 | ||
2024-04-02 Line 1 rec:w due:2024-04-09 | ||
2024-04-02 Line 1 rec:2m due:2024-06-02 | ||
2024-04-02 Line 1 rec:+1d due:2024-04-04 | ||
2024-04-02 Line 1 rec:7w due:2024-05-21 | ||
2024-04-02 Line 1 due:2023-07-24 rec:+1b | ||
2024-04-02 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y | ||
2024-04-02 Water plants @home +quick due:2024-04-09 t:2024-03-30 rec:1w | ||
2024-04-02 Line 1 rec:+1d t:2023-09-20 | ||
2024-04-02 Line 1 rec:1d pri:A due:2024-04-03 | ||
2024-04-02 (A) Do something rec:d t:2024-04-03 @SomeContext | ||
2024-04-02 Do something rec:0d | ||
2024-04-02 Do something rec:0d due:2024-04-02 | ||
2024-04-02 Do something rec:0d due:2024-04-02 t:2024-04-02 | ||
2024-04-04 Line 1 rec:1d due:2024-04-05 | ||
2024-04-04 Line 1 rec:w due:2024-04-11 | ||
2024-04-04 Line 1 rec:2m due:2024-06-04 | ||
2024-04-04 Line 1 rec:+1d due:2024-04-06 | ||
2024-04-04 Line 1 rec:7w due:2024-05-23 | ||
2024-04-04 Line 1 due:2023-07-24 rec:+1b | ||
2024-04-04 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y | ||
2024-04-04 Water plants @home +quick due:2024-04-11 t:2024-04-01 rec:1w | ||
2024-04-04 Line 1 rec:+1d t:2023-09-20 | ||
2024-04-04 Line 1 rec:1d pri:A due:2024-04-05 | ||
2024-04-04 (A) Do something rec:d t:2024-04-05 @SomeContext | ||
2024-04-04 Do something rec:0d | ||
2024-04-04 Do something rec:0d due:2024-04-04 | ||
2024-04-04 Do something rec:0d due:2024-04-04 t:2024-04-04 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { config } from '../../config'; | ||
|
||
function sortAndGroupTodoObjects(todoObjects: TodoObject[], sorting: Sorting[], settings: Settings): TodoObject[] { | ||
let rows; | ||
const fileSorting: boolean = config.get('fileSorting'); | ||
const showHidden: boolean = config.get('showHidden'); | ||
|
||
function compareValues(a: any, b: any, invert: boolean): number { | ||
const comparison = String(a).localeCompare(String(b), undefined, { sensitivity: 'base' }); | ||
return invert ? -comparison : comparison; | ||
} | ||
|
||
function applySorting(a: TodoObject, b: TodoObject, sorting): number { | ||
for (const { value, invert } of sorting) { | ||
const compareResult = compareValues(a[value], b[value], invert); | ||
if (compareResult !== 0) { | ||
return compareResult; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
function groupTodoObjectsByKey(todoObjects, attributeKey) { | ||
const grouped = {}; | ||
for (const todoObject of todoObjects) { | ||
const groupKey = todoObject[attributeKey] || ''; | ||
if (!grouped[groupKey]) { | ||
grouped[groupKey] = { | ||
title: groupKey, | ||
todoObjects: [], | ||
visible: false | ||
}; | ||
} | ||
rows++; | ||
todoObject.row = rows; | ||
grouped[groupKey].todoObjects.push(todoObject); | ||
grouped[groupKey].visible = grouped[groupKey].todoObjects.some(todoObject => { | ||
return !todoObject.hidden || (showHidden && todoObject.hidden); | ||
}); | ||
} | ||
return Object.values(grouped); | ||
} | ||
|
||
function sortTodoObjects(todoObjects: TodoObject[], sorting): any { | ||
const { value } = sorting[0]; | ||
const grouped = groupTodoObjectsByKey(todoObjects, value); | ||
return grouped; | ||
} | ||
|
||
if(fileSorting) { | ||
return [{ | ||
title: null, | ||
todoObjects: todoObjects, | ||
visible: true | ||
}] | ||
} | ||
rows = 0; | ||
const sortedTodoObjects = [...todoObjects].sort((a, b) => applySorting(a, b, sorting)); | ||
return sortTodoObjects(sortedTodoObjects, sorting); | ||
} | ||
|
||
export { sortAndGroupTodoObjects }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.