Show updated titles while updating/creating photos
This commit is contained in:
parent
6fdf215534
commit
5214d76f46
@ -28,6 +28,7 @@ export default function PhotoEditPageClient({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [pending, setIsPending] = useState(false);
|
const [pending, setIsPending] = useState(false);
|
||||||
|
const [updatedTitle, setUpdatedTitle] = useState('');
|
||||||
|
|
||||||
const hasExifDataBeenFound = !areSimpleObjectsEqual(
|
const hasExifDataBeenFound = !areSimpleObjectsEqual(
|
||||||
updatedExifData,
|
updatedExifData,
|
||||||
@ -38,7 +39,9 @@ export default function PhotoEditPageClient({
|
|||||||
<AdminChildPage
|
<AdminChildPage
|
||||||
backPath={PATH_ADMIN_PHOTOS}
|
backPath={PATH_ADMIN_PHOTOS}
|
||||||
backLabel="Photos"
|
backLabel="Photos"
|
||||||
breadcrumb={photo.title || photo.id}
|
breadcrumb={pending && updatedTitle
|
||||||
|
? updatedTitle
|
||||||
|
: photo.title || photo.id}
|
||||||
accessory={
|
accessory={
|
||||||
<form action={action}>
|
<form action={action}>
|
||||||
<input name="photoUrl" value={photo.url} hidden readOnly />
|
<input name="photoUrl" value={photo.url} hidden readOnly />
|
||||||
@ -59,6 +62,7 @@ export default function PhotoEditPageClient({
|
|||||||
? updatedExifData
|
? updatedExifData
|
||||||
: undefined}
|
: undefined}
|
||||||
uniqueTags={uniqueTags}
|
uniqueTags={uniqueTags}
|
||||||
|
onTitleChange={setUpdatedTitle}
|
||||||
onFormStatusChange={setIsPending}
|
onFormStatusChange={setIsPending}
|
||||||
/>
|
/>
|
||||||
</AdminChildPage>
|
</AdminChildPage>
|
||||||
|
|||||||
@ -17,17 +17,21 @@ export default function UploadPageClient({
|
|||||||
uniqueTags: Tags
|
uniqueTags: Tags
|
||||||
}) {
|
}) {
|
||||||
const [pending, setIsPending] = useState(false);
|
const [pending, setIsPending] = useState(false);
|
||||||
|
const [updatedTitle, setUpdatedTitle] = useState('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminChildPage
|
<AdminChildPage
|
||||||
backPath={PATH_ADMIN_UPLOADS}
|
backPath={PATH_ADMIN_UPLOADS}
|
||||||
backLabel="Uploads"
|
backLabel="Uploads"
|
||||||
breadcrumb={blobId}
|
breadcrumb={pending && updatedTitle
|
||||||
|
? updatedTitle
|
||||||
|
: blobId}
|
||||||
isLoading={pending}
|
isLoading={pending}
|
||||||
>
|
>
|
||||||
<PhotoForm
|
<PhotoForm
|
||||||
initialPhotoForm={photoFormExif}
|
initialPhotoForm={photoFormExif}
|
||||||
uniqueTags={uniqueTags}
|
uniqueTags={uniqueTags}
|
||||||
|
onTitleChange={setUpdatedTitle}
|
||||||
onFormStatusChange={setIsPending}
|
onFormStatusChange={setIsPending}
|
||||||
/>
|
/>
|
||||||
</AdminChildPage>
|
</AdminChildPage>
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export default function PhotoForm({
|
|||||||
type = 'create',
|
type = 'create',
|
||||||
uniqueTags,
|
uniqueTags,
|
||||||
debugBlur,
|
debugBlur,
|
||||||
|
onTitleChange,
|
||||||
onFormStatusChange,
|
onFormStatusChange,
|
||||||
}: {
|
}: {
|
||||||
initialPhotoForm: Partial<PhotoFormData>
|
initialPhotoForm: Partial<PhotoFormData>
|
||||||
@ -41,6 +42,7 @@ export default function PhotoForm({
|
|||||||
type?: 'create' | 'edit'
|
type?: 'create' | 'edit'
|
||||||
uniqueTags?: Tags
|
uniqueTags?: Tags
|
||||||
debugBlur?: boolean
|
debugBlur?: boolean
|
||||||
|
onTitleChange?: (updatedTitle: string) => void
|
||||||
onFormStatusChange?: (pending: boolean) => void
|
onFormStatusChange?: (pending: boolean) => void
|
||||||
}) {
|
}) {
|
||||||
const [formData, setFormData] =
|
const [formData, setFormData] =
|
||||||
@ -86,7 +88,7 @@ export default function PhotoForm({
|
|||||||
} = getDimensionsFromSize(THUMBNAIL_SIZE, formData.aspectRatio);
|
} = getDimensionsFromSize(THUMBNAIL_SIZE, formData.aspectRatio);
|
||||||
|
|
||||||
// Generate local date strings when
|
// Generate local date strings when
|
||||||
// none can be harvested from EXIF
|
// none can be extracted from EXIF
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!formData.takenAt || !formData.takenAtNaive) {
|
if (!formData.takenAt || !formData.takenAtNaive) {
|
||||||
setFormData(data => ({
|
setFormData(data => ({
|
||||||
@ -188,6 +190,9 @@ export default function PhotoForm({
|
|||||||
if (validate) {
|
if (validate) {
|
||||||
setFormErrors({ ...formErrors, [key]: validate(value) });
|
setFormErrors({ ...formErrors, [key]: validate(value) });
|
||||||
}
|
}
|
||||||
|
if (key === 'title') {
|
||||||
|
onTitleChange?.(value.trim());
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
selectOptions={selectOptions}
|
selectOptions={selectOptions}
|
||||||
selectOptionsDefaultLabel={selectOptionsDefaultLabel}
|
selectOptionsDefaultLabel={selectOptionsDefaultLabel}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user