Skip to content
Draft
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
25 changes: 23 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2025-10-14T17:59:40.618Z\n"
"PO-Revision-Date: 2025-10-14T17:59:40.618Z\n"
"POT-Creation-Date: 2025-10-15T16:41:05.367Z\n"
"PO-Revision-Date: 2025-10-15T16:41:05.367Z\n"

msgid "Events - Create/update"
msgstr ""
Expand Down Expand Up @@ -176,6 +176,9 @@ msgstr ""
msgid "Import strategy"
msgstr ""

msgid "Comment"
msgstr ""

msgid "File"
msgstr ""

Expand Down Expand Up @@ -230,6 +233,24 @@ msgstr ""
msgid "All"
msgstr ""

msgid "Comment for all imported data values"
msgstr ""

msgid ""
"You can add an optional comment below. If provided, it will be associated "
"with every data value that is created, updated, or deleted during this "
"import."
msgstr ""

msgid "Comment (optional)"
msgstr ""

msgid "CONTINUE WITHOUT COMMENT"
msgstr ""

msgid "SAVE AND CONTINUE"
msgstr ""

msgid ""
"There has been an error. You can either retry or contact your administrator "
"if you think there has been an un recoverable error"
Expand Down
23 changes: 22 additions & 1 deletion i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Bulk Load\n"
"POT-Creation-Date: 2025-10-14T17:59:40.618Z\n"
"POT-Creation-Date: 2025-10-15T16:41:05.367Z\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -198,6 +198,9 @@ msgstr "Estado"
msgid "Import strategy"
msgstr "Importar datos"

msgid "Comment"
msgstr ""

msgid "File"
msgstr ""

Expand Down Expand Up @@ -259,6 +262,24 @@ msgstr ""
msgid "All"
msgstr "Todos"

msgid "Comment for all imported data values"
msgstr ""

msgid ""
"You can add an optional comment below. If provided, it will be associated "
"with every data value that is created, updated, or deleted during this "
"import."
msgstr ""

msgid "Comment (optional)"
msgstr ""

msgid "CONTINUE WITHOUT COMMENT"
msgstr ""

msgid "SAVE AND CONTINUE"
msgstr ""

msgid ""
"There has been an error. You can either retry or contact your administrator "
"if you think there has been an un recoverable error"
Expand Down
23 changes: 22 additions & 1 deletion i18n/fr.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Bulk Load App\n"
"POT-Creation-Date: 2025-10-14T17:59:40.618Z\n"
"POT-Creation-Date: 2025-10-15T16:41:05.367Z\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -192,6 +192,9 @@ msgstr ""
msgid "Import strategy"
msgstr "Importer des données"

msgid "Comment"
msgstr ""

msgid "File"
msgstr ""

Expand Down Expand Up @@ -253,6 +256,24 @@ msgstr ""
msgid "All"
msgstr "Tout"

msgid "Comment for all imported data values"
msgstr ""

msgid ""
"You can add an optional comment below. If provided, it will be associated "
"with every data value that is created, updated, or deleted during this "
"import."
msgstr ""

msgid "Comment (optional)"
msgstr ""

msgid "CONTINUE WITHOUT COMMENT"
msgstr ""

msgid "SAVE AND CONTINUE"
msgstr ""

msgid ""
"There has been an error. You can either retry or contact your administrator "
"if you think there has been an un recoverable error"
Expand Down
23 changes: 22 additions & 1 deletion i18n/pt.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Bulk Load\n"
"POT-Creation-Date: 2025-10-14T17:59:40.618Z\n"
"POT-Creation-Date: 2025-10-15T16:41:05.367Z\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -200,6 +200,9 @@ msgstr "Estado"
msgid "Import strategy"
msgstr "Importar dados"

msgid "Comment"
msgstr ""

msgid "File"
msgstr ""

Expand Down Expand Up @@ -261,6 +264,24 @@ msgstr ""
msgid "All"
msgstr "Tudo"

msgid "Comment for all imported data values"
msgstr ""

msgid ""
"You can add an optional comment below. If provided, it will be associated "
"with every data value that is created, updated, or deleted during this "
"import."
msgstr ""

msgid "Comment (optional)"
msgstr ""

msgid "CONTINUE WITHOUT COMMENT"
msgstr ""

msgid "SAVE AND CONTINUE"
msgstr ""

msgid ""
"There has been an error. You can either retry or contact your administrator "
"if you think there has been an un recoverable error"
Expand Down
23 changes: 22 additions & 1 deletion i18n/ru.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Bulk Load\n"
"POT-Creation-Date: 2025-10-14T17:59:40.618Z\n"
"POT-Creation-Date: 2025-10-15T16:41:05.367Z\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -201,6 +201,9 @@ msgstr "Статус"
msgid "Import strategy"
msgstr "Импортные данные"

msgid "Comment"
msgstr ""

msgid "File"
msgstr ""

Expand Down Expand Up @@ -262,6 +265,24 @@ msgstr ""
msgid "All"
msgstr "Все"

msgid "Comment for all imported data values"
msgstr ""

msgid ""
"You can add an optional comment below. If provided, it will be associated "
"with every data value that is created, updated, or deleted during this "
"import."
msgstr ""

msgid "Comment (optional)"
msgstr ""

msgid "CONTINUE WITHOUT COMMENT"
msgstr ""

msgid "SAVE AND CONTINUE"
msgstr ""

