datagrid icon indicating copy to clipboard operation
datagrid copied to clipboard

Add method for setting custom Action href

Open Gappa opened this issue 6 years ago • 9 comments

Do you still accept PRs for 5.x branch?

I would also like this feature for 6.x, but still haven't updated to Nette 3, so that will have to wait :)

Gappa avatar Aug 23 '19 06:08 Gappa

Wouldn't better implementation be to check if passed argument is absolute url and use it with already existing parameter href?

dakorpar avatar Aug 23 '19 08:08 dakorpar

Well, it might not be an absolute URL (with protocol and everything), it might be relative - pointing to some other part of the application.

Also, href argument can be empty or just action - the createLink method then does its magic, so I didn't want to interfere with that in any way.

Maybe I didn't understand your point correctly? :)

EDIT: I see, the tests only have absolute urls.

Gappa avatar Aug 23 '19 08:08 Gappa

hm, if it's relative, then it should be covered with how it works now, not sure about empty href, but I see what you mean...

dakorpar avatar Aug 23 '19 08:08 dakorpar

It is covered, but in a basic way - the parameters are static and if it is a computed value, you need to have a method for that in your entity (if the datasource is that) which isn't all that intuitive at first.

And for conditional cases it is currently afaik impossible - something like this:

->setCustomHref(function(Entity $entity) use ($presenter) {
	if ($entity->getSometing()) {
		return $presenter->link(':Admin:Presenter:action', ['param' => $entity->getSometing()])
	} else {
		return 'http://www.example.com/?id=' . $entity->getId();
	}
});

This should be the typical use-case for this method.

I should have explained the PR more thoroughly in the initial comment.

Gappa avatar Aug 23 '19 08:08 Gappa

Hi, I would like to ask about this PR:

  • Is it even feasible to add features to 5.x branch?
  • Is the code itself acceptable, or needs polishing?
  • Is the feature something that should be included in the package? If it isn't the case, that's ok, I understand :)

As a workaround, I currently use complete manual rendering, but that takes more code when you want the button/icon combo to remain. Maybe there's a better way and this whole PR is meaningless? :)

Anyway, tests fail with this message (but should otherwise pass):

  • The command "mysql -e 'create database datagridTest;'" failed and exited with 1 during.

Maybe they stopped working for the 5.x branch?

Gappa avatar Oct 03 '19 11:10 Gappa

Thanks, I like it.

  • Yes, it is. But could you please prepare also a MR into the master branch? I'd like to keep this feature also in v6. Thanks!
  • It's fine. :)
  • It sure is. :)
  • Yes they fail currently for the v5.x branch. I will have a look at it.

paveljanda avatar Nov 24 '19 13:11 paveljanda

Ok, cool :)

Made PR for the v6.x branch - #853

Gappa avatar Nov 28 '19 07:11 Gappa

Can we close it here?

f3l1x avatar Nov 24 '21 10:11 f3l1x

Can we close it here?

If there is no plan to include it in 5.x, then I think we can :)

Gappa avatar Nov 25 '21 13:11 Gappa