ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\LegalDocuments\Table\HistoryTable Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\Table\HistoryTable:
+ Collaboration diagram for ILIAS\LegalDocuments\Table\HistoryTable:

Public Member Functions

 __construct (private readonly HistoryRepository $repository, private readonly ProvideDocument $document, public readonly string $reset_command, private readonly string $auto_complete_link, private readonly UI $ui, private readonly DocumentModal $modal, private readonly Closure $create, ?Closure $format_date=null)
 @template C More...
 
 columns ()
 
 config (TableConfig $config)
 
 rows (TableSelection $selection)
 
 name ()
 
 columns ()
 
 config (TableConfig $config)
 
 name ()
 
 rows (TableSelection $select)
 

Private Member Functions

 row (History $record)
 
 userName ()
 
 time ()
 
 showCriteria (History $record)
 

Private Attributes

readonly Closure $format_date
 

Detailed Description

Definition at line 40 of file HistoryTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Table\HistoryTable::__construct ( private readonly HistoryRepository  $repository,
private readonly ProvideDocument  $document,
public readonly string  $reset_command,
private readonly string  $auto_complete_link,
private readonly UI  $ui,
private readonly DocumentModal  $modal,
private readonly Closure  $create,
?Closure  $format_date = null 
)

@template C

Parameters
Closure(class-string<C>,mixed...)C $create
null|Closure(DateTimeImmutable)string $format_date

Definition at line 50 of file HistoryTable.php.

