-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathindex.twig
More file actions
92 lines (92 loc) · 5.06 KB
/
Copy pathindex.twig
File metadata and controls
92 lines (92 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{#
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 2.0.0
* @license https://www.opensource.org/licenses/mit-license.php MIT License
*/
#}
<?php
/**
* @var \{{ namespace }}\View\AppView $this
* @var iterable<\{{ entityClass }}> ${{ pluralVar }}
*/
?>
<div class="{{ pluralVar }} index content">
{% set fields = Bake.filterFields(fields, schema, modelObject, indexColumns, ['binary', 'text']) %}
<?= $this->Html->link({% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'New {{ singularHumanName }}'), ['action' => 'add'], ['class' => 'button float-right']) ?>
{% set done = [] %}
<h3><?= {% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'{{ pluralHumanName }}') ?></h3>
<div class="table-responsive">
<table>
<thead>
<tr>
{% for field in fields %}
<th><?= $this->Paginator->sort('{{ field }}') ?></th>
{% endfor %}
<th class="actions"><?= {% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach (${{ pluralVar }} as ${{ singularVar }}): ?>
<tr>
{% for field in fields %}
{%~ set isKey = false %}
{%~ if associations.BelongsTo is defined %}
{%~ for alias, details in associations.BelongsTo %}
{%~ if field == details.foreignKey %}
{%~ set isKey = true %}
<td><?= ${{ singularVar }}->hasValue('{{ details.property }}') ? $this->Html->link(${{ singularVar }}->{{ details.property }}->{{ details.displayField }}, ['controller' => '{{ details.controller }}', 'action' => 'view', ${{ singularVar }}->{{ details.property }}->{{ details.primaryKey[0] }}]) : '' ?></td>
{%~ endif %}
{%~ endfor %}
{%~ endif %}
{%~ if isKey is not same as(true) %}
{%~ set columnData = Bake.columnData(field, schema) %}
{%~ set supportsLabel = Bake.enumSupportsLabel(field, schema) %}
{%~ if columnData.type starts with 'enum-' %}
<td><?= ${{ singularVar }}->{{ field }} === null ? '' : h(${{ singularVar }}->{{ field }}->{% if supportsLabel %}label(){% else %}value{% endif %}) ?></td>
{%~ elseif columnData.type not in ['integer', 'float', 'decimal', 'biginteger', 'smallinteger', 'tinyinteger'] %}
<td><?= h(${{ singularVar }}->{{ field }}) ?></td>
{%~ elseif columnData.null %}
<td><?= ${{ singularVar }}->{{ field }} === null ? '' : $this->Number->format(${{ singularVar }}->{{ field }}) ?></td>
{%~ else %}
<td><?= $this->Number->format(${{ singularVar }}->{{ field }}) ?></td>
{%~ endif %}
{%~ endif %}
{% endfor %}
{% set pk = '$' ~ singularVar ~ '->' ~ primaryKey[0] %}
<td class="actions">
<?= $this->Html->link({% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'View'), ['action' => 'view', {{ pk|raw }}]) ?>
<?= $this->Html->link({% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'Edit'), ['action' => 'edit', {{ pk|raw }}]) ?>
<?= $this->Form->postLink(
{% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'Delete'),
['action' => 'delete', {{ pk|raw }}],
[
'method' => 'delete',
'confirm' => {% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'Are you sure you want to delete # {0}?', {{ pk|raw }}),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . {% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'first')) ?>
<?= $this->Paginator->prev('< ' . {% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next({% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'next') . ' >') ?>
<?= $this->Paginator->last({% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter({% if useDomain %}__d('{{ plugin }}', {% else %}__({% endif %}'Page {{ '{{' }}page{{ '}}' }} of {{ '{{' }}pages{{ '}}' }}, showing {{ '{{' }}current{{ '}}' }} record(s) out of {{ '{{' }}count{{ '}}' }} total')) ?></p>
</div>
</div>