diff --git a/public/js/views/ticketList.js b/public/js/views/ticketList.js index 73d2145..838065d 100644 --- a/public/js/views/ticketList.js +++ b/public/js/views/ticketList.js @@ -118,6 +118,7 @@ const TicketListView = { ` : ''} + @@ -310,6 +311,12 @@ const TicketListView = { batchApply.addEventListener('click', () => this.applyBatch()); } + // Batch add to group + const batchAddGroup = document.getElementById('batch-add-group'); + if (batchAddGroup) { + batchAddGroup.addEventListener('click', () => this.addToGroup()); + } + // Batch merge (Issue #7) const batchMerge = document.getElementById('batch-merge'); if (batchMerge) { @@ -597,6 +604,12 @@ const TicketListView = { count.textContent = `${this.selectedIds.size} selezionat${this.selectedIds.size === 1 ? 'o' : 'i'}`; } + // Enable/disable add to group button + const addGroupBtn = document.getElementById('batch-add-group'); + if (addGroupBtn) { + addGroupBtn.disabled = this.selectedIds.size === 0; + } + // Enable/disable merge button const mergeBtn = document.getElementById('batch-merge'); if (mergeBtn) { @@ -714,10 +727,86 @@ const TicketListView = { Toast.success(res.message || 'Ticket uniti con successo'); this.selectedIds.clear(); this.selectedOrder = []; - this.render(); } catch (err) { Toast.error('Errore durante l\'unione: ' + err.message); this.updateBatchBar(); } }, + + async addToGroup() { + if (this.selectedIds.size === 0) return; + + try { + const groups = await App.api('/api/groups'); + if (!groups || groups.length === 0) { + Toast.warning('non sono presenti gruppi'); + return; + } + + // Show group selection prompt/dialog + const groupOptions = groups.map(g => ``).join(''); + const dialogHtml = ` +
Seleziona il gruppo a cui aggiungere i ${this.selectedIds.size} ticket selezionati:
+ +