Skip to content

Commit

Permalink
Merge pull request #1206 from culturecreates/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AbhishekPAnil authored Jul 4, 2024
2 parents d8e9221 + f29c76d commit 3c5a921
Show file tree
Hide file tree
Showing 18 changed files with 477 additions and 226 deletions.
4 changes: 2 additions & 2 deletions src/components/Card/MandatoryField/MandatoryField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function MandatoryField(props) {

setAddedFields(updatedFields);
setAvailableFields([...availableFields, removedField]);
setDirtyStatus();
setDirtyStatus(true);
}
};

Expand All @@ -54,7 +54,7 @@ function MandatoryField(props) {
});
setAddedFields([...addedFields, { ...field, isRequiredField: true }]);
setAvailableFields(updatedFields);
setDirtyStatus();
setDirtyStatus(true);
};

useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/ImageUpload/ImageUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ function ImageUpload(props) {
};

const onRemove = () => {
form.setFieldsValue({
imageCrop: null,
});
setImageUrl(false);
};

Expand Down
70 changes: 63 additions & 7 deletions src/components/MultipleImageUpload/MultipleImageUpload.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DownloadOutlined, DeleteOutlined } from '@ant-design/icons';
import { Tooltip, Upload, message } from 'antd';
import { DownloadOutlined, DeleteOutlined, HolderOutlined } from '@ant-design/icons';
import { Upload, message } from 'antd';
import update from 'immutability-helper';
import React, { useCallback, useRef, useState } from 'react';
import { DndProvider, useDrag, useDrop } from 'react-dnd';
Expand All @@ -8,8 +8,10 @@ import { useTranslation } from 'react-i18next';
import Outlined from '../Button/Outlined';
const type = 'DragableUploadList';
import './multipleImageUpload.css';
import { getWidthFromAspectRatio } from '../../utils/getWidthFromAspectRatio';
import { useOutletContext } from 'react-router-dom';

