Преглед изворни кода

Refactored inline editing across all admin list pages to render edit fields in-place within each table column instead of a collapsed full-width row.

sebastian пре 1 недеља
родитељ
комит
ad20e08324
4 измењених фајлова са 68 додато и 88 уклоњено
  1. 20 27
      admin/activities.php
  2. 14 17
      admin/activity_groups.php
  3. 14 17
      admin/item_groups.php
  4. 20 27
      admin/items.php

+ 20 - 27
admin/activities.php

@@ -87,6 +87,13 @@ show_alerts();
   </form>
 </div>
 
+<?php foreach ($activities as $a): ?>
+<form id="edit-form-<?= $a['activityID'] ?>" method="POST">
+  <input type="hidden" name="action" value="edit">
+  <input type="hidden" name="activityID" value="<?= $a['activityID'] ?>">
+</form>
+<?php endforeach; ?>
+
 <table class="tbl">
   <thead><tr><th>#</th><th>Name</th><th>Group</th><th>Sort</th><th></th></tr></thead>
   <tbody>
@@ -108,33 +115,19 @@ show_alerts();
     </td>
   </tr>
   <tr id="edit-<?= $id ?>" style="display:none;background:rgba(79,209,197,.04);">
-    <td colspan="5">
-      <form method="POST" style="display:flex;gap:.75rem;align-items:flex-end;flex-wrap:wrap;padding:.25rem 0;">
-        <input type="hidden" name="action" value="edit">
-        <input type="hidden" name="activityID" value="<?= $id ?>">
-        <div>
-          <label>Activity Name</label>
-          <input type="text" name="activityName" value="<?= htmlspecialchars($a['activityName']) ?>" required style="margin-bottom:0;min-width:180px;">
-        </div>
-        <div>
-          <label>Group</label>
-          <select name="groupID" required style="margin-bottom:0;min-width:140px;">
-            <?php foreach ($groups as $g): ?>
-            <option value="<?= $g['groupID'] ?>" <?= $a['groupID'] == $g['groupID'] ? 'selected' : '' ?>>
-              <?= htmlspecialchars($g['groupName']) ?>
-            </option>
-            <?php endforeach; ?>
-          </select>
-        </div>
-        <div>
-          <label>Sort Order</label>
-          <input type="number" name="sortOrder" value="<?= (int)$a['sortOrder'] ?>" min="0" style="margin-bottom:0;max-width:90px;">
-        </div>
-        <div style="display:flex;gap:.4rem;padding-bottom:1px;">
-          <button type="submit" class="btn btn-sm btn-primary">💾 Save</button>
-          <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
-        </div>
-      </form>
+    <td style="color:var(--muted)"><?= $id ?></td>
+    <td><input type="text" name="activityName" form="edit-form-<?= $id ?>" value="<?= htmlspecialchars($a['activityName']) ?>" required style="margin:0;width:100%;"></td>
+    <td>
+      <select name="groupID" form="edit-form-<?= $id ?>" required style="margin:0;width:100%;">
+        <?php foreach ($groups as $g): ?>
+        <option value="<?= $g['groupID'] ?>" <?= $a['groupID'] == $g['groupID'] ? 'selected' : '' ?>><?= htmlspecialchars($g['groupName']) ?></option>
+        <?php endforeach; ?>
+      </select>
+    </td>
+    <td><input type="number" name="sortOrder" form="edit-form-<?= $id ?>" value="<?= (int)$a['sortOrder'] ?>" min="0" style="margin:0;width:100%;max-width:80px;"></td>
+    <td style="display:flex;gap:.4rem;justify-content:flex-end;">
+      <button type="submit" form="edit-form-<?= $id ?>" class="btn btn-sm btn-primary">💾 Save</button>
+      <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
     </td>
   </tr>
   <?php endforeach; ?>

+ 14 - 17
admin/activity_groups.php

@@ -70,6 +70,13 @@ show_alerts();
   </form>
 </div>
 
