Skip to content
Snippets Groups Projects
Commit 4410efe0 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Modification

parent 02efa44a
No related branches found
No related tags found
No related merge requests found
Pipeline #15736 passed
...@@ -17,16 +17,6 @@ class Module ...@@ -17,16 +17,6 @@ class Module
$moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager); $moduleRouteListener->attach($eventManager);
/* Active un layout spécial si la requête est de type AJAX. Valable pour TOUS les modules de l'application. */
$eventManager->getSharedManager()->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch',
function (MvcEvent $e) {
$request = $e->getRequest();
if ($request instanceof HttpRequest && $request->isXmlHttpRequest()) {
$e->getTarget()->layout('layout/ajax.phtml');
}
}
);
} }
public function getConfig() public function getConfig()
......
...@@ -5,9 +5,11 @@ namespace UnicaenAutoform\Entity\Db; ...@@ -5,9 +5,11 @@ namespace UnicaenAutoform\Entity\Db;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use UnicaenApp\Entity\HistoriqueAwareInterface; use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait; use UnicaenApp\Entity\HistoriqueAwareTrait;
use UnicaenAutoform\Entity\HasMotsClefsAwareTrait;
class Categorie implements HistoriqueAwareInterface { class Categorie implements HistoriqueAwareInterface {
use HistoriqueAwareTrait; use HistoriqueAwareTrait;
use HasMotsClefsAwareTrait;
/** @var integer */ /** @var integer */
private $id; private $id;
......
...@@ -190,7 +190,12 @@ class FormulaireInstance implements HistoriqueAwareInterface { ...@@ -190,7 +190,12 @@ class FormulaireInstance implements HistoriqueAwareInterface {
public function fetchChampReponseByMotsClefs(array $mots) : string public function fetchChampReponseByMotsClefs(array $mots) : string
{ {
foreach ($this->getReponses() as $reponse) { foreach ($this->getReponses() as $reponse) {
if ($reponse->getChamp()->hasMotsClefs($mots) AND $reponse->estNonHistorise()) return $reponse->getReponse(); if ($reponse->getChamp()->hasMotsClefs($mots) AND $reponse->estNonHistorise()) {
if ($reponse->getChamp()->getElement() !== 'Multiple') return $reponse->getReponse();
else {
return str_replace('on_','',$reponse->getReponse());
}
}
} }
return ""; return "";
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<field name="code" column="code" type="string" length="64" nullable="false" /> <field name="code" column="code" type="string" length="64" nullable="false" />
<field name="libelle" column="libelle" type="string" length="256" nullable="false" /> <field name="libelle" column="libelle" type="string" length="256" nullable="false" />
<field name="ordre" column="ordre" type="integer" nullable="false" /> <field name="ordre" column="ordre" type="integer" nullable="false" />
<field name="motsClefs" column="mots_clefs" type="string" length="1024" nullable="true" />
<many-to-one target-entity="UnicaenAutoform\Entity\Db\Formulaire" field="formulaire"> <many-to-one target-entity="UnicaenAutoform\Entity\Db\Formulaire" field="formulaire">
<join-column name="formulaire" referenced-column-name="id"/> <join-column name="formulaire" referenced-column-name="id"/>
......
...@@ -32,7 +32,7 @@ $reponses = explode(';', $reponse); ...@@ -32,7 +32,7 @@ $reponses = explode(';', $reponse);
<?php $found = true; ?> <?php $found = true; ?>
<input class="form-control" type="text" <input class="form-control" type="text"
id="<?php echo $champ->getId()?>_<?php echo $position; ?>" name="<?php echo $champ->getId()?>_<?php echo $position; ?>" id="<?php echo $champ->getId()?>_<?php echo $position; ?>" name="<?php echo $champ->getId()?>_<?php echo $position; ?>"
value="<?php echo trim($reponses[$position]); ?>" value="<?php echo isset($reponses[$position])?trim($reponses[$position]):null; ?>"
/> />
<?php endif; ?> <?php endif; ?>
<?php if ($params[0] === 'texte long') : ?> <?php if ($params[0] === 'texte long') : ?>
...@@ -47,7 +47,8 @@ $reponses = explode(';', $reponse); ...@@ -47,7 +47,8 @@ $reponses = explode(';', $reponse);
id="<?php echo $champ->getId(); ?>_<?php echo $position; ?>" name="<?php echo $champ->getId(); ?>_<?php echo $position; ?>" id="<?php echo $champ->getId(); ?>_<?php echo $position; ?>" name="<?php echo $champ->getId(); ?>_<?php echo $position; ?>"
> >
<?php for ($param_position = 2; $param_position < count($params) ; $param_position++) : ?> <?php for ($param_position = 2; $param_position < count($params) ; $param_position++) : ?>
<option value="<?php echo $params[$param_position]; ?>" <?php if ($params[$param_position]===$reponses[$position]) echo " selected "; ?>> <?php $creponse = isset($reponses[$position])?trim($reponses[$position]):null; ?>
<option value="<?php echo $params[$param_position]; ?>" <?php if ($params[$param_position]===$creponse) echo " selected "; ?>>
<?php echo $params[$param_position]; ?> <?php echo $params[$param_position]; ?>
</option> </option>
<?php endfor; ?> <?php endfor; ?>
......
...@@ -48,7 +48,9 @@ $a=1; ...@@ -48,7 +48,9 @@ $a=1;
</div> </div>
<div class="panel-body body-reductible"> <div class="panel-body body-reductible">
<?php foreach ($champs as $champ) : ?> <?php foreach ($champs as $champ) : ?>
<div> <?php echo $this->champAsInput()->render($champ, $reponses); ?> </div> <div>
<?php echo $this->champAsInput()->render($champ, $reponses); ?>
</div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
......
...@@ -83,6 +83,15 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch ...@@ -83,6 +83,15 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch
<?php if ($categorie->estHistorise()) : ?> <?php if ($categorie->estHistorise()) : ?>
<small>(<?php echo count($categorie->getChamps()); ?> champs)</small> <small>(<?php echo count($categorie->getChamps()); ?> champs)</small>
<?php endif; ?> <?php endif; ?>
<br/>
<?php
$mots = explode(";",$categorie->getMotsClefs());
$mots = array_filter($mots, function ($a) { return trim($a) !== '';});
?>
<?php foreach ($mots as $motclef) : ?>
<span class="motclef"> <?php echo $motclef; ?> </span>
<?php endforeach; ?>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
...@@ -159,6 +168,14 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch ...@@ -159,6 +168,14 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch
<?php <?php
echo $this->champAsInput()->render($champ); echo $this->champAsInput()->render($champ);
?> ?>
<?php
$mots = explode(";",$champ->getMotsClefs());
$mots = array_filter($mots, function ($a) { return trim($a) !== '';});
?>
<?php foreach ($mots as $motclef) : ?>
<span class="motclef"> <?php echo $motclef; ?> </span>
<?php endforeach; ?>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<?php if ($canModifierChamp) : ?> <?php if ($canModifierChamp) : ?>
...@@ -233,3 +250,17 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch ...@@ -233,3 +250,17 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch
}); });
}); });
</script> </script>
<style>
.motclef {
background: lightgrey;
color: black;
font-family: monospace;
border: 1px grey solid;
border-radius: 0.5rem;
margin-left: 0.5rem;
margin-bottom: 0.5rem;
padding-left: 1rem;
padding-right: 1rem;
}
</style>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment