mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 23:44:08 +00:00
Add delete logic
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
bfe923b1ee
commit
94e7a3f5fc
@ -20,6 +20,7 @@ import isImageType from './utils/isImageType';
|
||||
const EditForm = ({
|
||||
fileToEdit,
|
||||
onChange,
|
||||
onClickDeleteFileToUpload,
|
||||
onSubmitEditNewFile,
|
||||
setCropResult,
|
||||
}) => {
|
||||
@ -123,6 +124,10 @@ const EditForm = ({
|
||||
setIsCropping(false);
|
||||
};
|
||||
|
||||
const handleClickDelete = () => {
|
||||
onClickDeleteFileToUpload(fileToEdit.originalIndex);
|
||||
};
|
||||
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
|
||||
@ -139,7 +144,11 @@ const EditForm = ({
|
||||
<CardControlsWrapper className="card-control-wrapper">
|
||||
{!isCropping ? (
|
||||
<>
|
||||
<CardControl color="#9EA7B8" type="trash-alt" />
|
||||
<CardControl
|
||||
color="#9EA7B8"
|
||||
type="trash-alt"
|
||||
onClick={handleClickDelete}
|
||||
/>
|
||||
{canCrop && (
|
||||
<CardControl
|
||||
type="crop"
|
||||
@ -234,6 +243,7 @@ const EditForm = ({
|
||||
EditForm.defaultProps = {
|
||||
fileToEdit: null,
|
||||
onChange: () => {},
|
||||
onClickDeleteFileToUpload: () => {},
|
||||
onSubmitEditNewFile: e => e.preventDefault(),
|
||||
setCropResult: () => {},
|
||||
};
|
||||
@ -241,6 +251,7 @@ EditForm.defaultProps = {
|
||||
EditForm.propTypes = {
|
||||
fileToEdit: PropTypes.object,
|
||||
onChange: PropTypes.func,
|
||||
onClickDeleteFileToUpload: PropTypes.func,
|
||||
onSubmitEditNewFile: PropTypes.func,
|
||||
setCropResult: PropTypes.func,
|
||||
};
|
||||
|
||||
@ -55,6 +55,21 @@ const ModalStepper = ({ isOpen, onToggle }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleClickDeleteFileToUpload = fileIndex => {
|
||||
dispatch({
|
||||
type: 'REMOVE_FILE_TO_UPLOAD',
|
||||
fileIndex,
|
||||
});
|
||||
|
||||
if (currentStep === 'edit-new') {
|
||||
dispatch({
|
||||
type: 'RESET_FILE_TO_EDIT',
|
||||
});
|
||||
|
||||
goNext();
|
||||
}
|
||||
};
|
||||
|
||||
const handleClosed = () => {
|
||||
dispatch({
|
||||
type: 'RESET_PROPS',
|
||||
@ -198,6 +213,7 @@ const ModalStepper = ({ isOpen, onToggle }) => {
|
||||
fileToEdit={fileToEdit}
|
||||
filesToUpload={filesToUpload}
|
||||
onClickCancelUpload={handleCancelFileToUpload}
|
||||
onClickDeleteFileToUpload={handleClickDeleteFileToUpload}
|
||||
onClickEditNewFile={handleGoToEditNewFile}
|
||||
onGoToAddBrowseFiles={handleGoToAddBrowseFiles}
|
||||
onSubmitEditNewFile={handleSubmitEditNewFile}
|
||||
|
||||
@ -40,6 +40,8 @@ const reducer = (state, action) => {
|
||||
data => data.get('originalIndex') !== action.fileIndex
|
||||
);
|
||||
});
|
||||
case 'RESET_FILE_TO_EDIT':
|
||||
return state.update('fileToEdit', () => null);
|
||||
case 'RESET_PROPS':
|
||||
return initialState;
|
||||
case 'SET_CROP_RESULT': {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user