This commit is contained in:
oliver
2026-06-14 20:24:16 -03:00
parent f4c1a5cf96
commit 677cf54d60
2 changed files with 132 additions and 8 deletions
+31 -1
View File
@@ -21,6 +21,8 @@ let serversData = [];
let currentServerIdx = 0; let currentServerIdx = 0;
let keysData = []; let keysData = [];
let crmRecords = []; let crmRecords = [];
let crmSortKey = null;
let crmSortDir = 1;
let currentSession = null; let currentSession = null;
let currentEmail = null; let currentEmail = null;
@@ -1418,7 +1420,7 @@ function crmRender() {
document.getElementById("crm-search-category")?.value ?? "" document.getElementById("crm-search-category")?.value ?? ""
).toLowerCase(); ).toLowerCase();
const filtered = crmRecords.filter((r) => { let filtered = crmRecords.filter((r) => {
const name = (r.Name ?? "").toLowerCase(); const name = (r.Name ?? "").toLowerCase();
const company = (r.Company ?? "").toLowerCase(); const company = (r.Company ?? "").toLowerCase();
const email = (r.email ?? "").toLowerCase(); const email = (r.email ?? "").toLowerCase();
@@ -1435,6 +1437,23 @@ function crmRender() {
); );
}); });
// Sort
if (crmSortKey) {
filtered.sort((a, b) => {
const va = (a[crmSortKey] ?? "").toString().toLowerCase();
const vb = (b[crmSortKey] ?? "").toString().toLowerCase();
if (va < vb) return -1 * crmSortDir;
if (va > vb) return 1 * crmSortDir;
return 0;
});
}
// Update sort arrows
document.querySelectorAll(".sort-arrow").forEach((el) => {
el.textContent =
el.dataset.sort === crmSortKey ? (crmSortDir === 1 ? " ▲" : " ▼") : "";
});
const total = crmRecords.length; const total = crmRecords.length;
const countEl = document.getElementById("crm-record-count"); const countEl = document.getElementById("crm-record-count");
countEl.textContent = countEl.textContent =
@@ -1490,6 +1509,17 @@ function crmRender() {
crmUpdateDeleteBtn(); crmUpdateDeleteBtn();
} }
/* ─── CRM — Sort ───────────────────────────────────────────────── */
function crmToggleSort(key) {
if (crmSortKey === key) {
crmSortDir *= -1;
} else {
crmSortKey = key;
crmSortDir = 1;
}
crmRender();
}
/* ─── CRM — Checkbox helpers ────────────────────────────────────── */ /* ─── CRM — Checkbox helpers ────────────────────────────────────── */
function crmUpdateDeleteBtn() { function crmUpdateDeleteBtn() {
const checked = document.querySelectorAll(".crm-select:checked").length; const checked = document.querySelectorAll(".crm-select:checked").length;
+101 -7
View File
@@ -874,13 +874,107 @@
title="Select / deselect all" title="Select / deselect all"
/> />
</th> </th>
<th>Name</th> <th
<th>Company</th> onclick="crmToggleSort('Name')"
<th>Email</th> style="
<th>Stage</th> cursor: pointer;
<th>Strategy</th> user-select: none;
<th>Category</th> "
<th>Date Next Contact</th> >
Name
<span
class="sort-arrow"
data-sort="Name"
></span>
</th>
<th
onclick="
crmToggleSort('Company')
"
style="
cursor: pointer;
user-select: none;
"
>
Company
<span
class="sort-arrow"
data-sort="Company"
></span>
</th>
<th
onclick="crmToggleSort('email')"
style="
cursor: pointer;
user-select: none;
"
>
Email
<span
class="sort-arrow"
data-sort="email"
></span>
</th>
<th
onclick="crmToggleSort('Stage')"
style="
cursor: pointer;
user-select: none;
"
>
Stage
<span
class="sort-arrow"
data-sort="Stage"
></span>
</th>
<th
onclick="
crmToggleSort('strategy')
"
style="
cursor: pointer;
user-select: none;
"
>
Strategy
<span
class="sort-arrow"
data-sort="strategy"
></span>
</th>
<th
onclick="
crmToggleSort('category')
"
style="
cursor: pointer;
user-select: none;
"
>
Category
<span
class="sort-arrow"
data-sort="category"
></span>
</th>
<th
onclick="
crmToggleSort(
'date_next_contact',
)
"
style="
cursor: pointer;
user-select: none;
"
>
Date Next Contact
<span
class="sort-arrow"
data-sort="date_next_contact"
></span>
</th>
</tr> </tr>
</thead> </thead>
<tbody id="crm-table-body"> <tbody id="crm-table-body">