const DragableUploadListItem = ({ originNode, moveRow, file, fileList }) => {
const DragableUploadListItem = ({ moveRow, file, fileList, actions, width }) => {
const ref = useRef(null);

const index = fileList.indexOf(file);
Expand Down Expand Up @@ -39,15 +41,50 @@ const DragableUploadListItem = ({ originNode, moveRow, file, fileList }) => {
}),
});
drop(drag(ref));
const errorNode = <Tooltip title="Upload Error">{originNode.props.children}</Tooltip>;
// const errorNode = <Tooltip title="Upload Error">{originNode.props.children}</Tooltip>;
return (
<div
ref={ref}
className={`ant-upload-draggable-list-item ${isOver ? dropClassName : ''}`}
style={{
cursor: 'grab',
}}>
{file.status === 'error' ? errorNode : originNode}
<span className="image-footer">
<span className="image-contents">
<span className="image-actions">
<span
onClick={actions?.download}
data-cy="span-download-image"
style={{
cursor: 'grab',
}}>
<HolderOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '22px' }} />
</span>
</span>
<img
className="image-thumbnail"
src={file?.url ?? file?.thumbUrl}
style={{
width: width ? `${width}px` : 'auto',
minWidth: width ? `${width}px` : 'none',
}}
/>
<a
className="image-name"
target="_blank"
rel="noopener noreferrer"
href={file?.url}
data-cy="anchor-image-link">
{file?.name}
</a>
</span>
<span className="image-actions">
<span onClick={actions?.remove} data-cy="span-download-image">
<DeleteOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
</span>
</span>
{/* {file.status === 'error' ? errorNode : originNode} */}
</div>
);
};
Expand All @@ -63,8 +100,9 @@ const getBase64 = (img, callback) => {
});
};
const MultipleImageUpload = (props) => {
const { eventImageData, form, imageReadOnly } = props;
const { eventImageData, form, imageReadOnly, setShowDialog } = props;
const { t } = useTranslation();
const [currentCalendarData] = useOutletContext();

const [fileList, setFileList] = useState(
eventImageData?.length > 0
Expand Down Expand Up @@ -98,6 +136,14 @@ const MultipleImageUpload = (props) => {
: [],
);

let aspectRatio;
let width;

if (currentCalendarData?.imageConfig[0]?.thumbnail?.aspectRatio) {
aspectRatio = currentCalendarData.imageConfig[0]?.large.aspectRatio;
width = getWidthFromAspectRatio(aspectRatio, 48);
}

const moveRow = useCallback(
(dragIndex, hoverIndex) => {
const dragRow = fileList[dragIndex];
Expand Down Expand Up @@ -148,6 +194,7 @@ const MultipleImageUpload = (props) => {
form.setFieldsValue({
multipleImagesCrop: newFileList,
});
if (setShowDialog) setShowDialog(true);
};

const beforeUpload = (file) => {
Expand All @@ -174,6 +221,7 @@ const MultipleImageUpload = (props) => {
customRequest={customRequest}
beforeUpload={beforeUpload}
showUploadList={{
showRemoveIcon: imageReadOnly ? false : true,
removeIcon: <DeleteOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />,
}}
multiple
Expand All @@ -185,11 +233,19 @@ const MultipleImageUpload = (props) => {
fileList={currFileList}
moveRow={moveRow}
actions={actions}
width={width}
/>
) : (
<span className="image-footer">
<span className="image-contents">
<img className="image-thumbnail" src={file?.url ?? file?.thumbUrl} />
<img
className="image-thumbnail"
src={file?.url ?? file?.thumbUrl}
style={{
width: width ? `${width}px` : 'auto',
minWidth: width ? `${width}px` : 'none',
}}
/>
<a
className="image-name"
target="_blank"
Expand Down
11 changes: 9 additions & 2 deletions src/components/MultipleImageUpload/multipleImageUpload.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
justify-content: space-between;
width: 100%;
gap: 10px;
border: 1px solid #d9d9d9;
border-radius: 2px;
border: 1px solid #607efc;
border-radius: 4px;
height: 66px;
padding: 8px;
margin-top: 8px;
Expand Down Expand Up @@ -52,6 +52,13 @@
font-size: 16px;
}

.multiple-image-upload-wrapper .ant-upload-list-picture .ant-upload-list-item-name {
flex: auto;
margin: 0;
padding-right: 8px;
padding-left: 48px;
}

@media (max-width: 480px) {
.multiple-image-upload-wrapper .image-footer .image-name {
text-wrap: wrap;
Expand Down
7 changes: 6 additions & 1 deletion src/components/RecurringEvents/RecurringEvents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const RecurringEvents = function ({
eventDetails,
setFormFields,
dateType,
disabledDate,
onCalendarChange,
setSubEventCount,
subEventCount,
}) {
const [nummberofDates, setNumberofDates] = useState(numberOfDaysEvent);
const [isModalVisible, setIsModalVisible] = useState(false);
Expand All @@ -32,7 +36,6 @@ const RecurringEvents = function ({
const [isCustom, setIsCustom] = useState(false);
const [selectedWeekDays, setSelectedWeekDays] = useState([]);
const [dateModified, setDateModified] = useState(false);
const [subEventCount, setSubEventCount] = useState(0);
const startDateRecur = Form.useWatch('startDateRecur', form);
const { t } = useTranslation();
Form.useWatch('endTimeRecur', form);
Expand Down Expand Up @@ -341,6 +344,8 @@ const RecurringEvents = function ({
<DateRangePicker
style={{ width: '423px' }}
disabled={(isCustom || formFields?.frequency === 'CUSTOM') && startDateRecur?.length == 2 && true}
disabledDate={disabledDate}
onCalendarChange={onCalendarChange}
suffixIcon={
subEventCount > 0 && (
<Tags
Expand Down
71 changes: 39 additions & 32 deletions src/constants/calendarSettingsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,39 +143,46 @@ export const calendarSettingsFormFields = {
{
name: 'calendarName',
label: <Translation>{(t) => t('dashboard.settings.calendarSettings.calendarName')}</Translation>,
field: ({ t }) => (
<BilingualInput>
<Form.Item name="calendarNameFr">
<TextArea
autoSize
style={{
borderRadius: '4px',
border: '4px solid #E8E8E8',
width: '100%',
}}
size="large"
autoComplete="off"
placeholder={t('dashboard.settings.calendarSettings.placeholders.calendarNameFr')}
data-cy="input-calendar-name"
/>
</Form.Item>
field: ({ t, initialValues }) => {
const fieldData = {
fr: initialValues?.calendarNameFr,
en: initialValues?.calendarNameEn,
};

<Form.Item name="calendarNameEn">
<TextArea
autoSize
style={{
borderRadius: '4px',
border: '4px solid #E8E8E8',
width: '100%',
}}
size="large"
autoComplete="off"
placeholder={t('dashboard.settings.calendarSettings.placeholders.calendarNameEn')}
data-cy="input-calendar-name"
/>
</Form.Item>
</BilingualInput>
),
return (
<BilingualInput fieldData={fieldData}>
<Form.Item name="calendarNameFr">
<TextArea
autoSize
style={{
borderRadius: '4px',
border: '4px solid #E8E8E8',
width: '100%',
}}
size="large"
autoComplete="off"
placeholder={t('dashboard.settings.calendarSettings.placeholders.calendarNameFr')}
data-cy="input-calendar-name"
/>
</Form.Item>

<Form.Item name="calendarNameEn">
<TextArea
autoSize
style={{
borderRadius: '4px',
border: '4px solid #E8E8E8',
width: '100%',
}}
size="large"
autoComplete="off"
placeholder={t('dashboard.settings.calendarSettings.placeholders.calendarNameEn')}
data-cy="input-calendar-name"
/>
</Form.Item>
</BilingualInput>
);
},
rules: [
({ getFieldValue }) => ({
validator() {
Expand Down
5 changes: 4 additions & 1 deletion src/constants/formFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export const formFieldValue = [
eventImageGalleryData,
enableGallery,
t,
setShowDialog,
}) => (
<>
{position === 'top' && datatype === dataTypes.IMAGE && <p className="add-event-date-heading">{userTips}</p>}
Expand All @@ -390,10 +391,10 @@ export const formFieldValue = [
{name?.includes(mappedFieldTypes.IMAGE) && (
<Form.Item
label={t('dashboard.events.addEditEvent.otherInformation.image.additionalImages')}
className="subheading-wrap"
data-cy="form-item-event-multiple-image"
hidden={!enableGallery}>
<MultipleImageUpload
setShowDialog={setShowDialog}
form={form}
largeAspectRatio={largeAspectRatio}
thumbnailAspectRatio={thumbnailAspectRatio}
Expand Down Expand Up @@ -691,6 +692,7 @@ export const returnFormDataWithFields = ({
isEntitiesFetching,
adminOnlyFields,
mandatoryFields,
setShowDialog,
}) => {
return renderFormFields({
fieldName: field?.name,
Expand Down Expand Up @@ -767,6 +769,7 @@ export const returnFormDataWithFields = ({
isExternalSourceFetching,
isEntitiesFetching,
// required: checkMandatoryAdminOnlyFields(field?.name, mandatoryFields),
setShowDialog,
}),
key: index,
initialValue: formInitialValueHandler(field?.type, field?.mappedField, field?.datatype, entityData),
Expand Down
2 changes: 1 addition & 1 deletion src/locales/fr/transalationFr.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
"title": "Image",
"mainImage": "Image principale",
"additionalImages": "Images supplémentaires",
"subHeading": "Les images doivent être au format paysage ou carré et mesurer au moins 600 px de large. Uniquement les fichiers .jpeg et .png sont acceptés.",
"subHeading": "Uniquement les fichiers .jpeg et .png sont acceptés.",
"dragAndDrop": "ou glisser pour télécharger",
"browse": "Parcourir",
"imageGallery": "Galerie d'images",
Expand Down
Loading

0 comments on commit 3c5a921

Please sign in to comment.