Skip to content

Commit

Permalink
Merge pull request #103 from openimis/release/24.04
Browse files Browse the repository at this point in the history
MERGING release/24.04 into main
  • Loading branch information
delcroip authored Jun 26, 2024
2 parents 17c30e0 + 7f2b196 commit c2da818
Show file tree
Hide file tree
Showing 9 changed files with 312 additions and 174 deletions.
33 changes: 33 additions & 0 deletions src/components/AdminMainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,45 @@ import {
} from "../constants";

const ADMIN_MAIN_MENU_CONTRIBUTION_KEY = "admin.MainMenu";
const ADMIN_VOUCHER_MAIN_MENU_CONTRIBUTION_KEY = "admin.voucher.MainMenu";

class AdminMainMenu extends Component {
constructor(props) {
super(props);
this.isWorker = props.modulesManager.getConf("fe-core", "isWorker", false);
}

render() {
const { rights } = this.props;
const entries = [];

if (this.isWorker) {
if (rights.includes(RIGHT_USERS)) {
entries.push({
text: formatMessage(this.props.intl, "admin", "menu.users"),
icon: <Person />,
route: "/admin/users",
});
}

entries.push(
...this.props.modulesManager
.getContribs(ADMIN_VOUCHER_MAIN_MENU_CONTRIBUTION_KEY)
.filter((c) => !c.filter || c.filter(rights)),
);

if (!entries.length) return null;

return (
<MainMenuContribution
{...this.props}
header={formatMessage(this.props.intl, "admin", "mainMenu")}
icon={<LocationCity />}
entries={entries}
/>
);
}

if (rights.includes(RIGHT_PRODUCTS)) {
entries.push({
text: formatMessage(this.props.intl, "admin", "menu.products"),
Expand Down
127 changes: 74 additions & 53 deletions src/components/UserFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TextInput,
formatMessage,
} from "@openimis/fe-core";
import { DEFAULT } from "../constants";

const styles = (theme) => ({
dialogTitle: theme.dialog.title,
Expand All @@ -35,7 +36,6 @@ const extractLocations = (locations) => {
const village = municipality && locationsArray.find((l) => l.parent && l.parent.id === municipality.id);

return { region, district, municipality, village };

};

const getParentLocation = (locations) => {
Expand Down Expand Up @@ -71,10 +71,18 @@ const getParentLocation = (locations) => {
};
}
return newLocation;

};

class UserFilter extends Component {
constructor(props) {
super(props);
this.renderLastNameFirst = props.modulesManager.getConf(
"fe-insuree",
"renderLastNameFirst",
DEFAULT.RENDER_LAST_NAME_FIRST,
);
}

state = {
locationFilters: {},
selectedDistrict: {},
Expand All @@ -90,7 +98,6 @@ class UserFilter extends Component {
return !!filters && !!filters[k] ? filters[k].value : null;
};


filterTextFieldValue = (k) => {
const { filters } = this.props;
return !!filters && !!filters[k] ? filters[k].value : "";
Expand All @@ -103,7 +110,6 @@ class UserFilter extends Component {
return district;
};


onChangeCheckbox = (key, value) => {
const filters = [
{
Expand Down Expand Up @@ -163,8 +169,60 @@ class UserFilter extends Component {
onChangeFilters(filters);
};

renderLastNameField = (classes) => (
<ControlledField
module="admin"
id="userFilter.LastName"
field={
<Grid item xs={3} className={classes.item}>
<TextInput
module="user"
label="admin.user.lastName"
name="lastName"
value={this.filterTextFieldValue("lastName")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
id: "lastName",
value: v,
filter: `lastName: "${v}"`,
},
])
}
/>
</Grid>
}
/>
);

renderGivenNameField = (classes) => (
<ControlledField
module="admin"
id="userFilter.OtherNames"
field={
<Grid item xs={3} className={classes.item}>
<TextInput
module="user"
label="admin.user.otherNames"
name="otherNames"
value={this.filterTextFieldValue("otherNames")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
id: "otherNames",
value: v,
filter: `otherNames: "${v}"`,
},
])
}
/>
</Grid>
}
/>
);

render() {
const { classes, filters, onChangeFilters , intl} = this.props;
const { classes, filters, onChangeFilters, intl } = this.props;
const { locationFilters, currentUserType, currentUserRoles, selectedDistrict } = this.state;
return (
<section className={classes.form}>
Expand Down Expand Up @@ -204,7 +262,6 @@ class UserFilter extends Component {
pubRef="location.HealthFacilityPicker"
withNull={true}
value={this.filterValue("healthFacilityId") || ""}

district={selectedDistrict}
onChange={(v) => {
onChangeFilters([
Expand Down Expand Up @@ -255,52 +312,17 @@ class UserFilter extends Component {
</Grid>
}
/>
<ControlledField
module="admin"
id="userFilter.LastName"
field={
<Grid item xs={3} className={classes.item}>
<TextInput
module="user"
label="admin.user.lastName"
name="lastName"
value={this.filterTextFieldValue("lastName")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
id: "lastName",
value: v,
filter: `lastName: "${v}"`,
},
])
}
/>
</Grid>
}
/>
<ControlledField
module="admin"
id="userFilter.OtherNames"
field={
<Grid item xs={3} className={classes.item}>
<TextInput
module="user"
label="admin.user.otherNames"
name="otherNames"
value={this.filterTextFieldValue("otherNames")}
onChange={(v) =>
this.debouncedOnChangeFilter([
{
id: "otherNames",
value: v,
filter: `otherNames: "${v}"`,
},
])
}
/>
</Grid>
}
/>
{this.renderLastNameFirst ? (
<>
{this.renderLastNameField(classes)}
{this.renderGivenNameField(classes)}
</>
) : (
<>
{this.renderGivenNameField(classes)}
{this.renderLastNameField(classes)}
</>
)}
<ControlledField
module="admin"
id="userFilter.Email"
Expand Down Expand Up @@ -407,7 +429,6 @@ class UserFilter extends Component {
/>
}
label={formatMessage(intl, "admin", "UserFilter.showDeleted")}

/>
</Grid>
}
Expand Down
Loading

0 comments on commit c2da818

Please sign in to comment.