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,
listTags: [],
tagByKey: {},
taskByKey: {},
listAll: [],
listOpen: [],
listOpenWeekly: [],
@ -130,6 +131,8 @@ function computeData(jsonConvertedData) {
}
for (let taskItem of gtgData.tasklist[0].task) {
jsonAllData.stats.taskByKey[taskItem["$"].id] = taskItem
// count open and closed tasks
let now = new Date()
@ -402,26 +405,25 @@ function exportToMarkdown(res) {
function exportToOrgmode(res) {
console.log('jsonAllData.stats.tagByKey', jsonAllData.stats.tagByKey);
let orgmodeContent = `# Tâches exportées
`;
jsonAllData.stats.listAll.map(elem => {
orgmodeContent += `\n*`;
if(elem.$.status === 'Active'){
orgmodeContent += `TODO`;
jsonAllData.stats.listAll.map(taskItem => {
orgmodeContent += `\n* `;
if (taskItem.$.status === 'Active') {
orgmodeContent += `TODO`;
}
if(elem.$.status === 'Done'){
if (taskItem.$.status === 'Done') {
orgmodeContent += `DONE`;
}
if(elem.$.status === 'Dismiss'){
if (taskItem.$.status === 'Dismiss') {
orgmodeContent += `CANCELED`;
}
orgmodeContent += ` ${elem.title} `;
orgmodeContent += ` ${taskItem.title} `;
if (elem.tags[0]) {
elem.tags[0].tag.map(tag => {
if (taskItem.tags[0]) {
orgmodeContent += ` `;
taskItem.tags[0].tag.map(tag => {
// console.log('tag', tag);
// console.log('jsonAllData.stats.tagByKey[tag]', jsonAllData.stats.tagByKey[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