@k-int/stripes-kint-components 3.0.1 → 3.0.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 3.0.3 2022-10-04
2
+ * Fixed issue where custom property ctx is not removable
3
+
4
+ ## 3.0.2 2022-09-29
5
+ * Fixed inconsistency between CustomPropertiesEditCtx and CustomPropertiesViewCtx labelOverrides
6
+
1
7
  ## 3.0.1 2022-09-22
2
8
  * Removed unnecessary validate prop on CustomPropertyField, fixed broken out of range validator
3
9
 
@@ -197,10 +197,10 @@ var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
197
197
  deleteCustProp = _useMutateCustomPrope.delete;
198
198
 
199
199
  var handeContextSubmit = function handeContextSubmit(submitData) {
200
- var _submitData$ctx, _submitData$ctx$;
200
+ var _submitData$ctx$0$val, _submitData$ctx, _submitData$ctx$;
201
201
 
202
202
  return _objectSpread(_objectSpread({}, submitData), {}, {
203
- ctx: submitData === null || submitData === void 0 ? void 0 : (_submitData$ctx = submitData.ctx) === null || _submitData$ctx === void 0 ? void 0 : (_submitData$ctx$ = _submitData$ctx[0]) === null || _submitData$ctx$ === void 0 ? void 0 : _submitData$ctx$.value
203
+ ctx: (_submitData$ctx$0$val = submitData === null || submitData === void 0 ? void 0 : (_submitData$ctx = submitData.ctx) === null || _submitData$ctx === void 0 ? void 0 : (_submitData$ctx$ = _submitData$ctx[0]) === null || _submitData$ctx$ === void 0 ? void 0 : _submitData$ctx$.value) !== null && _submitData$ctx$0$val !== void 0 ? _submitData$ctx$0$val : ''
204
204
  });
205
205
  }; // When POSTing a custom property, the backend expects a shorthand "Integer" or "LocalDate"
206
206
  // When PUTing a custom property, the backend needs the full class name
@@ -50,17 +50,19 @@ var CustomPropertiesViewCtx = function CustomPropertiesViewCtx(_ref) {
50
50
  id: 'customProperties',
51
51
  overrideValue: labelOverrides.noContext
52
52
  });
53
- } // Label overrides for specific contexts
54
-
55
-
56
- if (labelOverrides[ctx]) {
57
- return labelOverrides[ctx];
58
- } // Label override for default title or finally built in default
53
+ } // Chain formatKintMessages together using provided fallbackMessage to
54
+ // allow for "If override or translation exists, use it, else use default"
59
55
 
60
56
 
61
57
  return kintIntl.formatKintMessage({
62
- id: 'customProperties.defaultTitle',
63
- overrideValue: labelOverrides.defaultTitle
58
+ id: "customProperties.ctx.".concat(ctx),
59
+ overrideValue: labelOverrides[ctx],
60
+ fallbackMessage: kintIntl.formatKintMessage({
61
+ id: 'customProperties.defaultTitle',
62
+ overrideValue: labelOverrides.defaultTitle
63
+ }, {
64
+ ctx: ctx
65
+ })
64
66
  }, {
65
67
  ctx: ctx
66
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -126,7 +126,7 @@ const CustomPropertiesSettings = ({
126
126
  const handeContextSubmit = (submitData) => {
127
127
  return {
128
128
  ...submitData,
129
- ctx: submitData?.ctx?.[0]?.value
129
+ ctx: submitData?.ctx?.[0]?.value ?? ''
130
130
  };
131
131
  };
132
132
 
@@ -28,16 +28,16 @@ const CustomPropertiesViewCtx = ({
28
28
  );
29
29
  }
30
30
 
31
- // Label overrides for specific contexts
32
- if (labelOverrides[ctx]) {
33
- return labelOverrides[ctx];
34
- }
35
-
36
- // Label override for default title or finally built in default
31
+ // Chain formatKintMessages together using provided fallbackMessage to
32
+ // allow for "If override or translation exists, use it, else use default"
37
33
  return (
38
34
  kintIntl.formatKintMessage({
39
- id: 'customProperties.defaultTitle',
40
- overrideValue: labelOverrides.defaultTitle
35
+ id: `customProperties.ctx.${ctx}`,
36
+ overrideValue: labelOverrides[ctx],
37
+ fallbackMessage: kintIntl.formatKintMessage({
38
+ id: 'customProperties.defaultTitle',
39
+ overrideValue: labelOverrides.defaultTitle
40
+ }, { ctx })
41
41
  }, { ctx })
42
42
  );
43
43
  };