msgid ""
"There has been an error. You can either retry or contact your administrator "
"if you think there has been an un recoverable error"
Expand Down
1 change: 1 addition & 0 deletions src/domain/entities/HistoryEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class HistoryEntry {
"selectedOrgUnits",
"duplicateStrategy",
"organisationUnitStrategy",
"comment",
]),
};
}
Expand Down
1 change: 1 addition & 0 deletions src/domain/entities/ImportTemplateConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface ImportTemplateConfiguration {
selectedOrgUnits?: string[];
duplicateStrategy?: DuplicateImportStrategy;
organisationUnitStrategy?: OrganisationUnitImportStrategy;
comment?: string;
}
62 changes: 58 additions & 4 deletions src/domain/usecases/ImportTemplateUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export class ImportTemplateUseCase implements UseCase {
duplicateStrategy = "ERROR",
organisationUnitStrategy = "ERROR",
settings,
comment,
}: ImportTemplateUseCaseParams,
dataForm: DataForm,
spreadSheet: Blob,
Expand Down Expand Up @@ -244,17 +245,25 @@ export class ImportTemplateUseCase implements UseCase {
});
}

const dataValuesWithComments =
dataForm.type === dataFormTypeMap.dataSets
? this.applyCommentsToDataValues(dataValues, instanceDataValues, comment)
: dataValues;

const shouldDeleteExistingData =
dataForm.type === dataFormTypeMap.dataSets ? this.shouldDeleteAggregatedData(duplicateStrategy) : false;

const deleteResult = shouldDeleteExistingData
? await this.instanceRepository.deleteAggregatedData(templateToDataPackage(instanceDataValues))
: undefined;

const importResult = await this.instanceRepository.importDataPackage(templateToDataPackage(dataValues), {
createAndUpdate: duplicateStrategy === "IMPORT_WITHOUT_DELETE" || duplicateStrategy === "ERROR",
multiTextTeiDelimiter: this.getMultiTextTeiDelimiter(template),
});
const importResult = await this.instanceRepository.importDataPackage(
templateToDataPackage(dataValuesWithComments),
{
createAndUpdate: duplicateStrategy === "IMPORT_WITHOUT_DELETE" || duplicateStrategy === "ERROR",
multiTextTeiDelimiter: this.getMultiTextTeiDelimiter(template),
}
);

const importResultHasErrors = importResult.flatMap(result => result.errors);
if (importResultHasErrors.length > 0 || deleteResult) {
Expand Down Expand Up @@ -612,6 +621,51 @@ export class ImportTemplateUseCase implements UseCase {
return importResultsWithErrorsDetails;
}

/**
* Returns the `dataPackage` with dataValues with comments populated from `existingDataPackage` and `userComment`
*/
private applyCommentsToDataValues(
dataPackage: TemplateDataPackage,
existingDataPackage: TemplateDataPackage,
userComment: Maybe<string>
): TemplateDataPackage {
if (dataPackage.type !== dataFormTypeMap.dataSets) {
return dataPackage;
}
const timestamp = moment().format("YYYYMMDD");
const formattedComment = userComment ? `${timestamp} - BL Import - ${userComment}` : "";

const dataEntriesWithComments = dataPackage.dataEntries.map(entry => ({
...entry,
dataValues: entry.dataValues.map(dv => {
const existingEntry = existingDataPackage.dataEntries.find(
existing =>
existing.orgUnit === entry.orgUnit &&
existing.period === entry.period &&
existing.dataForm === entry.dataForm
);
const existingDv = existingEntry?.dataValues.find(existing => existing.dataElement === dv.dataElement);
const existingComment = existingDv?.comment || "";
if (!formattedComment) {
return {
...dv,
comment: existingComment,
};
} else {
return {
...dv,
comment: existingComment ? `${existingComment.trim()}\n${formattedComment}` : formattedComment,
};
}
}),
}));

return {
...dataPackage,
dataEntries: dataEntriesWithComments,
};
}

private generateErrorDetails(errors: ErrorMessage[], allowedMessages: CustomErrorMatch[], orgUnits: OrgUnit[]) {
return errors.map(error => {
const orgUnit = orgUnits.find(ou => ou.id === error.id);
Expand Down
16 changes: 12 additions & 4 deletions src/webapp/components/history/HistoryImportSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ export function HistoryImportSummary({ summary, details }: HistoryImportSummaryP
<HistoryStatusIndicator status={summary.status} iconStyle={{ fontSize: 18, marginRight: 8 }} />
</div>
{details && (
<div className={classes.infoRow}>
<Typography className={classes.infoLabel}>{i18n.t("Import strategy")}:</Typography>
<Typography variant="body2">{getImportStrategyLabel(details, summary.dataFormType)}</Typography>
</div>
<>
<div className={classes.infoRow}>
<Typography className={classes.infoLabel}>{i18n.t("Import strategy")}:</Typography>
<Typography variant="body2">{getImportStrategyLabel(details, summary.dataFormType)}</Typography>
</div>
{details.configuration?.comment && (
<div className={classes.infoRow}>
<Typography className={classes.infoLabel}>{i18n.t("Comment")}:</Typography>
<Typography variant="body2">{details.configuration?.comment}</Typography>
</div>
)}
</>
)}
<div className={classes.infoRow}>
<Typography className={classes.infoLabel}>{i18n.t("File")}:</Typography>
Expand Down
Loading
Loading