Hi plugin stars. Firstly thanks for your valuable contributions.
Can you please guide me for my first Plugin?
I want to create a plugin that will override predefined_task_description. Currently, this function sets only the task description from a list of predefined title-description pairs. My plugin will set the task title as well as the description.
I read the Plugin Development documentation, and check the example plugin. But I don’t know where to start.
When editing a task, a dropdown appears under description section and it lists predefined title-description pairs. When selected, it copies the description to the task description. Specifically, I couldn’t find in the repo, where exactly this happens. I will just add the code to copy the title too.
I’m not sure i understand what exactly you are trying to accomplish, so it’s hard to assist.
I can show you where the templates are rendered tho:
Dear creecros, thank you for your help. Let me define my goal a bit more clear.
Predefined descriptions are defined as key-value pairs. Current functionality copies the value to the task description. I want to copy the key to the title field.
My question is: where does exactly the click event to the predefined Template list happens? That way maybe I can add some code to copy the key to the title as well.
If you have a better idea to achieve this goal, that is also appreciated.
The click event is triggered through js.
for instance, look at this line:
if the target was "input[name=title]"
then it would auto fill the title line instead. you could also send it via document.getElementById(“form-title”)
so, all you need to do is add a code that also sends the title to the title, using the appropriate target. and line 75 shows you exactly how to get that data to send: $this->helper->text->e($template['title'])
do i need to explain more, or do you think you got it now?
Very well explained. Thank you very much.
I will try it feedback here.
Best regards,
I have applied your directives on my local instance. It is working as requested.
Thank you very much.
Before going into version 1.0 of my first plugin, I want to make a small visual change.
How can I change the order of objects in task form? (as shown below)
The task creation template calls the helpers.
So, you will need to override the current template, with a new one, ordering the calls in the order you want.
Here is the template you need to override:
I have done the order change on both task_creation and task_modification. Thanks for your guidance.
This is a nice to have feature. Is it a good idea to override these codes?
When new versions release in the future, should I check and update it every time?
Not seeing another option, override. Its a small task to update if there are changes in the future. Its not but a couple overrides. As to how up to date you take the time to keep it, its up to you. Some of my plugins are a nightmare to keep up to date, so I just pray nothing changes…
Hello erpnedir
Nice work for this integration.
I happen to be also looking to implement this same feature for my project. (Task Title from Template…)
The only reference I could find is your thread…
Have you compiled a plugin that we ca use on the community - or would you provide some guidance on the line of code to change.
Thank you
Kind Regards
your answer is in the thread, i pretty much detailed it all out.
Thank you for your feedback
I’m not familiar with html and php
but following your direction I’ve just modified line 74 on the Taskhelper.php
$html .= '<a href="#" data-template-target="input[name=title]" data-template="'.$this->helper->text->e($template['title']).'" class="js-template">';
This is now copying the template Title
now to copy also Template description should I add anonther line below ? or a a full foreach … bloc
with this line :
$html .= '<a href="#" data-template-target="textarea[name=description]" data-template="'.$this->helper->text->e($template['description']).'" class="js-template">';
Yes, correct, you need to add a line to have both title & description auto populate. (no for each)
1 thing to keep in mind, doing it your way, just changing the code; that is not a plugin. If you ever update kanboard, you will loose all modifications.
The alternative approach would be to make a plugin. You’d have to read the docs to get familiar with that.
Dear Mehdi Yahya,
I did not create a plugin. I did the modifications by guidance of @creecros . But my customer did not use it so I removed the code later on. In my case a google like intellisense feature was needed, and it is out of my capabilities.
If you continue this work or need any help feel free to contact me.
Best regards,
Ok I got you on the Plugin issue
I’m struggling to put together a working code - sadly it’s a guessing game for me…
is this the right bloc:
foreach ($templates as $template) {
$html .= '<li>';
//Task template modifier
$html .= '<a href="#" data-template-target="input[name=title]" data-template="'.$this->helper->text->e($template['title']).'" class="js-template">';
$html .= '<a href="#" data-template-target="textarea[name=description]" data-template="'.$this->helper->text->e($template['description']).'" class="js-template">';
$html .= $this->helper->text->e($template['title']);
//End of Task template Modifier
$html .= '</a>';
$html .= '</li>';
}
With this only the Title is sent from template…
It was a bit more to it than that. Consider this a gift:
Great - you have my full gratitude !
Many thanks Creecros, you really saved me a lot of code hassle