Fix double-firing event handlers, non-bubbling keyboard status event, and saved filter status type
- Remove duplicate edit-comment/delete-comment cases from TicketView.php inline
script — ticket.js already handles them. Double-call of editComment() would
immediately open then close the edit form (second call sees .editing → cancels)
- Fix keyboard shortcut 1-4 status change: dispatchEvent(new Event('change'))
was non-bubbling (default), so the document-level change delegation in TicketView
never received it. Now uses { bubbles: true } so updateTicketStatus() fires correctly
- Fix saved filter status type: getCurrentFilterCriteria() was saving status as a
joined string "Open,Pending" but pill-click handler called .join() expecting an array
(TypeError swallowed by try/catch → status filter silently not applied). Now saves
as array; applySavedFilterCriteria handles both arrays and legacy strings
- Pill-click handler also updated to handle both array and string status formats
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -181,7 +181,7 @@ function getCurrentFilterCriteria() {
|
|||||||
|
|
||||||
const statusSelect = document.getElementById('adv-status');
|
const statusSelect = document.getElementById('adv-status');
|
||||||
const selectedStatuses = Array.from(statusSelect.selectedOptions).map(opt => opt.value);
|
const selectedStatuses = Array.from(statusSelect.selectedOptions).map(opt => opt.value);
|
||||||
if (selectedStatuses.length > 0) criteria.status = selectedStatuses.join(',');
|
if (selectedStatuses.length > 0) criteria.status = selectedStatuses; // keep as array — pill handler uses .join(',')
|
||||||
|
|
||||||
const priorityMin = document.getElementById('adv-priority-min').value;
|
const priorityMin = document.getElementById('adv-priority-min').value;
|
||||||
if (priorityMin) criteria.priority_min = priorityMin;
|
if (priorityMin) criteria.priority_min = priorityMin;
|
||||||
@@ -256,9 +256,11 @@ function applySavedFilterCriteria(criteria) {
|
|||||||
document.getElementById('adv-updated-from').value = criteria.updated_from || '';
|
document.getElementById('adv-updated-from').value = criteria.updated_from || '';
|
||||||
document.getElementById('adv-updated-to').value = criteria.updated_to || '';
|
document.getElementById('adv-updated-to').value = criteria.updated_to || '';
|
||||||
|
|
||||||
// Status
|
// Status — criteria.status may be an array (new saves) or a comma-joined string (old saves)
|
||||||
const statusSelect = document.getElementById('adv-status');
|
const statusSelect = document.getElementById('adv-status');
|
||||||
const statuses = criteria.status ? criteria.status.split(',') : [];
|
const statuses = criteria.status
|
||||||
|
? (Array.isArray(criteria.status) ? criteria.status : criteria.status.split(','))
|
||||||
|
: [];
|
||||||
Array.from(statusSelect.options).forEach(option => {
|
Array.from(statusSelect.options).forEach(option => {
|
||||||
option.selected = statuses.includes(option.value);
|
option.selected = statuses.includes(option.value);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
const option = Array.from(statusSelect.options).find(opt => opt.value === targetStatus);
|
const option = Array.from(statusSelect.options).find(opt => opt.value === targetStatus);
|
||||||
if (option && !option.disabled) {
|
if (option && !option.disabled) {
|
||||||
statusSelect.value = targetStatus;
|
statusSelect.value = targetStatus;
|
||||||
statusSelect.dispatchEvent(new Event('change'));
|
statusSelect.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1086,7 +1086,7 @@ if (window.lt) {
|
|||||||
var c = JSON.parse(btn.dataset.criteria);
|
var c = JSON.parse(btn.dataset.criteria);
|
||||||
var params = new URLSearchParams();
|
var params = new URLSearchParams();
|
||||||
if (c.search) params.set('search', c.search);
|
if (c.search) params.set('search', c.search);
|
||||||
if (c.status && c.status.length) params.set('status', c.status.join(','));
|
if (c.status && c.status.length) params.set('status', Array.isArray(c.status) ? c.status.join(',') : c.status);
|
||||||
if (c.priority_min) params.set('priority_min', c.priority_min);
|
if (c.priority_min) params.set('priority_min', c.priority_min);
|
||||||
if (c.priority_max) params.set('priority_max', c.priority_max);
|
if (c.priority_max) params.set('priority_max', c.priority_max);
|
||||||
if (c.assigned_to) params.set('assigned_to', c.assigned_to);
|
if (c.assigned_to) params.set('assigned_to', c.assigned_to);
|
||||||
|
|||||||
@@ -1104,17 +1104,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Click delegation for comment actions
|
// Click delegation — only handles actions NOT covered by ticket.js
|
||||||
|
// (edit-comment, delete-comment, remove-dependency, delete-attachment, select-mention,
|
||||||
|
// save/cancel-edit-comment, reply-comment, close-reply, submit-reply are in ticket.js)
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', function (e) {
|
||||||
var target = e.target.closest('[data-action]');
|
var target = e.target.closest('[data-action]');
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
var action = target.getAttribute('data-action');
|
var action = target.getAttribute('data-action');
|
||||||
var commentId = target.getAttribute('data-comment-id');
|
if (action === 'dismiss-priority-banner') {
|
||||||
if (action === 'edit-comment' && commentId) {
|
|
||||||
if (typeof editComment === 'function') editComment(parseInt(commentId, 10));
|
|
||||||
} else if (action === 'delete-comment' && commentId) {
|
|
||||||
if (typeof deleteComment === 'function') deleteComment(parseInt(commentId, 10));
|
|
||||||
} else if (action === 'dismiss-priority-banner') {
|
|
||||||
var banner = target.closest('[data-alert-id]');
|
var banner = target.closest('[data-alert-id]');
|
||||||
if (banner) {
|
if (banner) {
|
||||||
try { sessionStorage.setItem('lt_dismissed_' + banner.dataset.alertId, '1'); } catch(ex) {}
|
try { sessionStorage.setItem('lt_dismissed_' + banner.dataset.alertId, '1'); } catch(ex) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user