mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-15 21:04:34 +02:00
Check permissions for time travel and element undo.
This commit is contained in:
parent
254d4e6c69
commit
8a61b465d0
23 changed files with 370 additions and 90 deletions
|
@ -42,11 +42,13 @@ class IconLinkColumn extends AbstractColumn
|
|||
'icon' => 'fas fa-fw fa-edit',
|
||||
'title' => null,
|
||||
'href' => null,
|
||||
'disabled' => false,
|
||||
]);
|
||||
|
||||
$resolver->setAllowedTypes('title', ['null', 'string', 'callable']);
|
||||
$resolver->setAllowedTypes('icon', ['null', 'string', 'callable']);
|
||||
$resolver->setAllowedTypes('href', ['null', 'string', 'callable']);
|
||||
$resolver->setAllowedTypes('disabled', ['bool', 'callable']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -56,10 +58,12 @@ class IconLinkColumn extends AbstractColumn
|
|||
$href = $this->getHref($value, $context);
|
||||
$icon = $this->getIcon($value, $context);
|
||||
$title = $this->getTitle($value, $context);
|
||||
$disabled = $this->getDisabled($value, $context);
|
||||
|
||||
if ($href !== null) {
|
||||
return sprintf(
|
||||
'<a class="btn btn-primary btn-sm" href="%s" title="%s"><i class="%s"></i></a>',
|
||||
'<a class="btn btn-primary btn-sm %s" href="%s" title="%s"><i class="%s"></i></a>',
|
||||
$disabled ? 'disabled' : '',
|
||||
$href,
|
||||
$title,
|
||||
$icon
|
||||
|
@ -69,6 +73,18 @@ class IconLinkColumn extends AbstractColumn
|
|||
return "";
|
||||
}
|
||||
|
||||
protected function getDisabled($value, $context): bool
|
||||
{
|
||||
$provider = $this->options['disabled'];
|
||||
if (is_bool($provider)) {
|
||||
return $provider;
|
||||
}
|
||||
if (is_callable($provider)) {
|
||||
return call_user_func($provider, $value, $context);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHref($value, $context): ?string
|
||||
{
|
||||
$provider = $this->options['href'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue