Commit f5c6f7338a711ba25584d57a2e70f2ca8231c464
1 parent
2b8ee329
Exists in
master
and in
1 other branch
bugfix TESTS
Showing
3 changed files
with
62 additions
and
54 deletions
Show diff stats
src/Template/SurCategories/view.ctp
1 | +<?php | |
2 | +// Variables passées par le contrôleur | |
3 | + | |
4 | +// fonctions | |
5 | +$displayElement = $displayElement; | |
6 | +$categories = $categories; | |
7 | +$materiels = $materiels; | |
8 | +?> | |
1 | 9 | |
2 | 10 | <div class="surCategories view"> |
11 | + | |
3 | 12 | <h2>Détail domaine</h2> |
4 | 13 | <table style="margin-bottom: 30px;"> |
5 | 14 | |
... | ... | @@ -42,59 +51,14 @@ |
42 | 51 | |
43 | 52 | </table> |
44 | 53 | |
54 | + <?php | |
55 | + //displaySectionShowHide($this->Html, false, 'Aucune catégorie liée', 'categs', 'Catégories', $categories, 'nom', 'Categories', 'catégorie'); | |
56 | + $this->MyButton->displaySectionShowHide(false, 'Aucune catégorie liée', 'categs', 'Catégories', $categories, 'nom', 'Categories', 'catégorie'); | |
57 | + ?> | |
45 | 58 | |
46 | - <h3 id="t_categs" class='toggle' style="cursor: pointer;"> | |
47 | - <i class="icon-chevron-down" style="font-size: 14px;" id="i_categs"></i> | |
48 | - <span style="text-decoration: underline;">Catégories associées (<?= $categories->count() ?>)</span> | |
49 | - </h3> | |
50 | - | |
51 | - <div id="categs" style="margin-bottom: 20px;"> | |
52 | - | |
53 | - <?php if (!empty($categories)) { ?> | |
54 | - <table> | |
55 | - <tr> | |
56 | - <th><?= __('Nom') ?></th> | |
57 | - <th style="width: 50px;"><?= __('Détail') ?></th> | |
58 | - </tr> | |
59 | - <?php foreach ($categories as $category): ?> | |
60 | - <tr> | |
61 | - <td><?= $this->Html->link(h($category->nom), ['controller' => 'Categories', 'action' => 'view', h($category->id)]); ?></td> | |
62 | - | |
63 | - <td class="actions"> | |
64 | - <?= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => 'Categories', 'action' => 'view', $category->id], ['escape' => false, 'style' => 'margin:0']) ?> | |
65 | - </td> | |
66 | - </tr> | |
67 | - <?php endforeach; ?> | |
68 | - </table> | |
69 | - <?php }else { echo 'Aucune catégorie lié à ce domaine.'; } ?> | |
70 | - </div> | |
71 | - | |
72 | - | |
73 | - <h3 id="t_materiels" class='toggle' style="cursor: pointer;"> | |
74 | - <i class="icon-chevron-down" style="font-size: 14px;" id="i_materiels"></i> | |
75 | - <span style="text-decoration: underline;">Materiels associés (<?= $materiels->count()?>)</span> | |
76 | - </h3> | |
77 | - <div id="materiels" style="margin-bottom: 20px;"> | |
78 | - | |
79 | - <?php if (!empty($materiels)) { ?> | |
80 | - <table> | |
81 | - <tr> | |
82 | - <th><?= __('Désignation') ?></th> | |
83 | - <th style="width: 50px;"><?= __('Détail') ?></th> | |
84 | - </tr> | |
85 | - <?php foreach ($materiels as $materiel): ?> | |
86 | - <tr> | |
87 | - | |
88 | - <td><?= $this->Html->link(h($materiel->designation), ['controller' => 'Materiels', 'action' => 'view', h($materiel->id)]); ?></td> | |
89 | - | |
90 | - <td class="actions"> | |
91 | - <?= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => 'Materiels', 'action' => 'view', $materiel->id], ['escape' => false, 'style' => 'margin:0']) ?> | |
92 | - </td> | |
93 | - </tr> | |
94 | - <?php endforeach; ?> | |
95 | - </table> | |
96 | - <?php }else { echo 'Aucun matériel lié à ce domaine.'; } ?> | |
97 | - </div> | |
59 | + <?php | |
60 | + $this->MyButton->displaySectionShowHide(true, 'Aucun matériel lié', 'materiels', 'Matériels', $materiels, 'designation', 'Materiels', 'matériel'); | |
61 | + ?> | |
98 | 62 | |
99 | 63 | </div> |
100 | 64 | ... | ... |
src/View/Helper/MyButtonHelper.php
... | ... | @@ -54,4 +54,48 @@ class MyButtonHelper extends Helper { |
54 | 54 | if ($valeur!="") echo "<TR> <TD><strong>".__($nom)."</strong></TD> <$TD>".h($valeur)."</TD> </TR>"; |
55 | 55 | } |
56 | 56 | |
57 | + | |
58 | + function displaySectionShowHide($is_masculine, $none, $id_name, $title, $entities, $name_field, $controller, $entity_name) { | |
59 | + $id_h3 = 't_'.$id_name; | |
60 | + $id_i = 'i_'.$id_name; | |
61 | + $title = $title.' associé'. ($is_masculine ? 's' : 'es'); | |
62 | + | |
63 | + echo "<h3 id='$id_h3' class='toggle' style='cursor: pointer;'>"; | |
64 | + echo "<i class='icon-chevron-down' style='font-size: 14px;' id='$id_i'></i>"; | |
65 | + echo " <span style='text-decoration: underline;'>$title (".$entities->count().")</span>"; | |
66 | + echo "</h3>"; | |
67 | + | |
68 | + echo "<div id='$id_name' style='margin-bottom: 20px;'>"; | |
69 | + //if (true) { | |
70 | + if (empty($entities)) { | |
71 | + //echo "Aucune $entity_name liée à ce domaine."; | |
72 | + $none = $is_masculine ? "Aucun $entity_name associé" : "Aucune $entity_name associée"; | |
73 | + echo $none; | |
74 | + } | |
75 | + else { | |
76 | + echo "<table>"; | |
77 | + /* | |
78 | + <tr> | |
79 | + <th><= __('Nom') ?></th> | |
80 | + <th style="width: 50px;"><= __('Détail') ?></th> | |
81 | + </tr> | |
82 | + */ | |
83 | + foreach ($entities as $entity) { | |
84 | + echo "<tr>"; | |
85 | + echo "<td>"; | |
86 | + echo ' '.$this->Html->link(h($entity->$name_field), ['controller' => $controller, 'action' => 'view', h($entity->id)]); | |
87 | + echo "</td>"; | |
88 | + /* | |
89 | + <td class="actions"> | |
90 | + <= $this->Html->link(__('<i class="icon-search"></i>'), ['controller' => $controller, 'action' => 'view', $entity->id], ['escape' => false, 'style' => 'margin:0']) ?> | |
91 | + </td> | |
92 | + */ | |
93 | + echo "</tr>"; | |
94 | + } | |
95 | + echo "</table>"; | |
96 | + } | |
97 | + echo "</div>"; | |
98 | + } // displaySectionShowHide() | |
99 | + | |
100 | + | |
57 | 101 | } | ... | ... |
tests/TestCase/Controller/MaterielsControllerTest.php
... | ... | @@ -498,7 +498,7 @@ class MaterielsControllerTest extends General { |
498 | 498 | $this->assertResponseContains("Liste des matériels (6)", 'Le profil '.$role.' ne devrait PAS voir les matériels archivés.'); |
499 | 499 | $this->assertResponseNotContains("A valider", 'Le profil '.$role.' ne devrait PAS avoir accès à des filtres par statut.'); |
500 | 500 | } |
501 | - $this->assertResponseContainsIf($role, ($this->getUserRole() != 'Utilisateur'), ["Exporter la liste complete"=>"un bouton Exporter"]); | |
501 | + $this->assertResponseContainsIf($role, ($this->getUserRole() != 'Utilisateur'), ["Exporter la liste complète"=>"un bouton Exporter"]); | |
502 | 502 | |
503 | 503 | //$this->get('/materiels/index/CREATED'); |
504 | 504 | $this->get('/materiels/index?status=CREATED'); |
... | ... | @@ -592,7 +592,7 @@ class MaterielsControllerTest extends General { |
592 | 592 | //if ( in_array($role, ['ADMIN','ADMINP','SUPER']) ) { |
593 | 593 | if ($this->USER_IS_ADMIN_AT_LEAST()) { |
594 | 594 | $this->assertResponseContains("Informations administratives"); |
595 | - $this->assertResponseContains("CentreFinancier/EOTP"); | |
595 | + $this->assertResponseContains("Centre(s) Financier(s) / EOTP"); | |
596 | 596 | } |
597 | 597 | else $this->assertResponseNotContains("Informations administratives"); |
598 | 598 | ... | ... |