mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 12:32:59 +00:00
Add files via upload
This commit is contained in:
+32
-34
@@ -61,13 +61,13 @@
|
|||||||
<button
|
<button
|
||||||
id="showMainContacts"
|
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"
|
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
|
Hlavní kontakty
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
id="showInternalContacts"
|
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"
|
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
|
Interní kontakty
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -174,6 +174,25 @@
|
|||||||
function showContactsList() {
|
function showContactsList() {
|
||||||
document.getElementById('contactsList').classList.remove('hidden');
|
document.getElementById('contactsList').classList.remove('hidden');
|
||||||
document.getElementById('error').classList.add('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) {
|
function showError(message) {
|
||||||
@@ -202,25 +221,15 @@
|
|||||||
|
|
||||||
function filterContacts() {
|
function filterContacts() {
|
||||||
const query = document.getElementById('searchInput').value.toLowerCase().trim();
|
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) {
|
// Combine all contacts for searching
|
||||||
// Default to main contacts if no active button found
|
let allContacts = [...currentData.Contacts, ...currentData.InternalContacts];
|
||||||
return displayContacts(currentData.Contacts, query);
|
let filteredContacts = allContacts;
|
||||||
}
|
|
||||||
|
|
||||||
const activeTab = activeBtn.dataset.type;
|
// Apply search filter if query exists
|
||||||
let contacts = [];
|
|
||||||
|
|
||||||
if (activeTab === 'main') {
|
|
||||||
contacts = [...currentData.Contacts];
|
|
||||||
} else if (activeTab === 'internal') {
|
|
||||||
contacts = [...currentData.InternalContacts];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply search filter
|
|
||||||
if (query) {
|
if (query) {
|
||||||
contacts = contacts.filter(contact =>
|
filteredContacts = allContacts.filter(contact =>
|
||||||
(contact.name && contact.name.toLowerCase().includes(query)) ||
|
(contact.name && contact.name.toLowerCase().includes(query)) ||
|
||||||
(contact.position && contact.position.toLowerCase().includes(query)) ||
|
(contact.position && contact.position.toLowerCase().includes(query)) ||
|
||||||
(contact.phone && contact.phone.replace(/\s/g, '').includes(query.replace(/\s/g, ''))) ||
|
(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) {
|
function highlightText(text, query) {
|
||||||
@@ -315,21 +328,6 @@
|
|||||||
</div>`;
|
</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() {
|
async function reloadContacts() {
|
||||||
const btn = document.getElementById('reloadBtn');
|
const btn = document.getElementById('reloadBtn');
|
||||||
const originalText = btn.innerHTML;
|
const originalText = btn.innerHTML;
|
||||||
|
|||||||
Reference in New Issue
Block a user