add subtask orgmode

This commit is contained in:
Tykayn 2021-09-10 16:27:07 +02:00 committed by tykayn
parent 43d798085c
commit dc9d8d175b

View File

@ -110,6 +110,7 @@ function computeData(jsonConvertedData) {
maxTasksCountPerTag: 0, maxTasksCountPerTag: 0,
listTags: [], listTags: [],
tagByKey: {}, tagByKey: {},
taskByKey: {},
listAll: [], listAll: [],
listOpen: [], listOpen: [],
listOpenWeekly: [], listOpenWeekly: [],
@ -130,6 +131,8 @@ function computeData(jsonConvertedData) {
} }
for (let taskItem of gtgData.tasklist[0].task) { for (let taskItem of gtgData.tasklist[0].task) {
jsonAllData.stats.taskByKey[taskItem["$"].id] = taskItem
// count open and closed tasks // count open and closed tasks
let now = new Date() let now = new Date()
@ -402,26 +405,25 @@ function exportToMarkdown(res) {
function exportToOrgmode(res) { function exportToOrgmode(res) {
console.log('jsonAllData.stats.tagByKey', jsonAllData.stats.tagByKey);
let orgmodeContent = `# Tâches exportées let orgmodeContent = `# Tâches exportées
`; `;
jsonAllData.stats.listAll.map(elem => { jsonAllData.stats.listAll.map(taskItem => {
orgmodeContent += `\n*`; orgmodeContent += `\n* `;
if(elem.$.status === 'Active'){ if (taskItem.$.status === 'Active') {
orgmodeContent += `TODO`; orgmodeContent += `TODO`;
} }
if(elem.$.status === 'Done'){ if (taskItem.$.status === 'Done') {
orgmodeContent += `DONE`; orgmodeContent += `DONE`;
} }
if(elem.$.status === 'Dismiss'){ if (taskItem.$.status === 'Dismiss') {
orgmodeContent += `CANCELED`; orgmodeContent += `CANCELED`;
} }
orgmodeContent += ` ${elem.title} `; orgmodeContent += ` ${taskItem.title} `;
if (elem.tags[0]) { if (taskItem.tags[0]) {
orgmodeContent += ` `;
elem.tags[0].tag.map(tag => { taskItem.tags[0].tag.map(tag => {
// console.log('tag', tag); // console.log('tag', tag);
// console.log('jsonAllData.stats.tagByKey[tag]', jsonAllData.stats.tagByKey[tag]); // console.log('jsonAllData.stats.tagByKey[tag]', jsonAllData.stats.tagByKey[tag]);
if (tag) { if (tag) {
@ -431,6 +433,45 @@ function exportToOrgmode(res) {
} }
}) })
} }
if (taskItem.$.dates) {
console.log('elem.$.dates', taskItem.$.dates);
orgmodeContent += `\n `;
if (taskItem.$.dates[0].added) {
orgmodeContent += `CREATED ${taskItem.title} `;
}
}
if (taskItem.content) {
orgmodeContent += `\n`;
taskItem.content.map(content =>{
orgmodeContent += `\n ${content} `;
})
orgmodeContent += `\n ______`;
}
if (
// typeof elem.subtasks[0] === typeof Object &&
taskItem.subtasks[0].sub.length) {
let listSubTasks = taskItem.subtasks[0].sub
orgmodeContent += `\n `;
listSubTasks.map(subtaskid => {
let subTask = jsonAllData.stats.taskByKey[subtaskid]
console.log('subTask', subTask);
orgmodeContent += `\n * `;
if (taskItem.$.status === 'Active') {
orgmodeContent += `TODO`;
}
if (taskItem.$.status === 'Done') {
orgmodeContent += `DONE`;
}
if (taskItem.$.status === 'Dismiss') {
orgmodeContent += `CANCELED`;
}
orgmodeContent += ` => ${subTask.title} `;
})
}
}) })
// write file to disk // write file to disk