fix(admin): enable bulk actions in grouped articles view
- dev_run.sh: also remove app.db-shm and app.db-wal on reset to fix SQLite disk I/O error from stale WAL/SHM files - articles bulk: add checkboxes to grouped rows (data-ids holds all variant IDs); checking a group selects EN+DE together - restore select-all checkbox in grouped <th> - add toggleArticleGroupSelect() JS function - fix htmx:afterSwap to re-check group checkboxes correctly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,7 @@ PADDLE_ENVIRONMENT=${PADDLE_ENVIRONMENT:-sandbox}
|
||||
# -- Preparation -------------------------------------------------------------
|
||||
|
||||
info "Resetting database"
|
||||
rm -f "$DATABASE_PATH"
|
||||
rm -f "$DATABASE_PATH" "${DATABASE_PATH}-shm" "${DATABASE_PATH}-wal"
|
||||
ok "Removed $DATABASE_PATH"
|
||||
|
||||
info "Running migrations"
|
||||
|
||||
@@ -108,6 +108,15 @@ function toggleArticleSelect(id, checked) {
|
||||
updateArticleBulkBar();
|
||||
}
|
||||
|
||||
function toggleArticleGroupSelect(checkbox) {
|
||||
var ids = (checkbox.dataset.ids || '').split(',').map(Number).filter(Boolean);
|
||||
ids.forEach(function(id) {
|
||||
if (checkbox.checked) articleSelectedIds.add(id);
|
||||
else articleSelectedIds.delete(id);
|
||||
});
|
||||
updateArticleBulkBar();
|
||||
}
|
||||
|
||||
function clearArticleSelection() {
|
||||
articleSelectedIds.clear();
|
||||
document.querySelectorAll('.article-checkbox').forEach(function(cb) { cb.checked = false; });
|
||||
@@ -152,7 +161,12 @@ function submitArticleBulk() {
|
||||
document.body.addEventListener('htmx:afterSwap', function(evt) {
|
||||
if (evt.detail.target.id === 'article-results') {
|
||||
document.querySelectorAll('.article-checkbox').forEach(function(cb) {
|
||||
if (articleSelectedIds.has(Number(cb.dataset.id))) cb.checked = true;
|
||||
if (cb.dataset.ids) {
|
||||
var ids = cb.dataset.ids.split(',').map(Number).filter(Boolean);
|
||||
cb.checked = ids.length > 0 && ids.every(function(id) { return articleSelectedIds.has(id); });
|
||||
} else {
|
||||
cb.checked = articleSelectedIds.has(Number(cb.dataset.id));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<tr id="article-group-{{ g.url_path | replace('/', '-') | trim('-') }}">
|
||||
<td></td>
|
||||
<td onclick="event.stopPropagation()">
|
||||
<input type="checkbox" class="article-checkbox"
|
||||
data-ids="{{ g.variants | map(attribute='id') | join(',') }}"
|
||||
onchange="toggleArticleGroupSelect(this)">
|
||||
</td>
|
||||
<td style="max-width:260px">
|
||||
<div style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500" title="{{ g.url_path }}">{{ g.title }}</div>
|
||||
<div class="article-subtitle">{{ g.url_path }}</div>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
{% if not grouped %}
|
||||
<th style="width:32px"><input type="checkbox" id="article-select-all" onchange="document.querySelectorAll('.article-checkbox').forEach(cb => { cb.checked = this.checked; toggleArticleSelect(Number(cb.dataset.id), this.checked); })"></th>
|
||||
{% else %}
|
||||
<th style="width:32px"></th>
|
||||
<th style="width:32px"><input type="checkbox" id="article-select-all" onchange="document.querySelectorAll('.article-checkbox').forEach(cb => { cb.checked = this.checked; toggleArticleGroupSelect(cb); })"></th>
|
||||
{% endif %}
|
||||
<th>Title</th>
|
||||
<th>{% if grouped %}Variants{% else %}Status{% endif %}</th>
|
||||
|
||||
Reference in New Issue
Block a user