mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 00:43:54 +00:00
a5e733246d
* fix: format clock from preset * fix: add to all views * chore: format * refactor: return flat value from common.options.ts
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import type { ParamField } from './viewParams.types';
|
|
|
|
export const getTimeOption = (timeFormat: string): ParamField => {
|
|
const placeholder = `${timeFormat} (default)`;
|
|
return {
|
|
id: 'timeformat',
|
|
title: 'Clock time format, defaults to value from the Settings',
|
|
description: 'Format for the Time Now field, eg. HH:mm:ss or hh:mm:ss a, see docs for help',
|
|
type: 'string',
|
|
placeholder,
|
|
};
|
|
};
|
|
|
|
export const hideTimerSeconds: ParamField = {
|
|
id: 'hideTimerSeconds',
|
|
title: 'Hide seconds in timer',
|
|
description: 'Whether to hide seconds in the running timer',
|
|
type: 'boolean',
|
|
defaultValue: false,
|
|
};
|
|
|
|
export const showLeadingZeros: ParamField = {
|
|
id: 'showLeadingZeros',
|
|
title: 'Show leading zeros in timer',
|
|
description: 'Whether to show leading zeros in the running timer',
|
|
type: 'boolean',
|
|
defaultValue: false,
|
|
};
|
|
|
|
export type TimeOptions = {
|
|
timeformat: string | null;
|
|
};
|
|
|
|
/**
|
|
* Helper to get value of 'timeformat' from either source, prioritizing defaultValues
|
|
*/
|
|
export function getTimeOptionsFromParams(searchParams: URLSearchParams, defaultValues?: URLSearchParams) {
|
|
return defaultValues?.get('timeformat') ?? searchParams.get('timeformat');
|
|
}
|