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

datagrid in component - action link problem #592

Closed
zelina opened this Issue Nov 27, 2017 · 4 comments

Comments

3 participants
@zelina
Copy link

zelina commented Nov 27, 2017

If datagrid is used in component, action link (for signal!) is not generated properly. Exception for invalid link is throwed.

Problem is probably here:
https://github.com/ublaboo/datagrid/blob/06f364e3fbf5db2d6eae96705af4973a66da7c8d/src/Traits/TLink.php#L29

in component have to be:
$parent = $grid->getParent()->getParent(); // code could say more than thousands words ;)

then it generates proper action link (for signal!).

@zelina

This comment has been minimized.

Copy link
Author

zelina commented Jan 6, 2018

Could this be as a solution?

protected function createLink(DataGrid $grid, $href, $params)
	{
		try {
			$parent = $grid->getParent();

			if (Strings::endsWith($href,'!')) {
				$parentClass = ClassType::from($parent);

				while (!$parentClass->hasMethod('handle' . Strings::capitalize(Strings::trim($href, '!')))) {
					$parent = $parent->getParent();
					$parentClass = ClassType::from($parent);
				}
			}

			return $parent->link($href, $params);
		} catch (DataGridHasToBeAttachedToPresenterComponentException $e) {
			$parent = $grid->getPresenter();

		} catch (\InvalidArgumentException $e) {
			$parent = $grid->getPresenter();
		}

		return $parent->link($href, $params);
	}

paveljanda added a commit that referenced this issue Jan 11, 2018

@radekdostal

This comment has been minimized.

Copy link
Contributor

radekdostal commented Jan 12, 2018

I think, this is an BC break. When I have this action (datagrid as component):

$grid->addAction('movie', '', 'Movie:edit', ['id' => 'movie_id']);

It ends with "Component with name 'Movie' does not exist."

@paveljanda

This comment has been minimized.

Copy link
Member

paveljanda commented Jan 12, 2018

@radekdostal Aj, that should not.. can you try v5.5.1?

@radekdostal

This comment has been minimized.

Copy link
Contributor

radekdostal commented Jan 12, 2018

@paveljanda Yes, v5.5.1 seems to be OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.