fix: ora le ricerche lavorano nuovamente in cache. feat: aggiunto pulsante per eliminare rapidamente una ricerca testuale. feat: la ricerca in alto a destra rimanda alla ricerca spudorata ed il campo viene liberato.
This commit is contained in:
1 parent
c5e17ca57a
commit
c0c8a2531c
4 files changed
+57
-54
No files matched your search
@@ -24,36 +24,32 @@ const RicercaSpudorataView = {
|
||||
Filters.load();
|
||||
|
||||
const container = document.getElementById('view-container');
|
||||
container.innerHTML = `
|
||||
<div class="loading-screen">
|
||||
<div class="spinner"></div>
|
||||
<p>Inizializzazione Ricerca Spudorata...</p>
|
||||
</div>
|
||||
`;
|
||||
if (!container) return;
|
||||
|
||||
await App.ensureLookups();
|
||||
const urlParams = new URLSearchParams((window.location.hash.split('?')[1]) || '');
|
||||
const qParam = urlParams.get('q');
|
||||
|
||||
try {
|
||||
const settings = await App.api('/api/dashboard/settings');
|
||||
if (settings && settings.tickets_per_page) {
|
||||
this.perPage = settings.tickets_per_page;
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to load agent settings:', err);
|
||||
if (qParam && qParam !== this.searchTerm) {
|
||||
this.renderContainer(container);
|
||||
this.bindEvents();
|
||||
const input = document.getElementById('spudorata-search-input');
|
||||
if (input) input.value = qParam;
|
||||
this.executeSearch(qParam);
|
||||
return;
|
||||
}
|
||||
|
||||
// Instant render from memory cache if already searched
|
||||
if (this.hasSearched && this.cachedTickets) {
|
||||
this.renderContainer(container);
|
||||
this.bindEvents();
|
||||
this.renderLocalResults();
|
||||
return;
|
||||
}
|
||||
|
||||
this.renderContainer(container);
|
||||
this.bindEvents();
|
||||
|
||||
const urlParams = new URLSearchParams((window.location.hash.split('?')[1]) || '');
|
||||
const qParam = urlParams.get('q');
|
||||
if (qParam && !this.hasSearched) {
|
||||
const input = document.getElementById('spudorata-search-input');
|
||||
if (input) input.value = qParam;
|
||||
this.executeSearch(qParam);
|
||||
} else if (this.hasSearched && this.cachedTickets) {
|
||||
this.renderLocalResults();
|
||||
}
|
||||
App.ensureLookups();
|
||||
},
|
||||
|
||||
renderContainer(container) {
|
||||
|
||||
@@ -9,15 +9,20 @@ const TicketListView = {
|
||||
sortDir: 'DESC',
|
||||
selectedIds: new Set(),
|
||||
selectedOrder: [],
|
||||
rawTickets: null,
|
||||
rawTicketsByMode: {
|
||||
general: null,
|
||||
my: null
|
||||
},
|
||||
lastSearchTermByMode: {
|
||||
general: '',
|
||||
my: ''
|
||||
},
|
||||
otrsBaseUrl: null,
|
||||
lastMode: null,
|
||||
lastSearchTerm: '',
|
||||
needsRefresh: false,
|
||||
|
||||
invalidateCache() {
|
||||
this.rawTickets = null;
|
||||
this.lastMode = null;
|
||||
this.rawTicketsByMode.general = null;
|
||||
this.rawTicketsByMode.my = null;
|
||||
this.needsRefresh = true;
|
||||
},
|
||||
|
||||
@@ -38,11 +43,13 @@ const TicketListView = {
|
||||
const container = document.getElementById('view-container');
|
||||
if (!container) return;
|
||||
|
||||
const cachedTickets = this.rawTicketsByMode[newMode];
|
||||
const cachedSearchTerm = this.lastSearchTermByMode[newMode];
|
||||
|
||||
const shouldFetch = force ||
|
||||
this.needsRefresh ||
|
||||
!this.rawTickets ||
|
||||
this.lastMode !== newMode ||
|
||||
this.lastSearchTerm !== globalSearchVal;
|
||||
!cachedTickets ||
|
||||
cachedSearchTerm !== globalSearchVal;
|
||||
|
||||
if (shouldFetch) {
|
||||
if (!container.querySelector('.ticket-table-wrapper') && !container.querySelector('.ticket-table')) {
|
||||
@@ -78,10 +85,9 @@ const TicketListView = {
|
||||
return;
|
||||
}
|
||||
|
||||
this.rawTickets = data.tickets || [];
|
||||
this.rawTicketsByMode[newMode] = data.tickets || [];
|
||||
this.lastSearchTermByMode[newMode] = globalSearchVal;
|
||||
this.otrsBaseUrl = data.otrsBaseUrl || '';
|
||||
this.lastMode = newMode;
|
||||
this.lastSearchTerm = globalSearchVal;
|
||||
this.needsRefresh = false;
|
||||
} catch (err) {
|
||||
const currentHash = (window.location.hash || '#/dashboard').split('?')[0];
|
||||
@@ -133,8 +139,9 @@ const TicketListView = {
|
||||
},
|
||||
|
||||
getFilteredTickets() {
|
||||
if (!this.rawTickets) return [];
|
||||
let list = [...this.rawTickets];
|
||||
const rawTickets = this.rawTicketsByMode[Filters.currentMode] || [];
|
||||
if (!rawTickets || rawTickets.length === 0) return [];
|
||||
let list = [...rawTickets];
|
||||
const s = Filters.state;
|
||||
|
||||
// Sub-search text filter
|
||||
|
||||
Reference in new issue
Block a user