Skip to content

Commit

Permalink
Finish release/23.04
Browse files Browse the repository at this point in the history
MERGING RELEASE branches
  • Loading branch information
dragos-dobre authored Jul 18, 2023
2 parents ed2b162 + 2c1e40b commit ce9b3df
Show file tree
Hide file tree
Showing 9 changed files with 967 additions and 137 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It is dedicated to be deployed as a module of [openimis-fe_js](https://github.co
## Main Menu Contributions
* **Tools** (`tools.mainMenu` contribution key)

**Registers** (`tools.menu.registers` translation key), pointing to `/Registers.aspx` legacy openIMIS (via proxy page). Displayed only if user has one the `[131001,131002,131003,131004,131005,131006]` rights.
**Registers** (`tools.menu.registers` translation key), pointing to `/Registers.aspx` legacy openIMIS (via proxy page). Displayed only if user has one the `[131001,131002,131003,131004,131005,131006,131007,131008,131009,131010]` rights.

**Policy Renewals** (`tools.menu.renewals` translation key), pointing to `/PolicyRenewal.aspx` legacy openIMIS (via proxy page). Displayed only if user has the right `101205`.

Expand Down Expand Up @@ -42,4 +42,4 @@ None
* `state.core.user`, to access user info (rights,...)

## Configurations Options
None
None
1 change: 0 additions & 1 deletion src/components/ReportPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const ReportPicker = (props) => {
const { formatMessage } = useTranslations("tools", modulesManager);
const [searchString, setSearchString] = useState("");
const { isLoading, data } = useReportsQuery();

const options = useMemo(() => {
if (searchString) {
return data?.reports.filter((x) => x.name.toLowerCase().includes(searchString.toLowerCase()));
Expand Down
13 changes: 10 additions & 3 deletions src/components/ReportSearcher.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useCallback, useState } from "react";
import { useSelector } from "react-redux";
import { useReportsQuery } from "../hooks";
import { Searcher, useTranslations, useModulesManager } from "@openimis/fe-core";
import GenerateReportPicker from "./GenerateReportPicker";
import { Box, Button } from "@material-ui/core";
import ReportDefinitionEditorDialog from "./ReportDefinitionEditorDialog";
import { RIGHT_REPORT_EDIT, RIGHT_REPORT_ADD } from "../constants"

const HEADERS = ["tools.report.description", "tools.report.module", "tools.report.name", ""];

Expand All @@ -12,16 +14,21 @@ const ReportSearcher = () => {
const { formatMessageWithValues, formatMessage } = useTranslations("tools", modulesManager);
const { data, isLoading, error, refetch } = useReportsQuery();
const [editedReport, setEditedReport] = useState();
const rights = useSelector((state) => state.core?.user?.i_user?.rights ?? []);
const itemFormatters = useCallback(
() => [
(r) => r.description,
(r) => r.module,
(r) => r.name,
(r) => (
<Box display="flex" justifyContent={"flex-end"} gridGap={12}>
<Button onClick={() => setEditedReport(r)} size="small">
{formatMessage("ReportSearcher.editBtn")}
</Button>
{
rights.includes(RIGHT_REPORT_ADD) &&
rights.includes(RIGHT_REPORT_EDIT) &&
<Button onClick={() => setEditedReport(r)} size="small">
{formatMessage("ReportSearcher.editBtn")}
</Button>
}
<GenerateReportPicker name={r.name} />
</Box>
),
Expand Down
174 changes: 174 additions & 0 deletions src/components/Uploader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import React from "react";

import { ConstantBasedPicker } from "@openimis/fe-core";
import {
Grid,
Typography,
Button,
Divider,
Input,
FormControlLabel,
Checkbox,
Dialog,
DialogTitle,
DialogActions,
} from "@material-ui/core";

import Block from "../components/Block";

const Uploader = ({
acceptableFormats,
blockName,
blockTitle,
formatMessage,
forms,
handleFieldChange,
onPopupClose,
onRegisterDownload,
onSubmit,
openPopup,
popupName,
popupState,
strategies,
uploadLabel,
downloadLabel,
uploadPopupMessage,
}) => (
<>
<Grid item xs={4}>
<Block title={formatMessage(blockTitle)}>
<Grid container spacing={2} direction="column">
<Grid item>
<Typography variant="h6">{formatMessage(downloadLabel)}</Typography>
</Grid>
<Grid item>
<form noValidate>
<Grid container spacing={1} direction="column">
<ConstantBasedPicker
module="tools"
label="formatPicker"
onChange={(value) =>
handleFieldChange(blockName, "format", value)
}
required
constants={acceptableFormats}
withNull
/>
<Grid item>
<Button
variant="contained"
color="primary"
onClick={onRegisterDownload(
blockName,
forms[blockName]?.format
)}
disabled={!forms[blockName]?.format}
>
{formatMessage("downloadBtn")}
</Button>
</Grid>
</Grid>
</form>
</Grid>
<Grid item>
<Divider fullWidth />
</Grid>
<Grid item>
<Typography variant="h6">{formatMessage(uploadLabel)}</Typography>
</Grid>
<Grid item>
<form noValidate>
<Grid container spacing={1} direction="column">
<Grid item>
<Input
onChange={(event) =>
handleFieldChange(
blockName,
"file",
event.target.files[0]
)
}
required
id="import-button"
inputProps={{
accept: acceptableFormats,
}}
type="file"
/>
</Grid>
<Grid item>
<ConstantBasedPicker
module="tools"
label="strategyPicker"
onChange={(value) =>
handleFieldChange(blockName, "strategy", value)
}
required
constants={strategies}
withNull
/>
</Grid>
<Grid item>
<FormControlLabel
label={formatMessage("dryRunLabel")}
control={
<Checkbox
checked={forms[blockName]?.dryRun}
onChange={(e) =>
handleFieldChange(
blockName,
"dryRun",
e.target.checked
)
}
/>
}
/>
</Grid>
<Grid item>
<Button
variant="contained"
color="primary"
onClick={(e) => openPopup(e, blockName)}
disabled={
!(forms[blockName]?.file && forms[blockName]?.strategy)
}
>
{formatMessage("uploadBtn")}
</Button>
{popupState?.open && popupState?.[popupName] && (
<Dialog open onClose={onPopupClose} fullWidth maxWidth="sm">
<DialogTitle>
{formatMessage(uploadPopupMessage)}
</DialogTitle>
<DialogActions>
<Button
variant="contained"
color="primary"
onClick={() => onSubmit(forms[blockName], blockName)}
disabled={
!(
forms[blockName]?.file &&
forms[blockName]?.strategy
)
}
>
{formatMessage("uploadBtn")}
</Button>
<Button onClick={onPopupClose} variant="contained">
{formatMessage("cancelBtn")}
</Button>
</DialogActions>
</Dialog>
)}
</Grid>
</Grid>
</form>
</Grid>
</Grid>
</Block>
</Grid>
</>
);

export default Uploader;
30 changes: 27 additions & 3 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
export const RIGHT_REGISTERS = [131002, 131001, 131004, 131003, 131006, 131005];
export const RIGHT_REGISTERS = [
131002, 131001, 131004, 131003, 131006, 131005, 131008, 131007, 131010,
131009,
];
export const RIGHT_REGISTERS_DIAGNOSES = [131002, 131001];
export const RIGHT_REGISTERS_HEALTH_FACILITIES = [131004, 131003];
export const RIGHT_REGISTERS_LOCATIONS = [131006, 131005];
export const RIGHT_REGISTERS_ITEMS = [131008, 131007];
export const RIGHT_REGISTERS_SERVICES = [131010, 131009];
export const RIGHT_EXTRACTS = [131101, 131102, 131103, 131104, 131105, 131106];
export const RIGHT_REPORTS = [
131201, 131202, 131203, 131204, 131205, 131206, 131207, 131208, 131209, 131210, 131211, 131212, 131213, 131214,
131215, 131216, 131217, 131218, 131219, 131220, 131221, 131222, 131223,
131201, 131202, 131203, 131204, 131205, 131206, 131207, 131208, 131209,
131210, 131211, 131212, 131213, 131214, 131215, 131216, 131217, 131218,
131219, 131220, 131221, 131222, 131223, RIGHT_REPORT_ADD, RIGHT_REPORT_EDIT, 131226
];

export const RIGHT_REPORT_ADD = 131224;
export const RIGHT_REPORT_EDIT = 131225;

export const RIGHT_UTILITIES = [131301, 131302, 131303, 131304];
export const RIGHT_REGISTERS_INSUREES = [101102];
export const RIGHT_FUNDING = 131401;
export const RIGHT_POLICY_RENEWALS = 101205; // cfr.UsersBL.vb : that menu entry is provided when user has PolicyRenew!
export const RIGHT_FEEDBACK_PROMPT = 111008; // cfr.UsersBL.vb : that menu entry is provided when user has ClaimReview!
Expand All @@ -17,3 +28,16 @@ export const STRATEGY_INSERT = "INSERT";
export const STRATEGY_INSERT_UPDATE = "INSERT_UPDATE";
export const STRATEGY_UPDATE = "UPDATE";
export const STRATEGY_INSERT_UPDATE_DELETE = "INSERT_UPDATE_DELETE";

export const EXPORT_TYPE_CSV = "csv";
export const EXPORT_TYPE_XLS = "xls";
export const EXPORT_TYPE_XLSX = "xlsx";
export const EXPORT_TYPE_JSON = "json";
export const EXPORT_TYPE_XML = "xml";

export const INSUREES_TYPE = "insurees";
export const LOCATIONS_TYPE = "locations";
export const DIAGNOSIS_TYPE = "diagnosis";
export const HF_TYPE = "hf";
export const ITEMS_TYPE = "items";
export const SERVICES_TYPE = "services";
5 changes: 2 additions & 3 deletions src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useGraphqlMutation, useGraphqlQuery } from "@openimis/fe-core";
export const useReportsQuery = (config) => {
const { isLoading, error, data, refetch } = useGraphqlQuery(
`
query useReportsQuery {
reports {
query useReportsQuery {
reports {
name
module
description
Expand All @@ -13,7 +13,6 @@ export const useReportsQuery = (config) => {
{},
config
);

return { isLoading, error, refetch, data };
};

Expand Down
4 changes: 2 additions & 2 deletions src/pages/ExtractsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const OfficerDownloadBlock = (props) => {
</Grid>
<Grid item xs={6}>
<Button disabled={!officer} color="primary" variant="contained"
onClick={onExtractDownload("phone_extract", {officer_id})}>
onClick={onExtractDownload("feedbacks", {officer_id})}>
{formatMessage("OfficerDownloadBlock.downloadFeedbacksBtn")}
</Button>
</Grid>
<Grid item xs={6} align="right">
<Button disabled={!officer} color="primary" variant="contained"
onClick={onExtractDownload("phone_extract", {officer_id})}>
onClick={onExtractDownload("renewals", {officer_id})}>
{formatMessage("OfficerDownloadBlock.downloadRenewalsBtn")}
</Button>
</Grid>
Expand Down
Loading

0 comments on commit ce9b3df

Please sign in to comment.