Skip to content

Commit

Permalink
IA-3364: merge IA-3402
Browse files Browse the repository at this point in the history
  • Loading branch information
quang-le committed Sep 13, 2024
2 parents a091442 + 3f56f70 commit d21bf3b
Show file tree
Hide file tree
Showing 86 changed files with 2,402 additions and 716 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ type Props = {
currentIndex: number;
// eslint-disable-next-line no-unused-vars
setCurrentIndex?: (index: number) => void;
url: string | null;
urlLabel: { id: string; defaultMessage: string } | undefined;
url?: string | null;
urlLabel?: { id: string; defaultMessage: string } | undefined;
// eslint-disable-next-line no-unused-vars
getExtraInfos?: (image: ShortFile) => React.ReactNode;
};
Expand Down Expand Up @@ -157,7 +157,6 @@ const ImageGallery: FunctionComponent<Props> = ({
</IconButton>
)}
<IconButton
color="primary"
sx={styles.closeButton}
onClick={() => closeLightbox()}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from '@mui/material';
import { makeStyles } from '@mui/styles';
import { useSafeIntl, LinkWithLocation } from 'bluesquare-components';
import { LinkWithLocation, useSafeIntl } from 'bluesquare-components';
import React, { FunctionComponent } from 'react';

const useStyles = makeStyles(theme => ({
Expand All @@ -13,8 +13,8 @@ const useStyles = makeStyles(theme => ({
}));

type Props = {
url: string | null;
urlLabel: { id: string; defaultMessage: string } | undefined;
url?: string | null;
urlLabel?: { id: string; defaultMessage: string } | undefined;
};

export const ImageGalleryLink: FunctionComponent<Props> = ({
Expand Down
62 changes: 62 additions & 0 deletions hat/assets/js/apps/Iaso/components/files/FavButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import StarBorderIcon from '@mui/icons-material/StarBorder';
import StarRateIcon from '@mui/icons-material/StarRate';
import { IconButton, Tooltip } from '@mui/material';
import { useSafeIntl } from 'bluesquare-components';
import React, { FunctionComponent } from 'react';
import { defineMessages } from 'react-intl';
import { ShortFile } from '../../domains/instances/types/instance';

const styles = {
favButton: {
position: 'absolute',
top: 8,
right: 8,
backgroundColor: 'rgba(255, 255, 255, 0.7)',
boxShadow: '0 0 10px rgba(0, 0, 0, 0.2)',
'&:hover': {
backgroundColor: 'rgba(255, 255, 255, 0.9)',
},
},
};
const MESSAGES = defineMessages({
setAsDefault: {
id: 'iaso.orgUnits.setAsDefaultImage',
defaultMessage: 'Set as default image',
},
removeAsDefault: {
id: 'iaso.orgUnits.removeAsDefaultImage',
defaultMessage: 'Remove as default image',
},
});

type Props = {
file: ShortFile;
// eslint-disable-next-line no-unused-vars
onImageFavoriteClick: (id: number) => void;
// eslint-disable-next-line no-unused-vars
isDefaultImage: (id: number) => boolean;
};

export const FavButton: FunctionComponent<Props> = ({
file,
onImageFavoriteClick,
isDefaultImage,
}) => {
const isDefault = isDefaultImage(file.itemId);
const { formatMessage } = useSafeIntl();
const title = isDefault
? formatMessage(MESSAGES.removeAsDefault)
: formatMessage(MESSAGES.setAsDefault);
return (
<Tooltip title={title}>
<IconButton
color="primary"
sx={styles.favButton}
onClick={() => onImageFavoriteClick(file.itemId)}
>
{!isDefault && <StarBorderIcon />}
{isDefault && <StarRateIcon />}
</IconButton>
</Tooltip>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { FunctionComponent, useRef, useState, useEffect } from 'react';
import { Box, Grid } from '@mui/material';
import { grey } from '@mui/material/colors';

import { LoadingSpinner, LazyImage } from 'bluesquare-components';
import { getFileName } from '../../utils/filesUtils';
import { LazyImage, LoadingSpinner } from 'bluesquare-components';
import React, { FunctionComponent, useEffect, useRef, useState } from 'react';
import { ShortFile } from '../../domains/instances/types/instance';
import { getFileName } from '../../utils/filesUtils';
import { FavButton } from './FavButton';

const styles = {
imageItem: {
Expand All @@ -28,11 +28,17 @@ type Props = {
imageList: ShortFile[];
// eslint-disable-next-line no-unused-vars
onImageClick: (index: number) => void;
// eslint-disable-next-line no-unused-vars
onImageFavoriteClick?: (id: number) => void;
// eslint-disable-next-line no-unused-vars
isDefaultImage?: (id: number) => boolean;
};

const LazyImagesList: FunctionComponent<Props> = ({
imageList,
onImageClick,
onImageFavoriteClick,
isDefaultImage,
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const [width, setWidth] = useState<number | undefined>(undefined);
Expand Down Expand Up @@ -62,24 +68,44 @@ const LazyImagesList: FunctionComponent<Props> = ({
>
{(src, loading, isVisible) => (
<Box
onClick={() => onImageClick(index)}
role="button"
tabIndex={0}
sx={styles.imageContainer}
style={{
sx={{
...styles.imageContainer,
position: 'relative',
backgroundImage: loading
? 'none'
: `url('${src}')`,
}}
>
{loading && isVisible && (
<LoadingSpinner
fixed={false}
transparent
padding={4}
size={25}
/>
)}
{onImageFavoriteClick &&
isDefaultImage && (
<FavButton
file={file}
onImageFavoriteClick={
onImageFavoriteClick
}
isDefaultImage={
isDefaultImage
}
/>
)}
<Box
onClick={() => onImageClick(index)}
role="button"
tabIndex={0}
sx={{
width: '100%',
height: '100%',
}}
>
{loading && isVisible && (
<LoadingSpinner
fixed={false}
transparent
padding={4}
size={25}
/>
)}
</Box>
</Box>
)}
</LazyImage>
Expand Down
11 changes: 10 additions & 1 deletion hat/assets/js/apps/Iaso/constants/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import { OrgUnits } from '../domains/orgUnits';
import OrgUnitDetail from '../domains/orgUnits/details';
import Groups from '../domains/orgUnits/groups';
import Types from '../domains/orgUnits/orgUnitTypes';
import { ReviewOrgUnitChanges } from '../domains/orgUnits/reviewChanges/ReviewOrgUnitChanges';
import { ReviewOrgUnitChanges } from '../domains/orgUnits/reviewChanges';
import { ReviewOrgUnitChangesDetail } from '../domains/orgUnits/reviewChanges/details';
import Pages from '../domains/pages';
import { LotsPayments } from '../domains/payments/LotsPayments';
import { PotentialPayments } from '../domains/payments/PotentialPayments';
Expand Down Expand Up @@ -171,6 +172,13 @@ export const orgUnitChangeRequestPath = {
element: <ReviewOrgUnitChanges />,
};

export const orgUnitChangeRequestDetailPath = {
baseUrl: baseUrls.orgUnitsChangeRequestDetail,
routerUrl: `${baseUrls.orgUnitsChangeRequestDetail}/*`,
permissions: [Permission.ORG_UNITS_CHANGE_REQUEST_REVIEW],
element: <ReviewOrgUnitChangesDetail />,
};

export const registryPath = {
baseUrl: baseUrls.registry,
routerUrl: `${baseUrls.registry}/*`,
Expand Down Expand Up @@ -448,6 +456,7 @@ export const routeConfigs: (RoutePath | AnonymousRoutePath)[] = [
workflowsPath,
workflowsDetailPath,
orgUnitChangeRequestPath,
orgUnitChangeRequestDetailPath,
registryPath,
modulesPath,
potentialPaymentsPath,
Expand Down
7 changes: 7 additions & 0 deletions hat/assets/js/apps/Iaso/constants/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const paginationPathParamsWithPrefix = (prefix: string): string[] =>
paginationPathParams.map(p => `${prefix}${capitalize(p, true)}`);

export const FORMS_PREFIX = 'formsParams';
export const FILES_PREFIX = 'filesParams';
export const LINKS_PREFIX = 'linksParams';
export const LOGS_PREFIX = 'logsParams';
export const OU_CHILDREN_PREFIX = 'childrenParams';
Expand Down Expand Up @@ -184,6 +185,10 @@ export const baseRouteConfigs: Record<string, RouteConfig> = {
'potentialPaymentIds',
],
},
orgUnitsChangeRequestDetail: {
url: `${ORG_UNITS_CHANGE_REQUEST}/detail`,
params: ['accountId', 'changeRequestId'],
},
registry: {
url: 'orgunits/registry',
params: [
Expand Down Expand Up @@ -338,6 +343,7 @@ export const baseRouteConfigs: Record<string, RouteConfig> = {
'entityTypeIds',
'locationLimit',
'groups',
'fieldsSearch',
...paginationPathParams,
],
},
Expand Down Expand Up @@ -533,6 +539,7 @@ type IasoBaseUrls = {
orgUnits: string;
orgUnitDetails: string;
orgUnitsChangeRequest: string;
orgUnitsChangeRequestDetail: string;
registry: string;
registryDetail: string;
links: string;
Expand Down
3 changes: 3 additions & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@
"iaso.label.renderError": "Error rendering value",
"iaso.label.restore": "Restore",
"iaso.label.resultsLower": "result(s)",
"iaso.label.reviewChangeProposal": "Change proposals for {name}",
"iaso.label.reviewChangeProposals": "Review change proposals",
"iaso.label.save": "Save",
"iaso.label.search": "Search",
Expand Down Expand Up @@ -856,12 +857,14 @@
"iaso.orgUnits.project": "Project",
"iaso.orgUnits.referenceForm": "Reference form",
"iaso.orgUnits.referenceForms": "Reference forms",
"iaso.orgUnits.removeAsDefaultImage": "Remove as default image",
"iaso.orgUnits.removeFromGroups": "Remove from group(s)",
"iaso.orgUnits.search": "Search org unit",
"iaso.orgUnits.searchParams": "Use prefix “refs:” for external org unit ID search. Use prefix “ids:” for internal org unit ID search. You can also search multiple IDs at once, separated by a comma or a space. E.g. “ids: 123456, 654321” or “refs: O6uvpzGd5pu, ImspTQPwCqd”",
"iaso.orgUnits.selectionAction": "With selected org unit",
"iaso.orgUnits.selectOrgUnit": "Please select an org Unit",
"iaso.orgUnits.selectProjects": "Select a project",
"iaso.orgUnits.setAsDefaultImage": "Set as default image",
"iaso.orgUnits.shortName": "Short name",
"iaso.orgUnits.source": "Source",
"iaso.orgUnits.sourceLower": "source",
Expand Down
3 changes: 3 additions & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@
"iaso.label.renderError": "Erreur de rendu de la valeur",
"iaso.label.restore": "Restaurer",
"iaso.label.resultsLower": "résultat(s)",
"iaso.label.reviewChangeProposal": "Propositions de changement pour {name}",
"iaso.label.reviewChangeProposals": "Examiner les propositions de changement",
"iaso.label.save": "Sauver",
"iaso.label.search": "Recherche",
Expand Down Expand Up @@ -856,12 +857,14 @@
"iaso.orgUnits.project": "Projet",
"iaso.orgUnits.referenceForm": "Formulaire de référence",
"iaso.orgUnits.referenceForms": "Formulaires de référence",
"iaso.orgUnits.removeAsDefaultImage": "Retirer l'image par défaut",
"iaso.orgUnits.removeFromGroups": "Retirer du(des) groupe(s)",
"iaso.orgUnits.search": "Rechercher une unité d'org.",
"iaso.orgUnits.searchParams": "Utilisez le préfixe “refs:” pour la recherche d'ID externe d'unité d’organisation. Utilisez le préfixe “ids:” pour la recherche d'ID interne d'unité d’organisation. Vous pouvez également rechercher plusieurs ID à la fois, séparés par une virgule ou un espace. Par exemple: “ids: 123456, 654321” ou “refs: O6uvpzGd5pu, ImspTQPwCqd”",
"iaso.orgUnits.selectionAction": "Avec la sélection d'unités d'organisation",
"iaso.orgUnits.selectOrgUnit": "Merci de sélectionner une unité d'organisation",
"iaso.orgUnits.selectProjects": "Selectionner un projet",
"iaso.orgUnits.setAsDefaultImage": "Définir comme image par défaut",
"iaso.orgUnits.shortName": "Nom raccourci",
"iaso.orgUnits.source": "Source",
"iaso.orgUnits.sourceLower": "source",
Expand Down
Loading

0 comments on commit d21bf3b

Please sign in to comment.