SYNC: Merge pull request #5 from dbgate/feature/firestore

This commit is contained in:
Jan Prochazka
2025-07-24 10:59:56 +02:00
committed by Diflow
parent 0cf9ddb1cd
commit c171f93c93
22 changed files with 1353 additions and 69 deletions

View File

@@ -75,6 +75,37 @@ export function parseCellValue(value, editorTypes?: DataEditorTypesBehaviour) {
}
}
if (editorTypes?.parseGeopointAsDollar) {
const m = value.match(/^([\d\.]+)\s*°\s*([NS]),\s*([\d\.]+)\s*°\s*([EW])$/i);
if (m) {
let latitude = parseFloat(m[1]);
const latDir = m[2].toUpperCase();
let longitude = parseFloat(m[3]);
const lonDir = m[4].toUpperCase();
if (latDir === 'S') latitude = -latitude;
if (lonDir === 'W') longitude = -longitude;
return {
$geoPoint: {
latitude,
longitude,
},
};
}
}
if (editorTypes?.parseFsDocumentRefAsDollar) {
const trimmedValue = value.replace(/\s/g, '');
if (trimmedValue.startsWith('$ref:')) {
return {
$fsDocumentRef: {
documentPath: trimmedValue.slice(5),
},
};
}
}
if (editorTypes?.parseJsonNull) {
if (value == 'null') return null;
}
@@ -246,6 +277,32 @@ export function stringifyCellValue(
}
}
if (editorTypes?.parseGeopointAsDollar) {
if (value?.$geoPoint) {
const { latitude, longitude } = value.$geoPoint;
if (_isNumber(latitude) && _isNumber(longitude)) {
const latAbs = Math.abs(latitude);
const lonAbs = Math.abs(longitude);
const latDir = latitude >= 0 ? 'N' : 'S';
const lonDir = longitude >= 0 ? 'E' : 'W';
return {
value: `${latAbs}° ${latDir}, ${lonAbs}° ${lonDir}`,
gridStyle: 'valueCellStyle',
};
}
}
}
if (editorTypes?.parseFsDocumentRefAsDollar) {
if (value?.$fsDocumentRef) {
return {
value: `$ref: ${value.$fsDocumentRef.documentPath ?? ''}`,
gridStyle: 'valueCellStyle',
};
}
}
if (_isArray(value)) {
switch (intent) {
case 'gridCellIntent':