fix(phonebook,ucp): v2.6.4 affichage des postes multi-groupes dans chaque onglet de groupe
This commit is contained in:
1 parent
8cb8f1cdf7
commit
f918c929f5
3 files changed
+69
-32
No files matched your search
+15
-4
@@ -756,14 +756,26 @@ async function loadPhonebook() {
|
||||
}
|
||||
}
|
||||
|
||||
function getContactGroups(contact) {
|
||||
if (Array.isArray(contact?.groups) && contact.groups.length > 0) {
|
||||
return contact.groups.map(g => String(g || '').trim()).filter(Boolean);
|
||||
}
|
||||
const split = String(contact?.group_name || '')
|
||||
.split(',')
|
||||
.map(g => g.trim())
|
||||
.filter(Boolean);
|
||||
return split.length > 0 ? Array.from(new Set(split)) : ['Général'];
|
||||
}
|
||||
|
||||
function renderPhonebookGroupTabs(allContacts) {
|
||||
const tabsEl = document.getElementById('ucp-pb-group-tabs');
|
||||
if (!tabsEl) return;
|
||||
|
||||
const counts = {};
|
||||
for (const c of allContacts) {
|
||||
const grp = String(c.group_name || '').trim() || 'Général';
|
||||
counts[grp] = (counts[grp] || 0) + 1;
|
||||
for (const grp of getContactGroups(c)) {
|
||||
counts[grp] = (counts[grp] || 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
const groups = Object.keys(counts).sort((a, b) => {
|
||||
@@ -821,8 +833,7 @@ function renderPhonebookGrid() {
|
||||
const activeGroup = ucpState.selectedPbGroup || '__all__';
|
||||
const q = (document.getElementById('ucp-pb-search')?.value || '').trim().toLowerCase();
|
||||
const list = allContacts.filter(c => {
|
||||
const grp = String(c.group_name || '').trim() || 'Général';
|
||||
if (activeGroup !== '__all__' && grp !== activeGroup) return false;
|
||||
if (activeGroup !== '__all__' && !getContactGroups(c).includes(activeGroup)) return false;
|
||||
if (!q) return true;
|
||||
return [c.display_name, c.internal_number, c.mobile_number, c.other_number, c.email, c.group_name]
|
||||
.some(v => String(v || '').toLowerCase().includes(q));
|
||||
|
||||
Reference in new issue
Block a user