Fix: sheet export (#1606)

* add util to get keys from labels

* look for existing keys first then create new

* save ontime key to rundown metadata

* update test
This commit is contained in:
Alex Christoffer Rasmussen
2025-05-12 13:56:25 +02:00
committed by GitHub
parent 1f0cde6d0d
commit 1e1aa4bca5
4 changed files with 31 additions and 11 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ export { isAlphanumeric, isAlphanumericWithSpace } from './src/regex-utils/isAlp
export { isColourHex } from './src/regex-utils/isColourHex.js';
export { splitWhitespace } from './src/regex-utils/splitWhitespace.js';
export { customFieldLabelToKey } from './src/customField-utils/customFieldLabelToKey.js';
export { customFieldLabelToKey, customKeyFromLabel } from './src/customField-utils/customFieldLabelToKey.js';
// helpers from externals
export { deepmerge } from './src/externals/deepmerge.js';
@@ -1,3 +1,5 @@
import type { CustomFields } from 'ontime-types';
import { isAlphanumericWithSpace } from '../regex-utils/isAlphanumeric.js';
/**
@@ -9,3 +11,11 @@ export const customFieldLabelToKey = (label: string): string | null => {
}
return null;
};
export const customKeyFromLabel = (label: string, fields: CustomFields): string | null => {
const maybeMatchingKey = Object.keys(fields).find((key) => fields[key].label === label);
if (maybeMatchingKey) {
return maybeMatchingKey;
}
return null;
};