From 112f01ab71770d1afc8e373b5a5f670838b1e6fe Mon Sep 17 00:00:00 2001 From: jamesspeake Date: Wed, 1 Nov 2023 12:15:53 +0000 Subject: [PATCH 001/118] [CL-4162] Localized float return value --- .../admin/GraphCards/VisitorsCard/useVisitors/parse.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/app/components/admin/GraphCards/VisitorsCard/useVisitors/parse.ts b/front/app/components/admin/GraphCards/VisitorsCard/useVisitors/parse.ts index 1e90ee28acc0..75f668595d21 100644 --- a/front/app/components/admin/GraphCards/VisitorsCard/useVisitors/parse.ts +++ b/front/app/components/admin/GraphCards/VisitorsCard/useVisitors/parse.ts @@ -108,7 +108,7 @@ export const parseExcelData = ( const parsePageViews = (pageViews: string | null | undefined) => { if (!pageViews) return '-'; - return round(+pageViews, 2).toString(); + return round(+pageViews, 2).toLocaleString(); }; const parseVisitDuration = (seconds: string | null | undefined) => { From 65f0676630d9bb2d88de0046bb35dcfc67cd8c1b Mon Sep 17 00:00:00 2001 From: jamesspeake Date: Wed, 1 Nov 2023 12:21:04 +0000 Subject: [PATCH 002/118] [CL-4162] Localized date correctly in voting end dates and made phase use the same --- front/app/components/StatusModule/index.tsx | 4 ++-- .../ProjectsShowPage/timeline/PhaseTitle.tsx | 9 +++------ .../configs/votingMethodConfig/index.tsx | 20 +++++++++---------- front/app/utils/dateUtils.ts | 5 +++++ 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/front/app/components/StatusModule/index.tsx b/front/app/components/StatusModule/index.tsx index 25b4473b36e7..f6eef35844f3 100644 --- a/front/app/components/StatusModule/index.tsx +++ b/front/app/components/StatusModule/index.tsx @@ -25,7 +25,7 @@ import useAppConfiguration from 'api/app_configuration/useAppConfiguration'; // utils import { getVotingMethodConfig } from 'utils/configs/votingMethodConfig'; -import { pastPresentOrFuture, toFullMonth } from 'utils/dateUtils'; +import {getLocalisedDateString, pastPresentOrFuture} from 'utils/dateUtils'; import { isNilOrError } from 'utils/helperUtils'; // styling @@ -134,7 +134,7 @@ const StatusModule = ({ votingMethod, phase, project }: StatusModuleProps) => { {config?.getSubmissionTerm && formatMessage(config.getSubmissionTerm('plural'))}{' '} {formatMessage(messages.submittedUntil)}{' '} - {toFullMonth(phase.attributes.end_at, 'day')}. + {getLocalisedDateString(phase?.attributes.end_at)}. )} diff --git a/front/app/containers/ProjectsShowPage/timeline/PhaseTitle.tsx b/front/app/containers/ProjectsShowPage/timeline/PhaseTitle.tsx index a2af4b1658c1..4523fc1423bc 100644 --- a/front/app/containers/ProjectsShowPage/timeline/PhaseTitle.tsx +++ b/front/app/containers/ProjectsShowPage/timeline/PhaseTitle.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import moment from 'moment'; // hooks import usePhase from 'api/phases/usePhase'; @@ -11,7 +10,7 @@ import messages from 'containers/ProjectsShowPage/messages'; import { FormattedMessage } from 'utils/cl-intl'; // utils -import { pastPresentOrFuture } from 'utils/dateUtils'; +import {getLocalisedDateString, pastPresentOrFuture} from 'utils/dateUtils'; // style import styled from 'styled-components'; @@ -167,10 +166,8 @@ const PhaseTitle = ({ export default PhaseTitle; function getPhaseDates(phase: IPhaseData) { - const startMoment = moment(phase?.attributes.start_at, 'YYYY-MM-DD'); - const endMoment = moment(phase?.attributes.end_at, 'YYYY-MM-DD'); - const startDate = startMoment.format('LL'); - const endDate = endMoment.format('LL'); + const startDate = getLocalisedDateString(phase?.attributes.start_at); + const endDate = getLocalisedDateString(phase?.attributes.end_at); return { startDate, endDate }; } diff --git a/front/app/utils/configs/votingMethodConfig/index.tsx b/front/app/utils/configs/votingMethodConfig/index.tsx index 832f8f250ab2..dcc7cbfb3ef6 100644 --- a/front/app/utils/configs/votingMethodConfig/index.tsx +++ b/front/app/utils/configs/votingMethodConfig/index.tsx @@ -15,7 +15,7 @@ import { MessageDescriptor } from 'react-intl'; import { FormattedMessage } from 'utils/cl-intl'; // utils -import { toFullMonth } from 'utils/dateUtils'; +import {getLocalisedDateString} from 'utils/dateUtils'; // types import { IPhaseData } from 'api/phases/types'; @@ -25,7 +25,7 @@ import { VotingMethod } from 'utils/participationContexts'; import { FormatMessage } from 'typings'; /* Configuration Specifications - + StatusModule: - getStatusHeader: Returns header which appears directly above status module - getStatusTitle: Returns title for the status module @@ -166,7 +166,7 @@ const budgetingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), }} {...messages.budgetingSubmittedInstructions} /> @@ -189,7 +189,7 @@ const budgetingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), maxBudget: phase && phase.attributes.voting_max_total?.toLocaleString(), currency, @@ -324,7 +324,7 @@ const multipleVotingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), }} {...messages.votingSubmittedInstructions} /> @@ -347,7 +347,7 @@ const multipleVotingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), maxVotes: phase && phase.attributes.voting_max_total?.toLocaleString(), voteTerm, @@ -472,7 +472,7 @@ const singleVotingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), }} {...messages.votingSubmittedInstructions} /> @@ -498,7 +498,7 @@ const singleVotingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), maxVotes: votingMax?.toLocaleString(), optionCount: phase && phase.attributes.ideas_count, }} @@ -512,7 +512,7 @@ const singleVotingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), maxVotes: votingMax?.toLocaleString(), optionCount: phase && phase.attributes.ideas_count, }} @@ -527,7 +527,7 @@ const singleVotingConfig: VotingMethodConfig = { b: (chunks) => ( {chunks} ), - endDate: phase && toFullMonth(phase.attributes.end_at, 'day'), + endDate: getLocalisedDateString(phase?.attributes.end_at), }} {...messages.singleVotingUnlimitedEnded} /> diff --git a/front/app/utils/dateUtils.ts b/front/app/utils/dateUtils.ts index 9dba2c350e66..a0d96c81a6cb 100644 --- a/front/app/utils/dateUtils.ts +++ b/front/app/utils/dateUtils.ts @@ -183,3 +183,8 @@ export function getEventDateString(event: IEventData) { )} - ${endMoment.format('LT')}`; } } + +// Get a single date in local format - for example for voting phase end date +export function getLocalisedDateString(dateString: string | undefined) { + return dateString && moment(dateString, 'YYYY-MM-DD').format('LL'); +} From 54d8239a71fdeb409a2967c38aa69a2a3fa9bb8e Mon Sep 17 00:00:00 2001 From: Iva Date: Mon, 13 Nov 2023 15:02:37 +0200 Subject: [PATCH 003/118] Add bg color and max width to components --- .../Widgets/AccordionMultiloc/index.tsx | 2 ++ .../Widgets/ButtonMultiloc/index.tsx | 2 ++ .../Widgets/IframeMultiloc/index.tsx | 7 ++++++- .../Widgets/ImageMultiloc/index.tsx | 2 ++ .../Widgets/TextMultiloc/index.tsx | 7 ++++++- .../ContentBuilder/Widgets/ThreeColumn/index.tsx | 2 ++ .../ContentBuilder/Widgets/TwoColumn/index.tsx | 2 ++ .../components/CraftSections/Events/index.tsx | 10 ++++++++-- .../CraftSections/ImageTextCards/index.tsx | 10 +++++++++- .../components/CraftSections/Projects/index.tsx | 16 ++++++++++------ .../components/CraftSections/Proposals/index.tsx | 10 ++++++++-- 11 files changed, 57 insertions(+), 13 deletions(-) diff --git a/front/app/components/admin/ContentBuilder/Widgets/AccordionMultiloc/index.tsx b/front/app/components/admin/ContentBuilder/Widgets/AccordionMultiloc/index.tsx index 81acd10c6870..8db534759776 100644 --- a/front/app/components/admin/ContentBuilder/Widgets/AccordionMultiloc/index.tsx +++ b/front/app/components/admin/ContentBuilder/Widgets/AccordionMultiloc/index.tsx @@ -33,6 +33,8 @@ const Accordion = ({ text, title, openByDefault = false }: AccordionProps) => { return ( diff --git a/front/app/components/admin/ContentBuilder/Widgets/ButtonMultiloc/index.tsx b/front/app/components/admin/ContentBuilder/Widgets/ButtonMultiloc/index.tsx index 046bbbd3b529..f41a43e45119 100644 --- a/front/app/components/admin/ContentBuilder/Widgets/ButtonMultiloc/index.tsx +++ b/front/app/components/admin/ContentBuilder/Widgets/ButtonMultiloc/index.tsx @@ -58,6 +58,8 @@ const Button = ({ text, url, type, alignment }: ButtonProps) => { ? 'flex-start' : 'flex-end' } + maxWidth="1150px" + margin="0 auto" > {/* In edit view, show the button regardless if URL is set. The button should not be shown though in the live view if the URL is not set. */} diff --git a/front/app/components/admin/ContentBuilder/Widgets/IframeMultiloc/index.tsx b/front/app/components/admin/ContentBuilder/Widgets/IframeMultiloc/index.tsx index 087472b37135..59ecb9e11a94 100644 --- a/front/app/components/admin/ContentBuilder/Widgets/IframeMultiloc/index.tsx +++ b/front/app/components/admin/ContentBuilder/Widgets/IframeMultiloc/index.tsx @@ -41,7 +41,12 @@ interface Props { const Iframe = ({ url, height, hasError, title }: Props) => { const localize = useLocalize(); return ( - + {!hasError && url && (