3 declare(strict_types=1);
14 $ui_factory = $DIC->ui()->factory();
15 $renderer = $DIC->ui()->renderer();
17 $target = $DIC->http()->request()->getRequestTarget();
21 $tpl->addCss(
'src/UI/examples/Table/Presentation/presentation_alignment_example.css');
27 $aria_label =
"filter entries";
28 $active_view_control =
'Alle';
30 "Alle" => $target .
'&all=1',
31 "Mehr als 5 Antworten" => $target .
'&all=0' 35 $active_view_control =
'Mehr als 5 Antworten';
37 $view_controls = array(
38 $ui_factory->viewControl()->mode($actions, $aria_label)->withActive($active_view_control)
42 $modal = $ui_factory->modal()->interruptive(
'zur Frage',
'This is just an example',
'#')
43 ->withActionButtonLabel(
'Go');
45 $mapping_closure =
function ($row, $record, $ui_factory, $environment) use ($modal) {
47 ->withHeadline($record[
'question_title'])
49 $ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_ques.svg',
'')
51 ->withSubheadline($record[
'question_txt'])
52 ->withImportantFields(
55 'Beantwortet: ' => $record[
'stats'][
'total'],
56 'Häufigste Antwort: ' => $record[
'answers'][$record[
'stats'][
'most_common']][
'title']
60 $ui_factory->layout()->alignment()->horizontal()->dynamicallyDistributed(
61 $ui_factory->layout()->alignment()->vertical(
62 $ui_factory->listing()->descriptive([
63 'Werte' => $environment[
'totals']($record[
'answers'])
65 $ui_factory->listing()->descriptive([
66 'Chart' => $environment[
'chart']($record[
'answers'])
69 $ui_factory->listing()->descriptive([
70 '' => $environment[
'stats']($record)
75 $ui_factory->button()->standard(
'zur Frage',
'#')
76 ->withOnClick($modal->getShowSignal())
80 $ptable = $ui_factory->table()->presentation(
81 'Presentation Table with Alignments',
89 return $renderer->render([
91 $ptable->withData(
$data)
97 $totals =
function ($answers) {
98 $ret =
'<div class="example_block content"><table>';
99 $ret .=
'<tr><td></td>' 101 .
'<td style="padding-left: 10px;">Proportion</td></tr>';
103 foreach ($answers as $answer) {
105 .
'<td style="padding-right: 10px;">' . $answer[
'title'] .
'</td>' 106 .
'<td style="text-align:right">' . $answer[
'amount'] .
'</td>' 107 .
'<td style="text-align:right">' . $answer[
'proportion'] .
'%</td>' 111 $ret .=
'</table></div>';
115 $chart =
function ($answers) {
116 $ret =
'<div class="example_block content"><table style="width:100%">';
117 foreach ($answers as $answer) {
118 $ret .=
'<tr style="border-bottom: 1px solid black;">' 119 .
'<td style="width: 200px;">' 122 .
'<div style="background-color:grey; height:20px; width:' . $answer[
'proportion'] .
'%;"></div>' 125 $ret .=
'</table></div>';
129 $stats =
function ($answers) {
131 $ui_factory = $DIC->ui()->factory();
132 $ui_renderer = $DIC->ui()->renderer();
134 $icon = $ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_ques.svg',
'');
136 $ret =
'<div class="example_block stats">';
137 $ret .=
'<h5>' . $ui_renderer->render($icon) .
' ' . $answers[
'type'] .
'</h5>';
138 $ret .=
'<span class="c-stats--title">Beantwortet:</span> ' 139 . $answers[
'stats'][
'total'] .
'<br>' 140 .
'<span class="c-stats--title">Übersprungen:</span> ' 141 . $answers[
'stats'][
'skipped'] .
'<br>' 142 .
'<span class="c-stats--title">Häufigste Antwort:</span> ' 143 . $answers[
'answers'][$answers[
'stats'][
'most_common']][
'title'] .
'<br>' 144 .
'<span class="c-stats--title">Anzahl Häufigste:</span> ' 145 . $answers[
'stats'][
'most_common_total'] .
'<br>' 146 .
'<span class="c-stats--title">Median:</span> ' 147 . $answers[
'answers'][$answers[
'stats'][
'median']][
'title'];
163 'type' =>
'Single Choice Frage',
164 'question_title' =>
'Belastbarkeit',
165 'question_txt' =>
'Wie ausgeprägt ist die Belastbarkeit des / der Auszubildenden?',
167 array(
'title' =>
'weniger ausgeprägt',
'amount' => 2,
'proportion' => 20),
168 array(
'title' =>
'teilweise ausgeprägt',
'amount' => 0,
'proportion' => 0),
169 array(
'title' =>
'ausgeprägt',
'amount' => 6,
'proportion' => 60),
170 array(
'title' =>
'deutlich ausgeprägt',
'amount' => 1,
'proportion' => 10),
171 array(
'title' =>
'stark ausgeprägt',
'amount' => 0,
'proportion' => 0),
172 array(
'title' =>
'sehr stark ausgeprägt',
'amount' => 0,
'proportion' => 0),
173 array(
'title' =>
'übermäßig ausgeprägt',
'amount' => 1,
'proportion' => 10)
179 'most_common_total' => 6,
185 'type' =>
'Single Choice Frage',
186 'question_title' =>
'Dialogfähigkeit, Kundenorientierung, Beratungsfähigkeit',
187 'question_txt' =>
'Wie ausgeprägt ist die Dialogfähigkeit, Kundenorientierung und Beratungsfähigkeit des / der Auszubildenden?',
189 array(
'title' =>
'weniger ausgeprägt',
'amount' => 0,
'proportion' => 0),
190 array(
'title' =>
'teilweise ausgeprägt',
'amount' => 1,
'proportion' => 100),
191 array(
'title' =>
'ausgeprägt',
'amount' => 0,
'proportion' => 0),
192 array(
'title' =>
'deutlich ausgeprägt',
'amount' => 0,
'proportion' => 0),
193 array(
'title' =>
'stark ausgeprägt',
'amount' => 0,
'proportion' => 0),
194 array(
'title' =>
'sehr stark ausgeprägt',
'amount' => 0,
'proportion' => 0),
195 array(
'title' =>
'übermäßig ausgeprägt',
'amount' => 0,
'proportion' => 0)
201 'most_common_total' => 1,
base1()
You can also leave out "further fields" and use alignments instead, add one or more Blocks and Layout...
Refinery Factory $refinery