Merge start/end dates into compact trade fair term column
This commit is contained in:
@@ -1575,8 +1575,7 @@
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="thema">Thema</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="stadt">Stadt</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="bundesland">Bundesland</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="termin_start">Termin Start</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="termin_ende">Termin Ende</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="termin">Termin</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="besucher">Besucher</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="besucher_jahr">Besucher Jahr</button></th>
|
||||
<th><button type="button" class="bookmark-subpage__sort" data-trade-sort="besucher_status">Besucher Status</button></th>
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
'thema',
|
||||
'stadt',
|
||||
'bundesland',
|
||||
'termin_start',
|
||||
'termin_ende',
|
||||
'termin',
|
||||
'besucher',
|
||||
'besucher_jahr',
|
||||
'besucher_status',
|
||||
@@ -706,8 +705,7 @@
|
||||
thema: 'text',
|
||||
stadt: 'text',
|
||||
bundesland: 'text',
|
||||
termin_start: 'date',
|
||||
termin_ende: 'date',
|
||||
termin: 'date',
|
||||
besucher: 'number',
|
||||
besucher_jahr: 'number',
|
||||
besucher_status: 'text',
|
||||
@@ -763,7 +761,8 @@
|
||||
return {
|
||||
...row,
|
||||
tage_bis_start: getDaysUntil(row.termin_start),
|
||||
zuletzt_gesucht_am: lastOpenedByTradeFair[getTradeFairOpenKey(row)] || null
|
||||
zuletzt_gesucht_am: lastOpenedByTradeFair[getTradeFairOpenKey(row)] || null,
|
||||
termin: row.termin_start || null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -806,6 +805,40 @@
|
||||
return date.toLocaleDateString('de-DE');
|
||||
}
|
||||
|
||||
function formatTermRange(startIso, endIso) {
|
||||
const start = toDate(startIso);
|
||||
const end = toDate(endIso);
|
||||
|
||||
if (!start && !end) {
|
||||
return 'k.A.';
|
||||
}
|
||||
if (start && !end) {
|
||||
return formatDate(startIso);
|
||||
}
|
||||
if (!start && end) {
|
||||
return formatDate(endIso);
|
||||
}
|
||||
|
||||
const startDay = start.getDate();
|
||||
const startMonth = start.getMonth() + 1;
|
||||
const startYear = start.getFullYear();
|
||||
const endDay = end.getDate();
|
||||
const endMonth = end.getMonth() + 1;
|
||||
const endYear = end.getFullYear();
|
||||
|
||||
if (startYear === endYear) {
|
||||
if (startMonth === endMonth) {
|
||||
if (startDay === endDay) {
|
||||
return `${startDay}.${startMonth}.${startYear}`;
|
||||
}
|
||||
return `${startDay}.-${endDay}.${startMonth}.${startYear}`;
|
||||
}
|
||||
return `${startDay}.${startMonth}.-${endDay}.${endMonth}.${startYear}`;
|
||||
}
|
||||
|
||||
return `${startDay}.${startMonth}.${startYear}-${endDay}.${endMonth}.${endYear}`;
|
||||
}
|
||||
|
||||
function matchesSearch(row, term) {
|
||||
if (!term) {
|
||||
return true;
|
||||
@@ -1523,8 +1556,7 @@
|
||||
thema: createCell(row.thema, 'thema'),
|
||||
stadt: createCell(row.stadt, 'stadt'),
|
||||
bundesland: createCell(row.bundesland, 'bundesland'),
|
||||
termin_start: createCell(formatDate(row.termin_start), 'termin_start'),
|
||||
termin_ende: createCell(formatDate(row.termin_ende), 'termin_ende'),
|
||||
termin: createCell(formatTermRange(row.termin_start, row.termin_ende), 'termin'),
|
||||
besucher: createCell(formatNumber(row.besucher), 'besucher'),
|
||||
besucher_jahr: createCell(formatNumber(row.besucher_jahr), 'besucher_jahr'),
|
||||
besucher_status: createCell(row.besucher_status, 'besucher_status'),
|
||||
|
||||
Reference in New Issue
Block a user