Topic
Summary
1.How to display uncompleted sub-tasks which are unscheduled or upcoming?
Test
Summary
- dataview: v0.5.41
Input
Summary
dictionary files
- filename :
dic_20100301
---
Date: 2010-03-01
---
#Project/P03
- [ ] pp : test
- [ ] pp :spiral_calendar:2022-08-13
- [ ] 21 :spiral_calendar:2022-08-14
- [ ] 22 :spiral_calendar:2022-08-15
- [ ] abc 22 :spiral_calendar:2022-08-16
- [x] abc 69 :spiral_calendar:2022-08-17
- [ ] abc 69.1 :spiral_calendar:2022-08-17
- [x] abc 69 :spiral_calendar:2022-08-18
- filename :
dic_20100401
---
Date: 2010-04-01
---
#Project/P03
- [ ] KK : test
- [ ] KK :spiral_calendar:2023-08-13
- [ ] 21 :spiral_calendar:2023-08-14
- [ ] 22 :spiral_calendar:2023-08-15
- [ ] abc 22 :spiral_calendar:2023-08-16
- [x] abc 69 :spiral_calendar:2023-08-17
- [ ] abc 69.1 :spiral_calendar:2023-08-17
- [x] abc 69 :spiral_calendar:2023-08-18
DVJS10_use_fTasks_to_display_unscheduled_or_upcoming_tasks
Summary
Main DVJS
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DVJS10_use_fTasks_display _unscheduled_or_upcoming_tasks |
file.tasks | no | 1.To hide completed sub-tasks 2.To show uncompleted sub-tasks which are unscheduled or upcoming |
1.b_unscheduled = true : when task.text contains no due date string like “yyyy-MM-dd” at the end of the line. 2.b_upcoming = true : when task.text contains a due date string like “yyyy-MM-dd” at the end of the line and today is less than it. |
Notes
Summary_notes
code DVJS10_use_fTasks_to_display_unscheduled_or_upcoming_tasks
Summary_code
title: DVJS10_use_fTasks_to_display_unscheduled_or_upcoming_tasks => 1.To hide completed sub-tasks 2.To show uncompleted sub-tasks which are unscheduled or upcoming 3.b_unscheduled = true : when task.text contains no due date string like "yyyy-MM-dd" at the end of the line. 4.b_upcoming = true : when task.text contains a due date string like "yyyy-MM-dd" at the end of the line and today is less than it.
collapse: close
icon:
color:
```dataviewjs
// M11. define pages: gather all relevant pages
// #####################################################################
//let pages = dv.current();
let pages = dv
.pages('"100_Project/01_dataviewjs/01_by_example/Q15_Tasks/Q15_test_data" and #Project')
.where((page) => dv.func.contains(page.file.name, "dic_"));
// M21. define tasks:
// #####################################################################
let tasks = pages.file.tasks
.where((t) => !t.completed)
.where((t) => show_unscheduled_or_upcoming(t));
// M51. output tasks:
// #####################################################################
dv.taskList(tasks);
// M90. define function: show unscheduled or upcoming tasks
// #####################################################################
// case_10: return true if b_unscheduled;
// case_20: return true if !b_unscheduled && dt_today < dt_due_date_in_text;
function show_unscheduled_or_upcoming(task) {
// F13. define dt_today:
// #####################################################################
// let dt_today = dv.date("2022-08-18");//=>For debugging
let dt_today = dv.date("today");
// F21. define a_date_strings: get a_date_strings from the end of t.text
// #####################################################################
let a_date_strings = task.text.match(/\d{4}-\d{2}-\d{2}$/); //=>null or array
// F25. define b_unscheduled:
// false: when the end of task.text is /\d{4}-\d{2}-\d{2}$/
// #####################################################################
let b_unscheduled = true;
if (a_date_strings) {
b_unscheduled = false;
}
// F29. case_10: return true if b_unscheduled;
// #####################################################################
if (b_unscheduled) {
return true;
}
// F31. define dt_due_date_in_text:
// #####################################################################
let dt_due_date_in_text;
if (!b_unscheduled) {
dt_due_date_in_text = dv.date(a_date_strings[0]);
}
// F41. define b_upcoming:
// case_20: true if !b_unscheduled && dt_today < dt_due_date_in_text;
// #####################################################################
let b_upcoming = false;
if (!b_unscheduled && dt_today < dt_due_date_in_text) {
b_upcoming = true;
}
// F80. return :
// #####################################################################
return b_upcoming;
}
```