We strongly recommend you to search the forum with possible keywords before making a new feature request. If your request is very similar to an existing one, consider liking it and/or making a comment rather than making a new one.
Use case or problem
There are cases when the user needs to implement complex logic in the tasks, e.g. the user needs to take the starting data of a task and the ending date and make them into a duration span, check if the deadline is approaching soon, etc. All this requires writing code. However, despite we can use the DataView
plugin to do something like:
function print_duration(location) {
const page = dv.pages(location).first();
const val1 = new Date(page.Start);
const val2 = new Date(page.End);
const val3 = (val2 - val1) / (1000 * 3600 * 24);
dv.span(`Task B took ${val3}.`);
}
in a dataviewjs
block, we can only use that function inside that block. Thus, whenever we want to use that functionality, the whole block needs to be written.
Proposed solution
There should be a way to define a separate file where utility functions, written by the user can be added. Those functions should be importable from any task and reusable. This seems a lot like writing a plugin, but many users do not want to write a whole new plugin, we just need a few extra functions that we will have the freedom to implement for our particular usecase
Current workaround (optional)
I do not see any workaround, but living without this functionality.