orc-shared 5.9.0-dev.14 → 5.9.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +8 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/package.json +1 -1
- package/src/components/MaterialUI/Navigation/DropDownMenu.js +8 -0
- package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +24 -0
- package/src/utils/propertyBagHelper.js +2 -0
|
@@ -78,6 +78,13 @@ var DropDownMenu = function DropDownMenu(_ref) {
|
|
|
78
78
|
event.stopPropagation();
|
|
79
79
|
setAnchorEl(null);
|
|
80
80
|
};
|
|
81
|
+
|
|
82
|
+
// Even though we do nothing, we need to avoid mouse event propagation when the mouse
|
|
83
|
+
// button is released after hovering out the menu
|
|
84
|
+
var onMainMenuClick = function onMainMenuClick(event) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
};
|
|
81
88
|
var onMenuItemClick = function onMenuItemClick(action, itemContext) {
|
|
82
89
|
return function (event) {
|
|
83
90
|
onClose(event);
|
|
@@ -110,6 +117,7 @@ var DropDownMenu = function DropDownMenu(_ref) {
|
|
|
110
117
|
},
|
|
111
118
|
id: "scope-menu",
|
|
112
119
|
open: isOpened,
|
|
120
|
+
onClick: onMainMenuClick,
|
|
113
121
|
onClose: onClose,
|
|
114
122
|
autoFocus: autoFocus,
|
|
115
123
|
anchorEl: anchorEl
|
|
@@ -30,7 +30,8 @@ var customDataType = exports.customDataType = {
|
|
|
30
30
|
carrierProviderSelector: "CarrierProviderSelector",
|
|
31
31
|
routingProviderSelector: "RoutingProviderSelector",
|
|
32
32
|
multipleCarrierProvidersSelector: "MultipleCarrierProvidersSelector",
|
|
33
|
-
serviceLevelSelector: "ServiceLevelSelector"
|
|
33
|
+
serviceLevelSelector: "ServiceLevelSelector",
|
|
34
|
+
percentageDecimal: "PercentageDecimal"
|
|
34
35
|
};
|
|
35
36
|
var tieredAttributeTypes = [customDataType.priceTieredRateTable, customDataType.quantityTieredRateTable];
|
|
36
37
|
var isTieredAttribute = exports.isTieredAttribute = function isTieredAttribute(attribute) {
|
|
@@ -78,6 +79,7 @@ var toJsonCargo = exports.toJsonCargo = function toJsonCargo(attribute, value) {
|
|
|
78
79
|
case customDataType.money:
|
|
79
80
|
return createJsonCargo(_constants.jsonCargoType.double, Number(formatNumber(value, 2)));
|
|
80
81
|
case customDataType.moneyDecimal:
|
|
82
|
+
case customDataType.percentageDecimal:
|
|
81
83
|
return createJsonCargo(_constants.jsonCargoType.decimal, Number(formatNumber(value, 2)));
|
|
82
84
|
case customDataType.priceTieredRateTable:
|
|
83
85
|
case customDataType.quantityTieredRateTable:
|
package/package.json
CHANGED
|
@@ -47,6 +47,13 @@ const DropDownMenu = ({ payload, menuItems, children, dropDownMenuProps = new Dr
|
|
|
47
47
|
setAnchorEl(null);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
// Even though we do nothing, we need to avoid mouse event propagation when the mouse
|
|
51
|
+
// button is released after hovering out the menu
|
|
52
|
+
const onMainMenuClick = event => {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
event.stopPropagation();
|
|
55
|
+
};
|
|
56
|
+
|
|
50
57
|
const onMenuItemClick = (action, itemContext) => event => {
|
|
51
58
|
onClose(event);
|
|
52
59
|
action(payload, itemContext);
|
|
@@ -76,6 +83,7 @@ const DropDownMenu = ({ payload, menuItems, children, dropDownMenuProps = new Dr
|
|
|
76
83
|
classes={{ paper: classes.menu }}
|
|
77
84
|
id="scope-menu"
|
|
78
85
|
open={isOpened}
|
|
86
|
+
onClick={onMainMenuClick}
|
|
79
87
|
onClose={onClose}
|
|
80
88
|
autoFocus={autoFocus}
|
|
81
89
|
anchorEl={anchorEl}
|
|
@@ -8,6 +8,7 @@ import Icon from "../DataDisplay/Icon";
|
|
|
8
8
|
import DropDownMenu from "./DropDownMenu";
|
|
9
9
|
import { ignoreConsoleError } from "../../../utils/testUtils";
|
|
10
10
|
import { TestWrapper, createMuiTheme } from "./../../../utils/testUtils";
|
|
11
|
+
import Menu from "@material-ui/core/Menu";
|
|
11
12
|
|
|
12
13
|
describe("DropDownMenu", () => {
|
|
13
14
|
let store, menuItems, container;
|
|
@@ -92,4 +93,27 @@ describe("DropDownMenu", () => {
|
|
|
92
93
|
expect(menuItems[0].action, "to have calls satisfying", [{ args: [payload, "aContext"] }]);
|
|
93
94
|
expect(menuItems[1].action, "to have calls satisfying", [{ args: [payload, "myContext"] }]);
|
|
94
95
|
});
|
|
96
|
+
|
|
97
|
+
it("should handle onClick event on the menu", () => {
|
|
98
|
+
const payload = "payload";
|
|
99
|
+
|
|
100
|
+
const component = (
|
|
101
|
+
<Provider store={store}>
|
|
102
|
+
<DropDownMenu payload={payload} menuItems={menuItems} />
|
|
103
|
+
</Provider>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const mountedComponent = mount(component);
|
|
107
|
+
|
|
108
|
+
const event = {
|
|
109
|
+
preventDefault: sinon.spy().named("preventDefault"),
|
|
110
|
+
stopPropagation: sinon.spy().named("stopPropagation"),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const dropDownMenu = mountedComponent.find(Menu).at(0);
|
|
114
|
+
dropDownMenu.invoke("onClick")(event);
|
|
115
|
+
|
|
116
|
+
expect(event.preventDefault, "was called");
|
|
117
|
+
expect(event.stopPropagation, "was called");
|
|
118
|
+
});
|
|
95
119
|
});
|
|
@@ -19,6 +19,7 @@ export const customDataType = {
|
|
|
19
19
|
routingProviderSelector: "RoutingProviderSelector",
|
|
20
20
|
multipleCarrierProvidersSelector: "MultipleCarrierProvidersSelector",
|
|
21
21
|
serviceLevelSelector: "ServiceLevelSelector",
|
|
22
|
+
percentageDecimal: "PercentageDecimal",
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
const tieredAttributeTypes = [customDataType.priceTieredRateTable, customDataType.quantityTieredRateTable];
|
|
@@ -73,6 +74,7 @@ export const toJsonCargo = (attribute, value) => {
|
|
|
73
74
|
case customDataType.money:
|
|
74
75
|
return createJsonCargo(jsonCargoType.double, Number(formatNumber(value, 2)));
|
|
75
76
|
case customDataType.moneyDecimal:
|
|
77
|
+
case customDataType.percentageDecimal:
|
|
76
78
|
return createJsonCargo(jsonCargoType.decimal, Number(formatNumber(value, 2)));
|
|
77
79
|
case customDataType.priceTieredRateTable:
|
|
78
80
|
case customDataType.quantityTieredRateTable:
|