Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22dddb73bd | |||
| cb49c69662 | |||
| f18ae545d8 | |||
| 3003ced157 | |||
| 2b318ce5d6 | |||
| c10ab08803 | |||
| 85d4726415 | |||
| af13dc0237 |
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '1.9.40'
|
app.version: '1.9.44'
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
<IconLucideEye v-else class="w-5 h-5 mr-2" aria-hidden="true" />
|
<IconLucideEye v-else class="w-5 h-5 mr-2" aria-hidden="true" />
|
||||||
{{ isEditMode ? 'Voir détails' : 'Modifier' }}
|
{{ isEditMode ? 'Voir détails' : 'Modifier' }}
|
||||||
</button>
|
</button>
|
||||||
<NuxtLink :to="backDestination" class="btn btn-ghost btn-sm md:btn-md">
|
<button type="button" class="btn btn-ghost btn-sm md:btn-md" @click="goBack">
|
||||||
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
|
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
|
||||||
{{ backLabel }}
|
{{ backLabel }}
|
||||||
</NuxtLink>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -29,6 +29,7 @@ import IconLucideEye from '~icons/lucide/eye'
|
|||||||
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
|
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
title: string
|
title: string
|
||||||
@@ -43,12 +44,20 @@ defineEmits<{
|
|||||||
'toggle-edit': []
|
'toggle-edit': []
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const backDestination = computed(() => {
|
// Retour : on revient à l'URL précédente pour préserver l'état de la liste
|
||||||
|
// (recherche, tri, pagination persistés en query params). Fallback sur le
|
||||||
|
// backLink si pas d'historique applicatif (accès direct, refresh, lien partagé).
|
||||||
|
const goBack = () => {
|
||||||
if (route.query.from === 'machine' && route.query.machineId) {
|
if (route.query.from === 'machine' && route.query.machineId) {
|
||||||
return `/machine/${route.query.machineId}`
|
router.push(`/machine/${route.query.machineId}`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return props.backLink
|
if (window.history.state?.back) {
|
||||||
})
|
router.back()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
router.push(props.backLink)
|
||||||
|
}
|
||||||
|
|
||||||
const backLabel = computed(() => {
|
const backLabel = computed(() => {
|
||||||
if (route.query.from === 'machine') {
|
if (route.query.from === 'machine') {
|
||||||
|
|||||||
@@ -36,10 +36,10 @@
|
|||||||
>
|
>
|
||||||
<IconLucidePrinter class="w-4 h-4" aria-hidden="true" />
|
<IconLucidePrinter class="w-4 h-4" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
<NuxtLink to="/machines" class="btn btn-ghost btn-sm md:btn-md">
|
<button type="button" class="btn btn-ghost btn-sm md:btn-md" @click="goBack">
|
||||||
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
|
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
|
||||||
Parc machines
|
Parc machines
|
||||||
</NuxtLink>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,6 +52,18 @@ import IconLucidePrinter from '~icons/lucide/printer'
|
|||||||
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
|
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
|
||||||
|
|
||||||
const { canEdit } = usePermissions()
|
const { canEdit } = usePermissions()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
// Retour : revient à l'URL précédente pour préserver la recherche/filtres du
|
||||||
|
// parc machines (persistés en query params). Fallback vers /machines si pas
|
||||||
|
// d'historique applicatif (accès direct, refresh, lien partagé).
|
||||||
|
const goBack = () => {
|
||||||
|
if (window.history.state?.back) {
|
||||||
|
router.back()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
router.push('/machines')
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
title: string
|
title: string
|
||||||
|
|||||||
@@ -281,7 +281,10 @@ const doRefresh = async ({ resetOffset = false }: { resetOffset?: boolean } = {}
|
|||||||
limit.value = response.limit
|
limit.value = response.limit
|
||||||
}
|
}
|
||||||
catch (error: unknown) {
|
catch (error: unknown) {
|
||||||
if (error && typeof error === 'object' && (error as { name?: string }).name === 'AbortError') return
|
// Requête annulée volontairement (nouvelle recherche / démontage) : pas une
|
||||||
|
// vraie erreur. On teste le signal car ofetch encapsule l'AbortError dans
|
||||||
|
// une FetchError, donc error.name n'est pas fiable.
|
||||||
|
if (controller.signal.aborted) return
|
||||||
showError(extractErrorMessage(error))
|
showError(extractErrorMessage(error))
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
@@ -298,8 +298,9 @@ class CustomFieldValueController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Piece if its underlying row still exists in DB, otherwise null.
|
* Returns the Piece if its underlying row still exists in DB, otherwise null.
|
||||||
* Forces a lazy proxy to initialize via getId() and swallows EntityNotFoundException
|
* getId() on a Doctrine proxy does NOT trigger __load(), so we force the proxy
|
||||||
* so an orphan link to a deleted piece doesn't crash custom-field value writes.
|
* to initialize explicitly to handle orphan links here instead of crashing on
|
||||||
|
* the first real getter.
|
||||||
*/
|
*/
|
||||||
private function ensurePieceExists(?Piece $piece): ?Piece
|
private function ensurePieceExists(?Piece $piece): ?Piece
|
||||||
{
|
{
|
||||||
@@ -307,7 +308,7 @@ class CustomFieldValueController extends AbstractController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$piece->getId();
|
$this->entityManager->initializeObject($piece);
|
||||||
|
|
||||||
return $piece;
|
return $piece;
|
||||||
} catch (EntityNotFoundException) {
|
} catch (EntityNotFoundException) {
|
||||||
@@ -315,22 +316,42 @@ class CustomFieldValueController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getId() on a Doctrine proxy returns the identifier without triggering __load(),
|
||||||
|
* so it never raises EntityNotFoundException even if the row is gone. Force the
|
||||||
|
* proxy to initialize explicitly so an orphan CFV is handled here instead of
|
||||||
|
* crashing on the first real getter.
|
||||||
|
*/
|
||||||
|
private function ensureCustomFieldExists(?CustomField $cf): ?CustomField
|
||||||
|
{
|
||||||
|
if (null === $cf) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$this->entityManager->initializeObject($cf);
|
||||||
|
|
||||||
|
return $cf;
|
||||||
|
} catch (EntityNotFoundException) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function normalizeCustomFieldValue(CustomFieldValue $value): array
|
private function normalizeCustomFieldValue(CustomFieldValue $value): array
|
||||||
{
|
{
|
||||||
$customField = $value->getCustomField();
|
$customField = $this->ensureCustomFieldExists($value->getCustomField());
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $value->getId(),
|
'id' => $value->getId(),
|
||||||
'value' => $value->getValue(),
|
'value' => $value->getValue(),
|
||||||
'customFieldId' => $customField->getId(),
|
'customFieldId' => $customField?->getId(),
|
||||||
'customField' => [
|
'customField' => $customField ? [
|
||||||
'id' => $customField->getId(),
|
'id' => $customField->getId(),
|
||||||
'name' => $customField->getName(),
|
'name' => $customField->getName(),
|
||||||
'type' => $customField->getType(),
|
'type' => $customField->getType(),
|
||||||
'required' => $customField->isRequired(),
|
'required' => $customField->isRequired(),
|
||||||
'options' => $customField->getOptions(),
|
'options' => $customField->getOptions(),
|
||||||
'orderIndex' => $customField->getOrderIndex(),
|
'orderIndex' => $customField->getOrderIndex(),
|
||||||
],
|
] : null,
|
||||||
'machineId' => $value->getMachine()?->getId(),
|
'machineId' => $value->getMachine()?->getId(),
|
||||||
'composantId' => $value->getComposant()?->getId(),
|
'composantId' => $value->getComposant()?->getId(),
|
||||||
'pieceId' => $value->getPiece()?->getId(),
|
'pieceId' => $value->getPiece()?->getId(),
|
||||||
|
|||||||
@@ -815,8 +815,9 @@ class MachineStructureController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Piece if its underlying row still exists in DB, otherwise null.
|
* Returns the Piece if its underlying row still exists in DB, otherwise null.
|
||||||
* Forces a lazy proxy to initialize via getId() and swallows EntityNotFoundException
|
* getId() on a Doctrine proxy does NOT trigger __load() (the id is the key used
|
||||||
* so a stale FK (orphan link to a deleted piece) doesn't crash the whole machine view.
|
* to build the proxy), so we force initialization via initializeObject() to
|
||||||
|
* surface a stale FK here instead of crashing on the first real getter.
|
||||||
*/
|
*/
|
||||||
private function ensurePieceExists(?Piece $piece): ?Piece
|
private function ensurePieceExists(?Piece $piece): ?Piece
|
||||||
{
|
{
|
||||||
@@ -824,7 +825,7 @@ class MachineStructureController extends AbstractController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$piece->getId();
|
$this->entityManager->initializeObject($piece);
|
||||||
|
|
||||||
return $piece;
|
return $piece;
|
||||||
} catch (EntityNotFoundException) {
|
} catch (EntityNotFoundException) {
|
||||||
@@ -832,6 +833,26 @@ class MachineStructureController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the CustomField if its underlying row still exists, otherwise null.
|
||||||
|
* getId() on a Doctrine proxy does NOT trigger __load() — the id is the key used
|
||||||
|
* to build the proxy. We force initialization explicitly so a stale FK to a
|
||||||
|
* deleted CustomField surfaces here instead of crashing on getName() later.
|
||||||
|
*/
|
||||||
|
private function ensureCustomFieldExists(?CustomField $cf): ?CustomField
|
||||||
|
{
|
||||||
|
if (null === $cf) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$this->entityManager->initializeObject($cf);
|
||||||
|
|
||||||
|
return $cf;
|
||||||
|
} catch (EntityNotFoundException) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function normalizePiece(Piece $piece): array
|
private function normalizePiece(Piece $piece): array
|
||||||
{
|
{
|
||||||
$type = $piece->getTypePiece();
|
$type = $piece->getTypePiece();
|
||||||
@@ -942,7 +963,10 @@ class MachineStructureController extends AbstractController
|
|||||||
if (!$cfv instanceof CustomFieldValue) {
|
if (!$cfv instanceof CustomFieldValue) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$cf = $cfv->getCustomField();
|
$cf = $this->ensureCustomFieldExists($cfv->getCustomField());
|
||||||
|
if (null === $cf) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$items[] = [
|
$items[] = [
|
||||||
'id' => $cfv->getId(),
|
'id' => $cfv->getId(),
|
||||||
'value' => $cfv->getValue(),
|
'value' => $cfv->getValue(),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use DateTimeInterface;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\Common\EventSubscriber;
|
use Doctrine\Common\EventSubscriber;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\EntityNotFoundException;
|
||||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||||
use Doctrine\ORM\Events;
|
use Doctrine\ORM\Events;
|
||||||
use Doctrine\ORM\UnitOfWork;
|
use Doctrine\ORM\UnitOfWork;
|
||||||
@@ -432,7 +433,12 @@ abstract class AbstractAuditSubscriber implements EventSubscriber
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldName = 'customField:'.$cfv->getCustomField()->getName();
|
try {
|
||||||
|
$cfName = $cfv->getCustomField()->getName();
|
||||||
|
} catch (EntityNotFoundException) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$fieldName = 'customField:'.$cfName;
|
||||||
$diff = [$fieldName => ['from' => $from, 'to' => $to]];
|
$diff = [$fieldName => ['from' => $from, 'to' => $to]];
|
||||||
|
|
||||||
$pendingUpdates[$ownerId] = $this->mergeDiffs($pendingUpdates[$ownerId] ?? [], $diff);
|
$pendingUpdates[$ownerId] = $this->mergeDiffs($pendingUpdates[$ownerId] ?? [], $diff);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace App\Service;
|
|||||||
use App\Entity\Composant;
|
use App\Entity\Composant;
|
||||||
use App\Entity\CustomFieldValue;
|
use App\Entity\CustomFieldValue;
|
||||||
use App\Entity\Piece;
|
use App\Entity\Piece;
|
||||||
|
use Doctrine\ORM\EntityNotFoundException;
|
||||||
|
|
||||||
class ReferenceAutoGenerator
|
class ReferenceAutoGenerator
|
||||||
{
|
{
|
||||||
@@ -48,8 +49,12 @@ class ReferenceAutoGenerator
|
|||||||
|
|
||||||
/** @var CustomFieldValue $cfv */
|
/** @var CustomFieldValue $cfv */
|
||||||
foreach ($entity->getCustomFieldValues() as $cfv) {
|
foreach ($entity->getCustomFieldValues() as $cfv) {
|
||||||
$normalized = mb_strtoupper(trim($cfv->getValue()));
|
try {
|
||||||
$map[$cfv->getCustomField()->getName()] = $normalized;
|
$name = $cfv->getCustomField()->getName();
|
||||||
|
} catch (EntityNotFoundException) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$map[$name] = mb_strtoupper(trim($cfv->getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $map;
|
return $map;
|
||||||
|
|||||||
Reference in New Issue
Block a user