diff --git a/i18n/en.pot b/i18n/en.pot index c5c87af1..a0143cd8 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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: 2023-11-30T21:50:54.611Z\n" -"PO-Revision-Date: 2023-11-30T21:50:54.611Z\n" +"POT-Creation-Date: 2023-12-05T11:01:02.938Z\n" +"PO-Revision-Date: 2023-12-05T11:01:02.938Z\n" msgid "Validating Project" msgstr "" @@ -20,6 +20,9 @@ msgstr "" msgid "Unknown error" msgstr "" +msgid "Error uploading files: {{message}}" +msgstr "" + msgid "Files" msgstr "" @@ -514,7 +517,10 @@ msgstr "" msgid "Documents" msgstr "" -msgid "Is this DART applicable?" +msgid "DART" +msgstr "" + +msgid "Partner" msgstr "" msgid "Award Number should be a number of 5 digits" diff --git a/package.json b/package.json index f168dd6a..40c72ceb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "data-management-app", "description": "DHIS2 Data Management App", - "version": "1.6.1", + "version": "1.6.2", "license": "GPL-3.0", "author": "EyeSeeTea team", "homepage": ".", diff --git a/src/components/attach-files-dialog/AttachFilesDialog.tsx b/src/components/attach-files-dialog/AttachFilesDialog.tsx index d62c4cc9..02fa450d 100644 --- a/src/components/attach-files-dialog/AttachFilesDialog.tsx +++ b/src/components/attach-files-dialog/AttachFilesDialog.tsx @@ -67,7 +67,9 @@ export const AttachFilesDialog: React.FC = props => { onClose(); } catch (err: any) { const message = err?.response?.data?.message || i18n.t("Unknown error"); - snackbar.error(i18n.t("Error uploading files: {{message}}", { message })); + snackbar.error( + i18n.t("Error uploading files: {{message}}", { message, nsSeparator: false }) + ); } finally { loading.hide(); } diff --git a/src/components/steps/general-info/GeneralInfoStep.tsx b/src/components/steps/general-info/GeneralInfoStep.tsx index a608ff18..67426299 100644 --- a/src/components/steps/general-info/GeneralInfoStep.tsx +++ b/src/components/steps/general-info/GeneralInfoStep.tsx @@ -18,7 +18,7 @@ type StringField = "name" | "description" | "awardNumber" | "subsequentLettering type DateField = "startDate" | "endDate"; -type BooleanField = "isDartApplicable"; +type BooleanField = "isDartApplicable" | "partner"; type ProjectData = Pick; @@ -77,6 +77,12 @@ class GeneralInfoStep extends React.Component { checked: project.isDartApplicable, }, }), + getCheckBoxField("partner", project.partner, { + onUpdateField: this.onUpdateField, + props: { + checked: project.partner, + }, + }), ]; return ( diff --git a/src/models/Config.ts b/src/models/Config.ts index e20be720..dcdcff26 100644 --- a/src/models/Config.ts +++ b/src/models/Config.ts @@ -109,7 +109,8 @@ export const baseConfig = { awardNumberPrefix: "AWARD_NUMBER_", }, organisationUnitGroups: { - isDartApplicable: "IS_DART_APPLICABLE", + isDartApplicable: "DART", + partner: "PARTNER", }, organisationUnitGroupSets: { funder: "FUNDER", @@ -251,7 +252,10 @@ const metadataParams = { }, filter: { code: { - in: [baseConfig.organisationUnitGroups.isDartApplicable], + in: [ + baseConfig.organisationUnitGroups.isDartApplicable, + baseConfig.organisationUnitGroups.partner, + ], }, }, }, diff --git a/src/models/Project.ts b/src/models/Project.ts index cfe66074..1bbd6c08 100644 --- a/src/models/Project.ts +++ b/src/models/Project.ts @@ -109,6 +109,7 @@ export interface ProjectData { sharing: Sharing; documents: ProjectDocument[]; isDartApplicable: boolean; + partner: boolean; } export interface Dashboard { @@ -234,7 +235,8 @@ class Project { initialData: i18n.t("Initial Data"), sharing: i18n.t("Sharing"), documents: i18n.t("Documents"), - isDartApplicable: i18n.t("Is this DART applicable?"), + isDartApplicable: i18n.t("DART"), + partner: i18n.t("Partner"), }; static getFieldName(field: ProjectField): string { @@ -468,6 +470,7 @@ class Project { sharing: ProjectSharing.getInitialSharing(config), initialData: undefined, isDartApplicable: false, + partner: false, }; return new Project(api, config, projectData); } diff --git a/src/models/ProjectDb.ts b/src/models/ProjectDb.ts index 15d726dd..5c7cdbc1 100644 --- a/src/models/ProjectDb.ts +++ b/src/models/ProjectDb.ts @@ -758,6 +758,10 @@ export default class ProjectDb { group => group.id === config.organisationUnitGroups.isDartApplicable.id ); + const partnerGroup = orgUnit.organisationUnitGroups.some( + group => group.id === config.organisationUnitGroups.partner.id + ); + const projectData = { id: orgUnit.id, name: displayName, @@ -781,6 +785,7 @@ export default class ProjectDb { return ProjectDocument.create(projectDocument); }), isDartApplicable: isInDartApplicableGroup, + partner: partnerGroup, }; const project = new Project(api, config, { ...projectData, initialData: projectData }); return project; @@ -933,6 +938,7 @@ async function getOrgUnitGroupsMetadata( ...project.locations, awardNumberOrgUnitGroupBase, { id: config.organisationUnitGroups.isDartApplicable.id }, + { id: config.organisationUnitGroups.partner.id }, ]) ); @@ -962,14 +968,15 @@ async function getOrgUnitGroupsMetadata( const organisationUnitGroups = orgUnitGroupsToSave.map(orgUnitGroup => { if (orgUnitGroup.id === config.organisationUnitGroups.isDartApplicable.id) { - const currentOrgUnits = orgUnitGroup.organisationUnits || []; - const orgUnitsDartApplicable = project.isDartApplicable - ? _([...currentOrgUnits, { id: project.id }]) - .uniqBy(ou => ou.id) - .value() - : currentOrgUnits.filter(ou => ou.id !== project.id); - - return { ...orgUnitGroup, organisationUnits: orgUnitsDartApplicable }; + return checkIfProjectIsInGroup(orgUnitGroup, { + projectId: project.id, + condition: project.isDartApplicable, + }); + } else if (orgUnitGroup.id === config.organisationUnitGroups.partner.id) { + return checkIfProjectIsInGroup(orgUnitGroup, { + projectId: project.id, + condition: project.partner, + }); } else { const organisationUnits = _(orgUnitGroup.organisationUnits || []) .filter(ou => ou.id !== orgUnitId) @@ -991,6 +998,20 @@ async function getOrgUnitGroupsMetadata( return { organisationUnitGroups, organisationUnitGroupSets }; } +function checkIfProjectIsInGroup( + orgUnitGroup: OrgUnitGroup, + { projectId, condition }: { projectId: string; condition: boolean } +) { + const currentOrgUnits = orgUnitGroup.organisationUnits || []; + const orgUnitsDartApplicable = condition + ? _([...currentOrgUnits, { id: projectId }]) + .uniqBy(ou => ou.id) + .value() + : currentOrgUnits.filter(ou => ou.id !== projectId); + + return { ...orgUnitGroup, organisationUnits: orgUnitsDartApplicable }; +} + function getOrgUnitId(orgUnit: { path: string }): string { const id = _.last(orgUnit.path.split("/")); if (id) return id; diff --git a/src/models/ProjectInfo.ts b/src/models/ProjectInfo.ts index 7e9e109a..69c2aa6f 100644 --- a/src/models/ProjectInfo.ts +++ b/src/models/ProjectInfo.ts @@ -49,6 +49,7 @@ export class ProjectInfo { field(fields.isDartApplicable, project => project.isDartApplicable ? i18n.t("Yes") : i18n.t("No") ), + field(fields.partner, project => (project.partner ? i18n.t("Yes") : i18n.t("No"))), field(fields.funders, project => displayNames(project.funders)), field(i18n.t("Selected country"), project => project.parentOrgUnit ? project.parentOrgUnit.displayName : "-" diff --git a/src/models/__tests__/Project.spec.ts b/src/models/__tests__/Project.spec.ts index 152e69e7..a71394a8 100644 --- a/src/models/__tests__/Project.spec.ts +++ b/src/models/__tests__/Project.spec.ts @@ -75,6 +75,7 @@ describe("Project", () => { expect(project.dashboard).toEqual({}); expect(project.initialData).toEqual(undefined); expect(project.isDartApplicable).toEqual(false); + expect(project.partner).toEqual(false); }); it("has data element sets", () => { @@ -99,6 +100,7 @@ describe("Project", () => { moment("2020-03-31").format("L") ); expect(project.isDartApplicable).toEqual(true); + expect(project.partner).toEqual(true); expect(project.sectors.map(sector => sector.code)).toEqual(["SECTOR_LIVELIHOODS"]); expect(project.funders.map(funder => funder.displayName)).toEqual([]); expect(project.locations.map(location => location.displayName)).toEqual([ @@ -517,6 +519,9 @@ const metadataForGet = { { id: "q0u5u6Of0Wm", }, + { + id: "VnvEdFSucIW", + }, ], }, ], diff --git a/src/models/__tests__/ProjectDb.spec.ts b/src/models/__tests__/ProjectDb.spec.ts index 40fffe67..c2def890 100644 --- a/src/models/__tests__/ProjectDb.spec.ts +++ b/src/models/__tests__/ProjectDb.spec.ts @@ -133,7 +133,7 @@ describe("ProjectDb", () => { params: { "organisationUnitGroups:fields": ":owner", "organisationUnitGroups:filter": [ - "id:in:[aOYJkeWdv2t,yQKIZzBl22A,GsGG8967YDU,WIEp6vpQw6n,q0u5u6Of0Wm]", + "id:in:[aOYJkeWdv2t,yQKIZzBl22A,GsGG8967YDU,WIEp6vpQw6n,q0u5u6Of0Wm,VnvEdFSucIW]", ], }, }).replyOnce(200, orgUnitsMetadata); diff --git a/src/models/__tests__/__snapshots__/ProjectInfo.spec.ts.snap b/src/models/__tests__/__snapshots__/ProjectInfo.spec.ts.snap index 9a30558c..f5d1a733 100644 --- a/src/models/__tests__/__snapshots__/ProjectInfo.spec.ts.snap +++ b/src/models/__tests__/__snapshots__/ProjectInfo.spec.ts.snap @@ -7,7 +7,8 @@ exports[`getAsString 1`] = ` - Subsequent Lettering: en - Additional Designation (Funder, Location, Sector, etc): - - Period dates: October 2018 - March 2019 -- Is this DART applicable?: No +- DART: No +- Partner: No - Funders: funder-aOYJkeWdv2t, funder-yQKIZzBl22A - Selected country: Bahamas - Locations: loc-GsGG8967YDU @@ -33,7 +34,8 @@ exports[`getAsString on new project 1`] = ` - Subsequent Lettering: en - Additional Designation (Funder, Location, Sector, etc): - - Period dates: October 2018 - March 2019 -- Is this DART applicable?: No +- DART: No +- Partner: No - Funders: funder-aOYJkeWdv2t, funder-yQKIZzBl22A - Selected country: Bahamas - Locations: loc-GsGG8967YDU @@ -97,7 +99,14 @@ Array [ }, Object { "action": "none", - "name": "Is this DART applicable?", + "name": "DART", + "prevValue": "No", + "type": "field", + "value": "No", + }, + Object { + "action": "none", + "name": "Partner", "prevValue": "No", "type": "field", "value": "No", diff --git a/src/models/__tests__/config.json b/src/models/__tests__/config.json index 232f2621..2923978c 100644 --- a/src/models/__tests__/config.json +++ b/src/models/__tests__/config.json @@ -70,7 +70,8 @@ "awardNumberPrefix": "AWARD_NUMBER_" }, "organisationUnitGroups": { - "isDartApplicable": "IS_DART_APPLICABLE" + "isDartApplicable": "DART", + "partner": "PARTNER" }, "organisationUnitGroupSets": { "funder": "FUNDER", @@ -62945,7 +62946,11 @@ "organisationUnitGroups": { "isDartApplicable": { "id": "q0u5u6Of0Wm", - "code": "IS_DART_APPLICABLE" + "code": "DART" + }, + "partner": { + "id": "VnvEdFSucIW", + "code": "PARTNER" } } }