+<?php foreach ($groups as $g): ?>
+<form id="edit-form-<?= $g['groupID'] ?>" method="POST">
+  <input type="hidden" name="action" value="edit">
+  <input type="hidden" name="groupID" value="<?= $g['groupID'] ?>">
+</form>
+<?php endforeach; ?>
+
 <table class="tbl">
   <thead><tr><th>#</th><th>Name</th><th>Sort</th><th>Activities</th><th></th></tr></thead>
   <tbody>
@@ -94,23 +101,13 @@ show_alerts();
     </td>
   </tr>
   <tr id="edit-<?= $id ?>" style="display:none;background:rgba(79,209,197,.04);">
-    <td colspan="5">
-      <form method="POST" style="display:flex;gap:.75rem;align-items:flex-end;flex-wrap:wrap;padding:.25rem 0;">
-        <input type="hidden" name="action" value="edit">
-        <input type="hidden" name="groupID" value="<?= $id ?>">
-        <div>
-          <label>Group Name</label>
-          <input type="text" name="groupName" value="<?= htmlspecialchars($g['groupName']) ?>" required style="margin-bottom:0;min-width:180px;">
-        </div>
-        <div>
-          <label>Sort Order</label>
-          <input type="number" name="sortOrder" value="<?= (int)$g['sortOrder'] ?>" min="0" style="margin-bottom:0;max-width:100px;">
-        </div>
-        <div style="display:flex;gap:.4rem;padding-bottom:1px;">
-          <button type="submit" class="btn btn-sm btn-primary">💾 Save</button>
-          <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
-        </div>
-      </form>
+    <td style="color:var(--muted)"><?= $id ?></td>
+    <td><input type="text" name="groupName" form="edit-form-<?= $id ?>" value="<?= htmlspecialchars($g['groupName']) ?>" required style="margin:0;width:100%;"></td>
+    <td><input type="number" name="sortOrder" form="edit-form-<?= $id ?>" value="<?= (int)$g['sortOrder'] ?>" min="0" style="margin:0;width:100%;max-width:80px;"></td>
+    <td><span class="badge badge-group"><?= $actCount ?></span></td>
+    <td style="display:flex;gap:.4rem;justify-content:flex-end;">
+      <button type="submit" form="edit-form-<?= $id ?>" class="btn btn-sm btn-primary">💾 Save</button>
+      <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
     </td>
   </tr>
   <?php endforeach; ?>

+ 14 - 17
admin/item_groups.php

@@ -59,6 +59,13 @@ show_alerts();
   </form>
 </div>
 
+<?php foreach ($groups as $g): ?>
+<form id="edit-form-<?= $g['groupID'] ?>" method="POST">
+  <input type="hidden" name="action" value="edit">
+  <input type="hidden" name="groupID" value="<?= $g['groupID'] ?>">
+</form>
+<?php endforeach; ?>
+
 <table class="tbl">
   <thead><tr><th>#</th><th>Name</th><th>Sort</th><th>Items</th><th></th></tr></thead>
   <tbody>
@@ -83,23 +90,13 @@ show_alerts();
     </td>
   </tr>
   <tr id="edit-<?= $id ?>" style="display:none;background:rgba(79,209,197,.04);">
-    <td colspan="5">
-      <form method="POST" style="display:flex;gap:.75rem;align-items:flex-end;flex-wrap:wrap;padding:.25rem 0;">
-        <input type="hidden" name="action" value="edit">
-        <input type="hidden" name="groupID" value="<?= $id ?>">
-        <div>
-          <label>Group Name</label>
-          <input type="text" name="groupName" value="<?= htmlspecialchars($g['groupName']) ?>" required style="margin-bottom:0;min-width:180px;">
-        </div>
-        <div>
-          <label>Sort Order</label>
-          <input type="number" name="sortOrder" value="<?= (int)$g['sortOrder'] ?>" min="0" style="margin-bottom:0;max-width:100px;">
-        </div>
-        <div style="display:flex;gap:.4rem;padding-bottom:1px;">
-          <button type="submit" class="btn btn-sm btn-primary">💾 Save</button>
-          <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
-        </div>
-      </form>
+    <td style="color:var(--muted)"><?= $id ?></td>
+    <td><input type="text" name="groupName" form="edit-form-<?= $id ?>" value="<?= htmlspecialchars($g['groupName']) ?>" required style="margin:0;width:100%;"></td>
+    <td><input type="number" name="sortOrder" form="edit-form-<?= $id ?>" value="<?= (int)$g['sortOrder'] ?>" min="0" style="margin:0;width:100%;max-width:80px;"></td>
+    <td><span class="badge badge-group"><?= $cnt ?></span></td>
+    <td style="display:flex;gap:.4rem;justify-content:flex-end;">
+      <button type="submit" form="edit-form-<?= $id ?>" class="btn btn-sm btn-primary">💾 Save</button>
+      <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
     </td>
   </tr>
   <?php endforeach; ?>

