Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by Comment ID #1

Closed
aljawaid opened this issue Oct 25, 2022 · 27 comments
Closed

Search by Comment ID #1

aljawaid opened this issue Oct 25, 2022 · 27 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@aljawaid
Copy link
Owner

Can anybody help with how to find the comment ID and display the associated task? I've tried a few different ways, one is below, but nothing seems to work.

<?= $this->model->commentModel->getById($comment['id']); ?>
			<form method="get" action="<?= $this->url->dir() ?>#comment-<?= $comment['id']; ?>" class="search">
            <?= $this->form->hidden('controller', array('controller' => 'TaskViewController')) ?>
            <?= $this->form->hidden('action', array('action' => 'show','task_id' => $task['id'], 'project_id' => $task['project_id'], 'comment_id' => $comment['id'])) ?>

            

            <div class="glancer-bar-input">
                <?= $this->form->text('comment_id', array(), array(), array('placeholder="'.t('Enter Comment ID').'"', 'pattern="[0-9.]+" title="'.t('Enter Comment ID').'"'.'aria-label="'.t('Enter Comment ID').'"'.'style=""'), 'input-addon-field border-radius') ?>
            </div>
        	</form>
@aljawaid aljawaid added the help wanted Extra attention is needed label Oct 25, 2022
@aljawaid aljawaid self-assigned this Oct 25, 2022
@creecros
Copy link
Collaborator

The comment model is already setup to give you the info you need:
https://github.com/kanboard/kanboard/blob/a376ffbe533f845ee874e9277cd80c29b8a8414d/app/Model/CommentModel.php#L91-L101

so to get the Task ID from a Comment ID, call the model and ask for the task id.
$this->model->commentModel->getById($comment['id'])['task_id']

It makes more sense when you setup a variable first:

$data = $this->model->commentModel->getById($comment['id']);
$taskID = $data['task_id'];

@creecros
Copy link
Collaborator

after looking at your code, in order for this to work, you are going to need to approach this different. there isn't a way to interpret the user input of that comment id, and then send user to task page. you are trying to do it all on the front end, but there is no back end for it. I can tell you how to get the data you want, but you need a backend for the form data.

easiest way to do it, would be extend the TaskViewController with your own function to take the comment id input, and then get the task id, and send user to page.

@aljawaid
Copy link
Owner Author

after looking at your code, in order for this to work, you are going to need to approach this different. there isn't a way to interpret the user input of that comment id, and then send user to task page. you are trying to do it all on the front end, but there is no back end for it. I can tell you how to get the data you want, but you need a backend for the form data.

easiest way to do it, would be extend the TaskViewController with your own function to take the comment id input, and then get the task id, and send user to page.

haha Im a front end guy thats why.... right well all the above just went way over my head... so I will keep crawling on it.

@aljawaid
Copy link
Owner Author

easiest way to do it, would be extend the TaskViewController with your own function to take the comment id input, and then get the task id, and send user to page.

do you mean as a helper or as a controller?

@creecros
Copy link
Collaborator

a controller

@aljawaid aljawaid reopened this Oct 31, 2022
@aljawaid
Copy link
Owner Author

Is the rest of the code (for comments) okay in the form? am I just missing a controller now to (link a comment id to a task and go to it)?

@creecros
Copy link
Collaborator

im almost done, give me a few minutes.

@aljawaid aljawaid added this to the Search by Comment ID milestone Oct 31, 2022
@creecros
Copy link
Collaborator

ah crap, you pushed something while i was working on it ;p

@aljawaid
Copy link
Owner Author

ah crap, you pushed something while i was working on it ;p

oh so sorry, I didnt know you were working on it... i just pushed that suggested variable you suggested... i wont touch it now.... didnt realise you were on it.

@creecros
Copy link
Collaborator

and I lost the controller i wrote trying to merge....i suck at git apparently...

@creecros
Copy link
Collaborator

ok, done.

@aljawaid
Copy link
Owner Author

ok, done.

oh damn... excellent bugger, thanks so much I will test shortly.... big thanks on this as my head was fully baffled for ages on it

@creecros
Copy link
Collaborator

creecros commented Oct 31, 2022

only thing I didn't test was what will happen if you put a bad comment id in it...I'll leave that to you, pretty sure something bad would happen. it's late, I'm going to bed, and waking up early to shoot birds. you got this from here!

@aljawaid
Copy link
Owner Author

this is fantastic it works! a very big thanks for this!

@aljawaid
Copy link
Owner Author

only thing I didn't test was what will happen if you put a bad comment id in it...I'll leave that to you, pretty sure something bad would happen.

it gives a white blank page... also, there is no pretty url or even jumping direct to the comment (like in notifications)... is that by coding or is it a limit because its a plugin? (asking looking at the url) https://domain.com/?controller=TaskCommentViewController&action=showByCommentId&plugin=Glancer

@creecros
Copy link
Collaborator

creecros commented Oct 31, 2022

if my memory serves me correct, you need to setup a route, for a pretty url. that might go over your head.

you can default to the dashboard in the controller if a bad id is input.

@creecros
Copy link
Collaborator

@creecros
Copy link
Collaborator

this should give you more detail on what that route should look like:

https://github.com/kanboard/kanboard/blob/ce6c4dfc67713840b9f17551b816d3eef3bca3ab/app/ServiceProvider/RouteProvider.php#L91

@aljawaid
Copy link
Owner Author

great thanks, I will checkout routes later tonight when I am able to test

@aljawaid
Copy link
Owner Author

ok, done.

Fixed in fef769b

@aljawaid
Copy link
Owner Author

aljawaid commented Oct 31, 2022 via email

@aljawaid aljawaid reopened this Oct 31, 2022
@aljawaid aljawaid added the bug Something isn't working label Oct 31, 2022
@creecros
Copy link
Collaborator

creecros commented Oct 31, 2022

working fine for me, you need to be more descriptive.

Also, the controller does not interfere with filters in anyway, the only thing that uses that controller is your layout template. Period.

@creecros
Copy link
Collaborator

www.nachostudio.ml

Try it here
user: admin
pw: admin

@creecros
Copy link
Collaborator

Anyhow, I setup a route for the search by comment id. Took a bit for me to figure out how to get the task_id into the params to send to the controller and pull that variable before routing, but I figured it out.

inorder to prettify your other search fields, task id and project id, the only way I know how to do it, would be going through a controller. Unless you can figure out how to build the url for a premade route, that might work.

@aljawaid
Copy link
Owner Author

www.nachostudio.ml

Try it here user: admin pw: admin

I did and the plugin itself works but then when you go to the board and do a closed tasks filter or any filter, it comes up with this:

image

the result url in the browser is:
https://www.nachostudio.ml/?controller=BoardViewController&action=show&project_id=

@creecros
Copy link
Collaborator

should be all set now. it was the location of the template hook. moved to top, and all seems well now. everything else should be sorted as well, pretty urls and no blank pages, instead "Sorry, I didn't find this information in my database!" message if there is no comment id, etc...

@aljawaid
Copy link
Owner Author

Thats great, I'm excited to release the first version soon.... this has just become such a productive tool with any user being able to search by task, comment or project. Big thanks to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants