Show variant counts in catalog toggle
This commit is contained in:
@@ -426,6 +426,21 @@ function articleLabel(group: ProductGroup) {
|
||||
return selectedProduct(group)?.sku ?? '—';
|
||||
}
|
||||
|
||||
function variantCountLabel(count: number) {
|
||||
const mod10 = count % 10;
|
||||
const mod100 = count % 100;
|
||||
|
||||
if (mod10 === 1 && mod100 !== 11) {
|
||||
return `${count} вариант`;
|
||||
}
|
||||
|
||||
if (mod10 >= 2 && mod10 <= 4 && !(mod100 >= 12 && mod100 <= 14)) {
|
||||
return `${count} варианта`;
|
||||
}
|
||||
|
||||
return `${count} вариантов`;
|
||||
}
|
||||
|
||||
function toggleExpanded(group: ProductGroup) {
|
||||
getGroupState(group).isExpanded = !getGroupState(group).isExpanded;
|
||||
}
|
||||
@@ -653,7 +668,10 @@ function decrementSelected(group: ProductGroup) {
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
<span>{{ getGroupState(group).isExpanded ? 'Свернуть все варианты' : 'Развернуть все варианты' }}</span>
|
||||
<span>
|
||||
{{ getGroupState(group).isExpanded ? 'Свернуть все варианты' : 'Развернуть все варианты' }}
|
||||
({{ variantCountLabel(group.products.length) }})
|
||||
</span>
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user