From fead3d01e5ad1c498de02b49679b515913fa5bc2 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 15 Mar 2024 21:14:20 -0500 Subject: [PATCH] Hide caption field for photos without titles --- src/photo/form/PhotoForm.tsx | 4 ++-- src/photo/form/index.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/photo/form/PhotoForm.tsx b/src/photo/form/PhotoForm.tsx index 8db158c1..6cf08010 100644 --- a/src/photo/form/PhotoForm.tsx +++ b/src/photo/form/PhotoForm.tsx @@ -170,13 +170,13 @@ export default function PhotoForm({ validate, capitalize, hideIfEmpty, - hideBasedOnCamera, + shouldHide, loadingMessage, type, }]) => ( (!hideIfEmpty || formData[key]) && - !hideBasedOnCamera?.(formData.make) + !shouldHide?.(formData) ) && boolean + shouldHide?: (formData: Partial) => boolean loadingMessage?: string type?: FieldSetType selectOptions?: { value: string, label: string }[] @@ -54,7 +54,11 @@ const FORM_METADATA = ( tagOptions?: AnnotatedTag[] ): Record => ({ title: { label: 'title', capitalize: true }, - caption: { label: 'caption', capitalize: true }, + caption: { + label: 'caption', + capitalize: true, + shouldHide: ({ title, caption }) => !title && !caption, + }, description: { label: 'description', capitalize: true, hide: true}, tags: { label: 'tags', @@ -80,7 +84,7 @@ const FORM_METADATA = ( label: 'fujifilm simulation', selectOptions: FILM_SIMULATION_FORM_INPUT_OPTIONS, selectOptionsDefaultLabel: 'Unknown', - hideBasedOnCamera: make => make !== MAKE_FUJIFILM, + shouldHide: ({ make }) => make !== MAKE_FUJIFILM, }, focalLength: { label: 'focal length' }, focalLengthIn35MmFormat: { label: 'focal length 35mm-equivalent' },