mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
* datatable row actions
Below is a sample of extra param to enable feature:
$aExtraParams['row_actions'] = [
[
'tooltip' => 'remove an element',
'icon_css_class' => 'fa-minus',
'js_row_action' => 'console.log("You clicked the remove button");',
'confirmation' => [
'message' => 'UI:ConfirmationMessage',
'message_row_data' => "name",
'remember_choice_pref_key' => 'remove_do_not_show_again',
],
],
[
'tooltip' => 'open in new tab',
'icon_css_class' => 'fa-external-link-square-alt',
'on_action_js' => 'window.open("http://localhost/itop-branchs/dev/pages/UI.php?operation=details&class=UserRequest&id=" + aData.id + "&c[menu]=UserRequest%3AOpenRequests");',
],
[
'tooltip' => 'other actions',
'icon_css_class' => 'fa-ellipsis-v',
'on_action_js' => 'console.log(event);',
],
];
* Contrôleur pour la suppression et le détachement de liens
* Block UI pour l'édition des relations
* Block UI pour la visualisation des relations
* Boutons d'actions pour la suppression et le détachement de liens
* Gestion dialogue de confirmation pour les row actions
112 lines
2.7 KiB
PHP
112 lines
2.7 KiB
PHP
<?php
|
|
/*
|
|
* @copyright Copyright (C) 2010-2022 Combodo SARL
|
|
* @license http://opensource.org/licenses/AGPL-3.0
|
|
*/
|
|
|
|
namespace Combodo\iTop\Application\UI\Base\Component\DataTable;
|
|
|
|
use Combodo\iTop\Application\UI\Base\Component\Dialog\DialogUIBlockFactory;
|
|
use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory;
|
|
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
|
|
|
|
/**
|
|
* Trait tTableRowActions
|
|
*
|
|
* This brings the ability to add action rows to tables.
|
|
*
|
|
* @internal
|
|
* @package Combodo\iTop\Application\UI\Base\Component\DataTable
|
|
* @since 3.1.0
|
|
*/
|
|
trait tTableRowActions
|
|
{
|
|
/** @var bool static dialog initialized flag to avoid multiple html markups */
|
|
static public bool $bDialogInitialized = false;
|
|
|
|
/**
|
|
* @var $aRowActions array array of row actions
|
|
* action => {
|
|
* tooltip: string,
|
|
* icon_classes: string,
|
|
* js_row_action: string,
|
|
* confirmation => {
|
|
* message: string,
|
|
* message_row_data: string,
|
|
* remember_choice_pref_key: string
|
|
* }
|
|
* }
|
|
*/
|
|
protected $aRowActions;
|
|
|
|
/**
|
|
* Set row actions.
|
|
*
|
|
* @param array $aRowActions
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function SetRowActions(array $aRowActions)
|
|
{
|
|
$this->aRowActions = $aRowActions;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get row actions.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function GetRowActions(): array
|
|
{
|
|
return $this->aRowActions;
|
|
}
|
|
|
|
/**
|
|
* Return true if row actions is set and not empty.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function HasRowActions(): bool
|
|
{
|
|
return isset($this->aRowActions) && count($this->aRowActions);
|
|
}
|
|
|
|
/**
|
|
* Return row actions template.
|
|
*
|
|
* @return \Combodo\iTop\Application\UI\Base\Component\Template\Template
|
|
*/
|
|
public function GetRowActionsTemplate()
|
|
{
|
|
return DataTableUIBlockFactory::MakeActionRowToolbarTemplate($this);
|
|
}
|
|
|
|
/**
|
|
* GetRowActionsConfirmDialog.
|
|
*
|
|
* @return \Combodo\iTop\Application\UI\Base\Component\Html\Html
|
|
*/
|
|
public function GetRowActionsConfirmDialog()
|
|
{
|
|
static::$bDialogInitialized = true;
|
|
|
|
$oDialog = DialogUIBlockFactory::MakeNeutral('', '<div class="ibo-row-action--confirmation--explanation"></div>', 'table-row-action-confirmation-dialog');
|
|
|
|
$oContent = UIContentBlockUIBlockFactory::MakeStandard();
|
|
$oContent->AddCSSClass('ibo-row-action--confirmation--do-not-show-again');
|
|
$checkBox = InputUIBlockFactory::MakeStandard('checkbox', 'do_not_show_again', false);
|
|
$checkBox->AddCSSClass('ibo-row-action--confirmation--do-not-show-again--checkbox');
|
|
$checkBox->SetLabel(\Dict::S('UI:UserPref:DoNotShowAgain'));
|
|
$oContent->AddSubBlock($checkBox);
|
|
$oDialog->AddSubBlock($oContent);
|
|
|
|
return $oDialog;
|
|
}
|
|
|
|
public function GetRowActionsConfirmDialogInitializedFlag()
|
|
{
|
|
return static::$bDialogInitialized;
|
|
}
|
|
} |