From 19f3fd36a5fe17b182ed6d7d586eb334b44b5e6a Mon Sep 17 00:00:00 2001 From: Beygorghor Date: Wed, 17 Apr 2024 17:17:02 +0200 Subject: [PATCH 1/5] working one --- .../Iaso/domains/app/translations/en.json | 130 ++++++++--------- .../Iaso/domains/app/translations/fr.json | 2 + .../orgUnits/components/OrgUnitsFilters.tsx | 38 ++--- .../TreeView/OrgUnitTreeviewModal.js | 135 +++++++++++------- .../components/TreeView/SettingsPopper.tsx | 108 ++++++++++++++ .../orgUnits/components/TreeView/messages.js | 8 ++ .../orgUnits/components/TreeView/requests.js | 45 ++++-- iaso/api/org_unit_search.py | 15 +- iaso/api/org_units.py | 38 ++--- 9 files changed, 347 insertions(+), 172 deletions(-) create mode 100644 hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx diff --git a/hat/assets/js/apps/Iaso/domains/app/translations/en.json b/hat/assets/js/apps/Iaso/domains/app/translations/en.json index 9fc5c9fab0..56641477c5 100644 --- a/hat/assets/js/apps/Iaso/domains/app/translations/en.json +++ b/hat/assets/js/apps/Iaso/domains/app/translations/en.json @@ -1,12 +1,13 @@ { - "PeriodSelectorComponent.label.apply": "Apply", "blsq.buttons.label.close": "Close", "blsq.buttons.label.no": "No", "blsq.buttons.label.yes": "Yes", - "blsq.label.Files": "Files", "blsq.label.clickOrDragFile": "Drag files or click to select", "blsq.label.clicktoOpenFileSelect": "Click to open file selection", "blsq.label.dropHere": "Drop files here", + "blsq.label.Files": "Files", + "blsq.treeview.displayNew": "Show new organisation unit types", + "blsq.treeview.displayRejected": "Show rejected organisation unit types", "blsq.treeview.displayTypes": "Show organisation unit types", "blsq.treeview.error": "Please select an org unit", "blsq.treeview.label.selectMultiple": "Select org unit(s)", @@ -19,8 +20,6 @@ "blsq.treeview.search.options.label.noOptions": "No result found", "blsq.treeview.search.results.label.display": "Display", "blsq.treeview.search.results.label.resultsLower": "result(s)", - "iaso.CDS": "Health centre", - "iaso.SSC": "Community Health Site", "iaso.algo.addRun": "Add algorithm run", "iaso.archived.title": "Archives", "iaso.area": "Health area", @@ -45,6 +44,7 @@ "iaso.attachments.attachmentModalTitle": "Upload file", "iaso.attachments.uploadError": "Error uploading file", "iaso.attachments.uploadSuccess": "File uploaded successfully", + "iaso.CDS": "Health centre", "iaso.changeRequest.addComment": "Add comment for rejection", "iaso.changeRequest.closingDate": "Closing date", "iaso.changeRequest.comment": "Comment", @@ -79,10 +79,17 @@ "iaso.completenessStats.notCompleted": "Not completed", "iaso.completenessStats.selectAForm": "Please select a Form to watch completeness with the map view", "iaso.completenessStats.title": "Completeness stats", + "iaso.datasource.gpkg.title.update": "Update {sourceName} - {versionNumber}", + "iaso.datasources.addAskTitle": "{title} - Source: {source} - Version: {version}", + "iaso.datasources.button.label.copy": "Copy", + "iaso.datasources.button.label.csvPreview": "Preview", + "iaso.datasources.button.label.export": "Export", "iaso.dataSources.checkDHIS2.error": "Connection Error check settings", "iaso.dataSources.checkDHIS2.success": "Connection to server ok", "iaso.dataSources.continueOnError": "Continue on error", + "iaso.datasources.copyVersion": "Copy source version", "iaso.dataSources.create": "Create data sources", + "iaso.datasources.credentialsForExport": "Export to", "iaso.dataSources.dataSourceDetailsTitle": "Data source", "iaso.dataSources.dataSourceInformations": "Data source informations", "iaso.dataSources.dataSourceNoVersion": "This datasource is empty, there are no versions", @@ -99,32 +106,17 @@ "iaso.dataSources.dhisName": "DHIS2 name", "iaso.dataSources.dhisPassword": "DHIS2 password", "iaso.dataSources.dhisUrl": "DHIS2 url", - "iaso.dataSources.goToCurrentTask": "Launch and show task", - "iaso.dataSources.importFromDhis2": "Import a new version from DHIS2", - "iaso.dataSources.name": "Data Source name", - "iaso.dataSources.notDefinedDhis2ConnectionError": "Not defined dhis2 connection error.", - "iaso.dataSources.update": "Update data sources", - "iaso.dataSources.updateFromDhis2": "Update version from DHIS2", - "iaso.dataSources.useDefaultDhisSettings": "Use default DHIS2 settings", - "iaso.dataSources.validateStatus": "Validate status", - "iaso.dataSources.versionOnSourceTitle": "Versions", - "iaso.dataSources.viewDataSource": "View data source", - "iaso.datasource.gpkg.title.update": "Update {sourceName} - {versionNumber}", - "iaso.datasources.addAskTitle": "{title} - Source: {source} - Version: {version}", - "iaso.datasources.button.label.copy": "Copy", - "iaso.datasources.button.label.csvPreview": "Preview", - "iaso.datasources.button.label.export": "Export", - "iaso.datasources.copyVersion": "Copy source version", - "iaso.datasources.credentialsForExport": "Export to", "iaso.datasources.emptyProjectsError": "Please choose at least one project", "iaso.datasources.exportDataSource": "Export data source: {dataSourceName}", "iaso.datasources.geoPkg": "Import GeoPackage", + "iaso.dataSources.goToCurrentTask": "Launch and show task", "iaso.datasources.gpkg.chooseFile": "Choose file", "iaso.datasources.gpkg.explication": "Import OrgUnits from a GeoPackage file, all the OrgUnits present in the file will be updated.{breakingLine}The file must be correctly formatted.{breakingLine}", "iaso.datasources.gpkg.importTaskExplication": "The import will be processed in the background and can take a dozen minutes to complete.", "iaso.datasources.gpkg.title": "Import from GeoPackage", "iaso.datasources.gpkg.title.update": "Update {sourceName} - {versionNumber}", "iaso.datasources.gpkg.tooltip": "Import from a GeoPackage file", + "iaso.dataSources.importFromDhis2": "Import a new version from DHIS2", "iaso.datasources.label.chooseVersionNumber": "Choose version number", "iaso.datasources.label.credentials": "Credentials", "iaso.datasources.label.datasourceRef": "Reference data source", @@ -145,7 +137,9 @@ "iaso.datasources.message.copyToSourceWithVersion": "{sourceName} - version {versionNumber}", "iaso.datasources.message.overwriteWarning": "Warning: if a version with the selected number already exists, it will be overwritten", "iaso.datasources.message.willBeCopied": "will be copied to ", + "iaso.dataSources.name": "Data Source name", "iaso.datasources.noCredentialsForExport": "Please configure DHIS2 on source to enable export", + "iaso.dataSources.notDefinedDhis2ConnectionError": "Not defined dhis2 connection error.", "iaso.datasources.options.label.default": "default", "iaso.datasources.options.label.geometry": "Geometry", "iaso.datasources.options.label.groups": "Groups", @@ -157,7 +151,13 @@ "iaso.datasources.title.export": "Org units to export", "iaso.datasources.title.sourceDataSource": "Org units to compare with to generate export", "iaso.datasources.tooltip.compareAndExport": "Compare data sources and export to DHIS2", + "iaso.dataSources.update": "Update data sources", + "iaso.dataSources.updateFromDhis2": "Update version from DHIS2", + "iaso.dataSources.useDefaultDhisSettings": "Use default DHIS2 settings", + "iaso.dataSources.validateStatus": "Validate status", "iaso.datasources.version": "Versions", + "iaso.dataSources.versionOnSourceTitle": "Versions", + "iaso.dataSources.viewDataSource": "View data source", "iaso.devices.imei": "IMEI", "iaso.devices.last_owner": "Last owner", "iaso.devices.test_device": "Test device", @@ -220,10 +220,10 @@ "iaso.errors.notFound": "Page not found", "iaso.errors.unauthorized": "You are not allowed to see this page", "iaso.exporStatus.createdAt": "When", - "iaso.exportRequest.Status": "Status", "iaso.exportRequest.last_error_message": "Last error message", "iaso.exportRequest.last_export_success_at": "Last export success at", "iaso.exportRequest.launcher": "Exported by", + "iaso.exportRequest.Status": "Status", "iaso.form.addUpdate": "Add / Update", "iaso.form.attachment": "Attachment", "iaso.form.attachments": "Attachments", @@ -241,8 +241,8 @@ "iaso.forms.both": "Validated and not validated", "iaso.forms.closed": "Closed", "iaso.forms.create": "Create form", - "iaso.forms.createLegend": "Create legend", "iaso.forms.created_at": "Created", + "iaso.forms.createLegend": "Create legend", "iaso.forms.creator": "Creator", "iaso.forms.custom": "Custom", "iaso.forms.deleted_at": "Deleted", @@ -278,15 +278,15 @@ "iaso.forms.shape": "Shape", "iaso.forms.showDeleted": "Show only deleted", "iaso.forms.source": "Source", + "iaso.forms.source_ref": "External reference", "iaso.forms.source.derivated": "Derivated from actual data", "iaso.forms.source.pnltha": "PNLTHA", "iaso.forms.source.snis": "SNIS", "iaso.forms.source.ucla": "UCLA", - "iaso.forms.source_ref": "External reference", "iaso.forms.stats.title": "Form statistics", "iaso.forms.status": "Status", - "iaso.forms.subSource": "Sub-Source", "iaso.forms.sub_source": "Sub-source", + "iaso.forms.subSource": "Sub-Source", "iaso.forms.textSearch": "Text search", "iaso.forms.title": "Forms", "iaso.forms.type": "Type", @@ -295,8 +295,8 @@ "iaso.forms.updated_by": "Updated by", "iaso.forms.valid": "Valid", "iaso.forms.validated": "Validated", - "iaso.forms.validationStatus": "Validation status", "iaso.forms.validation_status": "Status", + "iaso.forms.validationStatus": "Validation status", "iaso.forms.viewForm": "View form", "iaso.forms.viewInstance": "View submission", "iaso.forms.viewInstances": "View submission(s)", @@ -313,7 +313,6 @@ "iaso.groups.sourceVersion": "Source version", "iaso.groups.update": "Update group", "iaso.hospital": "Hospital", - "iaso.instance.NoLocksHistory": "There is not locks History", "iaso.instance.coordinate": "Coordinates", "iaso.instance.created_at": "Created", "iaso.instance.delete": "Delete instance(s)", @@ -328,11 +327,11 @@ "iaso.instance.dialog.linkOrgUnitToInstanceReferenceTitle": "Are you sure you want to link this submission to the orgUnit as a reference one ?", "iaso.instance.dialog.lockActionDescription": "This will prevent modification of the submission by any user having lower access than you.", "iaso.instance.dialog.lockActionExistingLockDescription": "This submission is already locked by one or more locks, locking again will create an additional lock. Use the unlock action in the lock table on the bottom right to remove the lock on the submission", - "iaso.instance.dialog.lockOpened": "This lock has been opened", - "iaso.instance.dialog.lockSuccess": "Lock added on the submission", "iaso.instance.dialog.lockedCanModify": "Modifying the submission is prevented for some users however you have the right to modify it", "iaso.instance.dialog.lockedCannotModify": "There is a lock on the submission and you cannot modify it", "iaso.instance.dialog.lockedWarning": "Are you sure you want to lock the submission ?", + "iaso.instance.dialog.lockOpened": "This lock has been opened", + "iaso.instance.dialog.lockSuccess": "Lock added on the submission", "iaso.instance.dialog.unlockedWarning": "Are you sure you want to unlock the submission ?", "iaso.instance.disableColumnSelectionMessage": "Apply search to be able to select visible columns", "iaso.instance.duplicate": "Compare submissions", @@ -358,10 +357,10 @@ "iaso.instance.lockAction": "Lock the submission?", "iaso.instance.lockActionTooltip": "Lock the submission", "iaso.instance.lockAuthorLabel": "Author", - "iaso.instance.lockStatusLabel": "Status", - "iaso.instance.lockTopOrgUnitLabel": "Top org unit", "iaso.instance.locked": "Lock the submission", "iaso.instance.lockedTitle": "Locked", + "iaso.instance.lockStatusLabel": "Status", + "iaso.instance.lockTopOrgUnitLabel": "Top org unit", "iaso.instance.logs": "Compare all versions", "iaso.instance.logs.date": "Date of submission", "iaso.instance.logs.error": "Cannot find log with this Id", @@ -369,6 +368,7 @@ "iaso.instance.logs.versionB": "Version B", "iaso.instance.missingFile": "Cannot find an instance with a file", "iaso.instance.missingGeolocation": "Cannot find an instance with geolocation", + "iaso.instance.NoLocksHistory": "There is not locks History", "iaso.instance.org_unit": "Org unit", "iaso.instance.patchInstanceError": "An error occurred while saving submission", "iaso.instance.patchInstanceSuccesfull": "Submission saved successfully", @@ -379,8 +379,8 @@ "iaso.instance.table.label.instanceHeaderTooltip": "Label: {label} - Name: {key}", "iaso.instance.title": "Submissions", "iaso.instance.titleSingle": "Submission", - "iaso.instance.unDeleteCount": "Mark {count} isntance(s) as not deleted", "iaso.instance.undelete": "Mark instance(s) as not deleted", + "iaso.instance.unDeleteCount": "Mark {count} isntance(s) as not deleted", "iaso.instance.unlocked": "Unlock the submission", "iaso.instance.unlockedTitle": "Unlocked", "iaso.instance.updated_at": "Updated", @@ -429,19 +429,19 @@ "iaso.label.comment": "Comment", "iaso.label.comments": "Comments", "iaso.label.compare": "Compare", - "iaso.label.compareDuplicates": "Compare duplicates", "iaso.label.comparedFields": "Compared fields", + "iaso.label.compareDuplicates": "Compare duplicates", "iaso.label.config": "Admin", "iaso.label.confirm": "Confirm", "iaso.label.confirmApplyFormGpsToOrgUnit": "Apply directly gps from form to org unit", "iaso.label.create": "Create", - "iaso.label.createOrgUnit": "Create org. unit", - "iaso.label.createPlanning": "Create planning", "iaso.label.created": "Creation", - "iaso.label.createdDateFrom": "Creation date from", - "iaso.label.createdDateTo": "Creation date to", "iaso.label.created_at": "Created", "iaso.label.created_by": "Created by", + "iaso.label.createdDateFrom": "Creation date from", + "iaso.label.createdDateTo": "Creation date to", + "iaso.label.createOrgUnit": "Create org. unit", + "iaso.label.createPlanning": "Create planning", "iaso.label.creationDateFrom": "Creation from", "iaso.label.creationDateTo": "Creation until", "iaso.label.currentOu": "Current org Unit", @@ -454,10 +454,10 @@ "iaso.label.day": "Day", "iaso.label.delete": "Delete", "iaso.label.deleteAttachment": "Delete attachment : {attachmentName}", + "iaso.label.deleted": "Deleted", "iaso.label.deletePlanning": "Delete planning : {planningName}", "iaso.label.deleteText": "This operation cannot be undone.", "iaso.label.deleteWarning": "Are you sure you want to delete {name}?", - "iaso.label.deleted": "Deleted", "iaso.label.derived": "Deduced from another form", "iaso.label.destination": "Destination", "iaso.label.details": "Details", @@ -479,8 +479,8 @@ "iaso.label.editPlanning": "Edit planning", "iaso.label.email": "Email", "iaso.label.endDateUntil": "End date until", - "iaso.label.endPeriod": "End period", "iaso.label.ended_at": "Stopped at", + "iaso.label.endPeriod": "End period", "iaso.label.entities.takeValuesFromA": "Take all values from A", "iaso.label.entities.takeValuesFromB": "Take all values from B", "iaso.label.entityA": "Beneficiary A", @@ -499,9 +499,9 @@ "iaso.label.firstName": "First name", "iaso.label.forbiddenChars": "Characters not allowed: '&', '/','?','\"\"' and '%'", "iaso.label.formList": "Form list", + "iaso.label.forms": "Forms", "iaso.label.formSelectHelperText": "You must select a project before selecting forms", "iaso.label.formSubmissionLinkLabel": "Link to form submission", - "iaso.label.forms": "Forms", "iaso.label.from": "From", "iaso.label.fromOrgunit": "(from Org Unit)", "iaso.label.geo_json": "Geo json shape", @@ -519,9 +519,9 @@ "iaso.label.infos": "Infos", "iaso.label.instanceLocks": "Instance locks", "iaso.label.instanceStatus": "Status", - "iaso.label.instanceStatus.duplicateMulti": "Duplicated", "iaso.label.instanceStatus.duplicatedMulti": "Error (duplicated)", "iaso.label.instanceStatus.duplicatedSingle": "duplicated", + "iaso.label.instanceStatus.duplicateMulti": "Duplicated", "iaso.label.instanceStatus.error": "Error(s)", "iaso.label.instanceStatus.errorMulti": "Errors", "iaso.label.instanceStatus.errorSingle": "error", @@ -601,14 +601,14 @@ "iaso.label.pending": "Pending", "iaso.label.period": "Period", "iaso.label.periodPlaceHolder": "Please select a form with a period to filter", + "iaso.label.periods": "Periods", + "iaso.label.periodsAfterAllowed": "Periods after", + "iaso.label.periodsBeforeAllowed": "Periods before", "iaso.label.periodType": "Periodicity", "iaso.label.periodType.month": "Month", "iaso.label.periodType.quarter": "Quarter", "iaso.label.periodType.six_month": "Semester", "iaso.label.periodType.year": "Year", - "iaso.label.periods": "Periods", - "iaso.label.periodsAfterAllowed": "Periods after", - "iaso.label.periodsBeforeAllowed": "Periods before", "iaso.label.phoneNumber": "Phone number", "iaso.label.planning": "Planning", "iaso.label.planningList": "Planning list", @@ -635,9 +635,9 @@ "iaso.label.seeDetails": "See details", "iaso.label.seeParent": "See parent", "iaso.label.selectAll": "Select all", - "iaso.label.selectParentOrgUnit": "Select parent org Unit", "iaso.label.selection": "Selection", "iaso.label.selectionShort": "Sel.", + "iaso.label.selectParentOrgUnit": "Select parent org Unit", "iaso.label.sentEmailInvitation": "Send an invitation email", "iaso.label.sentEmailInvitationWhenAdresseExist": "Enter email address before sending an invitation email", "iaso.label.settings": "Settings", @@ -660,25 +660,25 @@ "iaso.label.stopDelete": "Stop delete", "iaso.label.stopEdit": "Stop edit", "iaso.label.storage": "Storage", - "iaso.label.storageType": "Storage type", "iaso.label.storages": "External storage", + "iaso.label.storageType": "Storage type", "iaso.label.submissionsLocations": "Submissions locations", "iaso.label.submitter": "Submitter", "iaso.label.submitterTeam": "Submitter team", "iaso.label.tasks": "Tasks", "iaso.label.team": "Team", - "iaso.label.teamSelectHelperText": "You must select a project before selecting a team", "iaso.label.teams": "Teams", + "iaso.label.teamSelectHelperText": "You must select a project before selecting a team", "iaso.label.text": "Text", "iaso.label.textSearch": "Search", "iaso.label.title": "Forms", "iaso.label.to": "to", "iaso.label.tooltip.storages": "NFC cards data management", "iaso.label.type": "Type", - "iaso.label.unSelectAll": "Unselect everything", "iaso.label.unknown": "Unknown", "iaso.label.unmatchedRemaining": "Unmatched fields remaining", "iaso.label.unpublished": "Unpublished", + "iaso.label.unSelectAll": "Unselect everything", "iaso.label.updated_at": "Updated", "iaso.label.updated_by": "Updated by", "iaso.label.url": "Url", @@ -693,12 +693,12 @@ "iaso.label.uuid": "Uuid", "iaso.label.valid": "Validated", "iaso.label.validate": "Validate", + "iaso.label.validatedOrgUnitCount": "Validated org units count", "iaso.label.validateOrRejectChanges": "Review changes", "iaso.label.validateOrRejectNewOrgUnit": "Review new org. unit", "iaso.label.validateSelected": "Approve selected change(s)", "iaso.label.validateXLSForm": "Validate your Form beforehand using the ", "iaso.label.validateXLSFormLink": "online tool", - "iaso.label.validatedOrgUnitCount": "Validated org units count", "iaso.label.validator": "Validator", "iaso.label.value": "Value", "iaso.label.version": "Version", @@ -710,11 +710,11 @@ "iaso.label.viewPlanning": "View planning", "iaso.label.with": "With", "iaso.label.withLocation": "With point only", - "iaso.label.withShape": "With territory only", "iaso.label.without": "Without", + "iaso.label.withShape": "With territory only", "iaso.label.workflow": "Workflow", - "iaso.label.workflowVersion": "Workflow version", "iaso.label.workflows": "Workflows", + "iaso.label.workflowVersion": "Workflow version", "iaso.label.wrongAccount": "You are connected to the wrong account, would you like to log out and connect with the correct account to see this link?", "iaso.label.wrongAccountTitle": "Wrong account", "iaso.label.xls_form_file": "XLSForm file", @@ -794,8 +794,6 @@ "iaso.modules.registry": "Registry", "iaso.modules.status": "Status", "iaso.modules.title": "Modules", - "iaso.orgUnits.GPSWarning": "GPS coordinates will NOT be updated for org units that already have coordinates or a shape", - "iaso.orgUnits.MultiReferenceInstancesLabel": "Reference submissions", "iaso.orgUnits.add": "Search org unit to add", "iaso.orgUnits.addForm": "Add form", "iaso.orgUnits.addOrgUnitType": "Add org unit type", @@ -804,9 +802,9 @@ "iaso.orgUnits.bulkChangeCount": "You are about to change {count} Org units", "iaso.orgUnits.closingDate": "Closing date", "iaso.orgUnits.confirmMultiChange": "Confirm bulk changes ?", + "iaso.orgUnits.createdBy": "Created By", "iaso.orgUnits.createSubUnitTypes": "Sub org units types to create", "iaso.orgUnits.createSubUnitTypesInfos": "Allow the creation of these sub org unit types (mobile)", - "iaso.orgUnits.createdBy": "Created By", "iaso.orgUnits.dataSources": "Data Sources", "iaso.orgUnits.depth": "Level", "iaso.orgUnits.depthInfos": "Level of the type in the hierarchy: province (1)> zone (2)> aire (3)> village (4)", @@ -816,10 +814,12 @@ "iaso.orgUnits.editValidation": "Edit validation", "iaso.orgUnits.forms.noData": "No form", "iaso.orgUnits.formsHelperText": "Form submissions", + "iaso.orgUnits.GPSWarning": "GPS coordinates will NOT be updated for org units that already have coordinates or a shape", "iaso.orgUnits.infos": "Infos", "iaso.orgUnits.instances_count": "Number of submissions", "iaso.orgUnits.missingGeolocation": "Cannot find an org unit with geolocation", "iaso.orgUnits.multiEditTitle": "Edit selection", + "iaso.orgUnits.MultiReferenceInstancesLabel": "Reference submissions", "iaso.orgUnits.multiSelectionAction": "Edit selected org units", "iaso.orgUnits.name": "Name", "iaso.orgUnits.new": "Create an org unit", @@ -836,10 +836,10 @@ "iaso.orgUnits.referenceForms": "Reference forms", "iaso.orgUnits.removeFromGroups": "Remove from group(s)", "iaso.orgUnits.search": "Search org unit", - "iaso.orgUnits.searchParams": "Use prefix \u201crefs:\u201d for external org unit ID search. Use prefix \u201cids:\u201d for internal org unit ID search. You can also search multiple IDs at once, separated by a comma or a space. E.g. \u201cids: 123456, 654321\u201d or \u201crefs: O6uvpzGd5pu, ImspTQPwCqd\u201d", + "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.selectionAction": "With selected org unit", "iaso.orgUnits.shortName": "Short name", "iaso.orgUnits.source": "Source", "iaso.orgUnits.sourceLower": "source", @@ -1030,12 +1030,13 @@ "iaso.snackBar.createDataSourceError": "Error occurred while saving the data source.", "iaso.snackBar.createExportRequestError": "An error occured while creating export request", "iaso.snackBar.createExportRequestErrorNoFormMappingError": "The form doesn't a form mapping to export to dhis2", - "iaso.snackBar.createExportRequestErrorNoVersionError": "One of the instance had no version specified", - "iaso.snackBar.createExportRequestErrorNotSupportedError": "Forcing export isn't supported for event tracker", "iaso.snackBar.createExportRequestErrorNothingToExportError": "We found nothing to export, change your filter or force the re-export", + "iaso.snackBar.createExportRequestErrorNotSupportedError": "Forcing export isn't supported for event tracker", + "iaso.snackBar.createExportRequestErrorNoVersionError": "One of the instance had no version specified", "iaso.snackBar.createExportRequestSuccess": "Export request queued", "iaso.snackBar.createFormError": "An error occurred while creating a form", "iaso.snackBar.createFormVersionError": "An error occurred while creating a form version", + "iaso.snackBar.delete_successful": "Deleted successfully", "iaso.snackBar.deleteEntityError": "An error occurred while deleting entity", "iaso.snackBar.deleteEntityTypeError": "An error occurred while deleting beneficiary type", "iaso.snackBar.deleteFormError": "An error occurred while deleting a form", @@ -1048,7 +1049,6 @@ "iaso.snackBar.deleteUserError": "An error occurred while deleting user profile", "iaso.snackBar.deleteUserRoleError": "An error occurred while deleting user role", "iaso.snackBar.deleteUserSuccessful": "User deleted", - "iaso.snackBar.delete_successful": "Deleted successfully", "iaso.snackBar.error": "An error occurred while saving", "iaso.snackBar.exportToDhis2Error": "An error occurred while exporting to DHIS2", "iaso.snackBar.exportToDhis2Success": "Export to DHIS2 was planned with success", @@ -1060,9 +1060,10 @@ "iaso.snackBar.fetchDevicesOwnershipError": "An error occurred while fetching devices ownerships list", "iaso.snackBar.fetchEnketoError": "Failed to upload to enketo, either the submission is currently edited or enketo is not available", "iaso.snackBar.fetchFormError": "An error occurred while fetching form detail", - "iaso.snackBar.fetchFormVersionsError": "An error occurred while fetching form versions", "iaso.snackBar.fetchFormsError": "An error occurred while fetching forms list", + "iaso.snackBar.fetchFormVersionsError": "An error occurred while fetching form versions", "iaso.snackBar.fetchGroupsError": "An error occurred while fetching groups list", + "iaso.snackBar.fetchingLogDetailError": "An error occurred while fetching log details", "iaso.snackBar.fetchInstanceDictError": "An error occurred while fetching instances list", "iaso.snackBar.fetchInstanceError": "An error occurred while fetching instance detail", "iaso.snackBar.fetchInstanceLocationError": "An error occurred while fetching instances locations", @@ -1074,8 +1075,8 @@ "iaso.snackBar.fetchMappingsError": "An error occurred while fetching mappings", "iaso.snackBar.fetchModules": "An error occurred while fetching modules", "iaso.snackBar.fetchOrgUnitError": "An error occurred while fetching org unit detail", - "iaso.snackBar.fetchOrgUnitTypesError": "An error occurred while fetching org unit types list", "iaso.snackBar.fetchOrgUnitsError": "An error occurred while fetching org unit list", + "iaso.snackBar.fetchOrgUnitTypesError": "An error occurred while fetching org unit types list", "iaso.snackBar.fetchPeriodsError": "An error occurred while fetching periods list", "iaso.snackBar.fetchPermissions": "An error occurred while fetching permissions list", "iaso.snackBar.fetchPlanningsError": "An error occurred while fetching plannings list", @@ -1084,7 +1085,6 @@ "iaso.snackBar.fetchSourcesError": "An error occurred while fetching sources list", "iaso.snackBar.fetchTasksError": "An error occurred while fetching tasks list", "iaso.snackBar.fetchUserRoles": "An error occurred while fetching user roles", - "iaso.snackBar.fetchingLogDetailError": "An error occurred while fetching log details", "iaso.snackBar.generateCSVError": "An error occurred while generating CSV file", "iaso.snackBar.generateDerivedRequestError": "Generation failed", "iaso.snackBar.generateDerivedRequestSuccess": "Generation scheduled", @@ -1126,12 +1126,13 @@ "iaso.snackBar.updateFormError": "An error occurred while updating a form", "iaso.snackBar.updateFormVersionError": "An error occurred while updating a form version", "iaso.sourceVersion.label.create": "Create a new version from DHIS2", + "iaso.sourceVersion.label.create_explication": "Import OrgUnits from a DHIS2 server.", "iaso.sourceVersion.label.createEmptyVersionDescription": "It will directly create a new empty version.", "iaso.sourceVersion.label.createNewEmptyVersion": "Create a new empty version", - "iaso.sourceVersion.label.create_explication": "Import OrgUnits from a DHIS2 server.", "iaso.sourceVersion.label.import_task_explication": "The import will be processed in the background and can take a dozen minutes to complete.", "iaso.sourceVersion.label.update": "Update version {version}", "iaso.sourceVersion.label.update_explication": "Update this version by syncing with DHIS2. New Orgunit from DHIS2 will be imported but OrgUnit already present on this version won't be modified.", + "iaso.SSC": "Community Health Site", "iaso.storages.changeStatus": "Change status", "iaso.storages.comment": "Comment", "iaso.storages.logs": "Logs", @@ -1163,9 +1164,9 @@ "iaso.task.label.SUCCESS": "Success", "iaso.tasks.errored": "Errored", "iaso.tasks.exported": "Exported", + "iaso.tasks.killed": "Killed", "iaso.tasks.killSignalSent": "Kill signal sent", "iaso.tasks.killTask": "Stop the task", - "iaso.tasks.killed": "Killed", "iaso.tasks.launcher": "User", "iaso.tasks.message": "Message", "iaso.tasks.name": "Name", @@ -1322,6 +1323,7 @@ "map.label.fitToBounds": "Center the map", "map.label.zoom.box": "Draw a square to zoom", "map.label.zoom.info": "Current zoom level", + "PeriodSelectorComponent.label.apply": "Apply", "trypelim.permissions.anonymous": "Anonymisation of patients", "trypelim.permissions.case_analysis": "Cases analysis", "trypelim.permissions.case_cases": "Cases", diff --git a/hat/assets/js/apps/Iaso/domains/app/translations/fr.json b/hat/assets/js/apps/Iaso/domains/app/translations/fr.json index 9ee61527bc..ad9454359a 100644 --- a/hat/assets/js/apps/Iaso/domains/app/translations/fr.json +++ b/hat/assets/js/apps/Iaso/domains/app/translations/fr.json @@ -6,6 +6,8 @@ "blsq.label.clicktoOpenFileSelect": "Cliquer pour sélectionner des fichiers", "blsq.label.dropHere": "Déposez les fichiers ici", "blsq.label.Files": "Fichiers", + "blsq.treeview.displayNew": "Afficher les nouvelles unités d'org.", + "blsq.treeview.displayRejected": "Afficher les types d'unités d'org. rejétées", "blsq.treeview.displayTypes": "Afficher les types d'unités d'org.", "blsq.treeview.error": "Veuillez sélectionner une unité d'org.", "blsq.treeview.label.selectMultiple": "Sélectionner des unité(s) d'organisation", diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/OrgUnitsFilters.tsx b/hat/assets/js/apps/Iaso/domains/orgUnits/components/OrgUnitsFilters.tsx index 6c530633d5..54373f48a4 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/OrgUnitsFilters.tsx +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/OrgUnitsFilters.tsx @@ -1,3 +1,11 @@ +import { Box, Divider, Grid, Typography } from '@mui/material'; +import { makeStyles } from '@mui/styles'; +import { + IntlFormatMessage, + commonStyles, + useSafeIntl, + useSkipEffectOnMount, +} from 'bluesquare-components'; import React, { Dispatch, FunctionComponent, @@ -6,34 +14,26 @@ import React, { useMemo, useState, } from 'react'; -import { Box, Divider, Grid, Typography } from '@mui/material'; -import { makeStyles } from '@mui/styles'; -import { - commonStyles, - IntlFormatMessage, - useSafeIntl, - useSkipEffectOnMount, -} from 'bluesquare-components'; -import InputComponent from '../../../components/forms/InputComponent'; +import DatesRange from '../../../components/filters/DatesRange'; import { ColorPicker } from '../../../components/forms/ColorPicker'; -import { OrgUnitTreeviewModal } from './TreeView/OrgUnitTreeviewModal'; +import InputComponent from '../../../components/forms/InputComponent'; import { LocationLimit } from '../../../utils/map/LocationLimit'; -import DatesRange from '../../../components/filters/DatesRange'; +import { OrgUnitTreeviewModal } from './TreeView/OrgUnitTreeviewModal'; import { getChipColors } from '../../../constants/chipColors'; -import { useGetGroups } from '../hooks/requests/useGetGroups'; -import { useGetDataSources } from '../hooks/requests/useGetDataSources'; -import { useGetValidationStatus } from '../../forms/hooks/useGetValidationStatus'; import { useCurrentUser } from '../../../utils/usersUtils'; +import { useGetValidationStatus } from '../../forms/hooks/useGetValidationStatus'; +import { useGetDataSources } from '../hooks/requests/useGetDataSources'; +import { useGetGroups } from '../hooks/requests/useGetGroups'; import { useGetOrgUnit } from './TreeView/requests'; -import { Search } from '../types/search'; -import MESSAGES from '../messages'; +import { InputWithInfos } from '../../../components/InputWithInfos'; import { useGetProjectsDropDown } from '../../projects/hooks/requests/useGetProjectsDropDown'; import { useGetOrgUnitTypes } from '../hooks/requests/useGetOrgUnitTypes'; -import { InputWithInfos } from '../../../components/InputWithInfos'; +import MESSAGES from '../messages'; +import { Search } from '../types/search'; type Props = { searches: [Search]; @@ -262,7 +262,7 @@ export const OrgUnitFilters: FunctionComponent = ({ label={MESSAGES.search} blockForbiddenChars onEnterPressed={onSearch} - onErrorChange={(hasError) => setTextSearchError(hasError)} + onErrorChange={hasError => setTextSearchError(hasError)} /> = ({ dateFrom={filters?.dateFrom} dateTo={filters?.dateTo} /> - )} + )} ); diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js index 21936abcb6..11ed3e8085 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js @@ -1,29 +1,36 @@ -import React, { useState, useCallback, useRef, useEffect } from 'react'; +import { Box, useTheme } from '@mui/material'; +import { makeStyles } from '@mui/styles'; +import { TreeViewWithSearch } from 'bluesquare-components'; +import { isEqual } from 'lodash'; import { + array, + arrayOf, bool, func, + number, object, - arrayOf, oneOfType, - number, string, - array, } from 'prop-types'; -import { isEqual } from 'lodash'; -import { makeStyles } from '@mui/styles'; -import { TreeViewWithSearch, useSafeIntl } from 'bluesquare-components'; -import { Box, FormControlLabel, Switch, useTheme } from '@mui/material'; +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; import ConfirmCancelDialogComponent from '../../../../components/dialogs/ConfirmCancelDialogComponent'; -import { MESSAGES } from './messages'; -import { getRootData, getChildrenData, searchOrgUnits } from './requests'; import { OrgUnitLabel, getOrgUnitAncestors } from '../../utils'; import { OrgUnitTreeviewPicker } from './OrgUnitTreeviewPicker'; +import { SettingsPopper } from './SettingsPopper.tsx'; +import { MESSAGES } from './messages'; +import { getChildrenData, getRootData, searchOrgUnits } from './requests'; import { formatInitialSelectedIds, formatInitialSelectedParents, - tooltip, makeTreeviewLabel, orgUnitTreeviewStatusIconsStyle, + tooltip, } from './utils'; const useStyles = makeStyles(orgUnitTreeviewStatusIconsStyle); @@ -47,9 +54,12 @@ const OrgUnitTreeviewModal = ({ errors, }) => { const theme = useTheme(); - const { formatMessage } = useSafeIntl(); const classes = useStyles(); - const [displayTypes, setDisplayTypes] = useState(true); + const [settings, setSettings] = useState({ + displayTypes: true, + displayRejected: true, + displayNew: true, + }); const [selectedOrgUnits, setSelectedOrgUnits] = useState(initialSelection); @@ -110,17 +120,33 @@ const OrgUnitTreeviewModal = ({ }, [selectedOrgUnitsIdsCopy, selectedOrgUnitParentsCopy], ); + const validationSatus = useMemo(() => { + let status = 'VALID'; + if (settings.displayRejected) { + status += ',REJECTED'; + } + if (settings.displayNew) { + status += ',NEW'; + } + return status; + }, [settings.displayNew, settings.displayRejected]); const getRootDataWithSource = useCallback(async () => { - if (version) return getRootData(version, 'version'); - return getRootData(source); - }, [source, version]); + if (version) return getRootData(version, 'version', validationSatus); + return getRootData(source, 'source', validationSatus); + }, [source, version, validationSatus]); const searchOrgUnitsWithSource = useCallback( async (value, count) => { - return searchOrgUnits({ value, count, source, version }); + return searchOrgUnits({ + value, + count, + source, + version, + validationStatus: validationSatus, + }); }, - [source, version], + [source, version, validationSatus], ); const resetSelection = useCallback(() => { @@ -186,45 +212,44 @@ const OrgUnitTreeviewModal = ({ maxWidth="sm" allowConfirm={selectedOrgUnitsIds?.length > 0} > - } - toolTip={tooltip} - parseNodeIds={getOrgUnitAncestors} - multiselect={multiselect} - preselected={selectedOrgUnitsIds} - preexpanded={selectedOrgUnitParents} - selectedData={selectedOrgUnits} - onUpdate={onUpdate} - allowSelection={item => { - if (allowedTypes.length === 0) return true; - return allowedTypes.includes(item.org_unit_type_id); - }} - /> - setDisplayTypes(!displayTypes)} - color="primary" - /> - } - label={formatMessage(MESSAGES.displayTypes)} + + + + ( + + )} + toolTip={tooltip} + parseNodeIds={getOrgUnitAncestors} + multiselect={multiselect} + queryOptions={{ keepPreviousData: true }} + preselected={selectedOrgUnitsIds} + preexpanded={selectedOrgUnitParents} + selectedData={selectedOrgUnits} + onUpdate={onUpdate} + allowSelection={item => { + if (allowedTypes.length === 0) return true; + return allowedTypes.includes(item.org_unit_type_id); + }} + dependency={validationSatus} + childrenDependency={validationSatus} /> diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx new file mode 100644 index 0000000000..7dc58e1e93 --- /dev/null +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx @@ -0,0 +1,108 @@ +import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; +import SettingsIcon from '@mui/icons-material/Settings'; +import { + Box, + FormControlLabel, + IconButton, + Paper, + Popper, + Switch, +} from '@mui/material'; +import { useSafeIntl } from 'bluesquare-components'; +import React, { + Dispatch, + FunctionComponent, + MouseEvent, + SetStateAction, + useState, +} from 'react'; +import { SxStyles } from '../../../../types/general'; +import { MESSAGES } from './messages'; + +export type Settings = { + displayTypes: boolean; + displayRejected: boolean; + displayNew: boolean; +}; + +const styles: SxStyles = { + popper: { + zIndex: 1300, + }, + closeButton: { + position: 'absolute', + right: 0, + top: 5, + zIndex: 1301, + }, + paper: { + padding: theme => theme.spacing(1, 3, 2, 2), + position: 'relative', + }, +}; + +type Props = { + settings: Settings; + setSettings: Dispatch>; +}; + +export const SettingsPopper: FunctionComponent = ({ + settings, + setSettings, +}) => { + const [anchorEl, setAnchorEl] = useState(null); + + const { formatMessage } = useSafeIntl(); + const handleClick = (event: MouseEvent) => { + setAnchorEl(anchorEl ? null : event.currentTarget); + }; + const handleChangeSettings = (setting: string) => { + setSettings({ + ...settings, + [setting]: !settings[setting], + }); + }; + const open = Boolean(anchorEl); + return ( + + + + + + + + + + {['displayTypes', 'displayRejected', 'displayNew'].map( + setting => ( + + + handleChangeSettings(setting) + } + color="primary" + /> + } + label={formatMessage(MESSAGES[setting])} + /> + + ), + )} + + + + ); +}; diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js index 7e4233038c..5d9ca30e51 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js @@ -29,6 +29,14 @@ const MESSAGES = defineMessages({ id: 'blsq.treeview.displayTypes', defaultMessage: 'Show organisation unit types', }, + displayRejected: { + id: 'blsq.treeview.displayRejected', + defaultMessage: 'Show rejected organisation unit types', + }, + displayNew: { + id: 'blsq.treeview.displayNew', + defaultMessage: 'Show new organisation unit types', + }, }); export { MESSAGES }; diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/requests.js b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/requests.js index 0daecce04b..4532feffb9 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/requests.js +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/requests.js @@ -1,8 +1,8 @@ -import { useSnackQuery } from '../../../../libs/apiHooks.ts'; +import { errorSnackBar } from '../../../../constants/snackBars'; import { getRequest } from '../../../../libs/Api'; -import { dispatch } from '../../../../redux/store'; +import { useSnackQuery } from '../../../../libs/apiHooks.ts'; import { enqueueSnackbar } from '../../../../redux/snackBarsReducer'; -import { errorSnackBar } from '../../../../constants/snackBars'; +import { dispatch } from '../../../../redux/store'; export const getChildrenData = (id, validationStatus = 'all') => { return getRequest( @@ -59,23 +59,30 @@ export const getRootData = (id, type = 'source', validationStatus = 'all') => { }; const endpoint = '/api/orgunits/'; -const search = (input1, input2, type) => { +const search = (input1, validationStatus = 'all', input2, type) => { switch (type) { case 'source': - return `searches=[{"validation_status":"all","search":"${input1}","source":${input2}}]`; + return `searches=[{"validation_status":"${validationStatus}","search":"${input1}","source":${input2}}]`; case 'version': - return `searches=[{"validation_status":"all","search":"${input1}","version":${input2}}]`; + return `searches=[{"validation_status":"${validationStatus}","search":"${input1}","version":${input2}}]`; default: - return `searches=[{"validation_status":"all","search":"${input1}","defaultVersion":"true"}]`; + return `searches=[{"validation_status":"${validationStatus}","search":"${input1}","defaultVersion":"true"}]`; } }; const sortingAndPaging = resultsCount => `order=name&page=1&limit=${resultsCount}&smallSearch=true`; -const makeSearchUrl = ({ value, count, source, version }) => { +const makeSearchUrl = ({ + value, + count, + source, + version, + validationStatus = 'all', +}) => { if (source) { return `${endpoint}?${search( value, + validationStatus, source, 'source', )}&${sortingAndPaging(count)}`; @@ -83,19 +90,35 @@ const makeSearchUrl = ({ value, count, source, version }) => { if (version) { return `${endpoint}?${search( value, + validationStatus, version, 'version', + validationStatus, )}&${sortingAndPaging(count)}`; } - return `${endpoint}?${search(value)}&${sortingAndPaging(count)}`; + return `${endpoint}?${search(value, validationStatus)}&${sortingAndPaging( + count, + )}`; }; /** * @param {string} searchValue * @param {number} resultsCount */ -export const searchOrgUnits = ({ value, count, source, version }) => { - const url = makeSearchUrl({ value, count, source, version }); +export const searchOrgUnits = ({ + value, + count, + source, + version, + validationStatus = 'all', +}) => { + const url = makeSearchUrl({ + value, + count, + source, + version, + validationStatus, + }); return getRequest(url) .then(result => result.orgunits) .catch(error => { diff --git a/iaso/api/org_unit_search.py b/iaso/api/org_unit_search.py index a1bb9e29cb..6226f26400 100644 --- a/iaso/api/org_unit_search.py +++ b/iaso/api/org_unit_search.py @@ -1,16 +1,16 @@ -from datetime import datetime import re +from datetime import datetime -from django.contrib.gis.db.models import PointField, MultiPolygonField +from django.contrib.gis.db.models import MultiPolygonField, PointField from django.contrib.gis.geos import GEOSGeometry -from django.db.models import Q, Count, Sum, Case, When, IntegerField +from django.db.models import Case, Count, IntegerField, Q, Sum, When from django.db.models.functions import Cast -from iaso.models import OrgUnit, Instance, DataSource +from iaso.models import DataSource, Instance, OrgUnit def build_org_units_queryset(queryset, params, profile): - validation_status = params.get("validation_status", OrgUnit.VALIDATION_VALID) + validation_statuses = params.get("validation_status", OrgUnit.VALIDATION_VALID) has_instances = params.get("hasInstances", None) date_from = params.get("dateFrom", None) date_to = params.get("dateTo", None) @@ -46,8 +46,9 @@ def build_org_units_queryset(queryset, params, profile): opening_date = params.get("opening_date", None) closed_date = params.get("closed_date", None) - if validation_status != "all": - queryset = queryset.filter(validation_status=validation_status) + if validation_statuses != "all": + validation_statuses_list = validation_statuses.split(",") + queryset = queryset.filter(validation_status__in=validation_statuses_list) if search: if search.startswith("ids:"): diff --git a/iaso/api/org_units.py b/iaso/api/org_units.py index f8805df219..f182766a48 100644 --- a/iaso/api/org_units.py +++ b/iaso/api/org_units.py @@ -1,31 +1,36 @@ import json +import typing from copy import deepcopy -from time import gmtime, strftime from datetime import datetime -import typing +from time import gmtime, strftime from django.conf import settings -from django.contrib.gis.geos import Point -from django.contrib.gis.geos import Polygon, GEOSGeometry, MultiPolygon +from django.contrib.gis.geos import GEOSGeometry, MultiPolygon, Point, Polygon from django.core.exceptions import ValidationError from django.core.paginator import Paginator -from django.db.models import Q, IntegerField, Value, Count -from django.http import StreamingHttpResponse, HttpResponse +from django.db.models import Count, IntegerField, Q, Value +from django.http import HttpResponse, StreamingHttpResponse from django.shortcuts import get_object_or_404 from django.utils.translation import gettext as _ -from rest_framework import viewsets, permissions +from rest_framework import permissions, viewsets from rest_framework.decorators import action from rest_framework.response import Response -from hat.api.export_utils import Echo, generate_xlsx, iter_items, timestamp_to_utc_datetime +from hat.api.export_utils import (Echo, generate_xlsx, iter_items, + timestamp_to_utc_datetime) from hat.audit import models as audit_models -from iaso.api.common import safe_api_import, CONTENT_TYPE_XLSX, CONTENT_TYPE_CSV -from iaso.api.org_unit_search import build_org_units_queryset, annotate_query -from iaso.api.serializers import OrgUnitSmallSearchSerializer, OrgUnitSearchSerializer, OrgUnitTreeSearchSerializer +from hat.menupermissions import models as permission +from iaso.api.common import (CONTENT_TYPE_CSV, CONTENT_TYPE_XLSX, + safe_api_import) +from iaso.api.org_unit_search import annotate_query, build_org_units_queryset +from iaso.api.serializers import (OrgUnitSearchSerializer, + OrgUnitSmallSearchSerializer, + OrgUnitTreeSearchSerializer) from iaso.gpkg import org_units_to_gpkg_bytes -from iaso.models import OrgUnit, OrgUnitType, Group, Project, SourceVersion, Form, Instance, DataSource +from iaso.models import (DataSource, Form, Group, Instance, OrgUnit, + OrgUnitType, Project, SourceVersion) from iaso.utils import geojson_queryset -from hat.menupermissions import models as permission + from ..utils.models.common import get_creator_name, get_org_unit_parents_ref @@ -339,7 +344,7 @@ def treesearch(self, request, **kwargs): queryset = self.get_queryset().order_by("name") params = request.GET parent_id = params.get("parent_id") - validation_status = params.get("validation_status") + validation_statuses = params.get("validation_status") roots_for_user = params.get("rootsForUser", None) source = params.get("source", None) version = params.get("version", None) @@ -374,8 +379,9 @@ def treesearch(self, request, **kwargs): get_object_or_404(self.get_queryset().only("id"), id=parent_id) queryset = queryset.filter(parent=parent_id) - if validation_status != "all": - queryset = queryset.filter(validation_status=validation_status) + if validation_statuses != "all": + validation_statuses_list = validation_statuses.split(",") + queryset = queryset.filter(validation_status__in=validation_statuses_list) if ignore_empty_names: queryset = queryset.filter(~Q(name="")) From 0e2eaf5914f41e629f23357dba2a26e7dee4aa3b Mon Sep 17 00:00:00 2001 From: Beygorghor Date: Thu, 18 Apr 2024 10:56:19 +0200 Subject: [PATCH 2/5] fine tuning --- .../TreeView/OrgUnitTreeviewModal.js | 44 +++++++------------ .../components/TreeView/SettingsPopper.tsx | 38 ++++++++-------- 2 files changed, 36 insertions(+), 46 deletions(-) diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js index 11ed3e8085..11e6420c48 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/OrgUnitTreeviewModal.js @@ -12,13 +12,7 @@ import { oneOfType, string, } from 'prop-types'; -import React, { - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import ConfirmCancelDialogComponent from '../../../../components/dialogs/ConfirmCancelDialogComponent'; import { OrgUnitLabel, getOrgUnitAncestors } from '../../utils'; import { OrgUnitTreeviewPicker } from './OrgUnitTreeviewPicker'; @@ -57,8 +51,8 @@ const OrgUnitTreeviewModal = ({ const classes = useStyles(); const [settings, setSettings] = useState({ displayTypes: true, - displayRejected: true, - displayNew: true, + displayRejected: false, + displayNew: false, }); const [selectedOrgUnits, setSelectedOrgUnits] = useState(initialSelection); @@ -120,21 +114,17 @@ const OrgUnitTreeviewModal = ({ }, [selectedOrgUnitsIdsCopy, selectedOrgUnitParentsCopy], ); - const validationSatus = useMemo(() => { - let status = 'VALID'; - if (settings.displayRejected) { - status += ',REJECTED'; - } - if (settings.displayNew) { - status += ',NEW'; - } - return status; - }, [settings.displayNew, settings.displayRejected]); + + const { displayTypes, displayRejected, displayNew } = settings; + + const validationStatus = `VALID${displayRejected ? ',REJECTED' : ''}${ + displayNew ? ',NEW' : '' + }`; const getRootDataWithSource = useCallback(async () => { - if (version) return getRootData(version, 'version', validationSatus); - return getRootData(source, 'source', validationSatus); - }, [source, version, validationSatus]); + if (version) return getRootData(version, 'version', validationStatus); + return getRootData(source, 'source', validationStatus); + }, [source, version, validationStatus]); const searchOrgUnitsWithSource = useCallback( async (value, count) => { @@ -143,10 +133,10 @@ const OrgUnitTreeviewModal = ({ count, source, version, - validationStatus: validationSatus, + validationStatus, }); }, - [source, version, validationSatus], + [source, version, validationStatus], ); const resetSelection = useCallback(() => { @@ -228,7 +218,7 @@ const OrgUnitTreeviewModal = ({ label={makeTreeviewLabel( classes, showStatusIconInTree, - settings.displayTypes, + displayTypes, )} toggleOnLabelClick={toggleOnLabelClick} onSelect={onOrgUnitSelect} @@ -248,8 +238,8 @@ const OrgUnitTreeviewModal = ({ if (allowedTypes.length === 0) return true; return allowedTypes.includes(item.org_unit_type_id); }} - dependency={validationSatus} - childrenDependency={validationSatus} + dependency={validationStatus} + childrenDependency={validationStatus} /> diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx index 7dc58e1e93..823bd3af5d 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/SettingsPopper.tsx @@ -41,6 +41,8 @@ const styles: SxStyles = { }, }; +const settingKeys: string[] = ['displayTypes', 'displayRejected', 'displayNew']; + type Props = { settings: Settings; setSettings: Dispatch>; @@ -82,25 +84,23 @@ export const SettingsPopper: FunctionComponent = ({ - {['displayTypes', 'displayRejected', 'displayNew'].map( - setting => ( - - - handleChangeSettings(setting) - } - color="primary" - /> - } - label={formatMessage(MESSAGES[setting])} - /> - - ), - )} + {settingKeys.map(settingKey => ( + + + handleChangeSettings(settingKey) + } + color="primary" + /> + } + label={formatMessage(MESSAGES[settingKey])} + /> + + ))} From 42af0328c7a7e890d56e18cf357c7713442cdac4 Mon Sep 17 00:00:00 2001 From: Beygorghor Date: Thu, 18 Apr 2024 11:30:02 +0200 Subject: [PATCH 3/5] black --- iaso/api/org_units.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/iaso/api/org_units.py b/iaso/api/org_units.py index f182766a48..a97bb115b5 100644 --- a/iaso/api/org_units.py +++ b/iaso/api/org_units.py @@ -16,19 +16,14 @@ from rest_framework.decorators import action from rest_framework.response import Response -from hat.api.export_utils import (Echo, generate_xlsx, iter_items, - timestamp_to_utc_datetime) +from hat.api.export_utils import Echo, generate_xlsx, iter_items, timestamp_to_utc_datetime from hat.audit import models as audit_models from hat.menupermissions import models as permission -from iaso.api.common import (CONTENT_TYPE_CSV, CONTENT_TYPE_XLSX, - safe_api_import) +from iaso.api.common import CONTENT_TYPE_CSV, CONTENT_TYPE_XLSX, safe_api_import from iaso.api.org_unit_search import annotate_query, build_org_units_queryset -from iaso.api.serializers import (OrgUnitSearchSerializer, - OrgUnitSmallSearchSerializer, - OrgUnitTreeSearchSerializer) +from iaso.api.serializers import OrgUnitSearchSerializer, OrgUnitSmallSearchSerializer, OrgUnitTreeSearchSerializer from iaso.gpkg import org_units_to_gpkg_bytes -from iaso.models import (DataSource, Form, Group, Instance, OrgUnit, - OrgUnitType, Project, SourceVersion) +from iaso.models import DataSource, Form, Group, Instance, OrgUnit, OrgUnitType, Project, SourceVersion from iaso.utils import geojson_queryset from ..utils.models.common import get_creator_name, get_org_unit_parents_ref From d1ee3d4dcf42c0e62d01775175c82d057e49ec2a Mon Sep 17 00:00:00 2001 From: Beygorghor Date: Fri, 19 Apr 2024 11:24:40 +0200 Subject: [PATCH 4/5] wording --- hat/assets/js/apps/Iaso/domains/app/translations/en.json | 4 ++-- hat/assets/js/apps/Iaso/domains/app/translations/fr.json | 4 ++-- .../Iaso/domains/orgUnits/components/TreeView/messages.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hat/assets/js/apps/Iaso/domains/app/translations/en.json b/hat/assets/js/apps/Iaso/domains/app/translations/en.json index 6c9fe5898d..264b858d84 100644 --- a/hat/assets/js/apps/Iaso/domains/app/translations/en.json +++ b/hat/assets/js/apps/Iaso/domains/app/translations/en.json @@ -6,8 +6,8 @@ "blsq.label.clicktoOpenFileSelect": "Click to open file selection", "blsq.label.dropHere": "Drop files here", "blsq.label.Files": "Files", - "blsq.treeview.displayNew": "Show new organisation unit types", - "blsq.treeview.displayRejected": "Show rejected organisation unit types", + "blsq.treeview.displayNew": "Show new organisation unit", + "blsq.treeview.displayRejected": "Show rejected organisation unit", "blsq.treeview.displayTypes": "Show organisation unit types", "blsq.treeview.error": "Please select an org unit", "blsq.treeview.label.selectMultiple": "Select org unit(s)", diff --git a/hat/assets/js/apps/Iaso/domains/app/translations/fr.json b/hat/assets/js/apps/Iaso/domains/app/translations/fr.json index ec04317210..3abe904c3d 100644 --- a/hat/assets/js/apps/Iaso/domains/app/translations/fr.json +++ b/hat/assets/js/apps/Iaso/domains/app/translations/fr.json @@ -6,8 +6,8 @@ "blsq.label.clicktoOpenFileSelect": "Cliquer pour sélectionner des fichiers", "blsq.label.dropHere": "Déposez les fichiers ici", "blsq.label.Files": "Fichiers", - "blsq.treeview.displayNew": "Afficher les nouvelles unités d'org.", - "blsq.treeview.displayRejected": "Afficher les types d'unités d'org. rejétées", + "blsq.treeview.displayNew": "Afficher les unités d'org.", + "blsq.treeview.displayRejected": "Afficher les unités d'org. rejétées", "blsq.treeview.displayTypes": "Afficher les types d'unités d'org.", "blsq.treeview.error": "Veuillez sélectionner une unité d'org.", "blsq.treeview.label.selectMultiple": "Sélectionner des unité(s) d'organisation", diff --git a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js index 5d9ca30e51..f146fdea30 100644 --- a/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js +++ b/hat/assets/js/apps/Iaso/domains/orgUnits/components/TreeView/messages.js @@ -31,7 +31,7 @@ const MESSAGES = defineMessages({ }, displayRejected: { id: 'blsq.treeview.displayRejected', - defaultMessage: 'Show rejected organisation unit types', + defaultMessage: 'Show rejected organisation unit', }, displayNew: { id: 'blsq.treeview.displayNew', From d41cd8cb7d0d4d1ecccbef54bde7fd9f6f8bc13b Mon Sep 17 00:00:00 2001 From: Beygorghor Date: Mon, 29 Apr 2024 10:06:18 +0200 Subject: [PATCH 5/5] upgrade blsq components --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a2be0cafa4..3da7fb1fb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6200,7 +6200,7 @@ }, "node_modules/bluesquare-components": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/BLSQ/bluesquare-components.git#4ff041549d0649c36a774145969aa9cc8ce65d11", + "resolved": "git+ssh://git@github.com/BLSQ/bluesquare-components.git#9e8bafc8c86990e979ba235321cbc4c253cff9e8", "license": "Apache-2.0", "dependencies": { "@babel/plugin-proposal-class-properties": "^7.18.6", @@ -33315,7 +33315,7 @@ "dev": true }, "bluesquare-components": { - "version": "git+ssh://git@github.com/BLSQ/bluesquare-components.git#4ff041549d0649c36a774145969aa9cc8ce65d11", + "version": "git+ssh://git@github.com/BLSQ/bluesquare-components.git#9e8bafc8c86990e979ba235321cbc4c253cff9e8", "from": "bluesquare-components@github:BLSQ/bluesquare-components", "requires": { "@babel/plugin-proposal-class-properties": "^7.18.6",