orc-shared 5.9.1-dev.0 → 5.10.0-dev.2

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.
@@ -87,16 +87,6 @@ export const useStyles = makeStyles(theme => ({
87
87
  backgroundColor: `${theme.palette.grey.borders} !important`,
88
88
  },
89
89
  },
90
- container: {
91
- display: "flex",
92
- flexDirection: "column",
93
- },
94
- errorText: {
95
- marginTop: theme.spacing(0.5),
96
- color: theme.palette.error.main,
97
- fontSize: theme.typography.fieldLabelSize,
98
- float: "left",
99
- },
100
90
  }));
101
91
 
102
92
  const Switch = ({ switchProps }) => {
@@ -110,7 +100,6 @@ const Switch = ({ switchProps }) => {
110
100
  const value = switchProps?.get(SwitchProps.propNames.value) || false;
111
101
  const onCaption = switchProps?.get(SwitchProps.propNames.onCaption);
112
102
  const offCaption = switchProps?.get(SwitchProps.propNames.offCaption);
113
- const error = switchProps?.get(SwitchProps.propNames.error);
114
103
  const disabled = switchProps?.get(SwitchProps.propNames.disabled) || false;
115
104
  const readOnly = switchProps?.get(SwitchProps.propNames.readOnly);
116
105
  const className = switchProps?.get(SwitchProps.propNames.className) || "";
@@ -131,7 +120,7 @@ const Switch = ({ switchProps }) => {
131
120
  ...className,
132
121
  };
133
122
 
134
- const switchComponent = (
123
+ return (
135
124
  <SwitchMui
136
125
  disabled={disabled}
137
126
  classes={switchClasses}
@@ -140,16 +129,6 @@ const Switch = ({ switchProps }) => {
140
129
  color={"primary"}
141
130
  />
142
131
  );
143
-
144
- return (
145
- (error && (
146
- <div className={classes.container}>
147
- {switchComponent}
148
- <div className={classNames(classes.errorText)}>{error}</div>
149
- </div>
150
- )) ||
151
- switchComponent
152
- );
153
132
  };
154
133
 
155
134
  export default Switch;
@@ -60,29 +60,6 @@ describe("Switch Component", () => {
60
60
  expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
61
61
  });
62
62
 
63
- it("Renders Switch component with an error", () => {
64
- const switchProps = new SwitchProps();
65
-
66
- switchProps.set(SwitchProps.propNames.update, update);
67
- switchProps.set(SwitchProps.propNames.value, true);
68
- switchProps.set(SwitchProps.propNames.error, "an error");
69
- switchProps.set(SwitchProps.propNames.onCaption, { id: "captionOn" });
70
- switchProps.set(SwitchProps.propNames.offCaption, { id: "captionOff" });
71
-
72
- const component = (
73
- <IntlProvider messages={messages} locale="en-US">
74
- <Switch switchProps={switchProps} />
75
- </IntlProvider>
76
- );
77
-
78
- const mountedComponent = mount(component);
79
- const expectedSwitch = <SwitchMUI checked={true} />;
80
- const expectedError = <div>an error</div>;
81
-
82
- expect(mountedComponent.containsMatchingElement(expectedSwitch), "to be truthy");
83
- expect(mountedComponent.containsMatchingElement(expectedError), "to be truthy");
84
- });
85
-
86
63
  it("Checkbox component handles check", () => {
87
64
  const switchProps = new SwitchProps();
88
65
 
@@ -10,7 +10,6 @@ class SwitchProps extends ComponentProps {
10
10
  readOnly: "readOnly",
11
11
  className: "className",
12
12
  id: "id",
13
- error: "error",
14
13
  metadata: "metadata",
15
14
  };
16
15
 
@@ -24,7 +23,6 @@ class SwitchProps extends ComponentProps {
24
23
  this.componentProps.set(this.constructor.propNames.readOnly, null);
25
24
  this.componentProps.set(this.constructor.propNames.className, null);
26
25
  this.componentProps.set(this.constructor.propNames.id, null);
27
- this.componentProps.set(this.constructor.propNames.error, null);
28
26
  this.componentProps.set(this.constructor.propNames.metadata, null);
29
27
 
30
28
  this._isSwitchProps = true;
@@ -11,7 +11,6 @@ describe("Switch Props", () => {
11
11
  "readOnly",
12
12
  "className",
13
13
  "id",
14
- "error",
15
14
  "metadata",
16
15
  ];
17
16
 
@@ -28,7 +27,6 @@ describe("Switch Props", () => {
28
27
  "readOnly",
29
28
  "className",
30
29
  "id",
31
- "error",
32
30
  "metadata",
33
31
  ];
34
32
 
@@ -1,7 +1,7 @@
1
1
  import { useSelector } from "react-redux";
2
2
  import { validationRules } from "../utils/modelValidationHelper";
3
3
  import { getModifiedModels } from "../selectors/view";
4
- import { setEditModelField, setEditModelFieldError, removeEditModelFieldError } from "../actions/view";
4
+ import { setEditModelField, setEditModelFieldError } from "../actions/view";
5
5
  import { useDispatchWithModulesData } from "./../hooks/useDispatchWithModulesData";
6
6
 
7
7
  /* This hook is used when a component has a dynamic number of fields that can be edited (e.g.: Orders' Custom Configuration Parameters).
@@ -25,7 +25,7 @@ const useMultipleFieldEditState = (entityId, sectionName, initialValues, extende
25
25
  const mergedValidationRules = { ...validationRules, ...extendedValidationRules };
26
26
  const modifiedStates = useSelector(getModifiedModels(entityId))[sectionName] || {};
27
27
 
28
- const useDynamicFieldState = (id, fieldName, errorTypes = [], fieldDependencies = {}) => {
28
+ const useDynamicFieldState = (id, fieldName, errorTypes = []) => {
29
29
  const keys = [id, fieldName];
30
30
 
31
31
  const initialValue = initialValues[id]?.[fieldName] ?? "";
@@ -42,15 +42,12 @@ const useMultipleFieldEditState = (entityId, sectionName, initialValues, extende
42
42
  dispatch(setEditModelField, [keys, initialValue, initialValue, entityId, sectionName]);
43
43
  };
44
44
 
45
- const isEditStateValid = (value, dependencies = {}) => {
45
+ const isEditStateValid = value => {
46
46
  const valueToValidate = value ?? editState.value;
47
47
 
48
48
  let hasAnyValidationErrors = false;
49
49
  errorTypes.forEach(errorType => {
50
- const isValid = mergedValidationRules[errorType](valueToValidate, id, fieldName, {
51
- ...fieldDependencies,
52
- ...dependencies,
53
- });
50
+ const isValid = mergedValidationRules[errorType](valueToValidate, id, fieldName);
54
51
 
55
52
  if (isValid === false) {
56
53
  dispatch(setEditModelFieldError, [keys, errorType, entityId, sectionName]);
@@ -60,10 +57,6 @@ const useMultipleFieldEditState = (entityId, sectionName, initialValues, extende
60
57
  }
61
58
  });
62
59
 
63
- if (!hasAnyValidationErrors) {
64
- dispatch(removeEditModelFieldError, [keys, entityId, sectionName]);
65
- }
66
-
67
60
  return !hasAnyValidationErrors;
68
61
  };
69
62
 
@@ -5,7 +5,7 @@ import Immutable from "immutable";
5
5
  import sinon from "sinon";
6
6
  import { mount } from "enzyme";
7
7
  import * as useDispatchWithModulesDataMock from "./useDispatchWithModulesData";
8
- import { removeEditModelFieldError, setEditModelField, setEditModelFieldError } from "./../actions/view";
8
+ import { setEditModelField, setEditModelFieldError } from "./../actions/view";
9
9
  import { validationErrorTypes } from "./../constants";
10
10
  import _ from "lodash";
11
11
 
@@ -404,54 +404,6 @@ describe("useMultipleFieldEditState", () => {
404
404
  }
405
405
  });
406
406
 
407
- it("Updates edit view value and reset error correctly with custom validation rules when validation was passed", () => {
408
- const useDispatchWithModulesDataSpy = sinon.spy();
409
- const useDispatchWithModulesDataStub = sinon
410
- .stub(useDispatchWithModulesDataMock, "useDispatchWithModulesData")
411
- .returns(useDispatchWithModulesDataSpy);
412
-
413
- try {
414
- // TODOJOC
415
- const mountedComponent = mountComponent();
416
-
417
- const fieldComponent = mountedComponent.find(`#id1-prop1-update`);
418
-
419
- const event = {
420
- target: {
421
- value: "anotherValue",
422
- },
423
- };
424
-
425
- fieldComponent.invoke("onClick")(event);
426
-
427
- const resetEvent = {
428
- target: {
429
- value: "custom",
430
- },
431
- };
432
-
433
- fieldComponent.invoke("onClick")(resetEvent);
434
-
435
- const id = "id1";
436
- const fieldName = "prop1";
437
- const initialFieldValue = fieldInitialValues[id][fieldName];
438
-
439
- expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
440
- args: [setEditModelField, [[id, fieldName], "anotherValue", initialFieldValue, entityId, sectionName]],
441
- });
442
-
443
- expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
444
- args: [setEditModelFieldError, [[id, fieldName], "customRule", entityId, sectionName]],
445
- });
446
-
447
- expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
448
- args: [removeEditModelFieldError, [[id, fieldName], entityId, sectionName]],
449
- });
450
- } finally {
451
- useDispatchWithModulesDataStub.restore();
452
- }
453
- });
454
-
455
407
  it.each([
456
408
  ["id1", "prop1"],
457
409
  ["id1", "prop2"],
package/src/requests ADDED
@@ -0,0 +1,34 @@
1
+ createCustomerLookupTypeDefinitionRequest
2
+ createEntityTypeRequest
3
+ createOrderLookupTypeDefinitionRequest
4
+ deleteTaskInfoRequest
5
+ getApplicationModules
6
+ getAuthorizedApplicationsRequest
7
+ getCountriesRequest
8
+ getCustomerDefinitionsRequest
9
+ getCustomerLookupRequest
10
+ getCustomerLookupsRequest
11
+ getOrderDefinitionRequest
12
+ getOrderLookupRequest
13
+ getOrderLookupsRequest
14
+ getProductDefinitionsRequest
15
+ getProductLookupsRequest
16
+ getProfileAttributeGroupsRequest
17
+ getRequesterTasksInfoRequest
18
+ getScopeExtendedConfigurationRequest
19
+ getSupportedCulturesRequest
20
+ getTaskExecutionLogsRequest
21
+ getTaskInfoRequest
22
+ getTimeZonesRequest
23
+ getUserApplicationRequest
24
+ getUserCultureRequest
25
+ getUserPermissionsRequest
26
+ getUserScopeRequest
27
+ getUserScopeTreeRequest
28
+ getVersionInfoRequest
29
+ saveUserApplicationRequest
30
+ saveUserCultureRequest
31
+ signOutRequest
32
+ updateCustomerLookupTypeDefinitionRequest
33
+ updateEntityTypeRequest
34
+ updateOrderLookupTypeDefinitionRequest
@@ -53,6 +53,23 @@ export const namedLookupValuesSelector = memoize((moduleName, lookupName) =>
53
53
  ),
54
54
  );
55
55
 
56
+ export const namedLookupsValuesSelector = memoize((moduleName, lookupNames) =>
57
+ createSelector(lookupSelector(moduleName), currentLocaleOrDefault, (lookups, locale) => {
58
+ const lookupsValues = {};
59
+
60
+ each(lookupNames, name => {
61
+ const lookup = lookups.get(name);
62
+ if (!lookup) return;
63
+
64
+ lookupsValues[name] = lookup
65
+ .get("values", Immutable.Map())
66
+ .map(lookupValue => setTranslationWithFallbackField(locale, lookupValue, "name", "displayName"));
67
+ });
68
+
69
+ return Immutable.fromJS(lookupsValues);
70
+ }),
71
+ );
72
+
56
73
  export const selectCurrentLookupDetails = memoize((moduleName, lookupName) =>
57
74
  namedLookupSelector(moduleName, lookupName),
58
75
  );
@@ -340,7 +357,7 @@ export const variantPropertyKeyValuesSelector = memoize(({ definitionName }, pro
340
357
  ? {
341
358
  ...acc,
342
359
  [rec]: resolveProductPropertyValue(propertyMap[camelCase(rec)], propertyBag[rec], locale, lookups),
343
- }
360
+ }
344
361
  : acc,
345
362
  {},
346
363
  );
@@ -31,6 +31,7 @@ import {
31
31
  lookupByNameSelector,
32
32
  mappedLookupsListSelector,
33
33
  lookupExistAndIsActiveSelector,
34
+ namedLookupsValuesSelector,
34
35
  } from "./metadata";
35
36
 
36
37
  const lookups = {
@@ -409,6 +410,109 @@ describe("namedLookupValuesSelector", () => {
409
410
  });
410
411
  });
411
412
 
413
+ describe("namedLookupsValuesSelector", () => {
414
+ let state;
415
+ beforeEach(() => {
416
+ state = Immutable.fromJS({
417
+ locale: { locale: "it-IT" },
418
+ metadata: {
419
+ lookups: {
420
+ order: {
421
+ index: {
422
+ CanceledStatusReasons: {
423
+ lookupName: "CanceledStatusReasons",
424
+ values: {
425
+ CanceledReason1: {
426
+ id: "e16d07f847284775b77cfb985724cf58",
427
+ value: "CanceledReason1",
428
+ lookupId: "CanceledStatusReasons",
429
+ sortOrder: 0,
430
+ isActive: true,
431
+ isSystem: true,
432
+ displayName: {
433
+ "en-CA": "Cancel for reason 1",
434
+ "en-US": "Cancel for reason 1",
435
+ "fr-CA": "Annulé pour raison 1",
436
+ "it-IT": "Annulla per motivo 1",
437
+ },
438
+ },
439
+ CanceledReason2: {
440
+ id: "6bbfe77703c745d68b8eaceb9cd484b1",
441
+ value: "CanceledReason2",
442
+ lookupId: "CanceledStatusReasons",
443
+ sortOrder: 0,
444
+ isActive: true,
445
+ isSystem: true,
446
+ displayName: {
447
+ "en-CA": "Cancel for reason 2",
448
+ "en-US": "Cancel for reason 2",
449
+ "fr-CA": "Annulé pour raison 2",
450
+ "it-IT": "Annulla per motivo 2",
451
+ },
452
+ },
453
+ },
454
+ isActive: true,
455
+ isSystem: true,
456
+ },
457
+ CartStatus: {
458
+ lookupName: "CartStatus",
459
+ values: {},
460
+ isActive: true,
461
+ isSystem: true,
462
+ },
463
+ },
464
+ list: [],
465
+ },
466
+ },
467
+ },
468
+ });
469
+ });
470
+
471
+ it("gets the value list for multiple named lookups", () =>
472
+ expect(
473
+ namedLookupsValuesSelector,
474
+ "when called with",
475
+ ["order", ["CanceledStatusReasons", "CartStatus"]],
476
+ "when called with",
477
+ [state],
478
+ "to satisfy",
479
+ Immutable.fromJS({
480
+ CanceledStatusReasons: {
481
+ CanceledReason1: {
482
+ id: "e16d07f847284775b77cfb985724cf58",
483
+ value: "CanceledReason1",
484
+ lookupId: "CanceledStatusReasons",
485
+ sortOrder: 0,
486
+ isActive: true,
487
+ isSystem: true,
488
+ displayName: "Annulla per motivo 1",
489
+ },
490
+ CanceledReason2: {
491
+ id: "6bbfe77703c745d68b8eaceb9cd484b1",
492
+ value: "CanceledReason2",
493
+ lookupId: "CanceledStatusReasons",
494
+ sortOrder: 0,
495
+ isActive: true,
496
+ isSystem: true,
497
+ displayName: "Annulla per motivo 2",
498
+ },
499
+ },
500
+ CartStatus: {},
501
+ }),
502
+ ));
503
+
504
+ it("will get an empty Map if lookup does not exist", () =>
505
+ expect(
506
+ namedLookupsValuesSelector,
507
+ "when called with",
508
+ ["order", ["NotALookup"]],
509
+ "when called with",
510
+ [state],
511
+ "to equal",
512
+ Immutable.fromJS({}),
513
+ ));
514
+ });
515
+
412
516
  describe("selectCurrentLookupDetails", () => {
413
517
  let state;
414
518
  beforeEach(() => {