Fix video preview and other small bugs

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2020-04-01 15:39:16 +02:00
parent 01a5bd4fb4
commit 67a2e6ab4b
7 changed files with 38 additions and 40 deletions

View File

@ -37,14 +37,15 @@ const getFilterType = type => {
id: 'components.FilterOptions.FILTER_TYPES._containss',
value: '_containss',
},
{
id: 'components.FilterOptions.FILTER_TYPES._in',
value: '_in',
},
{
id: 'components.FilterOptions.FILTER_TYPES._nin',
value: '_nin',
},
// These lines are commented until we support the array in the admin
// {
// id: 'components.FilterOptions.FILTER_TYPES._in',
// value: '_in',
// },
// {
// id: 'components.FilterOptions.FILTER_TYPES._nin',
// value: '_nin',
// },
];
case 'integer':
case 'biginteger':

View File

@ -35,14 +35,15 @@ describe('HELPER PLUGIN | utils | getFilterType', () => {
id: 'components.FilterOptions.FILTER_TYPES._containss',
value: '_containss',
},
{
id: 'components.FilterOptions.FILTER_TYPES._in',
value: '_in',
},
{
id: 'components.FilterOptions.FILTER_TYPES._nin',
value: '_nin',
},
// Commenting until we support them
// {
// id: 'components.FilterOptions.FILTER_TYPES._in',
// value: '_in',
// },
// {
// id: 'components.FilterOptions.FILTER_TYPES._nin',
// value: '_nin',
// },
];
it('should generate the expected array if type is text', () => {

View File

@ -81,13 +81,7 @@ const EditForm = forwardRef(
if (prefixedFileURL) {
setSrc(prefixedFileURL);
} else {
const reader = new FileReader();
reader.onloadend = () => {
setSrc(reader.result);
};
reader.readAsDataURL(fileToEdit.file);
setSrc(URL.createObjectURL(fileToEdit.file));
}
}
}, [isImg, isVideo, fileToEdit, prefixedFileURL]);

View File

@ -20,7 +20,7 @@ import Input from '../Input';
const InputMedia = ({ label, onChange, name, attribute, value, type }) => {
const [modal, setModal] = useState({
isOpen: false,
step: null,
step: 'list',
fileToEdit: null,
});
const [fileToDisplay, setFileToDisplay] = useState(0);
@ -123,7 +123,6 @@ const InputMedia = ({ label, onChange, name, attribute, value, type }) => {
<Input type="file" name={name} />
</CardPreviewWrapper>
{modal.isOpen && (
<InputModalStepper
isOpen={modal.isOpen}
step={modal.step}
@ -135,7 +134,6 @@ const InputMedia = ({ label, onChange, name, attribute, value, type }) => {
onToggle={handleClickToggleModal}
allowedTypes={attribute.allowedTypes}
/>
)}
</Wrapper>
);
};

View File

@ -206,14 +206,16 @@ const InputModalStepper = ({ isOpen, onToggle, onInputMediaChange }) => {
const handleToggle = () => {
if (filesToUploadLength > 0 || selectedFiles.length > 0) {
// eslint-disable-next-line no-alert
const confirm = window.confirm(formatMessage({ id: getTrad('window.confirm.close-modal') }));
const confirm = window.confirm(
formatMessage({ id: getTrad('window.confirm.close-modal.files') })
);
if (!confirm) {
return;
}
}
onToggle();
onToggle(true);
};
const shouldDisplayNextButton = currentStep === 'browse' && displayNextButton;

View File

@ -186,6 +186,8 @@ const InputModalStepperProvider = ({
};
const handleClose = () => {
setFormErrors(null);
dispatch({
type: 'RESET_PROPS',
});

View File

@ -333,7 +333,7 @@ const ModalStepper = ({
}
}
onToggle();
onToggle(true);
};
const handleUploadFiles = async () => {