mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 04:22:58 +00:00
Add files via upload
This commit is contained in:
+32
-34
@@ -61,13 +61,13 @@
|
||||
<button
|
||||
id="showMainContacts"
|
||||
class="px-4 py-2 text-sm font-medium rounded-l-lg border border-gray-200 bg-blue-600 text-white focus:z-10 focus:ring-2 focus:ring-blue-500"
|
||||
onclick="showContacts('main')">
|
||||
onclick="switchTab(this)">
|
||||
Hlavní kontakty
|
||||
</button>
|
||||
<button
|
||||
id="showInternalContacts"
|
||||
class="px-4 py-2 text-sm font-medium rounded-r-md border border-gray-200 bg-gray-100 text-gray-700 hover:bg-gray-200 focus:z-10 focus:ring-2 focus:ring-blue-500"
|
||||
onclick="showContacts('internal')">
|
||||
onclick="switchTab(this)">
|
||||
Interní kontakty
|
||||
</button>
|
||||
</div>
|
||||
@@ -174,6 +174,25 @@
|
||||
function showContactsList() {
|
||||
document.getElementById('contactsList').classList.remove('hidden');
|
||||
document.getElementById('error').classList.add('hidden');
|
||||
|
||||
// Show default tab (main contacts) if none active
|
||||
const activeBtn = document.querySelector('.switcher-btn.active');
|
||||
if (!activeBtn) {
|
||||
document.querySelector('.switcher-btn[data-type="main"]').classList.add('active');
|
||||
}
|
||||
|
||||
filterContacts();
|
||||
}
|
||||
|
||||
function switchTab(btn) {
|
||||
// Remove active class from all buttons
|
||||
document.querySelectorAll('.switcher-btn').forEach(b => b.classList.remove('active'));
|
||||
|
||||
// Add active class to clicked button
|
||||
btn.classList.add('active');
|
||||
|
||||
// Filter and display contacts
|
||||
filterContacts();
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
@@ -202,25 +221,15 @@
|
||||
|
||||
function filterContacts() {
|
||||
const query = document.getElementById('searchInput').value.toLowerCase().trim();
|
||||
const activeBtn = document.querySelector('.switcher-btn.active');
|
||||
const activeTab = document.querySelector('.switcher-btn.active')?.dataset.type || 'main';
|
||||
|
||||
if (!activeBtn) {
|
||||
// Default to main contacts if no active button found
|
||||
return displayContacts(currentData.Contacts, query);
|
||||
}
|
||||
// Combine all contacts for searching
|
||||
let allContacts = [...currentData.Contacts, ...currentData.InternalContacts];
|
||||
let filteredContacts = allContacts;
|
||||
|
||||
const activeTab = activeBtn.dataset.type;
|
||||
let contacts = [];
|
||||
|
||||
if (activeTab === 'main') {
|
||||
contacts = [...currentData.Contacts];
|
||||
} else if (activeTab === 'internal') {
|
||||
contacts = [...currentData.InternalContacts];
|
||||
}
|
||||
|
||||
// Apply search filter
|
||||
// Apply search filter if query exists
|
||||
if (query) {
|
||||
contacts = contacts.filter(contact =>
|
||||
filteredContacts = allContacts.filter(contact =>
|
||||
(contact.name && contact.name.toLowerCase().includes(query)) ||
|
||||
(contact.position && contact.position.toLowerCase().includes(query)) ||
|
||||
(contact.phone && contact.phone.replace(/\s/g, '').includes(query.replace(/\s/g, ''))) ||
|
||||
@@ -228,7 +237,11 @@
|
||||
);
|
||||
}
|
||||
|
||||
displayContacts(contacts, query);
|
||||
// Then filter by active tab if not searching
|
||||
let contactsToShow = query ? filteredContacts :
|
||||
(activeTab === 'main' ? currentData.Contacts : currentData.InternalContacts);
|
||||
|
||||
displayContacts(contactsToShow, query);
|
||||
}
|
||||
|
||||
function highlightText(text, query) {
|
||||
@@ -315,21 +328,6 @@
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function showContacts(type) {
|
||||
// Update switcher buttons
|
||||
document.querySelectorAll('.switcher-btn').forEach(btn => {
|
||||
btn.classList.remove('active', 'bg-blue-600', 'text-white');
|
||||
btn.classList.add('bg-gray-100', 'text-gray-700');
|
||||
if (btn.dataset.type === type) {
|
||||
btn.classList.add('active', 'bg-blue-600', 'text-white');
|
||||
btn.classList.remove('bg-gray-100', 'text-gray-700');
|
||||
}
|
||||
});
|
||||
|
||||
// Filter contacts for the selected type
|
||||
filterContacts();
|
||||
}
|
||||
|
||||
async function reloadContacts() {
|
||||
const btn = document.getElementById('reloadBtn');
|
||||
const originalText = btn.innerHTML;
|
||||
|
||||
Reference in New Issue
Block a user