19declare(strict_types=1);
21require_once(
"libs/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/TableTestBase.php");
28use Psr\Http\Message\ServerRequestInterface;
38 return $this->getMultiActionHandler($signal);
43 return $this->getActionRegistration($action_id, $action);
51 return $this->buildMultiActionsDropdown($actions, $action_signal, $modal_signal);
56 return $this->getSingleActionsForRow($row_id, $actions);
61 I\Table\Data $component,
65 return $this->renderTableHeader($default_renderer, $component,
$tpl, $sortation_signal);
90 return new I\Table\Action\Factory();
95 return new I\Table\Column\Factory(
102 $request = $this->createMock(ServerRequestInterface::class);
105 ->willReturn(
new class () {
106 public function __toString()
108 return 'http://localhost:80';
113 ->method(
"getQueryParams")
130 $this->table_factory = $table_factory;
134 return new I\Button\Factory();
138 return new I\Dropdown\Factory();
142 return new I\Symbol\Factory(
150 return $this->table_factory;
154 return new I\Divider\Factory();
163 $signal =
new I\Signal(
'signal_id');
164 $closure = $renderer->p_getMultiActionHandler($signal);
167 "$(document).on('signal_id', function(event, signal_data) {
168 il.UI.table.data.get('component_id').doMultiAction(signal_data);
172 $this->assertEquals($expected, $actual);
181 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
183 $action =
$f->standard(
'label', $builder,
$token);
184 $closure = $renderer->p_getActionRegistration(
'action_id', $action);
189 'il.UI.table.data.get(\'component_id\').registerAction(\'action_id\', false, new il.UI.core.URLBuilder(new URL("http://wwww.ilias.de?ref_id=1&namespace_param="), new Map([["namespace_param",new il.UI.core.URLBuilderToken(["namespace"], "param",'
191 $this->assertStringStartsWith($expected, $actual);
198 $signal1 =
new I\Signal(
'signal_id');
199 $signal2 =
new I\Signal(
'signal_id2');
202 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
204 $f->standard(
'label1', $builder,
$token),
205 $f->standard(
'label2', $builder,
$token)
208 $renderer->p_buildMultiActionsDropdown([], $signal1, $signal2)
212 count($renderer->p_buildMultiActionsDropdown($actions, $signal1, $signal2)->getItems())
221 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
223 'a1' =>
$f->standard(
'label1', $builder,
$token)->withAsync(),
224 'a2' =>
$f->standard(
'label2', $builder,
$token)
228 count($renderer->p_getSingleActionsForRow(
'row_id-1', $actions)->getItems())
235 $data_factory = new \ILIAS\Data\Factory();
236 $tpl = $this->
getTemplateFactory()->getTemplate(
"src/UI/templates/default/Table/tpl.datatable.html",
true,
true);
239 public function getRows(
240 Component\Table\DataRowBuilder $row_builder,
241 array $visible_column_ids,
245 ?array $additional_parameters
247 yield $row_builder->buldDataRow(
'', []);
249 public function getTotalRowCount(
251 ?array $additional_parameters
257 'f1' =>
$f->text(
"Field 1")->withIndex(1),
258 'f2' =>
$f->text(
"Field 2")->withIndex(2)->withIsSortable(
false),
259 'f3' =>
$f->number(
"Field 3")->withIndex(3)
261 $sortation_signal =
new I\Signal(
'sort_header_signal_id');
262 $sortation_signal->addOption(
'value',
'f1:ASC');
269<div
class=
"c-table-data" id=
"{ID}">
270 <div
class=
"viewcontrols">{VIEW_CONTROLS}</div>
271 <div
class=
"c-table-data__table-wrapper">
272 <table
class=
"c-table-data__table" role=
"grid" aria-labelledby=
"{ID}_label" aria-colcount=
"{COL_COUNT}">
274 <tr
class=
"c-table-data__header c-table-data__row" role=
"rowgroup">
275 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" role=
"columnheader" tabindex=
"-1" aria-colindex=
"0" aria-sort=
"order_option_generic_ascending">
276 <div
class=
"c-table-data__header__resize-wrapper">
277 <a tabindex=
"0" class=
"glyph" href=
"#" aria-label=
"sort_ascending" id=
"id_2"><span
class=
"glyphicon glyphicon-arrow-up" aria-hidden=
"true"></span></a>
278 <button
class=
"btn btn-link" id=
"id_1">Field 1</button>
281 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" role=
"columnheader" tabindex=
"-1" aria-colindex=
"1">
282 <div
class=
"c-table-data__header__resize-wrapper">Field 2</div>
284 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--number" role=
"columnheader" tabindex=
"-1" aria-colindex=
"2">
285 <div
class=
"c-table-data__header__resize-wrapper">
286 <button
class=
"btn btn-link" id=
"id_3">Field 3</button>
291 <tbody
class=
"c-table-data__body" role=
"rowgroup"></tbody>
294 <div
class=
"c-table-data__async_modal_container"></div>
296 <div
class=
"c-table-data__async_message modal" role=
"dialog" id=
"{ID}_msgmodal">
297 <div
class=
"modal-dialog" role=
"document">
298 <div
class=
"modal-content">
299 <div
class=
"modal-header">
300 <button type=
"button" class=
"close" data-dismiss=
"modal" aria-label=
"close"><span aria-hidden=
"true">×</span></button>
302 <div
class=
"c-table-data__async_messageresponse modal-body"></div>
310 $this->assertEquals($expected, $actual);
317 $data_factory = new \ILIAS\Data\Factory();
318 $tpl = $this->
getTemplateFactory()->getTemplate(
"src/UI/templates/default/Table/tpl.datatable.html",
true,
true);
321 public function getRows(
322 Component\Table\DataRowBuilder $row_builder,
323 array $visible_column_ids,
327 ?array $additional_parameters
329 yield $row_builder->buldDataRow(
'', []);
331 public function getTotalRowCount(
333 ?array $additional_parameters
339 'f1' =>
$f->text(
"Field 1")->withIsSortable(
false),
340 'f2' =>
$f->text(
"Field 2")->withIsSortable(
false)
343 $sortation_signal =
null;
350<div
class=
"c-table-data" id=
"{ID}">
351 <div
class=
"viewcontrols">{VIEW_CONTROLS}</div>
352 <div
class=
"c-table-data__table-wrapper">
353 <table
class=
"c-table-data__table" role=
"grid" aria-labelledby=
"{ID}_label" aria-colcount=
"{COL_COUNT}">
355 <tr
class=
"c-table-data__header c-table-data__row" role=
"rowgroup">
356 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" role=
"columnheader" tabindex=
"-1" aria-colindex=
"0">
357 <div
class=
"c-table-data__header__resize-wrapper">Field 1</div>
359 <th
class=
"c-table-data__header c-table-data__cell c-table-data__cell--text" role=
"columnheader" tabindex=
"-1" aria-colindex=
"1">
360 <div
class=
"c-table-data__header__resize-wrapper">Field 2</div>
364 <tbody
class=
"c-table-data__body" role=
"rowgroup"></tbody>
368 <div
class=
"c-table-data__async_modal_container"></div>
370 <div
class=
"c-table-data__async_message modal" role=
"dialog" id=
"{ID}_msgmodal">
371 <div
class=
"modal-dialog" role=
"document">
372 <div
class=
"modal-content">
373 <div
class=
"modal-header">
374 <button type=
"button" class=
"close" data-dismiss=
"modal" aria-label=
"close"><span aria-hidden=
"true">×</span></button>
376 <div
class=
"c-table-data__async_messageresponse modal-body"></div>
384 $this->assertEquals($expected, $actual);
390 $data_factory = new \ILIAS\Data\Factory();
391 $tpl = $this->
getTemplateFactory()->getTemplate(
"src/UI/templates/default/Table/tpl.datatable.html",
true,
true);
394 $url = $data_factory->uri(
'http://wwww.ilias.de?ref_id=1');
396 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
402 public function getRows(
403 Component\Table\DataRowBuilder $row_builder,
404 array $visible_column_ids,
408 ?array $additional_parameters
410 yield $row_builder->buldDataRow(
'', []);
412 public function getTotalRowCount(
414 ?array $additional_parameters
420 'f1' =>
$f->text(
"Field 1")->withIsSortable(
false),
423 $sortation_signal =
null;
426 ->withActions($actions)
431 $expected =
'<th class="c-table-data__header c-table-data__cell c-table-data__header__rowaction" role="columnheader" aria-colindex="1">actions</th>';
432 $this->assertStringContainsString($expected, $actual);
439 'f1' =>
$f->text(
"Field 1")->withIndex(1),
440 'f2' =>
$f->text(
"Field 2")->withIndex(2),
441 'f3' =>
$f->number(
"Field 3")->withIndex(3)
446 list($builder,
$token) = $url_builder->acquireParameter([
'namespace'],
'param');
448 'a1' =>
$f->standard(
'label1', $builder,
$token)->withAsync(),
449 'a2' =>
$f->standard(
'label2', $builder,
$token)
452 $rb = (
new I\Table\DataRowBuilder())
453 ->withMultiActionsPresent(
true)
454 ->withSingleActions($actions)
455 ->withVisibleColumns($columns);
457 $row = $rb->buildDataRow(
'row_id-1', []);
458 $this->assertInstanceOf(
Component\Table\DataRow::class, $row);
460 return [$rb, $columns, $actions];
468 list($rb, $columns, $actions) =
$params;
474 $row = $rb->buildDataRow(
'row_id-1', $record);
486 $row->getCellContent(
'f2')
499<td
class=
"c-table-data__cell c-table-data__rowselection" role=
"gridcell" tabindex=
"-1">
500 <input type=
"checkbox" value=
"row_id-1" class=
"c-table-data__row-selector">
502<td
class=
"c-table-data__cell c-table-data__cell--text " role=
"gridcell" aria-colindex=
"1" tabindex=
"-1">
503 <span
class=
"c-table-data__cell__col-title">Field 1:</span>v1
505<td
class=
"c-table-data__cell c-table-data__cell--text " role=
"gridcell" aria-colindex=
"2" tabindex=
"-1">
506 <span
class=
"c-table-data__cell__col-title">Field 2:</span>v2
508<td
class=
"c-table-data__cell c-table-data__cell--number " role=
"gridcell" aria-colindex=
"3" tabindex=
"-1">
509 <span
class=
"c-table-data__cell__col-title">Field 3:</span>3
511<td
class=
"c-table-data__cell c-table-data__rowaction" role=
"gridcell" tabindex=
"-1">
512 <div
class=
"dropdown">
513 <button
class=
"btn btn-default dropdown-toggle" type=
"button" data-toggle=
"dropdown" id=
"id_3" aria-label=
"actions" aria-haspopup=
"true" aria-expanded=
"false" aria-controls=
"id_3_menu"><span
class=
"caret"></span></button>
514 <ul
id=
"id_3_menu" class=
"dropdown-menu">
515 <li><button
class=
"btn btn-link" data-action=
"http://wwww.ilias.de?ref_id=1&namespace_param%5B%5D=row_id-1" id=
"id_1">label1</button></li>
516 <li><button
class=
"btn btn-link" data-action=
"http://wwww.ilias.de?ref_id=1&namespace_param%5B%5D=row_id-1" id=
"id_2">label2</button></li>
522 $this->assertEquals($expected, $actual);
528 public function getRows(
529 Component\Table\DataRowBuilder $row_builder,
530 array $visible_column_ids,
534 ?array $additional_parameters
539 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?
int
546 'f1' => $this->
getUIFactory()->table()->column()->text(
'f1'),
547 'f2' => $this->
getUIFactory()->table()->column()->text(
'f2'),
548 'f3' => $this->
getUIFactory()->table()->column()->text(
'f3'),
549 'f4' => $this->
getUIFactory()->table()->column()->text(
'f4'),
550 'f5' => $this->
getUIFactory()->table()->column()->text(
'f5'),
558 $translation = $this->
getLanguage()->txt(
'ui_table_no_records');
559 $column_count = count($columns);
562 $this->assertTrue(str_contains($html,
"colspan=\"$column_count\""));
564 $this->assertTrue(str_contains($html, $translation));
wrapper around the renderer to expose protected functions
p_renderTableHeader(TestDefaultRenderer $default_renderer, I\Table\Data $component, $tpl, ?I\Signal $sortation_signal)
p_getMultiActionHandler(I\Signal $signal)
p_getSingleActionsForRow(string $row_id, array $actions)
p_getActionRegistration(string $action_id, I\Table\Action\Action $action)
p_buildMultiActionsDropdown(array $actions, I\Signal $action_signal, I\Signal $modal_signal)
Tests for the Renderer of DataTables.
testDataTableMultiActionsDropdown()
testDataTableGetMultiActionHandler()
testRenderEmptyDataCell()
testDataTableSingleActionsDropdown()
testDataTableRenderHeaderWithActions()
testDataTableDataRowFromBuilder(array $params)
@depends testDataTableRowBuilder
testDataTableRenderTableHeader()
testDataTableRenderStandardRow(I\Table\DataRow $row)
@depends testDataTableDataRowFromBuilder
testDataTableRenderHeaderWithoutSortableColums()
testDataTableGetActionRegistration()
testDataTableRowBuilder()
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a range of whole positive numbers.
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Basic Tests for all Tables.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.