N°5073 - Implements line actions in a datatable (#337)

* datatable row actions

Below is a sample of extra param to enable feature:

		$aExtraParams['row_actions'] = [
			[
				'tooltip'        => 'add an element',
				'icon_css_class' => 'fa-plus',
				'css_class'      => 'ibo-is-success',
				'level'          => 'secondary',
				'on_action_js'   => 'console.log(aData);',
			],
			[
				'tooltip'        => 'remove an element',
				'icon_css_class' => 'fa-minus',
				'css_class'      => 'ibo-is-danger',
				'level'          => 'secondary',
				'on_action_js'   => 'console.log("You clicked the remove button");',
			],
			[
				'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);',
			],
		];

* datatable row actions (update)

* datatable row actions (update)

* datatable row actions (add template role)

* datatable row actions (align actions)

* datatable row actions (change template factory make to make standard)

* datatable row actions (use trait to handle row actions)

* datatable row actions (row actions templates)

* datatable row actions (row actions templates)

* datatable row actions (row actions templates)

* datatable row actions (extends to static and form)

* datatable row actions (extends to static and form)

* datatable row actions (code review S)

* datatable row actions (code review S)

* datatable row actions (code review S)

* Update js/dataTables.main.js

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update js/dataTables.main.js

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update templates/base/components/datatable/row-actions/handler.js.twig

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* datatable row actions (code review M)

* Update js/dataTables.main.js

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update js/dataTables.main.js

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update js/dataTables.main.js

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update js/dataTables.main.js

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* Update application/utils.inc.php

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>

* datatable row actions (code review M2)

* datatable row actions (code review M3)

Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
This commit is contained in:
bdalsass
2022-09-26 08:20:28 +02:00
committed by GitHub
parent 3196e105a1
commit 5157f511fc
23 changed files with 467 additions and 71 deletions

View File

@@ -9,6 +9,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\FormT
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\FormTableRow\FormTableRow;
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\StaticTable;
use Combodo\iTop\Application\UI\Base\Component\DataTable\tTableRowActions;
use Combodo\iTop\Application\UI\Base\iUIBlock;
/**
@@ -19,10 +20,10 @@ use Combodo\iTop\Application\UI\Base\iUIBlock;
class FormTable extends StaticTable
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-formtable';
public const REQUIRES_ANCESTORS_DEFAULT_JS_FILES = true;
public const REQUIRES_ANCESTORS_DEFAULT_CSS_FILES = true;
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/datatable/static/formtable/layout';
public const BLOCK_CODE = 'ibo-formtable';
public const REQUIRES_ANCESTORS_DEFAULT_JS_FILES = true;
public const REQUIRES_ANCESTORS_DEFAULT_CSS_FILES = true;
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/datatable/static/formtable/layout';
public const DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH = 'base/components/datatable/static/formtable/layout';
/** @var string */

View File

@@ -2,6 +2,7 @@
namespace Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable;
use Combodo\iTop\Application\UI\Base\Component\DataTable\tTableRowActions;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\tJSRefreshCallback;
use utils;
@@ -18,12 +19,13 @@ use utils;
class StaticTable extends UIContentBlock
{
use tJSRefreshCallback;
use tTableRowActions;
// Overloaded constants
public const BLOCK_CODE = 'ibo-datatable';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/datatable/static/layout';
public const BLOCK_CODE = 'ibo-datatable';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/datatable/static/layout';
public const DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH = 'base/components/datatable/static/layout';
public const DEFAULT_JS_FILES_REL_PATH = [
public const DEFAULT_JS_FILES_REL_PATH = [
'node_modules/datatables.net/js/jquery.dataTables.min.js',
'node_modules/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js',
'node_modules/datatables.net-responsive/js/dataTables.responsive.min.js',
@@ -59,7 +61,7 @@ class StaticTable extends UIContentBlock
private $aExtraParams;
/*@var string $sUrlForRefresh*/
private $sFilter;
/** @var array $aOptions
/** @var array $aOptions
* List of specific options for display datatable
*/
private $aOptions;
@@ -81,6 +83,17 @@ class StaticTable extends UIContentBlock
return $this->aColumns;
}
/**
* Return columns count.
*
* @return int
* @since 3.1.0
*/
public function GetColumnsCount(): int
{
return count($this->aColumns);
}
/**
* @param array $aColumns
*
@@ -129,8 +142,8 @@ class StaticTable extends UIContentBlock
{
//$('#".$this->sId."').DataTable().clear().rows.add(data).draw()
$aParams = [
'style' => 'list',
'filter' => $this->sFilter,
'style' => 'list',
'filter' => $this->sFilter,
'extra_params' => $this->aExtraParams,
];
@@ -140,7 +153,7 @@ class StaticTable extends UIContentBlock
$('#".$this->sId."').dataTable().fnAddData(data);
});";
}
/**
* @return mixed
*/
@@ -149,6 +162,7 @@ class StaticTable extends UIContentBlock
if (isset($this->aOptions[$sOption])) {
return $this->aOptions[$sOption];
}
return null;
}