mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-03 21:39:08 +00:00
refactor: custom fields casing
This commit is contained in:
committed by
Carlos Valente
parent
95b437e18c
commit
0c3c08ac98
@@ -46,7 +46,8 @@ const actionHandlers: Record<string, ActionHandler> = {
|
|||||||
if (typeof property !== 'string' || value === undefined) {
|
if (typeof property !== 'string' || value === undefined) {
|
||||||
throw new Error('Invalid property or value');
|
throw new Error('Invalid property or value');
|
||||||
}
|
}
|
||||||
const newObjectProperty = parseProperty(property, value);
|
// all custom fields keys are lowercase
|
||||||
|
const newObjectProperty = parseProperty(property.toLowerCase(), value);
|
||||||
|
|
||||||
if (patchEvent.custom && newObjectProperty.custom) {
|
if (patchEvent.custom && newObjectProperty.custom) {
|
||||||
Object.assign(patchEvent.custom, newObjectProperty.custom);
|
Object.assign(patchEvent.custom, newObjectProperty.custom);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export function parseProperty(property: string, value: unknown) {
|
|||||||
throw new Error(`Custom field ${customKey} not found`);
|
throw new Error(`Custom field ${customKey} not found`);
|
||||||
}
|
}
|
||||||
const parserFn = whitelistedPayload.custom;
|
const parserFn = whitelistedPayload.custom;
|
||||||
return { custom: { [customKey]: { value: parserFn(value) } } };
|
return { custom: { [customKey]: parserFn(value) } };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isKeyOfType(property, whitelistedPayload)) {
|
if (!isKeyOfType(property, whitelistedPayload)) {
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ export const parseCustomFields = (data: Partial<DatabaseModel>): CustomFields =>
|
|||||||
console.log('ERROR: missing required field, skipping');
|
console.log('ERROR: missing required field, skipping');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newCustomFields[field.label] = {
|
const key = field.label.toLowerCase();
|
||||||
|
newCustomFields[key] = {
|
||||||
type: field.type,
|
type: field.type,
|
||||||
colour: field.colour,
|
colour: field.colour,
|
||||||
label: field.label,
|
label: field.label,
|
||||||
|
|||||||
Reference in New Issue
Block a user