2222 <div class="card-body border-bottom">
2323 <div class="row g-3 align-items-end">
2424 <!-- Search -->
25- <div class="col-md-4 ">
25+ <div class="col-md-3 ">
2626 <label for="search-input" class="form-label small fw-medium"><?= __ ('common.search ' ) ?> </label>
2727 <div class="input-group">
2828 <input type="text" id="search-input" class="form-control" placeholder="Buscar feeds..." value="<?= $ this ->e ($ searchQuery ?? '' ) ?> ">
3838 </div>
3939
4040 <!-- Status Filter -->
41- <div class="col-md-4 ">
41+ <div class="col-md-3 ">
4242 <label for="status-filter" class="form-label small fw-medium"><?= __ ('admin.feeds.filter_status ' ) ?> </label>
4343 <select id="status-filter" class="form-select">
4444 <option value=""><?= __ ('admin.feeds.all_status ' ) ?> </option>
5151 </div>
5252
5353 <!-- Bulk Actions -->
54- <div class="col-md-4 ">
54+ <div class="col-md-6 ">
5555 <div class="d-flex gap-2 flex-wrap">
56+ <button id="bulk-status-btn" class="btn btn-outline-primary" disabled>
57+ <i class="bi bi-toggle-on me-1"></i>
58+ <?= __ ('admin.feeds.bulk_status ' ) ?>
59+ </button>
5660 <button id="bulk-categories-btn" class="btn btn-outline-primary" disabled>
5761 <i class="bi bi-folder me-1"></i>
5862 <?= __ ('admin.feeds.bulk_categories ' ) ?>
351355 </div>
352356</div>
353357
358+ <!-- Bulk Status Modal -->
359+ <div class="modal fade" id="bulk-status-modal" tabindex="-1" aria-labelledby="bulk-status-title" aria-hidden="true">
360+ <div class="modal-dialog">
361+ <div class="modal-content">
362+ <div class="modal-header">
363+ <h5 class="modal-title" id="bulk-status-title">Alterar Status em Lote</h5>
364+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
365+ </div>
366+ <div class="modal-body">
367+ <p class="text-secondary mb-3">
368+ Selecione o novo status para <span id="bulk-status-count">0</span> feed(s) selecionado(s):
369+ </p>
370+ <div class="form-group">
371+ <label for="bulk-status-select" class="form-label fw-medium">Novo Status</label>
372+ <select id="bulk-status-select" class="form-select">
373+ <option value="">Selecione um status...</option>
374+ <option value="online"><?= __ ('status.online ' ) ?> </option>
375+ <option value="offline"><?= __ ('status.offline ' ) ?> </option>
376+ <option value="paused"><?= __ ('status.paused ' ) ?> </option>
377+ <option value="pending"><?= __ ('status.pending ' ) ?> </option>
378+ <option value="rejected"><?= __ ('status.rejected ' ) ?> </option>
379+ </select>
380+ </div>
381+ </div>
382+ <div class="modal-footer">
383+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
384+ <i class="bi bi-x-lg me-1"></i>
385+ <?= __ ('common.cancel ' ) ?>
386+ </button>
387+ <button type="button" class="btn btn-primary" id="confirm-bulk-status">
388+ <i class="bi bi-check-lg me-1"></i>
389+ Aplicar Status
390+ </button>
391+ </div>
392+ </div>
393+ </div>
394+ </div>
395+
354396<?php $ this ->start ('scripts ' ) ?>
355397<script>
356398 document.addEventListener('DOMContentLoaded', function() {
@@ -444,6 +486,7 @@ function hideModal(modalElement) {
444486 // Bulk selection
445487 const selectAllCheckbox = document.getElementById('select-all');
446488 const feedCheckboxes = document.querySelectorAll('.feed-checkbox');
489+ const bulkStatusBtn = document.getElementById('bulk-status-btn');
447490 const bulkCategoriesBtn = document.getElementById('bulk-categories-btn');
448491 const bulkTagsBtn = document.getElementById('bulk-tags-btn');
449492 const selectionCount = document.getElementById('selection-count');
@@ -462,6 +505,8 @@ function hideModal(modalElement) {
462505 checkbox.addEventListener('change', updateBulkButtons);
463506 });
464507
508+ const bulkStatusModalElement = document.getElementById('bulk-status-modal');
509+
465510 document.querySelectorAll('[data-bs-dismiss="modal"]').forEach(button => {
466511 button.addEventListener('click', function() {
467512 const modal = this.closest('.modal');
@@ -471,7 +516,7 @@ function hideModal(modalElement) {
471516 });
472517 });
473518
474- [deleteModalElement, bulkCategoriesModalElement, bulkTagsModalElement].forEach(modal => {
519+ [deleteModalElement, bulkCategoriesModalElement, bulkTagsModalElement, bulkStatusModalElement ].forEach(modal => {
475520 modal.addEventListener('click', function(e) {
476521 if (e.target === this) {
477522 hideModal(this);
@@ -483,6 +528,7 @@ function updateBulkButtons() {
483528 const selectedCount = Array.from(feedCheckboxes).filter(cb => cb.checked).length;
484529 const hasSelection = selectedCount > 0;
485530
531+ bulkStatusBtn.disabled = !hasSelection;
486532 bulkCategoriesBtn.disabled = !hasSelection;
487533 bulkTagsBtn.disabled = !hasSelection;
488534
@@ -498,6 +544,52 @@ function updateBulkButtons() {
498544 selectAllCheckbox.indeterminate = selectedCount > 0 && selectedCount < feedCheckboxes.length;
499545 }
500546
547+ // Bulk status
548+ bulkStatusBtn.addEventListener('click', function() {
549+ const selectedCount = Array.from(feedCheckboxes).filter(cb => cb.checked).length;
550+ document.getElementById('bulk-status-count').textContent = selectedCount;
551+ document.getElementById('bulk-status-select').value = '';
552+ showModal(bulkStatusModalElement);
553+ });
554+
555+ document.getElementById('confirm-bulk-status').addEventListener('click', function() {
556+ const selectedFeeds = Array.from(feedCheckboxes)
557+ .filter(cb => cb.checked)
558+ .map(cb => parseInt(cb.value));
559+
560+ const newStatus = document.getElementById('bulk-status-select').value;
561+
562+ if (!newStatus) {
563+ alert('Selecione um status');
564+ return;
565+ }
566+
567+ fetch('/admin/feeds/bulk/status', {
568+ method: 'POST',
569+ headers: {
570+ 'Content-Type': 'application/json',
571+ },
572+ body: JSON.stringify({
573+ feed_ids: selectedFeeds,
574+ status: newStatus
575+ })
576+ })
577+ .then(response => response.json())
578+ .then(data => {
579+ if (data.success) {
580+ hideModal(bulkStatusModalElement);
581+ alert(data.message);
582+ window.location.reload();
583+ } else {
584+ alert('Erro: ' + data.message);
585+ }
586+ })
587+ .catch(error => {
588+ console.error('Error:', error);
589+ alert('Ocorreu um erro ao atualizar o status.');
590+ });
591+ });
592+
501593 // Bulk categories
502594 bulkCategoriesBtn.addEventListener('click', function() {
503595 const selectedCount = Array.from(feedCheckboxes).filter(cb => cb.checked).length;
0 commit comments