|
|
@@ -94,40 +94,52 @@ show_alerts();
|
|
|
</form>
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
-<table class="tbl">
|
|
|
+<table class="tbl tbl-fixed">
|
|
|
+ <colgroup>
|
|
|
+ <col style="width:60px">
|
|
|
+ <col>
|
|
|
+ <col style="width:180px">
|
|
|
+ <col style="width:100px">
|
|
|
+ <col style="width:200px">
|
|
|
+ </colgroup>
|
|
|
<thead><tr><th>#</th><th>Name</th><th>Group</th><th>Sort</th><th></th></tr></thead>
|
|
|
<tbody>
|
|
|
<?php foreach ($activities as $a):
|
|
|
$id = $a['activityID'];
|
|
|
?>
|
|
|
- <tr id="view-<?= $id ?>">
|
|
|
+ <tr id="row-<?= $id ?>" data-editing="false">
|
|
|
<td style="color:var(--muted)"><?= $id ?></td>
|
|
|
- <td><?= htmlspecialchars($a['activityName']) ?></td>
|
|
|
- <td><span class="badge badge-group"><?= htmlspecialchars($a['groupName']) ?></span></td>
|
|
|
- <td><?= $a['sortOrder'] ?></td>
|
|
|
- <td style="display:flex;gap:.4rem;justify-content:flex-end;">
|
|
|
- <button type="button" onclick="startEdit(<?= $id ?>)" class="btn btn-sm btn-teal">Edit</button>
|
|
|
- <form method="POST" onsubmit="return confirm('Delete this activity?')">
|
|
|
- <input type="hidden" name="action" value="delete">
|
|
|
- <input type="hidden" name="activityID" value="<?= $id ?>">
|
|
|
- <button class="btn btn-sm btn-danger">Delete</button>
|
|
|
- </form>
|
|
|
+ <td>
|
|
|
+ <div class="view"><?= htmlspecialchars($a['activityName']) ?></div>
|
|
|
+ <div class="edit"><input type="text" name="activityName" form="edit-form-<?= $id ?>" value="<?= htmlspecialchars($a['activityName']) ?>" required></div>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="view"><span class="badge badge-group"><?= htmlspecialchars($a['groupName']) ?></span></div>
|
|
|
+ <div class="edit">
|
|
|
+ <select name="groupID" form="edit-form-<?= $id ?>" required>
|
|
|
+ <?php foreach ($groups as $g): ?>
|
|
|
+ <option value="<?= $g['groupID'] ?>" <?= $a['groupID'] == $g['groupID'] ? 'selected' : '' ?>><?= htmlspecialchars($g['groupName']) ?></option>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
</td>
|
|
|
- </tr>
|
|
|
- <tr id="edit-<?= $id ?>" style="display:none;background:rgba(79,209,197,.04);">
|
|
|
- <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>
|
|
|
+ <div class="view"><?= $a['sortOrder'] ?></div>
|
|
|
+ <div class="edit"><input type="number" name="sortOrder" form="edit-form-<?= $id ?>" value="<?= (int)$a['sortOrder'] ?>" min="0"></div>
|
|
|
</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>
|
|
|
+ <div class="view actions-buttons">
|
|
|
+ <button type="button" onclick="startEdit(<?= $id ?>)" class="btn btn-sm btn-teal">Edit</button>
|
|
|
+ <form method="POST" onsubmit="return confirm('Delete this activity?')">
|
|
|
+ <input type="hidden" name="action" value="delete">
|
|
|
+ <input type="hidden" name="activityID" value="<?= $id ?>">
|
|
|
+ <button class="btn btn-sm btn-danger">Delete</button>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ <div class="edit actions-buttons">
|
|
|
+ <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>
|
|
|
+ </div>
|
|
|
</td>
|
|
|
</tr>
|
|
|
<?php endforeach; ?>
|
|
|
@@ -136,13 +148,13 @@ show_alerts();
|
|
|
|
|
|
<script>
|
|
|
function startEdit(id) {
|
|
|
- document.getElementById('view-' + id).style.display = 'none';
|
|
|
- document.getElementById('edit-' + id).style.display = '';
|
|
|
- document.querySelector('#edit-' + id + ' input[name="activityName"]').focus();
|
|
|
+ var row = document.getElementById('row-' + id);
|
|
|
+ row.dataset.editing = 'true';
|
|
|
+ var input = row.querySelector('.edit input[name="activityName"]');
|
|
|
+ if (input) input.focus();
|
|
|
}
|
|
|
function cancelEdit(id) {
|
|
|
- document.getElementById('edit-' + id).style.display = 'none';
|
|
|
- document.getElementById('view-' + id).style.display = '';
|
|
|
+ document.getElementById('row-' + id).dataset.editing = 'false';
|
|
|
}
|
|
|
</script>
|
|
|
|