<xf:form action="{{ link('posts/better-managed-attachments', $post) }}" method="post">
<xf:if is="$attachments">
<p>{{ phrase('nuzforums_attachments_found', {'count': $attachments|count}) }}</p>
<ul>
<xf:foreach loop="$attachments" value="$attachment">
<li style="list-style-type: none; padding-left: 0;">
<xf:checkbox class="attachment-checkbox" name="attachments[{$attachment.attachment_id}]" value="1" checked="checked">
<xf:option value="1">{{ phrase('attachment_number', {'id': $attachment.attachment_id, 'filename': $attachment.filename}) }}</xf:option>
</xf:checkbox>
</li>
</xf:foreach>
</ul>
</xf:if>
<xf:if is="!$attachments">
<p>{{ phrase('nuzforums_no_attachments') }}</p>
</xf:if>
<div>
<xf:checkbox id="checkAll" value="1" checked="checked">
<xf:option value="1">{{ phrase('check_all') }}</xf:option>
</xf:checkbox>
</div>
<div style="margin-top:40px">
<xf:checkbox name="acknowledge" required="true" value="1">
<xf:option value="1">{{ phrase('nuzforums_acknowledge_beta') }}</xf:option>
</xf:checkbox>
</div>
<div class="formSubmitRow">
<button type="submit" class="button button--icon button--icon--confirm">
<span class="button-text">{{ phrase('confirm') }}</span>
</button>
<a href="{{ link('posts', $post) }}" class="button button--icon button--icon--cancel">
<span class="button-text">{{ phrase('cancel') }}</span>
</a>
</div>
<input type="hidden" name="_xfToken" value="{{ csrf_token('post') }}" />
</xf:form>
<script>
document.addEventListener('DOMContentLoaded', function() {
const checkAll = document.getElementById('checkAll');
const attachmentCheckboxes = document.querySelectorAll('.attachment-checkbox');
checkAll.addEventListener('change', function() {
attachmentCheckboxes.forEach(function(checkbox) {
checkbox.checked = checkAll.checked;
});
});
});
</script>