-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathFormBuilderDialogGridViewRowLink.class.php
More file actions
65 lines (58 loc) · 2.06 KB
/
FormBuilderDialogGridViewRowLink.class.php
File metadata and controls
65 lines (58 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace wcf\system\gridView;
use wcf\data\DatabaseObject;
use wcf\system\interaction\InteractionEffect;
use wcf\util\StringUtil;
/**
* Represents a row link that opens a form builder dialog.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
class FormBuilderDialogGridViewRowLink extends AbstractGridViewRowLink
{
public function __construct(
private readonly string $identifier,
private readonly string $endpoint,
private readonly InteractionEffect $interactionEffect = InteractionEffect::ReloadItem,
?\Closure $isAvailableCallback = null,
) {
parent::__construct($isAvailableCallback);
}
#[\Override]
public function render(mixed $value, DatabaseObject $row, bool $isPrimaryColumn = false): string
{
$identifier = StringUtil::encodeHTML($this->identifier);
$endpoint = StringUtil::encodeHTML(
\sprintf($this->endpoint, $row->getObjectID())
);
$tabindex = $isPrimaryColumn ? '0' : '-1';
return <<<HTML
<button
type="button"
data-interaction="{$identifier}"
data-endpoint="{$endpoint}"
data-interaction-effect="{$this->interactionEffect->toString()}"
class="gridView__rowLink"
tabindex="{$tabindex}"
>
{$value}
</button>
HTML;
}
#[\Override]
public function renderInitialization(string $containerId): ?string
{
$identifier = StringUtil::encodeJS($this->identifier);
$containerId = StringUtil::encodeJS($containerId);
return <<<HTML
<script data-relocate="true">
require(['WoltLabSuite/Core/Component/Interaction/FormBuilderDialog'], ({ setup }) => {
setup('{$identifier}', document.getElementById('{$containerId}'));
});
</script>
HTML;
}
}