Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/issue 1100 #1382

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions src/components/ImageUpload/ImageUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,45 +145,46 @@ function ImageUpload(props) {
maxCount={1}
onRemove={onRemove}
itemRender={(reactNode, file, fileList, actions) => {
return (
<span className="image-footer">
<span className="image-contents">
<img
className="image-thumbnail"
style={{
width: width ? `${width}px` : 'auto',
minWidth: width ? `${width}px` : 'none',
}}
src={imageUrl || (file?.url ?? file?.thumbUrl)}
/>
<a
className="image-name"
target="_blank"
rel="noopener noreferrer"
href={file?.url ?? imageUrl}
data-cy="anchor-image-link">
{file?.name}
</a>
if (imageUrl || (file?.url ?? file?.thumbUrl))
return (
<span className="image-footer">
<span className="image-contents">
<img
className="image-thumbnail"
style={{
width: width ? `${width}px` : 'auto',
minWidth: width ? `${width}px` : 'none',
}}
src={imageUrl || (file?.url ?? file?.thumbUrl)}
/>
<a
className="image-name"
target="_blank"
rel="noopener noreferrer"
href={file?.url ?? imageUrl}
data-cy="anchor-image-link">
{file?.name}
</a>
</span>
<span className="image-actions">
{props?.imageReadOnly && (
<span onClick={actions?.download} data-cy="span-download-image">
<DownloadOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
)}
{!props?.imageReadOnly && imageUrl && (
<span onClick={actions?.remove} data-cy="span-remove-image">
<DeleteOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
)}
{!props?.imageReadOnly && (props?.imageUrl || imageUrl) && isCrop && (
<span className="edit-image" onClick={actions?.preview} data-cy="span-preview-crop-image">
<EditOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
)}
</span>
</span>
<span className="image-actions">
{props?.imageReadOnly && (
<span onClick={actions?.download} data-cy="span-download-image">
<DownloadOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
)}
{!props?.imageReadOnly && imageUrl && (
<span onClick={actions?.remove} data-cy="span-remove-image">
<DeleteOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
)}
{!props?.imageReadOnly && (props?.imageUrl || imageUrl) && isCrop && (
<span className="edit-image" onClick={actions?.preview} data-cy="span-preview-crop-image">
<EditOutlined style={{ color: '#1B3DE6', fontWeight: '600', fontSize: '16px' }} />
</span>
)}
</span>
</span>
);
);
}}
defaultFileList={
props?.imageUrl && [
Expand Down
58 changes: 31 additions & 27 deletions src/components/MultipleImageUpload/MultipleImageUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,37 @@ const MultipleImageUpload = (props) => {

const [fileList, setFileList] = useState(
eventImageData?.length > 0
? eventImageData?.map((image) => {
return {
uid: image?.original?.entityId,
name: image?.original?.entityId,
status: 'done',
url: image?.original?.uri,
cropValues: {
large: {
x: image?.large?.xCoordinate ?? undefined,
y: image?.large?.yCoordinate ?? undefined,
height: image?.large?.height ?? undefined,
width: image?.large?.width ?? undefined,
},
original: {
entityId: image?.original?.entityId ?? null,
height: image?.original?.height ?? undefined,
width: image?.original?.width ?? undefined,
},
thumbnail: {
x: image?.thumbnail?.xCoordinate ?? undefined,
y: image?.thumbnail?.yCoordinate ?? undefined,
height: image?.thumbnail?.height ?? undefined,
width: image?.thumbnail?.width ?? undefined,
},
},
};
})
? eventImageData
?.map((image) => {
if (image)
return {
uid: image?.original?.entityId,
name: image?.original?.entityId,
status: 'done',
url: image?.original?.uri,
cropValues: {
large: {
x: image?.large?.xCoordinate ?? undefined,
y: image?.large?.yCoordinate ?? undefined,
height: image?.large?.height ?? undefined,
width: image?.large?.width ?? undefined,
},
original: {
entityId: image?.original?.entityId ?? null,
height: image?.original?.height ?? undefined,
width: image?.original?.width ?? undefined,
},
thumbnail: {
x: image?.thumbnail?.xCoordinate ?? undefined,
y: image?.thumbnail?.yCoordinate ?? undefined,
height: image?.thumbnail?.height ?? undefined,
width: image?.thumbnail?.width ?? undefined,
},
},
};
else return [];
})
?.flat()
: [],
);

Expand Down
5 changes: 3 additions & 2 deletions src/pages/Dashboard/EventReadOnly/EventReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function EventReadOnly() {
let artsDataLink = eventData?.sameAs?.filter((item) => item?.type === sameAsTypes.ARTSDATA_IDENTIFIER);
const mainImageData = eventData?.image?.find((image) => image?.isMain) || null;
const imageConfig = currentCalendarData?.imageConfig?.length > 0 && currentCalendarData?.imageConfig[0];
const imageGalleryData = eventData?.image?.filter((image) => image && !image?.isMain) || [];

const formConstants = currentCalendarData?.forms?.filter((form) => form?.formName === 'Event')[0];
let mandatoryStandardFields = [];
Expand Down Expand Up @@ -862,7 +863,7 @@ function EventReadOnly() {
)}
</div>
)}
{eventData?.image?.length > 0 && imageConfig.enableGallery && (
{imageGalleryData?.length > 0 && imageConfig.enableGallery && (
<div
style={{
display: standardAdminOnlyFields?.includes(eventFormRequiredFieldNames?.IMAGE)
Expand All @@ -886,7 +887,7 @@ function EventReadOnly() {
? imageConfig?.thumbnail?.aspectRatio
: null
}
eventImageData={eventData?.image?.filter((image) => !image?.isMain)}
eventImageData={imageGalleryData}
/>
</div>
)}
Expand Down
40 changes: 20 additions & 20 deletions src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function OrganizationsReadOnly() {

const calendarContentLanguage = currentCalendarData?.contentLanguage;
const imageConfig = currentCalendarData?.imageConfig?.length > 0 && currentCalendarData?.imageConfig[0];
const imageGalleryData = organizationData?.image?.filter((image) => image && !image?.isMain) || [];

const formConstants = currentCalendarData?.forms?.filter((form) => form?.formName === 'Organization')[0];
let mandatoryStandardFields = [];
Expand Down Expand Up @@ -425,31 +426,30 @@ function OrganizationsReadOnly() {
)}
{checkIfFieldIsToBeDisplayed(
organizationFormFieldNames.IMAGE,
imageConfig.enableGallery ? organizationData?.image?.filter((image) => !image?.isMain) : [],
imageConfig.enableGallery ? imageGalleryData : [],
) && (
<div>
<p className="read-only-event-content-sub-title-primary">
{t('dashboard.events.addEditEvent.otherInformation.image.additionalImages')}
</p>
{organizationData?.image?.filter((image) => !image?.isMain)?.length > 0 &&
imageConfig.enableGallery && (
<>
<MultipleImageUpload
imageReadOnly={true}
largeAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.large?.aspectRatio
: null
}
thumbnailAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.thumbnail?.aspectRatio
: null
}
eventImageData={organizationData?.image?.filter((image) => !image?.isMain)}
/>
</>
)}
{imageGalleryData?.length > 0 && imageConfig.enableGallery && (
<>
<MultipleImageUpload
imageReadOnly={true}
largeAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.large?.aspectRatio
: null
}
thumbnailAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.thumbnail?.aspectRatio
: null
}
eventImageData={imageGalleryData}
/>
</>
)}
</div>
)}
{checkIfFieldIsToBeDisplayed(
Expand Down
33 changes: 16 additions & 17 deletions src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function PersonReadOnly() {

const mainImageData = personData?.image?.find((image) => image?.isMain) || null;
const imageConfig = currentCalendarData?.imageConfig?.length > 0 && currentCalendarData?.imageConfig[0];
const imageGalleryData = personData?.image?.filter((image) => image && !image?.isMain) || [];

const formConstants = currentCalendarData?.forms?.filter((form) => form?.formName === 'Organization')[0];
let mandatoryStandardFields = [];
Expand Down Expand Up @@ -462,27 +463,25 @@ function PersonReadOnly() {
))}
</Col>
)}
{imageConfig.enableGallery && (
{imageConfig.enableGallery && imageGalleryData?.length > 0 && (
<Col span={24}>
<p className="read-only-event-content-sub-title-primary">
{t('dashboard.events.addEditEvent.otherInformation.image.additionalImages')}
</p>
{personData?.image?.length > 0 && (
<MultipleImageUpload
imageReadOnly={true}
largeAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.large?.aspectRatio
: null
}
thumbnailAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.thumbnail?.aspectRatio
: null
}
eventImageData={personData?.image?.filter((image) => !image?.isMain)}
/>
)}
<MultipleImageUpload
imageReadOnly={true}
largeAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.large?.aspectRatio
: null
}
thumbnailAspectRatio={
currentCalendarData?.imageConfig?.length > 0
? imageConfig?.thumbnail?.aspectRatio
: null
}
eventImageData={imageGalleryData}
/>
</Col>
)}
</Row>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function PlaceReadOnly() {
const calendarContentLanguage = currentCalendarData?.contentLanguage;
const mainImageData = placeData?.image?.find((image) => image?.isMain) || null;
const imageConfig = currentCalendarData?.imageConfig?.length > 0 && currentCalendarData?.imageConfig[0];
const imageGalleryData = placeData?.image?.filter((image) => image && !image?.isMain) || [];

const formConstants = currentCalendarData?.forms?.filter((form) => form?.formName === 'Place')[0];
let mandatoryStandardFields = [];
Expand Down Expand Up @@ -475,7 +476,7 @@ function PlaceReadOnly() {
)}
</Col>
)}
{placeData?.image?.length > 0 && imageConfig.enableGallery && (
{imageGalleryData?.length > 0 && imageConfig.enableGallery && (
<Col span={24}>
<div>
<p className="read-only-event-content-sub-title-primary">
Expand All @@ -493,7 +494,7 @@ function PlaceReadOnly() {
? imageConfig?.thumbnail?.aspectRatio
: null
}
eventImageData={placeData?.image?.filter((image) => !image?.isMain)}
eventImageData={imageGalleryData}
/>
</div>
</Col>
Expand Down
9 changes: 5 additions & 4 deletions src/utils/formInitialValueHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ export const formInitialValueHandler = (type, mappedField, datatype, data) => {
case formTypes.MULTISELECT:
if (initialData?.length > 0) return initialData?.map((concept) => concept?.entityId);
else return [];

case formTypes.IMAGE:
if (Array.isArray(initialData) && initialData.length > 0) {
return [
{
uid: initialData[0]?.original?.entityId,
name: initialData[0]?.original?.entityId,
status: 'done',
url: initialData[0].original.uri,
url: initialData[0]?.original?.uri,
},
];
} else if (initialData?.original?.uri) {
return [
{
uid: initialData.original.entityId,
name: initialData.original.entityId,
uid: initialData?.original?.entityId,
name: initialData?.original?.entityId,
status: 'done',
url: initialData.original.uri,
url: initialData?.original?.uri,
},
];
}
Expand Down