Skip to content

Commit 42e27d2

Browse files
committed
feat: rows per pages config
1 parent 022f607 commit 42e27d2

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export function fetchUser(mm, userId, clientMutationId) {
215215
id
216216
phone
217217
languageId
218+
defaultRowsPerPage
218219
lastName
219220
otherNames
220221
roles { id name isSystem}

src/components/UserMasterPanel.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import {
1111
withModulesManager,
1212
useTranslations,
1313
TextInput,
14+
SelectInput,
1415
PublishedComponent,
1516
ValidatedTextInput,
1617
passwordGenerator,
1718
validatePassword,
19+
ROWS_PER_PAGE_OPTIONS,
1820
} from "@openimis/fe-core";
1921
import { CLAIM_ADMIN_USER_TYPE, ENROLMENT_OFFICER_USER_TYPE, EMAIL_REGEX_PATTERN, DEFAULT, RIGHT_HEALTHFACILITIES } from "../constants";
2022
import {
@@ -295,7 +297,7 @@ const UserMasterPanel = (props) => {
295297
</Grid>
296298

297299
<Grid item xs={12} className={classes.sectionHeader}>
298-
<Typography className={classes.sectionTitle}>{formatMessage("UserMasterPanel.loginDetailsTitle")}</Typography>
300+
<Typography className={classes.sectionTitle}>{formatMessage("UserMasterPanel.preferencesTitle")}</Typography>
299301
<Divider variant="fullWidth" />
300302
</Grid>
301303
<Grid item xs={4} className={classes.item}>
@@ -311,6 +313,22 @@ const UserMasterPanel = (props) => {
311313
onChange={(language) => onEditedChanged({ ...edited, language })}
312314
/>
313315
</Grid>
316+
<Grid item xs={4} className={classes.item}>
317+
<SelectInput
318+
module="admin"
319+
label="user.defaultRowsPerPage"
320+
readOnly={readOnly}
321+
required
322+
options={ROWS_PER_PAGE_OPTIONS.map((option) => ({ value: option, label: option }))}
323+
value={edited?.defaultRowsPerPage ?? ""}
324+
onChange={(defaultRowsPerPage) => onEditedChanged({ ...edited, defaultRowsPerPage })}
325+
/>
326+
</Grid>
327+
328+
<Grid item xs={12} className={classes.sectionHeader}>
329+
<Typography className={classes.sectionTitle}>{formatMessage("UserMasterPanel.loginDetailsTitle")}</Typography>
330+
<Divider variant="fullWidth" />
331+
</Grid>
314332
<Grid item xs={4} className={classes.item}>
315333
<TextInput
316334
module="admin"

src/translations/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"admin.user.lastName": "Last name",
4242
"admin.user.openNewTab.buttonText": "Open",
4343
"admin.user.language": "Interface Language",
44+
"admin.user.defaultRowsPerPage": "Default rows per page",
4445
"admin.user.openNewTab": "Open in new tab",
4546
"admin.user.otherNames": "Other names",
4647
"admin.user.givenNames": "Given names",
@@ -77,6 +78,7 @@
7778
"admin.UserPicker.clearText": "Clear",
7879
"admin.UserPicker.openText": "Open",
7980
"admin.UserPicker.closeText": "Close",
81+
"admin.UserMasterPanel.preferencesTitle": "User Preferences",
8082
"admin.UserMasterPanel.loginDetailsTitle": "Login Details",
8183
"admin.UserMasterPanel.language.null": "Select a language",
8284
"admin.EnrolmentOfficerPicker.label": "Select an Officer",

src/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const mapQueriesUserToStore = (u) => {
4646
u.phoneNumber = u.iUser.phone;
4747
u.healthFacility = u.iUser.healthFacility;
4848
u.language = u.iUser.languageId;
49+
u.defaultRowsPerPage = u.iUser.defaultRowsPerPage;
4950
u.roles = u.iUser.roles;
5051
u.districts = u.iUser.districts.map((d) => d.location);
5152
}
@@ -89,6 +90,7 @@ export const mapUserValuesToInput = (values) => {
8990
districts: values.districts.map((d) => decodeId(d.id)),
9091
locationId: values.location ? decodeId(values.location.id) : null,
9192
language: values.language,
93+
defaultRowsPerPage: values.defaultRowsPerPage ? parseInt(values.defaultRowsPerPage, 10) : null,
9294
roles: values.roles.map((r) => decodeId(r.id)),
9395
birthDate: values.birthDate,
9496
address: values.address,

0 commit comments

Comments
 (0)