mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-06 23:09:08 +00:00
refactor: add none option to optional select
This commit is contained in:
committed by
Alex Christoffer Rasmussen
parent
bffa863fb4
commit
a2505c838b
@@ -56,13 +56,18 @@ export function makeCustomFieldSelectOptions(customFields: CustomFields, filterI
|
|||||||
/**
|
/**
|
||||||
* Creates data for a select element that displays project custom data
|
* Creates data for a select element that displays project custom data
|
||||||
*/
|
*/
|
||||||
export function makeProjectDataOptions(projectData: ProjectData): SelectOption[] {
|
export function makeProjectDataOptions(
|
||||||
return projectData.custom.map((entry, index) => {
|
projectData: ProjectData,
|
||||||
|
additionalOptions: SelectOption[] = [],
|
||||||
|
): SelectOption[] {
|
||||||
|
const generatedOptions = projectData.custom.map((entry, index) => {
|
||||||
return {
|
return {
|
||||||
value: `${index}-${entry.title}`,
|
value: `${index}-${entry.title}`,
|
||||||
label: entry.title,
|
label: entry.title,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return [...additionalOptions, ...generatedOptions];
|
||||||
}
|
}
|
||||||
|
|
||||||
type ViewParamsObj = { [key: string]: string | FormDataEntryValue };
|
type ViewParamsObj = { [key: string]: string | FormDataEntryValue };
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { isStringBoolean } from '../viewers/common/viewUtils';
|
|||||||
|
|
||||||
export const getOperatorOptions = (customFields: CustomFields, timeFormat: string): ViewOption[] => {
|
export const getOperatorOptions = (customFields: CustomFields, timeFormat: string): ViewOption[] => {
|
||||||
const fieldOptions = makeOptionsFromCustomFields(customFields, [
|
const fieldOptions = makeOptionsFromCustomFields(customFields, [
|
||||||
|
{ value: 'none', label: 'None' },
|
||||||
{ value: 'title', label: 'Title' },
|
{ value: 'title', label: 'Title' },
|
||||||
{ value: 'note', label: 'Note' },
|
{ value: 'note', label: 'Note' },
|
||||||
]);
|
]);
|
||||||
@@ -38,7 +39,7 @@ export const getOperatorOptions = (customFields: CustomFields, timeFormat: strin
|
|||||||
description: 'Field to be shown in the second line of text',
|
description: 'Field to be shown in the second line of text',
|
||||||
type: 'option',
|
type: 'option',
|
||||||
values: fieldOptions,
|
values: fieldOptions,
|
||||||
defaultValue: '',
|
defaultValue: 'none',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'subscribe',
|
id: 'subscribe',
|
||||||
|
|||||||
@@ -17,8 +17,11 @@ export const getBackstageOptions = (
|
|||||||
customFields: CustomFields,
|
customFields: CustomFields,
|
||||||
projectData: ProjectData,
|
projectData: ProjectData,
|
||||||
): ViewOption[] => {
|
): ViewOption[] => {
|
||||||
const secondaryOptions = makeOptionsFromCustomFields(customFields, [{ value: 'note', label: 'Note' }]);
|
const secondaryOptions = makeOptionsFromCustomFields(customFields, [
|
||||||
const projectDataOptions = makeProjectDataOptions(projectData);
|
{ value: 'none', label: 'None' },
|
||||||
|
{ value: 'note', label: 'Note' },
|
||||||
|
]);
|
||||||
|
const projectDataOptions = makeProjectDataOptions(projectData, [{ value: 'none', label: 'None' }]);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{ title: OptionTitle.ClockOptions, collapsible: true, options: [getTimeOption(timeFormat)] },
|
{ title: OptionTitle.ClockOptions, collapsible: true, options: [getTimeOption(timeFormat)] },
|
||||||
@@ -32,7 +35,7 @@ export const getBackstageOptions = (
|
|||||||
description: 'Select the data source for auxiliary text shown in now and next cards',
|
description: 'Select the data source for auxiliary text shown in now and next cards',
|
||||||
type: 'option',
|
type: 'option',
|
||||||
values: secondaryOptions,
|
values: secondaryOptions,
|
||||||
defaultValue: '',
|
defaultValue: 'none',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -47,7 +50,7 @@ export const getBackstageOptions = (
|
|||||||
description: 'Select a project data source to show in the view',
|
description: 'Select a project data source to show in the view',
|
||||||
type: 'option',
|
type: 'option',
|
||||||
values: projectDataOptions,
|
values: projectDataOptions,
|
||||||
defaultValue: '',
|
defaultValue: 'none',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ export const getCountdownOptions = (
|
|||||||
customFields: CustomFields,
|
customFields: CustomFields,
|
||||||
persistedSubscriptions: EntryId[],
|
persistedSubscriptions: EntryId[],
|
||||||
): ViewOption[] => {
|
): ViewOption[] => {
|
||||||
const secondaryOptions = makeOptionsFromCustomFields(customFields, [{ value: 'note', label: 'Note' }]);
|
const secondaryOptions = makeOptionsFromCustomFields(customFields, [
|
||||||
|
{ value: 'none', label: 'None' },
|
||||||
|
{ value: 'note', label: 'Note' },
|
||||||
|
]);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{ title: OptionTitle.ClockOptions, collapsible: true, options: [getTimeOption(timeFormat)] },
|
{ title: OptionTitle.ClockOptions, collapsible: true, options: [getTimeOption(timeFormat)] },
|
||||||
@@ -28,7 +31,7 @@ export const getCountdownOptions = (
|
|||||||
description: 'Select the data source for auxiliary text shown in the card',
|
description: 'Select the data source for auxiliary text shown in the card',
|
||||||
type: 'option',
|
type: 'option',
|
||||||
values: secondaryOptions,
|
values: secondaryOptions,
|
||||||
defaultValue: '',
|
defaultValue: 'none',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user