From 98adf062e8deb8f7c598eb548f09b5fdb2cfb120 Mon Sep 17 00:00:00 2001 From: Eudaldo Alonso Date: Fri, 2 Feb 2024 06:58:40 +0000 Subject: [PATCH] LPD-16407 Partial revert of 9be93c5b0403e2a1c066ca52ea967495eac67b6a, since it is still been used in ddm_template/edit_small_image.jsp --- .../META-INF/resources/js/ImageInput.es.js | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 modules/apps/journal/journal-web/src/main/resources/META-INF/resources/js/ImageInput.es.js diff --git a/modules/apps/journal/journal-web/src/main/resources/META-INF/resources/js/ImageInput.es.js b/modules/apps/journal/journal-web/src/main/resources/META-INF/resources/js/ImageInput.es.js new file mode 100644 index 00000000000000..150b1a490949ae --- /dev/null +++ b/modules/apps/journal/journal-web/src/main/resources/META-INF/resources/js/ImageInput.es.js @@ -0,0 +1,85 @@ +/** + * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ + +import ClayButton from '@clayui/button'; +import ClayForm, {ClayInput} from '@clayui/form'; +import ClayIcon from '@clayui/icon'; +import {sub} from 'frontend-js-web'; +import React, {useRef, useState} from 'react'; + +export default function ImageInput({name, portletNamespace, previewURL}) { + const [fileName, setFileName] = useState(previewURL || ''); + const imageTitleId = `${portletNamespace}${name}`; + const inputRef = useRef(); + + return ( +
+ {previewURL ? ( +
+ {Liferay.Language.get('preview')} +
+ ) : null} + + {name ? ( + + + + + + + setFileName( + event.target.files?.[0]?.name || '' + ) + } + ref={inputRef} + type="file" + /> + + inputRef.current?.click()} + placeholder={Liferay.Language.get( + 'select-image' + )} + readOnly + sizing="sm" + value={fileName} + /> + + + + inputRef.current?.click()} + size="sm" + title={sub( + fileName + ? Liferay.Language.get('change-x') + : Liferay.Language.get('select-x'), + Liferay.Language.get('image') + )} + > + + + + + + ) : null} +
+ ); +}