MMM-GoogleTasks icon indicating copy to clipboard operation
MMM-GoogleTasks copied to clipboard

Subtasks appear above parent task

Open klearlab opened this issue 5 years ago • 4 comments

When you create a sub task it appears above the parent task

klearlab avatar Aug 06 '19 09:08 klearlab

Added a pull request from my fork to master on a quick and dirty sorting of items.

gubbsjuk avatar Nov 20 '19 09:11 gubbsjuk

This is still an issue

z0mb13k1ll avatar Jul 24 '21 18:07 z0mb13k1ll

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

altany avatar Aug 14 '21 18:08 altany

Hi, I added this code, but then the Task Module don't show Maybe share conpleted file

jbarkhuizen avatar Oct 21 '21 14:10 jbarkhuizen