• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

akvo / nmis-mobile / 5675387899

27 Jul 2023 01:14AM UTC coverage: 77.182% (-0.06%) from 77.239%
5675387899

Pull #73

github

web-flow
Merge d728dec7e into 42aac4c2e
Pull Request #73: Feature/72 saving draft form and clear response

539 of 736 branches covered (73.23%)

Branch coverage included in aggregate %.

109 of 109 new or added lines in 5 files covered. (100.0%)

1115 of 1407 relevant lines covered (79.25%)

11.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.44
/app/src/form/support/SaveDropdownMenu.js
1
import React from 'react';
2
import { Button } from '@rneui/themed';
3
import { Menu, MenuItem, MenuDivider } from 'react-native-material-menu';
4
import { config } from '../../pages/Settings/config';
5
import DialogForm from '../../pages/Settings/DialogForm';
6
import { UIState } from '../../store';
7

8
const userInterfaceConfigId = 2;
16✔
9

10
const SaveDropdownMenu = ({ anchor, visible, setVisible, handleOnSaveAndExit, handleOnExit }) => {
16✔
11
  const [showLanguageSelectionDialog, setShowLanguageSelectionDialog] = React.useState(false);
24✔
12

13
  const languageSelectionDialogConfig = React.useMemo(() => {
24✔
14
    const findFieldsConfig = config.find((x) => x.id === userInterfaceConfigId)?.fields || [];
28!
15
    return findFieldsConfig.find((x) => x.name === 'lang') || {};
14!
16
  }, []);
17

18
  const handleOnOk = (value) => {
24✔
19
    UIState.update((s) => {
1✔
20
      s.lang = value;
×
21
    });
22
    setShowLanguageSelectionDialog(false);
1✔
23
  };
24

25
  return (
24✔
26
    <>
27
      <Menu
28
        animationDuration={0}
29
        visible={visible}
30
        anchor={
31
          anchor || (
37✔
32
            <Button
33
              testID="anchor-dropdown-menu"
34
              onPress={() => {
35
                if (setVisible) {
1!
36
                  setVisible(true);
1✔
37
                }
38
              }}
39
            >
40
              Show Menu
41
            </Button>
42
          )
43
        }
44
        onRequestClose={() => {
45
          if (setVisible) {
×
46
            return setVisible(false);
×
47
          }
48
        }}
49
        testID="save-dropdown-menu"
50
      >
51
        <MenuItem
52
          onPress={() => {
53
            if (handleOnSaveAndExit) {
1!
54
              return handleOnSaveAndExit();
1✔
55
            }
56
          }}
57
          testID="save-and-exit-menu-item"
58
        >
59
          Save and Exit
60
        </MenuItem>
61
        <MenuItem
62
          onPress={() => {
63
            if (handleOnExit) {
1!
64
              return handleOnExit();
1✔
65
            }
66
          }}
67
          testID="exit-without-saving-menu-item"
68
        >
69
          Exit without Saving
70
        </MenuItem>
71
        <MenuDivider />
72
        <MenuItem
73
          testID="language-selection-menu-item"
74
          onPress={() => {
75
            setShowLanguageSelectionDialog(true);
2✔
76
            setVisible(false);
2✔
77
          }}
78
        >
79
          Language Selection
80
        </MenuItem>
81
      </Menu>
82
      <DialogForm
83
        onOk={handleOnOk}
84
        onCancel={() => setShowLanguageSelectionDialog(false)}
×
85
        showDialog={showLanguageSelectionDialog}
86
        edit={languageSelectionDialogConfig}
87
      />
88
    </>
89
  );
90
};
91

92
export default SaveDropdownMenu;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc