Skip to content
Open
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
4 changes: 4 additions & 0 deletions app/src/components/domain/ImageWithCaptionInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface Props<N> {
name: N;
url: SupportedPaths;
value: Value | null | undefined;
readOnly: boolean;
onChange: (value: SetValueArg<Value> | undefined, name: N) => void;
error: ObjectError<Value> | undefined;
fileIdToUrlMap: Record<number, string>;
Expand All @@ -44,6 +45,7 @@ interface Props<N> {
function ImageWithCaptionInput<const N extends string | number>(props: Props<N>) {
const {
className,
readOnly,
name,
value,
url,
Expand Down Expand Up @@ -92,6 +94,7 @@ function ImageWithCaptionInput<const N extends string | number>(props: Props<N>)
name="id"
accept="image/*"
value={value?.id}
readOnly={readOnly}
onChange={handleFileInputChange}
url={url}
fileIdToUrlMap={fileIdToUrlMap}
Expand All @@ -116,6 +119,7 @@ function ImageWithCaptionInput<const N extends string | number>(props: Props<N>)
className={styles.captionInput}
name="caption"
value={value?.caption}
readOnly={readOnly}
onChange={setFieldValue}
error={error?.caption}
placeholder={strings.imageWithCaptionEnterCaption}
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/domain/LanguageMismatchMessage/i18n.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"namespace": "languageMismatchMessage",
"strings": {
"languageMismatchErrorTitle": "Edit not available in selected language!",
"languageMismatchErrorMessage": "This form was originally created in {originalLanguage} and cannot be edited in a different language!",
"languageMismatchHelpMessage": "Please change the language to {originalLanguage} to edit it!"
"languageMismatchErrorTitle": "Edit not available in {selectedLanguage} language!",
"languageMismatchErrorMessage": "This is because form was originally created in {originalLanguage} language and edits cannot be edited in the {selectedLanguage} language.",
"languageMismatchHelpMessage": "To make changes, please switch to the original language of the form."
}
}
17 changes: 8 additions & 9 deletions app/src/components/domain/LanguageMismatchMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ interface Props {
// FIXME: typings should be fixed in the server
// this should be of type Language
originalLanguage: string | undefined;
selectedLanguage: Language;
}

function LanguageMismatchMessage(props: Props) {
const strings = useTranslation(i18n);

const {
title = strings.languageMismatchErrorTitle,
originalLanguage = 'en',
originalLanguage,
selectedLanguage,
} = props;

return (
Expand All @@ -32,16 +34,13 @@ function LanguageMismatchMessage(props: Props) {
resolveToString(
strings.languageMismatchErrorMessage,
// FIXME: this should not require cast
{ originalLanguage: languageNameMapEn[originalLanguage as Language] ?? '--' },
)
}
actions={
resolveToString(
strings.languageMismatchHelpMessage,
// FIXME: this should not require cast
{ originalLanguage: languageNameMapEn[originalLanguage as Language] ?? '--' },
{
originalLanguage: languageNameMapEn[originalLanguage as Language] ?? '--',
selectedLanguage: languageNameMapEn[selectedLanguage] ?? '--',
},
)
}
actions={strings.languageMismatchHelpMessage}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface Props<N> {
label: React.ReactNode;
icons?: React.ReactNode;
actions?: React.ReactNode;
readOnly?: boolean;
disabled?: boolean;
}

Expand All @@ -62,6 +63,7 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
label,
icons,
actions,
readOnly,
disabled,
} = props;

Expand Down Expand Up @@ -139,6 +141,7 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
icons={icons}
actions={actions}
withoutPreview
readOnly={readOnly}
disabled={disabled}
>
{label}
Expand Down Expand Up @@ -168,7 +171,7 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
ariaLabel={strings.removeImagesButtonTitle}
variant="secondary"
spacing="none"
disabled={disabled}
disabled={disabled || readOnly}
>
<DeleteBinLineIcon />
</IconButton>
Expand All @@ -187,6 +190,7 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
onChange={handleCaptionChange}
error={imageError?.caption}
placeholder={strings.enterCaptionPlaceholder}
readOnly={readOnly}
disabled={disabled}
/>
</div>
Expand Down
6 changes: 5 additions & 1 deletion app/src/components/domain/SourceInformationInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface Props {
onRemove: (index: number) => void;
index: number;
disabled?: boolean;
readOnly: boolean;
}

function SourceInformationInput(props: Props) {
Expand All @@ -41,6 +42,7 @@ function SourceInformationInput(props: Props) {
index,
onRemove,
disabled,
readOnly,
} = props;

const strings = useTranslation(i18n);
Expand Down Expand Up @@ -92,6 +94,7 @@ function SourceInformationInput(props: Props) {
value={value.source_name}
error={error?.source_name}
onChange={onFieldChange}
readOnly={readOnly}
disabled={disabled}
/>
<TextInput
Expand All @@ -101,14 +104,15 @@ function SourceInformationInput(props: Props) {
value={value.source_link}
error={error?.source_link}
onChange={handleSourceFieldChange}
readOnly={readOnly}
disabled={disabled}
/>
<Button
className={styles.removeButton}
name={index}
onClick={onRemove}
variant="tertiary"
disabled={disabled}
disabled={disabled || readOnly}
title={strings.sourceInformationDeleteButton}
>
<DeleteBinTwoLineIcon />
Expand Down
5 changes: 3 additions & 2 deletions app/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ export const FONT_FAMILY_HEADER = 'Montserrat';
// FIXME: fix typing in server (medium priority)
// This should not be the same as OperationType.
export type DrefStatus = components<'read'>['schemas']['DrefDrefStatusEnumKey'];
// const DREF_STATUS_COMPLETED = 1 satisfies DrefStatus;
export const DREF_STATUS_IN_PROGRESS = 0 satisfies DrefStatus;
export const DREF_STATUS_DRAFT = 1 satisfies DrefStatus;
export const DREF_STATUS_FINALIZED = 2 satisfies DrefStatus;
export const DREF_STATUS_APPROVED = 3 satisfies DrefStatus;

export type TypeOfDrefEnum = components<'read'>['schemas']['DrefDrefDrefTypeEnumKey'];
export const DREF_TYPE_IMMINENT = 0 satisfies TypeOfDrefEnum;
Expand Down
5 changes: 4 additions & 1 deletion app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import useUserMe from '#hooks/domain/useUserMe';
import useFilterState from '#hooks/useFilterState';
import {
DREF_STATUS_APPROVED,
DREF_TYPE_LOAN,
type TypeOfDrefEnum,
} from '#utils/constants';
Expand Down Expand Up @@ -230,13 +231,15 @@ function ActiveDrefTable(props: Props) {

const {
unpublished_op_update_count,
is_published,
status,
has_ops_update,
has_final_report,
country_details,
is_dref_imminent_v2,
} = originalDref;

const is_published = status === DREF_STATUS_APPROVED;

const canAddOpsUpdate = (is_published ?? false)
&& (applicationType === 'DREF' || applicationType === 'OPS_UPDATE')
&& !has_final_report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function CompletedDrefTable(props: Props) {
dref: datum.dref,
glide_code: datum.glide_code,
date_of_publication: datum.date_of_publication,
original_language: datum.original_language,
}),
),
{
Expand Down
4 changes: 4 additions & 0 deletions app/src/views/AccountMyFormsDref/DrefTableActions/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"namespace": "accountMyFormsDref",
"strings": {
"dropdownActionApproveLabel": "Approved",
"dropdownActionFinalizeLabel": "Finalize",
"dropdownActionAllocationFormLabel": "Allocation Form",
"dropdownActionAddOpsUpdateLabel": "Add Operational Update",
"dropdownActionCreateFinalReportLabel": "Create Final Report",
Expand All @@ -10,10 +11,13 @@
"dropdownActionEditLabel": "Edit",
"drefApprovalSuccessTitle": "Successfully approved the DREF!",
"drefApprovalFailureTitle": "Failed to approve the DREF!",
"drefFinalizeSuccessTitle": "Successfully finalized the DREF!",
"drefFinalizeFailureTitle": "Failed to finalize the DREF!",
"drefApprovalInProgressTitle": "Approval in progress...",
"drefAccountCouldNotCreate": "Could not create new operational update",
"drefAccountCouldNotCreateFinalReport": "Could not create final report",
"drefAccountConfirmMessage": "You're about to Approve this DREF. Once approved, it can no longer be edited. Are you sure you want to Approve?",
"drefAccountFinalizeConfirmMessage": "You're about to Finalize this DREF. Once finalize, it can no longer be edited. Are you sure you want to Finalize?",
"dropdownActionImminentNewOpsUpdateConfirmationHeading": "Confirm addition of Operational Update",
"dropdownActionImminentNewOpsUpdateConfirmationMessage": "The DREF type will be changed to Response (from Imminent) for the Operational Update. Once created, you'll be able to change it to other types except Imminent. Are you sure you want to add an Operational Update?"
}
Expand Down
Loading
Loading