Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1369,14 +1369,21 @@ function onPageChange (page) {
|
|||||||
|
|
||||||
function togglePriceOption (value) {
|
function togglePriceOption (value) {
|
||||||
if (!allowedPriceOptions.value.some((x) => x.value === value)) return
|
if (!allowedPriceOptions.value.some((x) => x.value === value)) return
|
||||||
const set = new Set(selectedPriceOptions.value || [])
|
const clickedLevel = getPriceLevel(value)
|
||||||
|
const current = normalizeSameLevelPriceOptions(selectedPriceOptions.value || [])
|
||||||
|
const set = new Set(current.filter((x) => getPriceLevel(x) === clickedLevel))
|
||||||
if (set.has(value)) set.delete(value)
|
if (set.has(value)) set.delete(value)
|
||||||
else set.add(value)
|
else set.add(value)
|
||||||
selectedPriceOptions.value = allowedPriceOptions.value.map((x) => x.value).filter((x) => set.has(x))
|
selectedPriceOptions.value = allowedPriceOptions.value
|
||||||
|
.map((x) => x.value)
|
||||||
|
.filter((x) => getPriceLevel(x) === clickedLevel && set.has(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAllPrices () {
|
function selectAllPrices () {
|
||||||
selectedPriceOptions.value = allowedPriceOptions.value.map((x) => x.value)
|
const level = getActivePriceLevel(selectedPriceOptions.value || [])
|
||||||
|
selectedPriceOptions.value = allowedPriceOptions.value
|
||||||
|
.map((x) => x.value)
|
||||||
|
.filter((x) => getPriceLevel(x) === level)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAllPrices () {
|
function clearAllPrices () {
|
||||||
@@ -1386,13 +1393,44 @@ function clearAllPrices () {
|
|||||||
function normalizeSelectedPriceOptions () {
|
function normalizeSelectedPriceOptions () {
|
||||||
const allowedValues = allowedPriceOptions.value.map((x) => x.value)
|
const allowedValues = allowedPriceOptions.value.map((x) => x.value)
|
||||||
const allowed = new Set(allowedValues)
|
const allowed = new Set(allowedValues)
|
||||||
const current = (selectedPriceOptions.value || []).filter((x) => allowed.has(x))
|
const current = normalizeSameLevelPriceOptions((selectedPriceOptions.value || []).filter((x) => allowed.has(x)))
|
||||||
if (current.length > 0 || allowedValues.length === 0) {
|
if (current.length > 0 || allowedValues.length === 0) {
|
||||||
selectedPriceOptions.value = current
|
selectedPriceOptions.value = current
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const preferred = ['usd5', 'try5'].filter((x) => allowed.has(x))
|
const preferred = ['usd5', 'try5'].filter((x) => allowed.has(x))
|
||||||
selectedPriceOptions.value = preferred.length ? preferred : allowedValues.slice(0, 2)
|
selectedPriceOptions.value = preferred.length ? normalizeSameLevelPriceOptions(preferred) : allowedValues.filter((x) => getPriceLevel(x) === getPriceLevel(allowedValues[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPriceLevel (value) {
|
||||||
|
const match = String(value || '').match(/^(?:usd|eur|try)(\d)$/i)
|
||||||
|
return match ? Number(match[1]) : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPriceCurrency (value) {
|
||||||
|
const match = String(value || '').match(/^(usd|eur|try)/i)
|
||||||
|
return match ? match[1].toUpperCase() : String(value || '').toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActivePriceLevel (list) {
|
||||||
|
const normalized = normalizeSameLevelPriceOptions(list)
|
||||||
|
if (normalized.length > 0) return getPriceLevel(normalized[0])
|
||||||
|
const preferred = ['usd5', 'try5'].find((x) => allowedPriceOptions.value.some((opt) => opt.value === x))
|
||||||
|
if (preferred) return getPriceLevel(preferred)
|
||||||
|
return getPriceLevel(allowedPriceOptions.value[0]?.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeSameLevelPriceOptions (list) {
|
||||||
|
const allowed = new Set(allowedPriceOptions.value.map((x) => x.value))
|
||||||
|
const clean = (Array.isArray(list) ? list : []).filter((x) => allowed.has(x))
|
||||||
|
if (clean.length === 0) return []
|
||||||
|
const level = getPriceLevel(clean[0])
|
||||||
|
return allowedPriceOptions.value.map((x) => x.value).filter((x) => getPriceLevel(x) === level && clean.includes(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
function priceHeaderLabel (value, campaign = false) {
|
||||||
|
const currency = getPriceCurrency(value)
|
||||||
|
return campaign ? `${currency} KMP` : currency
|
||||||
}
|
}
|
||||||
|
|
||||||
function col (name, label, field, width, extra = {}) {
|
function col (name, label, field, width, extra = {}) {
|
||||||
@@ -1426,8 +1464,8 @@ const allColumns = [
|
|||||||
col('icerik', 'ICERIK', 'icerik', 92, { sortable: true, classes: 'ps-col' }),
|
col('icerik', 'ICERIK', 'icerik', 92, { sortable: true, classes: 'ps-col' }),
|
||||||
col('karisim', 'KARISIM', 'karisim', 88, { sortable: true, classes: 'ps-col karisim-wrap-col' }),
|
col('karisim', 'KARISIM', 'karisim', 88, { sortable: true, classes: 'ps-col karisim-wrap-col' }),
|
||||||
...campaignPairs.flatMap((p) => [
|
...campaignPairs.flatMap((p) => [
|
||||||
col(p.base, p.base.toUpperCase().replace(/([A-Z]+)(\d)/, '$1 $2'), p.base, 78, { align: 'right', classes: `${p.base.slice(0, 3)}-col` }),
|
col(p.base, priceHeaderLabel(p.base), p.base, 78, { align: 'right', classes: `${p.base.slice(0, 3)}-col` }),
|
||||||
col(p.derived, `${p.base.toUpperCase().replace(/([A-Z]+)(\d)/, '$1 $2')} KMP`, p.derived, 88, { align: 'right', classes: `${p.base.slice(0, 3)}-col campaign-price-col` })
|
col(p.derived, priceHeaderLabel(p.base, true), p.derived, 88, { align: 'right', classes: `${p.base.slice(0, 3)}-col campaign-price-col` })
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1669,7 +1707,7 @@ async function printVisibleRows () {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr class="report-title"><th colspan="${cols.length}">
|
<tr class="report-title"><th colspan="${cols.length}">
|
||||||
<div class="title-main">Fiyat Listesi</div>
|
<div class="title-main">Fiyat Listesi</div>
|
||||||
<div class="title-meta">Tarih: ${escapeHtml(generatedAt)} | Satir: ${filteredRows.value.length} | Fiyatlar: ${escapeHtml(selectedPriceOptions.value.join(', '))}</div>
|
<div class="title-meta">Tarih: ${escapeHtml(generatedAt)} | Satir: ${filteredRows.value.length} | Fiyatlar: ${escapeHtml(selectedPriceOptions.value.map((x) => getPriceCurrency(x)).join(', '))}</div>
|
||||||
</th></tr>
|
</th></tr>
|
||||||
<tr>${headerCols}</tr>
|
<tr>${headerCols}</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
Reference in New Issue
Block a user