Skip to content

Commit ab331e4

Browse files
committed
[PRAC/cont] Cor "dynamic" logic for fill cont/cell
Organiz observ/order contacts/icon display in tbl/cell (like drop-down). Worth noting: - thus, excluding random addition.. UX improvement. core: B-3 / JS-BL
1 parent 738cd5d commit ab331e4

File tree

1 file changed

+14
-0
lines changed
  • core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-client/js

1 file changed

+14
-0
lines changed

core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-client/js/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,20 @@
567567
emptyLi.innerHTML = `<i class="crm__output-table-body-cell_contacts-empty-item-i table-row-contacts-icon bi bi-dash-lg"></i>`;
568568
contactsList.append(emptyLi);
569569
} else {
570+
// соблюдение порядка отображения контактов ("строго" как в drop-down меню, так и будет в ячейке/таблице)
571+
contacts.sort((a, b) => {
572+
const order = [
573+
'phone',
574+
'extra-phone',
575+
'email',
576+
'vk',
577+
'facebook',
578+
'twitter',
579+
'extra-contact',
580+
];
581+
return order.indexOf(a.type) - order.indexOf(b.type);
582+
});
583+
570584
contacts.forEach(({ type, value }) => {
571585
const contactData =
572586
contactIconsLinks[type] || contactIconsLinks['extra-contact'];

0 commit comments

Comments
 (0)