fix_process_id
This commit is contained in:
parent
8952456aea
commit
9764ef219c
@ -177,9 +177,19 @@ function populateAutocompleteList(select: HTMLSelectElement, query: string, drop
|
||||
|
||||
if (dropdown) {
|
||||
let messagingCounter = 1;
|
||||
const messagingOptions = autocomplete_options.filter(option => option === 'messaging');
|
||||
|
||||
options_to_show = autocomplete_options.map(option => {
|
||||
if (option === 'messaging') {
|
||||
return `messaging ${messagingCounter++}`;
|
||||
const allMessagingOptions = select.querySelectorAll('option[value="messaging"]');
|
||||
const currentMessagingOption = allMessagingOptions[messagingCounter - 1];
|
||||
const processId = currentMessagingOption?.getAttribute('data-process-id');
|
||||
const optionText = `messaging ${messagingCounter}`;
|
||||
|
||||
// Stocker le processId avec son index spécifique
|
||||
select.setAttribute(`data-messaging-id-${messagingCounter}`, processId || '');
|
||||
messagingCounter++;
|
||||
return optionText;
|
||||
}
|
||||
return option;
|
||||
});
|
||||
@ -221,17 +231,30 @@ function populateAutocompleteList(select: HTMLSelectElement, query: string, drop
|
||||
|
||||
// Listener to autocomplete results when clicked set the selected property in the select option
|
||||
function selectOption(e: any) {
|
||||
console.log('🚀 ~ selectOption ~ e:', e);
|
||||
console.log('🎯 Click event:', e);
|
||||
console.log('🎯 Target value:', e.target.dataset.value);
|
||||
|
||||
const wrapper = e.target.parentNode.parentNode.parentNode;
|
||||
const select = wrapper.querySelector('select');
|
||||
const input_search = wrapper.querySelector('.selected-input');
|
||||
const option = wrapper.querySelector(`select option[value="${e.target.dataset.value}"]`);
|
||||
|
||||
console.log('🎯 Selected option:', option);
|
||||
console.log('🎯 Process ID:', option?.getAttribute('data-process-id'));
|
||||
|
||||
console.log('🚀 ~ selectOption ~ option:', option);
|
||||
if (e.target.dataset.value.includes('messaging')) {
|
||||
const messagingNumber = parseInt(e.target.dataset.value.split(' ')[1]);
|
||||
const processId = select.getAttribute(`data-messaging-id-${messagingNumber}`);
|
||||
|
||||
console.log('🎯 Navigating to chat with process:', {
|
||||
value: e.target.dataset.value,
|
||||
processId: processId
|
||||
});
|
||||
|
||||
const event = new CustomEvent('navigate', {
|
||||
detail: {
|
||||
page: 'chat',
|
||||
processId: option?.getAttribute('data-process-id') || ''
|
||||
processId: processId || ''
|
||||
}
|
||||
});
|
||||
document.dispatchEvent(event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user