59 {
60 $this->format_date = $format_date ?? fn(DateTimeImmutable $date) => ilDatePresentation::formatDate(new ilDateTime($date->getTimestamp(), IL_CAL_UNIX));
61 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling

References ILIAS\LegalDocuments\Table\HistoryTable\$format_date, ilDatePresentation\formatDate(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

Member Function Documentation

◆ columns()

ILIAS\LegalDocuments\Table\HistoryTable::columns ( )
Returns
array<string, list<string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 63 of file HistoryTable.php.

63 : array
64 {
65 return [
66 'created' => [$this->ui->txt('tbl_hist_head_acceptance_date'), 'created'],
67 'login' => [$this->ui->txt('tbl_hist_head_login'), 'login'],
68 'firstname' => [$this->ui->txt('tbl_hist_head_firstname'), 'firstname'],
69 'lastname' => [$this->ui->txt('tbl_hist_head_lastname'), 'lastname'],
70 'document' => [$this->ui->txt('tbl_hist_head_document'), 'document'],
71 'criteria' => [$this->ui->txt('tbl_hist_head_criteria')],
72 ];
73 }

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ config()

ILIAS\LegalDocuments\Table\HistoryTable::config ( TableConfig  $config)

Implements ILIAS\LegalDocuments\Table.

Definition at line 75 of file HistoryTable.php.

75 : void
76 {
77 $config->setTitle($this->ui->txt('acceptance_history'));
78 $config->setDefaultOrderField('created');
79 $config->setDefaultOrderDirection('DESC');
80 $config->setSelectableColumns('firstname', 'lastname', 'criteria');
81
82 $filter = $config->asFilter($this->reset_command);
83 $filter->addFilterItem($this->userName());
84 $filter->addFilterItem($this->time(), true);
85 }
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setDefaultOrderField(string $a_defaultorderfield)
setDefaultOrderDirection(string $a_defaultorderdirection)
asFilter(string $reset_command)
setSelectableColumns(string ... $names)

References ILIAS\LegalDocuments\TableConfig\asFilter(), ILIAS\LegalDocuments\TableConfig\setDefaultOrderDirection(), ILIAS\LegalDocuments\TableConfig\setDefaultOrderField(), ILIAS\LegalDocuments\TableConfig\setSelectableColumns(), ILIAS\LegalDocuments\TableConfig\setTitle(), ILIAS\LegalDocuments\Table\HistoryTable\time(), ILIAS\Repository\ui(), and ILIAS\LegalDocuments\Table\HistoryTable\userName().

+ Here is the call graph for this function:

◆ name()

ILIAS\LegalDocuments\Table\HistoryTable::name ( )

Implements ILIAS\LegalDocuments\Table.

Definition at line 104 of file HistoryTable.php.

104 : string
105 {
106 return self::class;
107 }

◆ row()

ILIAS\LegalDocuments\Table\HistoryTable::row ( History  $record)
private

Definition at line 109 of file HistoryTable.php.

109 : array
110 {
111 $user = ($this->create)(ilObjUser::class, $record->creation()->user());
112
113 return [
114 'created' => ($this->format_date)($record->creation()->time()),
115 'login' => $user?->getLogin() ?? $this->ui->txt('deleted'),
116 'firstname' => $user?->getFirstname() ?? '-',
117 'lastname' => $user?->getLastname() ?? '-',
118 'document' => [...$this->modal->create($record->documentContent()), ...$this->modal->popComponents()],
119 'criteria' => $this->showCriteria($record),
120 ];
121 }
modal(string $title="", string $cancel_label="")

References ILIAS\LegalDocuments\Table\HistoryTable\$format_date, ILIAS\LegalDocuments\Value\History\creation(), ILIAS\LegalDocuments\Value\History\documentContent(), ILIAS\Repository\modal(), ILIAS\LegalDocuments\Table\HistoryTable\showCriteria(), and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\rows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rows()

ILIAS\LegalDocuments\Table\HistoryTable::rows ( TableSelection  $select)
Returns
list<array<string, string|Closure(): string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 87 of file HistoryTable.php.

87 : array
88 {
89 $filter = $selection->filter();
90 $period = $filter['period'] ?? [];
91 unset($filter['period']);
92 $filter = array_filter([...$filter, ...$period]);
93
94 $selection->setMaxCount($this->repository->countAll($filter));
95
96 return array_map($this->row(...), $this->repository->all(
97 $filter,
98 [$selection->getOrderField() => $selection->getOrderDirection()],
99 $selection->getOffset(),
100 $selection->getLimit()
101 ));
102 }

References ILIAS\LegalDocuments\TableSelection\filter(), ILIAS\LegalDocuments\TableSelection\getLimit(), ILIAS\LegalDocuments\TableSelection\getOffset(), ILIAS\LegalDocuments\TableSelection\getOrderDirection(), ILIAS\LegalDocuments\TableSelection\getOrderField(), ILIAS\UI\examples\Deck\repository(), ILIAS\LegalDocuments\Table\HistoryTable\row(), and ILIAS\LegalDocuments\TableSelection\setMaxCount().

+ Here is the call graph for this function:

◆ showCriteria()

ILIAS\LegalDocuments\Table\HistoryTable::showCriteria ( History  $record)
private
Returns
string|list<Component>

Definition at line 149 of file HistoryTable.php.

150 {
151 $conv = $this->document->toCondition(...);
152 $components = array_map(fn($c) => $conv($c)->asComponent(), $record->criteriaContent());
153
154 return $components === [] ?
155 $this->ui->txt('tbl_hist_cell_not_criterion') :
157 }
$components
$c
Definition: deliver.php:25

References $c, $components, ILIAS\LegalDocuments\Value\History\criteriaContent(), and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\row().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ time()

ILIAS\LegalDocuments\Table\HistoryTable::time ( )
private

Definition at line 132 of file HistoryTable.php.

133 {
134 class_exists(ilDateTime::class); // Trigger autoloader to ensure IL_CAL_UNIX is defined.
135 $duration = ($this->create)(ResettingDurationInputGUI::class, $this->ui->txt('period'), 'period');
136 $duration->setAllowOpenIntervals(true);
137 $duration->setShowTime(true);
138 $duration->setStartText($this->ui->txt('period_from'));
139 $duration->setEndText($this->ui->txt('period_until'));
140 $duration->setStart(($this->create)(ilDateTime::class, null, IL_CAL_UNIX));
141 $duration->setEnd(($this->create)(ilDateTime::class, null, IL_CAL_UNIX));
142
143 return $duration;
144 }
$duration
input GUI for a time span (start and end date)

References $duration, IL_CAL_UNIX, and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\config().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userName()

ILIAS\LegalDocuments\Table\HistoryTable::userName ( )
private

Definition at line 123 of file HistoryTable.php.

124 {
125 $ul = ($this->create)(ilTextInputGUI::class, join('/', array_map($this->ui->txt(...), ['login', 'email', 'name'])), 'query');
126 $ul->setDataSource($this->auto_complete_link);
127 $ul->setSize(20);
128 $ul->setSubmitFormOnEnter(true);
129 return $ul;
130 }
This class represents a text property in a property form.
setDataSource(string $href, ?string $a_delimiter=null)

References ilTextInputGUI\setDataSource(), and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\config().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $format_date

readonly Closure ILIAS\LegalDocuments\Table\HistoryTable::$format_date
private

The documentation for this class was generated from the following file: