Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrooker committed Mar 15, 2021
2 parents 50d9cef + e728713 commit 0ada12c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions MMM-Todoist.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ Module.register("MMM-Todoist", {
case "dueDateDesc":
sorteditems = self.sortByDueDateDesc(items);
break;
case "dueDateDescPriority":
sorteditems = self.sortByDueDateDescPriority(items);
break;
default:
sorteditems = self.sortByTodoist(items);
break;
Expand Down Expand Up @@ -435,6 +438,16 @@ Module.register("MMM-Todoist", {
});
return itemstoSort;
},
sortByDueDateDescPriority: function (itemstoSort) {
itemstoSort.sort(function (a, b) {
if (a.date > b.date) return 1;
if (a.date < b.date) return -1;

if (a.priority < b.priority) return 1;
if (a.priority > b.priority) return -1;
});
return itemstoSort;
},
createCell: function(className, innerHTML) {
var cell = document.createElement("div");
cell.className = "divTableCell " + className;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ The following properties can be configured:
<code>"priority"</code> <span>- Sort based on the priority, in Descending order. (Highest priority first)</span> </br >
<code>"dueDateAsc"</code> <span>- Sort based on the Due Date of the Todo Ascending. (Oldest date first)</span> </br>
<code>"dueDateDesc"</code> <span>- Sort based on the Due Date of the Todo Descending. (Newest date first)</span></br>
<code>"dueDateDescPriority"</code> <span>- Sort based on the Due Date of the Todo Descending and by priority high to low.</span></br>
<br><b>Default value:</b> <code>"todoist"</code>
</td>
</tr>
Expand Down

0 comments on commit 0ada12c

Please sign in to comment.