PSMList 0.4.0 PSM-040-009
| Ordre affichage : | 8 | Création : | 26/04/2023 13h52 |
| Index BL : | 9 | Modification : | 20/06/2023 10h25 |
| BL : | PSM-040-009 | ||
| Source : | Aucune | Soeurs : | - |
| Fin dev : | D (Done) | Ticket : | - |
| Contrôle dev effectué : | Fiche : | - | |
| C.Qualif. : | #000000 | ||
| Activé : | Icône FA : | Par défaut | |
| Contact : | ARS - Arshellan | Qualification : | Nouveauté |
| Répartition : | - | Module : | Custom |
| Dev : | ARS - Arshellan | Sous module : | Expansion |
| Provenance : | 0.4.0 New | Constat : | - |
| Début : | - | Charge j. : | - |
| Fin : | - | Délai j. : | - |
| Priorité : | - | Pokercard : | - |
| Estimatif j. : | - | ||
| Description : | Creation forms for custom stuff should autofill the numid field with the smallest empty spot in the expansion, prevent the users from accessing the form altogether if he can't add more stuff | ||
| Texte Commit : | - | ||
| Description client : | The creation forms now guess which spot in the numbering scheme of your custom expansion is available and will autofill the field with that number. (You can still change it if you want to use a different ID) | ||
| Fascicule : | Ne pas communiquer : | ||
| Alerte Mailing : |
| Statut PreP : | OK - Validé | Testeur : | ARS - Arshellan |
in extensionRepository:<br/><br/><br/><br/><br/> /**<br/> * Finds the smallest unusued numid from an expansion.<br/> * @param Extension $extension<br/> * @return string<br/> */<br/> public function getSmallestAvailableNumid(Extension $extension): string<br/> {<br/> $qb = $this->entityManager->createQueryBuilder();<br/> $qb->select('s.numid')<br/> ->from('App:Ship', 's')<br/> ->where('s.extension = :extension')<br/> ->setParameter('extension', $extension);<br/> $results = $qb->getQuery()->getResult();<br/> $shipNumids = array_column($results, 'numid');<br/> $qb = null;<br/><br/> $qb = $this->entityManager->createQueryBuilder();<br/> $qb->select('c.numid')<br/> ->from('App:Crew', 'c')<br/> ->where('c.extension = :extension')<br/> ->setParameter('extension', $extension);<br/> $results = $qb->getQuery()->getResult();<br/> $crewNumids = array_column($results, 'numid');<br/> $qb = null;<br/><br/> $qb = $this->entityManager->createQueryBuilder();<br/> $qb->select('t.numid')<br/> ->from('App:Treasure', 't')<br/> ->where('t.extension = :extension')<br/> ->setParameter('extension', $extension);<br/> $results = $qb->getQuery()->getResult();<br/> $treasureNumids = array_column($results, 'numid');<br/> $qb = null;<br/><br/> // merge the results together<br/> $expNumids = array_merge($shipNumids, $crewNumids, $treasureNumids);<br/> asort($expNumids);<br/> dump($expNumids);<br/> $expNumids_int = array_map('intval', $expNumids);<br/> dump($expNumids_int);<br/><br/> // Find the smallest missing number<br/> $smallestSpot = min(array_diff(range(min($expNumids_int), max($expNumids_int)), $expNumids_int));<br/><br/> dump($smallestSpot);<br/><br/> return str_pad( $smallestSpot,3, '0', STR_PAD_LEFT);<br/> }
shipController line 320 :<br/><br/><br/> $obj = new Ship();<br/> $defaultExpansion = null;<br/> $expansionParam = $request->query->get('e');<br/> if ($expansionParam <> null) {<br/> $defaultExpansion = $expansionRepo->findOneBy(array('slugname'=>$expansionParam));<br/> <br/> $numidParam = $request->query->get('i');<br/> if ($numidParam == null) {<br/> $obj->setNumid($expansionRepo->getSmallestAvailableNumid($defaultExpansion));<br/> } else {<br/> $sanitizedNumidParam = substr(filter_var($numidParam, FILTER_SANITIZE_NUMBER_INT), 0, 3);<br/> if ($sanitizedNumidParam == '') {<br/> $obj->setNumid($expansionRepo->getSmallestAvailableNumid($defaultExpansion));<br/> } else {<br/> $obj->setNumid(str_pad($sanitizedNumidParam,3, '0', STR_PAD_LEFT));<br/> }<br/> }<br/> }<br/><br/><br/>and also remove the previous (new Ship) line