@integry/sdk 4.6.65 → 4.6.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integry/sdk",
3
- "version": "4.6.65",
3
+ "version": "4.6.67",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -1812,7 +1812,22 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1812
1812
  ><//>
1813
1813
  </div>
1814
1814
  `;
1815
- case 'DYNAMIC':
1815
+ case 'DYNAMIC': {
1816
+ let fieldVal = null;
1817
+ if (this.props.onFieldChangeCallback) {
1818
+ if (
1819
+ Object.prototype.hasOwnProperty.call(
1820
+ this.state.dynamicFieldsData || {},
1821
+ el.activity_field?.machine_name || '',
1822
+ )
1823
+ ) {
1824
+ fieldVal = this.state.dynamicFieldsData[
1825
+ el.activity_field?.machine_name || ''
1826
+ ];
1827
+ } else {
1828
+ fieldVal = el.default_value;
1829
+ }
1830
+ }
1816
1831
  return html`
1817
1832
  <div
1818
1833
  key=${el.id}
@@ -1824,6 +1839,7 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1824
1839
  <${DynamicField}
1825
1840
  stepId=${selectedStep.id}
1826
1841
  dynamicField=${el}
1842
+ objectValue=${fieldVal}
1827
1843
  endpointData=${JSON.stringify({
1828
1844
  authorization_id:
1829
1845
  (this.props.stepMapping &&
@@ -1867,9 +1883,28 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1867
1883
  .refreshRootStepData}
1868
1884
  parentFieldChanged=${this.state
1869
1885
  .parentFieldChanged}
1886
+ onChangeCallback=${this.props
1887
+ .onFieldChangeCallback
1888
+ ? (val: any) => {
1889
+ if (
1890
+ this.props.onFieldChangeCallback
1891
+ ) {
1892
+ this.onFieldChange({
1893
+ stepId: step.id,
1894
+ fieldId: el.id,
1895
+ value: val,
1896
+ isRequired: el.is_required,
1897
+ machineName:
1898
+ el.activity_field
1899
+ ?.machine_name,
1900
+ });
1901
+ }
1902
+ }
1903
+ : null}
1870
1904
  />
1871
1905
  </div>
1872
1906
  `;
1907
+ }
1873
1908
  case 'SECTION':
1874
1909
  return html`
1875
1910
  <div
@@ -27,6 +27,8 @@ export type DynamicFieldsProps = {
27
27
  placeHolder?: string;
28
28
  refreshRootStepData?: (callback?: any) => void;
29
29
  parentFieldChanged?: boolean;
30
+ onChangeCallback?: (val: any) => void;
31
+ objectValue?: any;
30
32
  } & StoreType;
31
33
 
32
34
  interface DynamicDataItem {
@@ -52,9 +54,12 @@ const DynamicFields = (props: DynamicFieldsProps) => {
52
54
  placeHolder = '',
53
55
  refreshRootStepData,
54
56
  parentFieldChanged = false,
57
+ onChangeCallback = () => null,
58
+ objectValue = {},
55
59
  } = props;
56
60
  const [dynamicItems, setDynamicItems] = useState<DynamicDataItem[]>([]);
57
61
  const [loading, setLoading] = useState<boolean>(true);
62
+ const [customFieldsData, setCustomFieldsData] = useState<any>(objectValue);
58
63
  const [
59
64
  isErrorOnLoadingCustomFields,
60
65
  setIsErrorOnLoadingCustomFields,
@@ -149,12 +154,22 @@ const DynamicFields = (props: DynamicFieldsProps) => {
149
154
  });
150
155
  });
151
156
 
152
- props.setStepMappingData({
153
- stepId,
154
- fieldId: dynamicField.id,
155
- id: machineName,
156
- value: valSubstituded,
157
- });
157
+ if (onChangeCallback && objectValue !== null) {
158
+ const data = {
159
+ ...customFieldsData,
160
+ [machineName]: val,
161
+ };
162
+ setCustomFieldsData(data);
163
+
164
+ onChangeCallback(data);
165
+ } else {
166
+ props.setStepMappingData({
167
+ stepId,
168
+ fieldId: dynamicField.id,
169
+ id: machineName,
170
+ value: valSubstituded,
171
+ });
172
+ }
158
173
  };
159
174
 
160
175
  return html`
@@ -171,10 +186,9 @@ const DynamicFields = (props: DynamicFieldsProps) => {
171
186
  ? props.stepDataMapping[stepId][dynamicField.id]
172
187
  : ({} as { objectValue: Record<string, string | number> });
173
188
  let fieldVal = '';
174
- const parsedVal = ele.objectValue as Record<
175
- string,
176
- string | number
177
- >;
189
+ const parsedVal =
190
+ objectValue ||
191
+ (ele.objectValue as Record<string, string | number>);
178
192
  if (parsedVal && parsedVal[el.id]) {
179
193
  fieldVal = `${parsedVal[el.id]}`;
180
194
  }