mirror of
https://github.com/strapi/strapi.git
synced 2025-12-16 17:53:53 +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 = ({
|
const EditForm = ({
|
||||||
fileToEdit,
|
fileToEdit,
|
||||||
onChange,
|
onChange,
|
||||||
|
onClickDeleteFileToUpload,
|
||||||
onSubmitEditNewFile,
|
onSubmitEditNewFile,
|
||||||
setCropResult,
|
setCropResult,
|
||||||
}) => {
|
}) => {
|
||||||
@ -123,6 +124,10 @@ const EditForm = ({
|
|||||||
setIsCropping(false);
|
setIsCropping(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClickDelete = () => {
|
||||||
|
onClickDeleteFileToUpload(fileToEdit.originalIndex);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = e => {
|
const handleSubmit = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -139,7 +144,11 @@ const EditForm = ({
|
|||||||
<CardControlsWrapper className="card-control-wrapper">
|
<CardControlsWrapper className="card-control-wrapper">
|
||||||
{!isCropping ? (
|
{!isCropping ? (
|
||||||
<>
|
<>
|
||||||
<CardControl color="#9EA7B8" type="trash-alt" />
|
<CardControl
|
||||||
|
color="#9EA7B8"
|
||||||
|
type="trash-alt"
|
||||||
|
onClick={handleClickDelete}
|
||||||
|
/>
|
||||||
{canCrop && (
|
{canCrop && (
|
||||||
<CardControl
|
<CardControl
|
||||||
type="crop"
|
type="crop"
|
||||||
@ -234,6 +243,7 @@ const EditForm = ({
|
|||||||
EditForm.defaultProps = {
|
EditForm.defaultProps = {
|
||||||
fileToEdit: null,
|
fileToEdit: null,
|
||||||
onChange: () => {},
|
onChange: () => {},
|
||||||
|
onClickDeleteFileToUpload: () => {},
|
||||||
onSubmitEditNewFile: e => e.preventDefault(),
|
onSubmitEditNewFile: e => e.preventDefault(),
|
||||||
setCropResult: () => {},
|
setCropResult: () => {},
|
||||||
};
|
};
|
||||||
@ -241,6 +251,7 @@ EditForm.defaultProps = {
|
|||||||
EditForm.propTypes = {
|
EditForm.propTypes = {
|
||||||
fileToEdit: PropTypes.object,
|
fileToEdit: PropTypes.object,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
|
onClickDeleteFileToUpload: PropTypes.func,
|
||||||
onSubmitEditNewFile: PropTypes.func,
|
onSubmitEditNewFile: PropTypes.func,
|
||||||
setCropResult: 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 = () => {
|
const handleClosed = () => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'RESET_PROPS',
|
type: 'RESET_PROPS',
|
||||||
@ -198,6 +213,7 @@ const ModalStepper = ({ isOpen, onToggle }) => {
|
|||||||
fileToEdit={fileToEdit}
|
fileToEdit={fileToEdit}
|
||||||
filesToUpload={filesToUpload}
|
filesToUpload={filesToUpload}
|
||||||
onClickCancelUpload={handleCancelFileToUpload}
|
onClickCancelUpload={handleCancelFileToUpload}
|
||||||
|
onClickDeleteFileToUpload={handleClickDeleteFileToUpload}
|
||||||
onClickEditNewFile={handleGoToEditNewFile}
|
onClickEditNewFile={handleGoToEditNewFile}
|
||||||
onGoToAddBrowseFiles={handleGoToAddBrowseFiles}
|
onGoToAddBrowseFiles={handleGoToAddBrowseFiles}
|
||||||
onSubmitEditNewFile={handleSubmitEditNewFile}
|
onSubmitEditNewFile={handleSubmitEditNewFile}
|
||||||
|
|||||||
@ -40,6 +40,8 @@ const reducer = (state, action) => {
|
|||||||
data => data.get('originalIndex') !== action.fileIndex
|
data => data.get('originalIndex') !== action.fileIndex
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
case 'RESET_FILE_TO_EDIT':
|
||||||
|
return state.update('fileToEdit', () => null);
|
||||||
case 'RESET_PROPS':
|
case 'RESET_PROPS':
|
||||||
return initialState;
|
return initialState;
|
||||||
case 'SET_CROP_RESULT': {
|
case 'SET_CROP_RESULT': {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user