@resconet/jsbridge 14.1.0 → 15.1.0

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": "@resconet/jsbridge",
3
- "version": "14.1.0",
3
+ "version": "15.1.0",
4
4
  "main": "./src/JSBridge.js",
5
5
  "types": "./src/JSBridge.d.ts",
6
6
  "description": "Install npm JSBridge module",
package/src/JSBridge.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // JSBridge.js TypeScript definition file
2
- // v13.1
3
- // (c) 2020 Resco
2
+ // v15.1
3
+ // (c) 2022 Resco
4
4
 
5
5
  declare module MobileCRM {
6
6
 
@@ -603,6 +603,17 @@ declare module MobileCRM {
603
603
  */
604
604
  public static email(address: string, subject: string, body: string, errorCallback?: () => void, scope?: any);
605
605
  /**
606
+ * @since 15.0
607
+ * Opens the platform-specific e-mail message form with pre-filled data.
608
+ * @param address Recipients email address.
609
+ * @param subject An e-mail subject.
610
+ * @param body A string with email body.
611
+ * @param mimeType Body content MIME type.
612
+ * @param errorCallback The errorCallback which is called asynchronously in case of error.
613
+ * @param scope The scope for errorCallback.
614
+ */
615
+ public static sendEmail(address: string, subject: string, body: string, mimeType: string, errorCallback?: () => void, scope?: any);
616
+ /**
606
617
  * @since 9.1
607
618
  * Sends a list of files (full paths or IReferences to blobs) as email attachments.
608
619
  * This method either open the CRM Email form or the native mail client (depending on application settings).
@@ -1094,8 +1105,10 @@ declare module MobileCRM.Services {
1094
1105
  nextInfo: FileInfo;
1095
1106
  }
1096
1107
  class DocumentService {
1097
- /**Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size.*/
1098
- maxImageSize: number;
1108
+ /**Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size. [640x480,1024x768,1600x1200,2048x1536,2592x1936].*/
1109
+ maxImageSize: string;
1110
+ /**Gets or sets the maximum uploaded image size. If uploaded image size is greater then image is resized to specified maximum size [640x480,1024x768,1600x1200,2048x1536,2592x1936].*/
1111
+ maxUploadImageSize: string;
1099
1112
  /**Gets or sets the record quality for audio/video recordings.*/
1100
1113
  recordQuality: number;
1101
1114
  /**Indicates whether the video files should be included into the image picker when selecting the photos. The default is true.*/
@@ -1110,7 +1123,8 @@ declare module MobileCRM.Services {
1110
1123
  selectMultiplePhotos(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1111
1124
  loadFrom(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1112
1125
  loadFromMultiple(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1113
- selectFile(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1126
+ selectFile(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1127
+ selectMultipleFiles(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1114
1128
  recordAudio(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1115
1129
  recordVideo(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1116
1130
  pasteFile(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
@@ -1464,6 +1478,13 @@ declare module MobileCRM.UI {
1464
1478
  */
1465
1479
  getController(name: string): _Controller;
1466
1480
  /**
1481
+ * Returns the entity list by its view name.
1482
+ * This method looks for plain associated views but also for controllers that can be flipped into a list (in addition to map or chart).
1483
+ * @param name A name of associated view.
1484
+ * @returns IEntityList
1485
+ */
1486
+ getEntityList(name: string): IEntityList;
1487
+ /**
1467
1488
  * Sets the address fields according to the current geo-location from platform-specific location service.
1468
1489
  * @param latitude The latitude from geo-location from platform-specific location service
1469
1490
  * @param longitude longitude from geo-location from platform-specific location service
@@ -1553,6 +1574,14 @@ declare module MobileCRM.UI {
1553
1574
  */
1554
1575
  public static onChange(handler: (entityForm: EntityForm) => void, bind: boolean, scope?: any);
1555
1576
  /**
1577
+ * @since 15.1
1578
+ * Binds or unbinds the handler for onProcessLoaded event on EntityForm.
1579
+ * @param handler The handler function that has to be bound or unbound.
1580
+ * @param bind Determines whether to bind or unbind the handler.
1581
+ * @param scope The scope for callbacks.
1582
+ */
1583
+ public static onProcessLoaded(handler: (entityForm: EntityForm) => void, bind: boolean, scope?: any);
1584
+ /**
1556
1585
  * @since 11.2
1557
1586
  * Binds or unbinds the handler for specific item change event on EntityForm.
1558
1587
  * @param itemName The name of desired detail item (mostly logical name of the field).
@@ -2124,6 +2153,14 @@ declare module MobileCRM.UI {
2124
2153
  * Closes the form ignoring all changes that have been made on it.
2125
2154
  */
2126
2155
  public static closeWithoutSaving();
2156
+ /**
2157
+ * Binds or unbinds the handler for QuestionnaireForm command.
2158
+ * @param command The name of the QuestionnaireForm command.
2159
+ * @param handler The handler function that has to be bound or unbound.
2160
+ * @param bind Determines whether to bind or unbind the handler.
2161
+ * @param scope The scope for callbacks.
2162
+ */
2163
+ public static onCommand(command: string, handler: (entityForm: QuestionnaireForm) => void, bind: boolean, scope?: any);
2127
2164
  }
2128
2165
 
2129
2166
  namespace QuestionnaireForm {
@@ -2300,6 +2337,20 @@ declare module MobileCRM.UI {
2300
2337
  * @param scope The scope for callback.
2301
2338
  */
2302
2339
  changeProccess(callback: (processReference: MobileCRM.Reference) => void, errorCallback?: (err: string) => void, scope?: any);
2340
+ /**
2341
+ * @since 15.0
2342
+ * Progresses to the next stage of the active process.
2343
+ * @param errorCallback The errorCallback which is called asynchronously in case of error
2344
+ * @param scope The scope for callback.
2345
+ */
2346
+ MoveToPreviousStage(errorCallback?: (err: string) => void, scope?: any);
2347
+ /**
2348
+ * @since 15.0
2349
+ * Moves to the previous stage of the active process.
2350
+ * @param errorCallback The errorCallback which is called asynchronously in case of error
2351
+ * @param scope The scope for callback.
2352
+ */
2353
+ MoveToNextStage(errorCallback?: (err: string) => void, scope?: any);
2303
2354
  }
2304
2355
 
2305
2356
  class ViewDefinition {
@@ -2571,10 +2622,123 @@ declare module MobileCRM.UI {
2571
2622
  */
2572
2623
  suspendSave(): IFormSaveHandler;
2573
2624
  }
2574
- /** Represents the Javascript equivalent view of tourplan form object. */
2625
+ interface IRoutePlanItemSaveContext {
2626
+ errorMessage: string;
2627
+ entityToSave: DynamicEntity;
2628
+ }
2629
+ interface IRoutePlanItemPostSaveContext {
2630
+ savedEntity: DynamicEntity;
2631
+ }
2632
+ interface IRoutePlanItemContext {
2633
+ entity: DynamicEntity;
2634
+ }
2635
+ /** Represents the Javascript equivalent view of RoutePlan form object. */
2636
+ class RoutePlan {
2637
+ /** A list of route entities. */
2638
+ myRoute: DynamicEntity[];
2639
+ /** A list of completed entities that are about to be removed from route plan. */
2640
+ completedEntities: DynamicEntity[];
2641
+ /** Logical name of the route visit entity. */
2642
+ routeEntityName: string;
2643
+ /** Currently selected route day. */
2644
+ routeDay: Date;
2645
+ /** Controls whether the form is dirty and requires save, or whether it can be closed.*/
2646
+ isDirty: boolean;
2647
+ /** Event-specific context. */
2648
+ public context?: IFormSaveContext | IRoutePlanItemSaveContext | IRoutePlanItemPostSaveContext | IRoutePlanItemContext;
2649
+ /**
2650
+ * @since 11.2
2651
+ * Requests the managed RoutePlan object.
2652
+ * Method initiates an asynchronous request which either ends with calling the <b>errorCallback</b> or with calling the <b>callback</b> with Javascript version of RoutePlan object.
2653
+ * @param callback The callback function that is called asynchronously with serialized RoutePlan object as argument.
2654
+ * @param errorCallback The errorCallback which is called in case of error.
2655
+ * @param scope The scope for callbacks.
2656
+ */
2657
+ static requestObject(callback: (routePlan: RoutePlan) => boolean, errorCallback?: (err: string) => void, scope?: any);
2658
+ /**
2659
+ * Binds or unbinds the handler for route save validation.
2660
+ * The RoutePlan context object contains IFormSaveContext object.
2661
+ * Use suspendSave method to suspend the save process if an asynchronous operation is required.
2662
+ * @param handler The handler function that has to be bound or unbound.
2663
+ * @param bind Determines whether to bind or unbind the handler.
2664
+ * @param scope The scope for handler calls.
2665
+ */
2666
+ static onSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2667
+ /**
2668
+ * Binds or unbinds the handler for validating single visit entity save.
2669
+ * The RoutePlan context object contains IRoutePlanItemSaveContext object.
2670
+ * Use suspendSave method to suspend the save process if an asynchronous operation is required.
2671
+ * @param handler The handler function that has to be bound or unbound.
2672
+ * @param bind Determines whether to bind or unbind the handler.
2673
+ * @param scope The scope for handler calls.
2674
+ */
2675
+ static onItemSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2676
+ /**
2677
+ * Suspends current 'onSave' validation and allows performing another asynchronous tasks to determine the validation result.
2678
+ * A request object with single function 'resumeSave'; which has to be called with the validation result (either error message string or 'null' in case of success).
2679
+ */
2680
+ suspendSave(): IFormSaveHandler;
2681
+
2682
+ /**
2683
+ * Binds or unbinds the handler for further actions on saved route.
2684
+ * Use suspendPostSave method to suspend the save process if an asynchronous operation is required.
2685
+ * @param handler The handler function that has to be bound or unbound.
2686
+ * @param bind Determines whether to bind or unbind the handler.
2687
+ * @param scope The scope for handler calls.
2688
+ */
2689
+ static onPostSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2690
+ /**
2691
+ * Binds or unbinds the handler for further actions on saved visit entity.
2692
+ * The RoutePlan context object contains IRoutePlanItemPostSaveContext object.
2693
+ * Use suspendPostSave method to suspend the save process if an asynchronous operation is required.
2694
+ * @param handler The handler function that has to be bound or unbound.
2695
+ * @param bind Determines whether to bind or unbind the handler.
2696
+ * @param scope The scope for handler calls.
2697
+ */
2698
+ static onItemPostSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2699
+ /**
2700
+ * Suspends current 'onPostSave' action and allows performing another asynchronous tasks.
2701
+ * A request object with single function 'resumePostSave';
2702
+ */
2703
+ suspendPostSave(): IFormPostSaveHandler;
2704
+
2705
+ /**
2706
+ * Binds or unbinds the handler called after route is reloaded.
2707
+ * Bound handler is called with the RoutePlan object as an argument on start or when day or filter field is changed.
2708
+ * @param handler The handler function that has to be bound or unbound.
2709
+ * @param bind Determines whether to bind or unbind the handler.
2710
+ * @param scope The scope for handler calls.
2711
+ */
2712
+ static onRouteReloaded(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2713
+ /**
2714
+ * Binds or unbinds the handler for for &quot;Item Added&quot; event.
2715
+ * The RoutePlan context object contains IRoutePlanItemContext object.
2716
+ * @param handler The handler function that has to be bound or unbound.
2717
+ * @param bind Determines whether to bind or unbind the handler.
2718
+ * @param scope The scope for handler calls.
2719
+ */
2720
+ static onItemAdded(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2721
+ /**
2722
+ * Binds or unbinds the handler for for &quot;Item Completed&quot; event triggered when user completes already-saved visit record.
2723
+ * The RoutePlan context object contains IRoutePlanItemContext object.
2724
+ * @param handler The handler function that has to be bound or unbound.
2725
+ * @param bind Determines whether to bind or unbind the handler.
2726
+ * @param scope The scope for handler calls.
2727
+ */
2728
+ static onItemCompleted(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2729
+ /**
2730
+ * Binds or unbinds the handler for for &quot;Item Removed&quot; event triggered when user removes a visit which hasn't been saved yet.
2731
+ * The RoutePlan context object contains IRoutePlanItemContext object.
2732
+ * @param handler The handler function that has to be bound or unbound.
2733
+ * @param bind Determines whether to bind or unbind the handler.
2734
+ * @param scope The scope for handler calls.
2735
+ */
2736
+ static onItemRemoved(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2737
+ }
2738
+ /** Represents the Javascript equivalent view of tourplan form object. */
2575
2739
  class TourplanForm {
2576
- public isDirty: boolean;
2577
- public isLoaded: boolean;
2740
+ public isDirty: boolean;
2741
+ public isLoaded: boolean;
2578
2742
  public view: AppointmentView;
2579
2743
  public context?: ITourplanCreateNewContext;
2580
2744
  /**
package/src/JSBridge.js CHANGED
@@ -1,6 +1,6 @@
1
- // v14.0
1
+ // v15.1
2
2
  (function () {
3
- var _scriptVersion = 14.10
3
+ var _scriptVersion = 15.1
4
4
  // Private objects & functions
5
5
  var _inherit = (function () {
6
6
  function _() { }
@@ -60,6 +60,12 @@
60
60
  }
61
61
  }
62
62
  };
63
+ var _registerEventHandler = function (event, handler, handlers, bind, scope) {
64
+ var register = handlers.length == 0;
65
+ _bindHandler(handler, handlers, bind, scope);
66
+ if (register)
67
+ MobileCRM.bridge.command("registerEvents", event);
68
+ };
63
69
  var _callHandlers = function (handlers) {
64
70
  var params = [];
65
71
  var i = 1;
@@ -613,7 +619,17 @@
613
619
  this.allowedLanguages = [];
614
620
  this.defaultReport = null;
615
621
  },
616
-
622
+
623
+ RoutePlan: function () {
624
+ /// <summary>[v14.2] Represents the Javascript equivalent view of RoutePlan form object.</summary>
625
+ /// <field name="myRoute" type="DynamicEntity[]">A list of route entities.</field>
626
+ /// <field name="completedEntities" type="DynamicEntity[]"> A list of completed entities that are about to be removed from route plan.</field>
627
+ /// <field name="routeEntityName" type="String">Logical name of the route visit entity.</field>
628
+ /// <field name="routeDay" type="Date">Currently selected route day.</field>
629
+ /// <field name="isDirty" type="Boolean">Controls whether the form is dirty and requires save, or whether it can be closed.</field>
630
+ MobileCRM.UI.RoutePlan.superproto.constructor.apply(this, arguments);
631
+ },
632
+
617
633
  IFrameForm: function () {
618
634
  /// <summary>[v9.0] Represents the iFrame form object.</summary>
619
635
  /// <field name="form" type="MobileCRM.UI.Form">Gets the form hosting the iFrame.</field>
@@ -921,6 +937,7 @@
921
937
  DocumentService: function () {
922
938
  /// <summary>[v8.1] Represents a service for acquiring the documents.</summary>
923
939
  /// <field name="maxImageSize" type="String">Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size [640x480,1024x768,1600x1200,2048x1536,2592x1936 ].</field>
940
+ /// <field name="maxUploadImageSize" type="String">Gets or sets the maximum uploaded image size. If uploaded image size is greater then image is resized to specified maximum size [640x480,1024x768,1600x1200,2048x1536,2592x1936 ].</field>
924
941
  /// <field name="recordQuality" type="String">Gets or sets the record quality for audio/video recordings [Low, Medium, High].</field>
925
942
  /// <field name="allowChooseVideo" type="Boolean">Indicates whether the video files should be included into the image picker when selecting the photos. The default is true.</field>
926
943
  /// <field name="allowMultipleFiles" type="Boolean">Indicates whether to allow multiple files for DocumentActions SelectPhoto and SelectFile.[Not implemented on iOS.]</field>
@@ -1043,7 +1060,7 @@
1043
1060
  MobileCRM.Bridge.prototype._callAsyncMethod = function (cmdId, result) {
1044
1061
  if (result instanceof Promise) {
1045
1062
  result.then(function (asyncRes) {
1046
- MobileCRM.bridge.command(cmdId, typeof (result) == "string" ? asyncRes : JSON.stringify(asyncRes));
1063
+ MobileCRM.bridge.command(cmdId, typeof (asyncRes) == "string" ? asyncRes : JSON.stringify(asyncRes));
1047
1064
  }).catch(function (err) {
1048
1065
  MobileCRM.bridge.command(cmdId, "Err:" + err);
1049
1066
  });
@@ -1101,7 +1118,7 @@
1101
1118
  MobileCRM.UI.MediaTab.prototype.selectFile = function (errorCallback) {
1102
1119
  /// <summary>Executes the select file command on this media tab.</summary>
1103
1120
  this._onCommand(8, errorCallback);
1104
- };
1121
+ };
1105
1122
  MobileCRM.UI.MediaTab.prototype.recordAudio = function (errorCallback) {
1106
1123
  /// <summary>Executes the record audio command on this media tab.</summary>
1107
1124
  this._onCommand(16, errorCallback);
@@ -1467,7 +1484,19 @@
1467
1484
  /// <param name="writable" type="Boolean">Indicates whether the property should have setter.</param>
1468
1485
  /// <param name="value" type="">An initial value.</param>
1469
1486
  _addProperty(this, name, writable, value);
1470
- };
1487
+ };
1488
+ MobileCRM.ObservableObject.prototype.runCallback = function (callback, scope) {
1489
+ /// <summary>Invokes callback passing this instance of ObservableObject as argument.</summary>
1490
+ /// <param name="callback" type="function">The callback function.</param>
1491
+ /// <param name="scope" type="Object">The scope for callback.</param>
1492
+ /// <returns type="Object">An object clone containing all properties changed during the callback call.</returns>
1493
+ var obj = this;
1494
+ if (callback.call(scope, obj) != false) {
1495
+ var changed = obj.getChanged();
1496
+ return changed;
1497
+ }
1498
+ return '';
1499
+ }
1471
1500
  MobileCRM.ObservableObject.prototype.getChanged = function () {
1472
1501
  /// <summary>Creates a clone of this object containing all properties that were changed since object construction.</summary>
1473
1502
  /// <remarks>This method enumerates object recursively and creates the object clone containing only the changed properties.</remarks>
@@ -1522,12 +1551,8 @@
1522
1551
  /// <param name="callback" type="function(config)">The callback function that is called asynchronously with <see cref="MobileCRM.Configuration">MobileCRM.Configuration</see> object instance as argument. Callback should return true to apply changed properties.</param>
1523
1552
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
1524
1553
  /// <param name="scope" type="Object">The scope for callbacks.</param>
1525
- MobileCRM.bridge.requestObject("Configuration", function (obj) {
1526
- if (callback.call(scope, obj) != false) {
1527
- var changed = obj.getChanged();
1528
- return changed;
1529
- }
1530
- return '';
1554
+ MobileCRM.bridge.requestObject("Configuration", function (obj) {
1555
+ return obj.runCallback(callback, scope);
1531
1556
  }, errorCallback, scope);
1532
1557
  };
1533
1558
  // MobileCRM._Settings
@@ -2659,6 +2684,18 @@
2659
2684
  var emailContent = { Address: address, Subject: subject, Body: body };
2660
2685
  _executePlatformAction(1, emailContent, null, errorCallback, scope);
2661
2686
  };
2687
+ MobileCRM.Platform.sendEmail = function (address, subject, body, mimeType, errorCallback, scope) {
2688
+ /// <summary>[v15.0] Opens the platform-specific e-mail message form with pre-filled data.</summary>
2689
+ /// <param name="address" type="String">Recipient&#39;s email address.</param>
2690
+ /// <param name="subject" type="String">An e-mail subject.</param>
2691
+ /// <param name="body" type="String">A string with email body.</param>
2692
+ /// <param name="mimeType" type="String">Body content MIME type.</param>
2693
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called asynchronously in case of error.</param>
2694
+ /// <param name="scope" type="Object">The scope for errorCallback.</param>
2695
+
2696
+ var emailContent = { Address: address, Subject: subject, Body: body, MimeType: mimeType };
2697
+ _executePlatformAction(1, emailContent, null, errorCallback, scope);
2698
+ };
2662
2699
  MobileCRM.Platform.openDocument = function (path, mimeType, args, errorCallback, scope) {
2663
2700
  /// <summary>[v8.1] Opens specified document in associated program.</summary>
2664
2701
  /// <remarks>Apple security policy doesn&amp;t allow this functionality on iOS.</remarks>
@@ -3066,10 +3103,138 @@
3066
3103
  MobileCRM.UI.FormManager.showEditDialog(entityName, null, relationship, options);
3067
3104
  }
3068
3105
 
3069
- _inherit(MobileCRM.UI.TourplanForm, MobileCRM.ObservableObject);
3106
+ _inherit(MobileCRM.UI.RoutePlan, MobileCRM.ObservableObject);
3107
+ MobileCRM.UI.RoutePlan.requestObject = function (callback, errorCallback, scope) {
3108
+ /// <summary>Requests the managed RoutePlan object.</summary>
3109
+ /// <remarks>Method initiates an asynchronous request which either ends with calling the <b>errorCallback</b> or with calling the <b>callback</b> with Javascript version of RoutePlan object. See <see cref="MobileCRM.Bridge.requestObject">MobileCRM.Bridge.requestObject</see> for further details.</remarks>
3110
+ /// <param name="callback" type="function(platform)">The callback function that is called asynchronously with serialized RoutePlan object as argument.</param>
3111
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
3112
+ /// <param name="scope" type="Object">The scope for callbacks.</param>
3113
+ MobileCRM.bridge.requestObject("RoutePlan", function (obj) {
3114
+ return obj.runCallback(callback, scope);
3115
+ }, errorCallback, scope);
3116
+ };
3117
+ MobileCRM.UI.RoutePlan.onSave = function (handler, bind, scope) {
3118
+ /// <summary>Binds or unbinds the handler for route save validation.</summary>
3119
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>The RoutePlan context object contains property &quot;errorMessage&quot; that can be used to cancel save with an error.</p><p>Use <see cref="MobileCRM.UI.RoutePlan.suspendSave">suspendSave</see> method to suspend the save process if an asynchronous operation is required.</p></remarks>
3120
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3121
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3122
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3123
+ _registerEventHandler("onSave", handler, MobileCRM.UI.RoutePlan._handlers.onSave, bind, scope);
3124
+ };
3125
+ MobileCRM.UI.RoutePlan.onPostSave = function (handler, bind, scope) {
3126
+ /// <summary>Binds or unbinds the handler for further actions on saved route.</summary>
3127
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>Use <see cref="MobileCRM.UI.RoutePlan.suspendPostSave">suspendPostSave</see> method to suspend the post-save process if an asynchronous operation is required.</p></remarks>
3128
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3129
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3130
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3131
+ _registerEventHandler("onPostSave", handler, MobileCRM.UI.RoutePlan._handlers.onPostSave, bind, scope);
3132
+ };
3133
+ MobileCRM.UI.RoutePlan.onRouteReloaded = function (handler, bind, scope) {
3134
+ /// <summary>Binds or unbinds the handler called after route is reloaded.</summary>
3135
+ /// <remarks>Bound handler is called with the RoutePlan object as an argument on start or when day or filter field is changed.</remarks>
3136
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3137
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3138
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3139
+ _registerEventHandler("onRouteReloaded", handler, MobileCRM.UI.RoutePlan._handlers.onRouteReloaded, bind, scope);
3140
+ };
3141
+ MobileCRM.UI.RoutePlan.onItemAdded = function (handler, bind, scope) {
3142
+ /// <summary>Binds or unbinds the handler for &quot;Item Added&quot; event.</summary>
3143
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>The RoutePlan context object contains property &quot;entity&quot; carrying DynamicEntity object of the new visit record.</p></remarks>
3144
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3145
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3146
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3147
+ _registerEventHandler("onItemAdded", handler, MobileCRM.UI.RoutePlan._handlers.onItemAdded, bind, scope);
3148
+ };
3149
+ MobileCRM.UI.RoutePlan.onItemRemoved = function (handler, bind, scope) {
3150
+ /// <summary>Binds or unbinds the handler for &quot;Item Removed&quot; event.</summary>
3151
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>The RoutePlan context object contains property &quot;entity&quot; carrying DynamicEntity object of unsaved visit record being removed from route plan.</p></remarks>
3152
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3153
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3154
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3155
+ _registerEventHandler("onItemRemoved", handler, MobileCRM.UI.RoutePlan._handlers.onItemRemoved, bind, scope);
3156
+ };
3157
+ MobileCRM.UI.RoutePlan.onItemCompleted = function (handler, bind, scope) {
3158
+ /// <summary>Binds or unbinds the handler for &quot;Item Completed&quot; event.</summary>
3159
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>The RoutePlan context object contains property &quot;entity&quot; carrying DynamicEntity object af completed visit record being removed from route plan.</p></remarks>
3160
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3161
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3162
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3163
+ _registerEventHandler("onItemCompleted", handler, MobileCRM.UI.RoutePlan._handlers.onItemCompleted, bind, scope);
3164
+ };
3165
+ MobileCRM.UI.RoutePlan.onItemSave = function (handler, bind, scope) {
3166
+ /// <summary>Binds or unbinds the handler for validating single visit entity save.</summary>
3167
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>The RoutePlan context object contains property &quot;errorMessage&quot; that can be used to cancel save with an error and property &quot;entityToSave&quot; carrying visit DynamicEntity record.</p><p>Use <see cref="MobileCRM.UI.RoutePlan.suspendSave">suspendSave</see> method to suspend the save process if an asynchronous operation is required.</p></remarks>
3168
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3169
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3170
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3171
+ _registerEventHandler("onItemSave", handler, MobileCRM.UI.RoutePlan._handlers.onItemSave, bind, scope);
3172
+ };
3173
+ MobileCRM.UI.RoutePlan.onItemPostSave = function (handler, bind, scope) {
3174
+ /// <summary>Binds or unbinds the handler for further actions on saved visit entity.</summary>
3175
+ /// <remarks><p>Bound handler is called with the RoutePlan object as an argument.</p><p>The RoutePlan context object contains property &quot;errorMessage&quot; that can be used to cancel save with an error.</p><p>Use <see cref="MobileCRM.UI.RoutePlan.suspendSave">suspendSave</see> method to suspend the save process if an asynchronous operation is required and property &quot;savedEntity&quot; carrying saved DynamicEntity object.</p></remarks>
3176
+ /// <param name="handler" type="function(RoutePlan)">The handler function that has to be bound or unbound.</param>
3177
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
3178
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
3179
+ _registerEventHandler("onItemPostSave", handler, MobileCRM.UI.RoutePlan._handlers.onItemPostSave, bind, scope);
3180
+ };
3181
+ var _pendingRoutePlanSaveId = 0;
3182
+ MobileCRM.UI.RoutePlan.prototype.suspendSave = function () {
3183
+ /// <summary>Suspends current &quot;onSave&quot; process and allows performing asynchronous tasks to save the data.</summary>
3184
+ /// <returns type="Object">A request object with single method &quot;resumeSave&quot; which has to be called with the result (either error message string or &quot;null&quot; in case of success). To cancel the validation without any message, pass "#NoMessage#" text to this method.</returns>
3185
+ var cmdId = "RoutePlanPendingValidation" + (++_pendingRoutePlanSaveId);
3186
+ var self = this;
3187
+ self.context.pendingSaveCommand = cmdId;
3188
+ return {
3189
+ resumeSave: function (result) {
3190
+ if (self._inCallback) {
3191
+ // still in "onSave" callback - do not send a command (handler not installed yet)
3192
+ self.context.errorMessage = result;
3193
+ self.context.pendingSaveCommand = null;
3194
+ }
3195
+ else
3196
+ MobileCRM.bridge.command(cmdId, result);
3197
+ }
3198
+ };
3199
+ }
3200
+ var _pendingRPPostSaveId = 0;
3201
+ MobileCRM.UI.RoutePlan.prototype.suspendPostSave = function () {
3202
+ /// <summary>Suspends current &quot;onPostSave&quot; operations and allows performing another asynchronous tasks before the form is closed.</summary>
3203
+ /// <returns type="Object">A request object with single method &quot;resumePostSave&quot; which has to be called to resume the post-save operations.</returns>
3204
+ var cmdId = "RoutePlanPendingPostSave" + (++_pendingRPPostSaveId);
3205
+ var _this = this;
3206
+ _this.context.pendingPostSaveCommand = cmdId;
3207
+ return {
3208
+ resumePostSave: function () {
3209
+ if (_this._inCallback) {
3210
+ // still in "onPostSave" callback - do not send a command (handler not installed yet)
3211
+ _this.context.pendingPostSaveCommand = null;
3212
+ }
3213
+ else
3214
+ MobileCRM.bridge.command(cmdId);
3215
+ }
3216
+ };
3217
+ };
3218
+ MobileCRM.UI.RoutePlan._callHandlers = function (event, data, context) {
3219
+ var handlers = MobileCRM.UI.RoutePlan._handlers[event];
3220
+ if (handlers && handlers.length > 0) {
3221
+ data.context = context;
3222
+ data._inCallback = true;
3223
+ var result = '';
3224
+ if (_callHandlers(handlers, data) != false) {
3225
+ var changed = data.getChanged();
3226
+ result = JSON.stringify(changed);
3227
+ }
3228
+ data._inCallback = false;
3229
+ return result;
3230
+ }
3231
+ };
3232
+ MobileCRM.UI.RoutePlan._handlers = { onSave: [], onPostSave: [], onRouteReloaded: [], onItemAdded: [], onItemRemoved: [], onItemCompleted: [], onItemSave: [], onItemPostSave: [] };
3233
+
3234
+ _inherit(MobileCRM.UI.TourplanForm, MobileCRM.ObservableObject);
3070
3235
  MobileCRM.UI.TourplanForm.requestObject = function (callback, errorCallback, scope) {
3071
3236
  /// <summary>Requests the managed TourplanForm object.</summary>
3072
- /// <remarks>Method initiates an asynchronous request which either ends with calling the <b>errorCallback</b> or with calling the <b>callback</b> with Javascript version of Platform object. See <see cref="MobileCRM.Bridge.requestObject">MobileCRM.Bridge.requestObject</see> for further details.</remarks>
3237
+ /// <remarks>Method initiates an asynchronous request which either ends with calling the <b>errorCallback</b> or with calling the <b>callback</b> with Javascript version of TourplanForm object. See <see cref="MobileCRM.Bridge.requestObject">MobileCRM.Bridge.requestObject</see> for further details.</remarks>
3073
3238
  /// <param name="callback" type="function(platform)">The callback function that is called asynchronously with serialized TourplanForm object as argument.</param>
3074
3239
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
3075
3240
  /// <param name="scope" type="Object">The scope for callbacks.</param>
@@ -3459,7 +3624,25 @@
3459
3624
  var controller = MobileCRM.bridge.exposeObjectAsync("EntityForm.GetController", [this.view.name]);
3460
3625
  controller.invokeMethodAsync("ChangeProcessTo", [processRef], function () { }, errorCallback, scope);
3461
3626
  controller.release();
3462
- };
3627
+ };
3628
+
3629
+ MobileCRM.UI.ProcessController.prototype.moveToPreviousStage = function (errorCallback, scope) {
3630
+ /// <summary>[15.0] Moves to the previous stage of the active process.</summary>
3631
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called asynchronously in case of error.</param>
3632
+ /// <param name="scope" type="Object">The scope for callback.</param>
3633
+ var controller = MobileCRM.bridge.exposeObjectAsync("EntityForm.GetController", [this.view.name]);
3634
+ controller.invokeMethodAsync("MoveToPreviousStage", [], function () { }, errorCallback, scope);
3635
+ controller.release();
3636
+ };
3637
+
3638
+ MobileCRM.UI.ProcessController.prototype.moveToNextStage = function ( errorCallback, scope) {
3639
+ /// <summary>[15.0] Progresses to the next stage of the active process.</summary>
3640
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called asynchronously in case of error.</param>
3641
+ /// <param name="scope" type="Object">The scope for callback.</param>
3642
+ var controller = MobileCRM.bridge.exposeObjectAsync("EntityForm.GetController", [this.view.name]);
3643
+ controller.invokeMethodAsync("MoveToNextStage", [], function () { }, errorCallback, scope);
3644
+ controller.release();
3645
+ };
3463
3646
 
3464
3647
  // MobileCRM.UI.ViewDefinition
3465
3648
  MobileCRM.UI.ViewDefinition.loadEntityViews = function (entityName, callback, errorCallback, scope) {
@@ -3618,11 +3801,7 @@
3618
3801
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
3619
3802
  /// <param name="scope" type="Object">The scope for callbacks.</param>
3620
3803
  MobileCRM.bridge.requestObject("Form", function (obj) {
3621
- if (callback.call(scope, obj) != false) {
3622
- var changed = obj.getChanged();
3623
- return changed;
3624
- }
3625
- return '';
3804
+ return obj.runCallback(callback, scope);
3626
3805
  }, errorCallback, scope);
3627
3806
  };
3628
3807
 
@@ -3657,11 +3836,7 @@
3657
3836
  MobileCRM.bridge.requestObject("HomeForm", function (obj) {
3658
3837
  obj.lastSyncResult = new MobileCRM.Services.SynchronizationResult(obj.lastSyncResult);
3659
3838
  delete obj._privChanged.lastSyncResult;
3660
- if (callback.call(scope, obj) != false) {
3661
- var changed = obj.getChanged();
3662
- return changed;
3663
- }
3664
- return '';
3839
+ return obj.runCallback(callback, scope);
3665
3840
  }, errorCallback, scope);
3666
3841
  };
3667
3842
 
@@ -3874,11 +4049,7 @@
3874
4049
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
3875
4050
  /// <param name="scope" type="Object">The scope for callbacks.</param>
3876
4051
  MobileCRM.bridge.requestObject("IFrameForm", function (obj) {
3877
- if (callback.call(scope, obj) != false) {
3878
- var changed = obj.getChanged();
3879
- return changed;
3880
- }
3881
- return '';
4052
+ return obj.runCallback(callback, scope);
3882
4053
  }, errorCallback, scope);
3883
4054
  };
3884
4055
 
@@ -4004,11 +4175,7 @@
4004
4175
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
4005
4176
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4006
4177
  MobileCRM.bridge.requestObject("EntityList", function (obj) {
4007
- if (callback.call(scope, obj) != false) {
4008
- var changed = obj.getChanged();
4009
- return changed;
4010
- }
4011
- return '';
4178
+ return obj.runCallback(callback, scope);
4012
4179
  }, errorCallback, scope);
4013
4180
  };
4014
4181
  MobileCRM.UI.EntityList.selectView = function (viewName) {
@@ -4399,11 +4566,7 @@
4399
4566
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
4400
4567
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4401
4568
  MobileCRM.bridge.requestObject("QuestionnaireForm", function (obj) {
4402
- if (callback.call(scope, obj) != false) {
4403
- var changed = obj.getChanged();
4404
- return changed;
4405
- }
4406
- return '';
4569
+ return obj.runCallback(callback, scope);
4407
4570
  }, errorCallback, scope);
4408
4571
  }
4409
4572
  MobileCRM.UI.QuestionnaireForm._callHandlers = function (event, data, context) {
@@ -4589,10 +4752,23 @@
4589
4752
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4590
4753
  MobileCRM.bridge.invokeMethodAsync("QuestionnaireForm", "get_Questionnaire", [], callback, errorCallback, scope);
4591
4754
  };
4755
+ MobileCRM.UI.QuestionnaireForm.onCommand = function (command, handler, bind, scope) {
4756
+ /// <summary>Binds or unbinds the handler for QuestionnaireForm command.</summary>
4757
+ /// <param name="command" type="String">The name of the QuestionnaireForm command.</param>
4758
+ /// <param name="handler" type="function(questionnaireForm)">The handler function that has to be bound or unbound.</param>
4759
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
4760
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
4761
+ var handlers = MobileCRM.UI.QuestionnaireForm._handlers[command];
4762
+ if (!handlers)
4763
+ handlers = MobileCRM.UI.QuestionnaireForm._handlers[command] = [];
4764
+ _bindHandler(handler, handlers, bind, scope);
4765
+ var action = ((bind == false && handlers.length == 0) ? "cmdDel" : "cmd");
4766
+ MobileCRM.bridge.command("registerEvents", action + ":" + command);
4767
+ }
4592
4768
 
4593
4769
  // MobileCRM.UI.EntityForm
4594
4770
  _inherit(MobileCRM.UI.EntityForm, MobileCRM.ObservableObject);
4595
- MobileCRM.UI.EntityForm._handlers = { onChange: [], onSave: [], onPostSave: [], onDetailCollectionChange: [], onSelectedViewChanged: [] };
4771
+ MobileCRM.UI.EntityForm._handlers = { onChange: [], onSave: [], onPostSave: [], onDetailCollectionChange: [], onSelectedViewChanged: [], onProcessLoaded: [] };
4596
4772
 
4597
4773
  MobileCRM.UI.EntityForm.prototype.getDetailView = function (name) {
4598
4774
  /// <summary>Returns the DetailView by its name.</summary>
@@ -4824,6 +5000,17 @@
4824
5000
  if (register)
4825
5001
  MobileCRM.bridge.command("registerEvents", "onChange");
4826
5002
  }
5003
+ MobileCRM.UI.EntityForm.onProcessLoaded = function (handler, bind, scope) {
5004
+ /// <summary>Binds or unbinds the handler for onProcessLoaded event on EntityForm.</summary>
5005
+ /// <param name="handler" type="function(entityForm)">The handler function that has to be bound or unbound.</param>
5006
+ /// <param name="bind" type="Boolean">Determines whether to bind or unbind the handler.</param>
5007
+ /// <param name="scope" type="Object">The scope for handler calls.</param>
5008
+ var handlers = MobileCRM.UI.EntityForm._handlers.onProcessLoaded;
5009
+ var register = handlers.length == 0;
5010
+ _bindHandler(handler, handlers, bind, scope);
5011
+ if (register)
5012
+ MobileCRM.bridge.command("registerEvents", "onProcessLoaded");
5013
+ }
4827
5014
  MobileCRM.UI.EntityForm.onItemChange = function (itemName, handler, bind, scope) {
4828
5015
  /// <summary>[v11.2] Binds or unbinds the handler for specific item change event on EntityForm.</summary>
4829
5016
  /// <param name="itemName" type="String">The name of desired detail item (mostly logical name of the field).</param>
@@ -4895,11 +5082,7 @@
4895
5082
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
4896
5083
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4897
5084
  MobileCRM.bridge.requestObject("EntityForm", function (obj) {
4898
- if (callback.call(scope, obj) != false) {
4899
- var changed = obj.getChanged();
4900
- return changed;
4901
- }
4902
- return '';
5085
+ return obj.runCallback(callback, scope);
4903
5086
  }, errorCallback, scope);
4904
5087
  }
4905
5088
  MobileCRM.UI.EntityForm._callHandlers = function (event, data, context) {
@@ -5175,7 +5358,8 @@
5175
5358
  MobileCRM.Services.DocumentService.prototype._executeAction = function (action, callback, errorCallback, scope) {
5176
5359
  var params = {
5177
5360
  action: action,
5178
- maxImageSize: this.maxImageSize,
5361
+ maxImageSize: this.maxImageSize,
5362
+ maxUploadImageSize: this.maxUploadImageSize,
5179
5363
  recordQuality: this.recordQuality,
5180
5364
  allowChooseVideo: this.allowChooseVideo,
5181
5365
  allowMultipleFiles: this.allowMultipleFiles,
@@ -5232,6 +5416,14 @@
5232
5416
  /// <param name="scope" type="Object">The scope for callbacks.</param>
5233
5417
  this._executeAction(0x1000000, callback, errorCallback, scope);
5234
5418
  };
5419
+ MobileCRM.Services.DocumentService.prototype.selectMultipleFiles = function (callback, errorCallback, scope) {
5420
+ /// <summary>[v14.2.0] Asks the user to choose multiple files and calls the async callback with linked list of file infos (see <see cref="MobileCRM.Services.FileInfo">FileInfo.nextInfo</see>).</summary>
5421
+ /// <param name="callback" type="function(MobileCRM.Services.FileInfo)">The callback function which is called asynchronously with <see cref="MobileCRM.Services.FileInfo">MobileCRM.Services.FileInfo</see> object as an argument.</param>
5422
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
5423
+ /// <param name="scope" type="Object">The scope for callbacks.</param>
5424
+ this.allowMultipleFiles = true;
5425
+ this._executeAction(0x10000000, callback, errorCallback, scope);
5426
+ };
5235
5427
  MobileCRM.Services.DocumentService.prototype.loadFrom = function (callback, errorCallback, scope) {
5236
5428
  /// <summary>[13.3.4]Asks the user to choose a file and calls the async callback with file info.</summary>
5237
5429
  /// <param name="callback" type="function(MobileCRM.Services.FileInfo)">The callback function which is called asynchronously with <see cref="MobileCRM.Services.FileInfo">MobileCRM.Services.FileInfo</see> object as an argument.</param>