project-card.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Partial: carte d'un projet
  4. * Variables attendues dans le scope :
  5. * - $map : tableau associatif représentant la carte
  6. */
  7. ?>
  8. <div class="col-lg-4 col-md-6">
  9. <div class="card h-100 map-card" data-map-id="<?php echo $map['id']; ?>">
  10. <div class="card-body d-flex flex-column">
  11. <!-- En-tête de la carte -->
  12. <div class="d-flex align-items-start justify-content-between mb-3">
  13. <div class="flex-grow-1">
  14. <h6 class="card-title mb-1">
  15. <?php echo htmlspecialchars($map['name']); ?>
  16. <small class="text-muted fw-normal">(ID: <?php echo $map['id']; ?>)</small>
  17. </h6>
  18. <small class="text-muted">
  19. <i class="bi bi-calendar me-1"></i>
  20. <?php echo date('d/m/Y H:i', strtotime($map['created_at'])); ?>
  21. </small>
  22. </div>
  23. <div class="dropdown">
  24. <button class="btn btn-sm btn-outline-secondary" type="button" data-bs-toggle="dropdown">
  25. <i class="bi bi-three-dots-vertical"></i>
  26. </button>
  27. <ul class="dropdown-menu">
  28. <li>
  29. <a class="dropdown-item" href="/projects/<?php echo $map['id']; ?>/edit">
  30. <i class="bi bi-pencil me-2"></i>Modifier
  31. </a>
  32. </li>
  33. <li>
  34. <a class="dropdown-item" href="#" onclick="duplicateMap(<?php echo $map['id']; ?>)">
  35. <i class="bi bi-copy me-2"></i>Dupliquer
  36. </a>
  37. </li>
  38. <li><hr class="dropdown-divider"></li>
  39. <li>
  40. <!-- Bouton suppression (JS) + fallback form POST pour progressive enhancement -->
  41. <a class="dropdown-item text-danger" href="#" onclick="deleteMap(<?php echo $map['id']; ?>, '<?php echo htmlspecialchars($map['name']); ?>')">
  42. <i class="bi bi-trash me-2"></i>Supprimer
  43. </a>
  44. </li>
  45. </ul>
  46. </div>
  47. </div>
  48. <!-- Informations de la carte -->
  49. <div class="mb-3">
  50. <div class="row text-center">
  51. <div class="col-6">
  52. <small class="text-muted d-block">Dimensions</small>
  53. <strong><?php echo $map['width']; ?> × <?php echo $map['height']; ?></strong>
  54. </div>
  55. <div class="col-6">
  56. <small class="text-muted d-block">Taille</small>
  57. <strong><?php echo number_format($map['width'] * $map['height']); ?> cases</strong>
  58. </div>
  59. </div>
  60. </div>
  61. <!-- Description -->
  62. <?php if (!empty($map['description'])): ?>
  63. <p class="card-text small text-muted mb-3">
  64. <?php echo htmlspecialchars(substr($map['description'], 0, 100)); ?>
  65. <?php if (strlen($map['description']) > 100): ?>...<?php endif; ?>
  66. </p>
  67. <?php endif; ?>
  68. <!-- Actions principales -->
  69. <div class="mt-auto">
  70. <div class="d-flex gap-2">
  71. <a class="btn btn-outline-primary btn-sm" href="/?load=<?php echo $map['id']; ?>">
  72. <i class="bi bi-folder-open me-1"></i>Ouvrir
  73. </a>
  74. </div>
  75. </div>
  76. <!-- Fallback form pour suppression si JS désactivé -->
  77. <form method="POST" action="/projects/delete" class="d-none" id="delete-form-<?php echo $map['id']; ?>">
  78. <input type="hidden" name="id" value="<?php echo $map['id']; ?>">
  79. <noscript>
  80. <button type="submit" class="btn btn-danger btn-sm mt-2">Supprimer (JS désactivé)</button>
  81. </noscript>
  82. </form>
  83. </div>
  84. </div>
  85. </div>