fix_process_id
This commit is contained in:
parent
0fe3c3d0c2
commit
b9e11c4263
@ -177,9 +177,19 @@ function populateAutocompleteList(select: HTMLSelectElement, query: string, drop
|
|||||||
|
|
||||||
if (dropdown) {
|
if (dropdown) {
|
||||||
let messagingCounter = 1;
|
let messagingCounter = 1;
|
||||||
|
const messagingOptions = autocomplete_options.filter(option => option === 'messaging');
|
||||||
|
|
||||||
options_to_show = autocomplete_options.map(option => {
|
options_to_show = autocomplete_options.map(option => {
|
||||||
if (option === 'messaging') {
|
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;
|
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
|
// Listener to autocomplete results when clicked set the selected property in the select option
|
||||||
function selectOption(e: any) {
|
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 wrapper = e.target.parentNode.parentNode.parentNode;
|
||||||
|
const select = wrapper.querySelector('select');
|
||||||
const input_search = wrapper.querySelector('.selected-input');
|
const input_search = wrapper.querySelector('.selected-input');
|
||||||
const option = wrapper.querySelector(`select option[value="${e.target.dataset.value}"]`);
|
const option = wrapper.querySelector(`select option[value="${e.target.dataset.value}"]`);
|
||||||
|
|
||||||
console.log('🚀 ~ selectOption ~ option:', option);
|
console.log('🎯 Selected option:', option);
|
||||||
|
console.log('🎯 Process ID:', option?.getAttribute('data-process-id'));
|
||||||
|
|
||||||
if (e.target.dataset.value.includes('messaging')) {
|
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', {
|
const event = new CustomEvent('navigate', {
|
||||||
detail: {
|
detail: {
|
||||||
page: 'chat',
|
page: 'chat',
|
||||||
processId: option?.getAttribute('data-process-id') || ''
|
processId: processId || ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.dispatchEvent(event);
|
document.dispatchEvent(event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user