Use luxon date formatters in studvw student list

This commit is contained in:
chfhtw
2026-07-15 14:48:55 +02:00
parent 11cfa670d6
commit b8d86ba628
3 changed files with 83 additions and 31 deletions
@@ -65,19 +65,15 @@ return [
title: "Geburtsdatum",
titlePhrase: 'person/geburtsdatum',
field: "gebdatum",
formatter: 'dateFormatter',
headerFilter: true,
headerFilterFunc(headerValue, rowValue) {
const matches = headerValue.match(/^(([0-9]{2})\.)?([0-9]{2})\.([0-9]{4})?$/);
let comparestr = headerValue;
if(matches !== null) {
const year = (matches[4] !== undefined) ? matches[4] : '';
const month = matches[3];
const day = (matches[2] !== undefined) ? matches[2] : '';
comparestr = year + '-' + month + '-' + day;
}
return rowValue.match(comparestr);
}
formatter: 'datetime',
formatterParams: {
inputFormat: "iso",
outputFormat: "dd.MM.yyyy",
invalidPlaceholder: " ",
timezone: FHC_JS_DATA_STORAGE_OBJECT.timezone
},
headerFilter: 'input',
headerFilterFunc: 'dateinput'
},
{
title: "Geschlecht",
@@ -179,15 +175,28 @@ return [
titlePhrase: 'profilUpdate/statusDate',
field: "status_datum",
visible: false,
formatter: 'dateFormatter'
formatter: 'datetime',
formatterParams: {
inputFormat: "iso",
outputFormat: "dd.MM.yyyy",
invalidPlaceholder: " ",
timezone: FHC_JS_DATA_STORAGE_OBJECT.timezone
}
},
{
title: "Status Bestaetigung",
titlePhrase: 'global/status_bestaetigung',
field: "status_bestaetigung",
visible: false,
formatter: 'dateFormatter',
headerFilter: true
formatter: 'datetime',
formatterParams: {
inputFormat: "iso",
outputFormat: "dd.MM.yyyy",
invalidPlaceholder: " ",
timezone: FHC_JS_DATA_STORAGE_OBJECT.timezone
},
headerFilter: 'input',
headerFilterFunc: 'dateinput'
},
{
title: "EMail (Privat)",
@@ -14,6 +14,9 @@ import draggable from '../../../directives/draggable.js';
import StvColumns from '../../../../../index.ci.php/js/tabulatorcolumns/stv';
import ModuleFilterFilters from '../../../tabulator/filter/filters.js';
Tabulator.extendModule("filter", "filters", ModuleFilterFilters);
export default {
name: "ListPrestudents",
components: {
@@ -53,20 +56,6 @@ export default {
'filterActive'
],
data() {
Tabulator.extendModule("format", "formatters", {
dateFormatter(cell) {
let val = cell.getValue();
if (!val)
return ' ';
let date = new Date(val);
return date.toLocaleDateString('de-AT', {
"day": "2-digit",
"month": "2-digit",
"year": "numeric"
});
}
});
return {
tabulatorOptions: {
columns: StvColumns,
@@ -226,7 +215,7 @@ export default {
return "StudentList_" + today + ".csv";
},
},
created: function() {
created() {
if(this.tagsEnabled) {
const coltags = {
title: 'Tags',
+54
View File
@@ -0,0 +1,54 @@
function dateinput(headerValue, rowValue, rowData, config) {
if (!luxon)
return this.like(headerValue, rowValue, rowData, config);
let inputFormat = config.inputFormat || 'iso';
let outputFormat = config.outputFormat || 'dd.MM.yyyy';
let value;
if (inputFormat == 'iso')
value = luxon.DateTime.fromISO(rowValue);
else
value = luxon.DateTime.fromFormat(rowValue, inputFormat);
let range = [];
range = headerValue.split(' - ');
if (range.length == 1) {
range = headerValue.split('-');
}
if (range.length == 2) {
range = range.map(r => {
r = r.trim();
if (r) {
let d = luxon.DateTime.fromFormat(r, outputFormat);
if (!d.isValid && inputFormat != 'iso' && inputFormat != outputFormat)
d = luxon.DateTime.fromFormat(r, inputFormat);
if (!d.isValid)
d = luxon.DateTime.fromISO(r);
if (d.isValid)
return d;
}
return null;
});
if (!range[0] && !range[1])
return true;
else if (!range[0])
return this['<='](range[1], value, rowData, config);
else if (!range[1])
return this['>='](range[0], value, rowData, config);
let smaller = this['<='](range[1], value, rowData, config);
let bigger = this['>='](range[0], value, rowData, config);
return smaller && bigger;
}
// fallback
return this.like(headerValue, value.toFormat(outputFormat), rowData, config);
}
export {
dateinput
};
export default {
dateinput
};