@superleapai/flow-ui 2.6.1 → 2.6.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.
package/core/crm.js CHANGED
@@ -248,18 +248,17 @@
248
248
  }
249
249
 
250
250
  /**
251
- * Register a callback for when the CRM form is submitted successfully.
252
- * The CRM sends a 'crm:formSubmitSuccess' message after the form saves.
251
+ * Notify the CRM that the form was submitted successfully.
252
+ * The CRM listens for 'crm:formSubmitSuccess' and can react
253
+ * (e.g. close the form, refresh data, show a toast).
253
254
  *
254
- * @param {Function} callbackreceives (payload)
255
- * @returns {Function} unsubscribe function
255
+ * @param {Object} [payload]optional data about the submission
256
256
  */
257
- function onFormSubmitSuccess(callback) {
257
+ function formSubmittedSuccessfully(payload) {
258
258
  var bridge = getBridge();
259
- if (!bridge) {
260
- return function () {};
259
+ if (bridge && bridge.isConnected()) {
260
+ bridge.send("crm:formSubmitSuccess", payload || {});
261
261
  }
262
- return bridge.onMessage("crm:onFormSubmitSuccess", callback);
263
262
  }
264
263
 
265
264
  // ---------------------------------------------------------------------------
@@ -336,7 +335,8 @@
336
335
  global.superleapClient.disconnect = disconnect;
337
336
  global.superleapClient.setLoading = setLoading;
338
337
  global.superleapClient.closeForm = closeForm;
339
- global.superleapClient.onFormSubmitSuccess = onFormSubmitSuccess;
338
+ global.superleapClient.formSubmittedSuccessfully =
339
+ formSubmittedSuccessfully;
340
340
  global.superleapClient.toast = toast;
341
341
  global.superleapClient.navigate = navigate;
342
342
  global.superleapClient.getContext = getContext;