How are task states implemented?

I noticed that the taskItem template takes a state variable, and any changes to the state variable is synced to the task.

How do I programmatically manipulate this from custom widgets? Do I just manipulate the associated task state object?

@Mr.Red you have something similar going on with the task manager no?

1 Like

what exactly do you mean by task state?

you mean:

  • [ ] and [x] as task state
    or
  • [status: "todo"], [status: "doing"], [status: "done"] attributes
    or
  • :backhand_index_pointing_right: Custom Task states like [todo], [doing], [done] ?

each of this uses other techniques and logic.

let me know what exactly you're refering too, best with an example if possible to know exactly what you want to achieve.

1 Like

[ ] and [x] is what I'm referring to.

I don't mind switching to custom task states if I can toggle them with a press / touch.

1 Like

I think I've figured it out for my use case (from your code). I feel like it's kinda annoying that you have to replace the text of the state

1 Like

Actually you don’t need to do that, you can simply run the cycleTask state function, and it will
cycle even through the custom states. The issue is that if you trigger it from a query template and the task is not on your current page, the task state won’t sync with your query-task. That I think it is a known bug. And that’s why I decided to not use the cycle task state, and also because I was already AST-parsing the whole task for editing the attributes, so I said why not also handle the task state as an attribute itself.

But why don’t you do tell what you are exactly trying to achieve, so maybe the cycle task state would work for you. Do you have something in mind you want to do, or you were just asking generally?

1 Like

Essentially looking to write my own widget in HTML/JS that offers a custom view for tasks;
So when there are buttons on my end that I press, I want to be able to manipulate task states with javascript.

1 Like

maybe this helps:

2 Likes