MMM-GoogleTasks
MMM-GoogleTasks copied to clipboard
Subtasks appear above parent task
When you create a sub task it appears above the parent task
Added a pull request from my fork to master on a quick and dirty sorting of items.
This is still an issue
If anyone is interested, I have fixed this with the code below and I am happy to send a PR soon.
if (this.config.ordering === "myorder") {
let titleWrapper, dateWrapper, noteWrapper, item;
let orderedTasks = [];
let parentTasks = this.tasks.filter((task) => !task.parent);
parentTasks.forEach((parentTask) => {
orderedTasks.push(parentTask);
const childrenTasks = this.tasks.filter(
(childTask) => childTask.parent === parentTask.id
);
orderedTasks.push(...childrenTasks);
});
//this.tasks.forEach((item, index) => {
for (let i = 0; i < numTasks; i++) {
item = orderedTasks[i];
titleWrapper = document.createElement("div");
titleWrapper.className = "item title";
titleWrapper.innerHTML =
'<i class="fa fa-circle-thin" ></i>' + item.title;
// If item is completed change icon to checkmark
if (item.status === "completed") {
titleWrapper.innerHTML = '<i class="fa fa-check" ></i>' + item.title;
}
if (item.parent) {
titleWrapper.className = "item child";
}
if (item.notes) {
noteWrapper = document.createElement("div");
noteWrapper.className = "item notes light";
noteWrapper.innerHTML = item.notes.replace(/\n/g, "<br>");
titleWrapper.appendChild(noteWrapper);
}
dateWrapper = document.createElement("div");
dateWrapper.className = "item date light";
if (item.due) {
var date = moment(item.due);
dateWrapper.innerHTML = date.utc().format(this.config.dateFormat);
}
// Create borders between parent items
if (i < numTasks - 1 && !orderedTasks[i + 1].parent) {
titleWrapper.style.borderBottom = "1px solid #666";
dateWrapper.style.borderBottom = "1px solid #666";
}
wrapper.appendChild(titleWrapper);
wrapper.appendChild(dateWrapper);
}
return wrapper;
}
This needs to replace the rendering code in modules/MMM-GoogleTasks/MMM-GoogleTasks.js
lines 92-147
Hi, I added this code, but then the Task Module don't show Maybe share conpleted file