+ 20 - 27
admin/items.php

@@ -76,6 +76,13 @@ show_alerts();
   </form>
 </div>
 
+<?php foreach ($items as $item): ?>
+<form id="edit-form-<?= $item['itemID'] ?>" method="POST">
+  <input type="hidden" name="action" value="edit">
+  <input type="hidden" name="itemID" value="<?= $item['itemID'] ?>">
+</form>
+<?php endforeach; ?>
+
 <table class="tbl">
   <thead><tr><th>#</th><th>Name</th><th>Group</th><th>Sort</th><th></th></tr></thead>
   <tbody>
@@ -97,33 +104,19 @@ show_alerts();
     </td>
   </tr>
   <tr id="edit-<?= $id ?>" style="display:none;background:rgba(79,209,197,.04);">
-    <td colspan="5">
-      <form method="POST" style="display:flex;gap:.75rem;align-items:flex-end;flex-wrap:wrap;padding:.25rem 0;">
-        <input type="hidden" name="action" value="edit">
-        <input type="hidden" name="itemID" value="<?= $id ?>">
-        <div>
-          <label>Item Name</label>
-          <input type="text" name="itemName" value="<?= htmlspecialchars($item['itemName']) ?>" required style="margin-bottom:0;min-width:180px;">
-        </div>
-        <div>
-          <label>Group</label>
-          <select name="groupID" required style="margin-bottom:0;min-width:140px;">
-            <?php foreach ($igroups as $g): ?>
-            <option value="<?= $g['groupID'] ?>" <?= $item['groupID'] == $g['groupID'] ? 'selected' : '' ?>>
-              <?= htmlspecialchars($g['groupName']) ?>
-            </option>
-            <?php endforeach; ?>
-          </select>
-        </div>
-        <div>
-          <label>Sort Order</label>
-          <input type="number" name="sortOrder" value="<?= (int)$item['sortOrder'] ?>" min="0" style="margin-bottom:0;max-width:90px;">
-        </div>
-        <div style="display:flex;gap:.4rem;padding-bottom:1px;">
-          <button type="submit" class="btn btn-sm btn-primary">💾 Save</button>
-          <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
-        </div>
-      </form>
+    <td style="color:var(--muted)"><?= $id ?></td>
+    <td><input type="text" name="itemName" form="edit-form-<?= $id ?>" value="<?= htmlspecialchars($item['itemName']) ?>" required style="margin:0;width:100%;"></td>
+    <td>
+      <select name="groupID" form="edit-form-<?= $id ?>" required style="margin:0;width:100%;">
+        <?php foreach ($igroups as $g): ?>
+        <option value="<?= $g['groupID'] ?>" <?= $item['groupID'] == $g['groupID'] ? 'selected' : '' ?>><?= htmlspecialchars($g['groupName']) ?></option>
+        <?php endforeach; ?>
+      </select>
+    </td>
+    <td><input type="number" name="sortOrder" form="edit-form-<?= $id ?>" value="<?= (int)$item['sortOrder'] ?>" min="0" style="margin:0;width:100%;max-width:80px;"></td>
+    <td style="display:flex;gap:.4rem;justify-content:flex-end;">
+      <button type="submit" form="edit-form-<?= $id ?>" class="btn btn-sm btn-primary">💾 Save</button>
+      <button type="button" onclick="cancelEdit(<?= $id ?>)" class="btn btn-sm btn-secondary">Cancel</button>
     </td>
   </tr>
   <?php endforeach; ?>