@resconet/jsbridge 14.0.0 → 15.0.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.0.0",
3
+ "version": "15.0.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.0
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).
@@ -728,13 +739,12 @@ declare module MobileCRM {
728
739
  * Asynchronously gets the token using passed OAuth settings and parameters. Configuration name is used to find already settings.
729
740
  * @param configurationName Define the name of oauth configuration, what is key for saved setting if any.
730
741
  * @param oauthSettings Defines the OAuth settings for authentication.
731
- * @param resourceUrl The App ID URI of the target web API (secured resource).
732
742
  * @param prompt Whether to force the user to enter credentials again.
733
743
  * @param success A callback function for successful asynchronous result. The <b>result</b> will carry a string with the access token.
734
744
  * @param failed A callback function for command failure. The <b>error</b> argument will carry the error message.
735
745
  * @param scope A scope for calling the callbacks; set &quot;null&quot; to call the callbacks in global scope.
736
746
  */
737
- public static getOAuthAccessToken(configurationName: string, oauthSettings: MobileCRM.OAuthSettings, resourceUrl: string, prompt: boolean, success: (textAccessToken: string) => void, failed?: (err: string) => void, scope?: any);
747
+ public static getOAuthAccessToken(configurationName: string, oauthSettings: MobileCRM.OAuthSettings, prompt: boolean, success: (textAccessToken: string) => void, failed?: (err: string) => void, scope?: any);
738
748
  }
739
749
 
740
750
  /**
@@ -1095,8 +1105,10 @@ declare module MobileCRM.Services {
1095
1105
  nextInfo: FileInfo;
1096
1106
  }
1097
1107
  class DocumentService {
1098
- /**Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size.*/
1099
- 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;
1100
1112
  /**Gets or sets the record quality for audio/video recordings.*/
1101
1113
  recordQuality: number;
1102
1114
  /**Indicates whether the video files should be included into the image picker when selecting the photos. The default is true.*/
@@ -1108,10 +1120,11 @@ declare module MobileCRM.Services {
1108
1120
 
1109
1121
  capturePhoto(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1110
1122
  selectPhoto(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1111
- selectMultiplePhotos(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1112
- loadFrom(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1113
- loadFromMultiple(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1114
- selectFile(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1123
+ selectMultiplePhotos(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1124
+ loadFrom(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1125
+ loadFromMultiple(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);
1115
1128
  recordAudio(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1116
1129
  recordVideo(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
1117
1130
  pasteFile(callback: (fileInfo: FileInfo) => void, errorCallback?: (error: string) => void, scope?: any);
@@ -1465,6 +1478,13 @@ declare module MobileCRM.UI {
1465
1478
  */
1466
1479
  getController(name: string): _Controller;
1467
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
+ /**
1468
1488
  * Sets the address fields according to the current geo-location from platform-specific location service.
1469
1489
  * @param latitude The latitude from geo-location from platform-specific location service
1470
1490
  * @param longitude longitude from geo-location from platform-specific location service
@@ -2125,6 +2145,14 @@ declare module MobileCRM.UI {
2125
2145
  * Closes the form ignoring all changes that have been made on it.
2126
2146
  */
2127
2147
  public static closeWithoutSaving();
2148
+ /**
2149
+ * Binds or unbinds the handler for QuestionnaireForm command.
2150
+ * @param command The name of the QuestionnaireForm command.
2151
+ * @param handler The handler function that has to be bound or unbound.
2152
+ * @param bind Determines whether to bind or unbind the handler.
2153
+ * @param scope The scope for callbacks.
2154
+ */
2155
+ public static onCommand(command: string, handler: (entityForm: QuestionnaireForm) => void, bind: boolean, scope?: any);
2128
2156
  }
2129
2157
 
2130
2158
  namespace QuestionnaireForm {
@@ -2277,7 +2305,7 @@ declare module MobileCRM.UI {
2277
2305
  viewCount: number;
2278
2306
  visible: boolean;
2279
2307
 
2280
- requestObject(callback: (form: Form) => void, errorCallback?: (err: string) => void, scope?: any);
2308
+ public static requestObject(callback: (form: Form) => void, errorCallback?: (err: string) => void, scope?: any);
2281
2309
  public static showPleaseWait(caption: string): any;
2282
2310
  /**
2283
2311
  * Shows a toast window over the app window which is dismissed after a few seconds.
@@ -2301,6 +2329,20 @@ declare module MobileCRM.UI {
2301
2329
  * @param scope The scope for callback.
2302
2330
  */
2303
2331
  changeProccess(callback: (processReference: MobileCRM.Reference) => void, errorCallback?: (err: string) => void, scope?: any);
2332
+ /**
2333
+ * @since 15.0
2334
+ * Progresses to the next stage of the active process.
2335
+ * @param errorCallback The errorCallback which is called asynchronously in case of error
2336
+ * @param scope The scope for callback.
2337
+ */
2338
+ MoveToPreviousStage(errorCallback?: (err: string) => void, scope?: any);
2339
+ /**
2340
+ * @since 15.0
2341
+ * Moves to the previous stage of the active process.
2342
+ * @param errorCallback The errorCallback which is called asynchronously in case of error
2343
+ * @param scope The scope for callback.
2344
+ */
2345
+ MoveToNextStage(errorCallback?: (err: string) => void, scope?: any);
2304
2346
  }
2305
2347
 
2306
2348
  class ViewDefinition {
@@ -2572,10 +2614,123 @@ declare module MobileCRM.UI {
2572
2614
  */
2573
2615
  suspendSave(): IFormSaveHandler;
2574
2616
  }
2575
- /** Represents the Javascript equivalent view of tourplan form object. */
2617
+ interface IRoutePlanItemSaveContext {
2618
+ errorMessage: string;
2619
+ entityToSave: DynamicEntity;
2620
+ }
2621
+ interface IRoutePlanItemPostSaveContext {
2622
+ savedEntity: DynamicEntity;
2623
+ }
2624
+ interface IRoutePlanItemContext {
2625
+ entity: DynamicEntity;
2626
+ }
2627
+ /** Represents the Javascript equivalent view of RoutePlan form object. */
2628
+ class RoutePlan {
2629
+ /** A list of route entities. */
2630
+ myRoute: DynamicEntity[];
2631
+ /** A list of completed entities that are about to be removed from route plan. */
2632
+ completedEntities: DynamicEntity[];
2633
+ /** Logical name of the route visit entity. */
2634
+ routeEntityName: string;
2635
+ /** Currently selected route day. */
2636
+ routeDay: Date;
2637
+ /** Controls whether the form is dirty and requires save, or whether it can be closed.*/
2638
+ isDirty: boolean;
2639
+ /** Event-specific context. */
2640
+ public context?: IFormSaveContext | IRoutePlanItemSaveContext | IRoutePlanItemPostSaveContext | IRoutePlanItemContext;
2641
+ /**
2642
+ * @since 11.2
2643
+ * Requests the managed RoutePlan object.
2644
+ * 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.
2645
+ * @param callback The callback function that is called asynchronously with serialized RoutePlan object as argument.
2646
+ * @param errorCallback The errorCallback which is called in case of error.
2647
+ * @param scope The scope for callbacks.
2648
+ */
2649
+ static requestObject(callback: (routePlan: RoutePlan) => boolean, errorCallback?: (err: string) => void, scope?: any);
2650
+ /**
2651
+ * Binds or unbinds the handler for route save validation.
2652
+ * The RoutePlan context object contains IFormSaveContext object.
2653
+ * Use suspendSave method to suspend the save process if an asynchronous operation is required.
2654
+ * @param handler The handler function that has to be bound or unbound.
2655
+ * @param bind Determines whether to bind or unbind the handler.
2656
+ * @param scope The scope for handler calls.
2657
+ */
2658
+ static onSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2659
+ /**
2660
+ * Binds or unbinds the handler for validating single visit entity save.
2661
+ * The RoutePlan context object contains IRoutePlanItemSaveContext object.
2662
+ * Use suspendSave method to suspend the save process if an asynchronous operation is required.
2663
+ * @param handler The handler function that has to be bound or unbound.
2664
+ * @param bind Determines whether to bind or unbind the handler.
2665
+ * @param scope The scope for handler calls.
2666
+ */
2667
+ static onItemSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2668
+ /**
2669
+ * Suspends current 'onSave' validation and allows performing another asynchronous tasks to determine the validation result.
2670
+ * 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).
2671
+ */
2672
+ suspendSave(): IFormSaveHandler;
2673
+
2674
+ /**
2675
+ * Binds or unbinds the handler for further actions on saved route.
2676
+ * Use suspendPostSave method to suspend the save process if an asynchronous operation is required.
2677
+ * @param handler The handler function that has to be bound or unbound.
2678
+ * @param bind Determines whether to bind or unbind the handler.
2679
+ * @param scope The scope for handler calls.
2680
+ */
2681
+ static onPostSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2682
+ /**
2683
+ * Binds or unbinds the handler for further actions on saved visit entity.
2684
+ * The RoutePlan context object contains IRoutePlanItemPostSaveContext object.
2685
+ * Use suspendPostSave method to suspend the save process if an asynchronous operation is required.
2686
+ * @param handler The handler function that has to be bound or unbound.
2687
+ * @param bind Determines whether to bind or unbind the handler.
2688
+ * @param scope The scope for handler calls.
2689
+ */
2690
+ static onItemPostSave(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2691
+ /**
2692
+ * Suspends current 'onPostSave' action and allows performing another asynchronous tasks.
2693
+ * A request object with single function 'resumePostSave';
2694
+ */
2695
+ suspendPostSave(): IFormPostSaveHandler;
2696
+
2697
+ /**
2698
+ * Binds or unbinds the handler called after route is reloaded.
2699
+ * Bound handler is called with the RoutePlan object as an argument on start or when day or filter field is changed.
2700
+ * @param handler The handler function that has to be bound or unbound.
2701
+ * @param bind Determines whether to bind or unbind the handler.
2702
+ * @param scope The scope for handler calls.
2703
+ */
2704
+ static onRouteReloaded(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2705
+ /**
2706
+ * Binds or unbinds the handler for for &quot;Item Added&quot; event.
2707
+ * The RoutePlan context object contains IRoutePlanItemContext object.
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 onItemAdded(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2713
+ /**
2714
+ * Binds or unbinds the handler for for &quot;Item Completed&quot; event triggered when user completes already-saved visit record.
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 onItemCompleted(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2721
+ /**
2722
+ * Binds or unbinds the handler for for &quot;Item Removed&quot; event triggered when user removes a visit which hasn't been saved yet.
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 onItemRemoved(handler: (routePlan: RoutePlan) => boolean, bind: boolean, scope?: any);
2729
+ }
2730
+ /** Represents the Javascript equivalent view of tourplan form object. */
2576
2731
  class TourplanForm {
2577
- public isDirty: boolean;
2578
- public isLoaded: boolean;
2732
+ public isDirty: boolean;
2733
+ public isLoaded: boolean;
2579
2734
  public view: AppointmentView;
2580
2735
  public context?: ITourplanCreateNewContext;
2581
2736
  /**
@@ -2795,4 +2950,4 @@ declare module MobileCRM.UI.DetailViewItems {
2795
2950
  /**Gets relative unit type.*/
2796
2951
  star = 2
2797
2952
  }
2798
- }
2953
+ }
package/src/JSBridge.js CHANGED
@@ -1,6 +1,6 @@
1
- // v14.0
1
+ // v15.0
2
2
  (function () {
3
- var _scriptVersion = 14.0;
3
+ var _scriptVersion = 15.0
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) {
@@ -4074,6 +4241,8 @@
4074
4241
  /// <param name="saveImmediately" type="Boolean">Indicates whether to save entity immediately or whether to just make it dirty.</param>
4075
4242
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called asynchronously in case of error.</param>
4076
4243
  /// <param name="scope" type="Object">The scope for callback.</param>
4244
+ editValue = (typeof editValue) === "object" ? JSON.stringify(editValue) : editValue;
4245
+
4077
4246
  MobileCRM.bridge.invokeMethodAsync("EntityList", "FinishListEditByName", [rowIndex, propertyName, editValue, saveImmediately ? MobileCRM.UI.EntityListCellAction.DirectEdit : 0], null, errorCallback, scope);
4078
4247
  };
4079
4248
  MobileCRM.UI.EntityList.startEditCell = function (rowIndex, cellIndex, saveImmediately, binding, errorCallback, scope) {
@@ -4397,11 +4566,7 @@
4397
4566
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
4398
4567
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4399
4568
  MobileCRM.bridge.requestObject("QuestionnaireForm", function (obj) {
4400
- if (callback.call(scope, obj) != false) {
4401
- var changed = obj.getChanged();
4402
- return changed;
4403
- }
4404
- return '';
4569
+ return obj.runCallback(callback, scope);
4405
4570
  }, errorCallback, scope);
4406
4571
  }
4407
4572
  MobileCRM.UI.QuestionnaireForm._callHandlers = function (event, data, context) {
@@ -4587,6 +4752,19 @@
4587
4752
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4588
4753
  MobileCRM.bridge.invokeMethodAsync("QuestionnaireForm", "get_Questionnaire", [], callback, errorCallback, scope);
4589
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
+ }
4590
4768
 
4591
4769
  // MobileCRM.UI.EntityForm
4592
4770
  _inherit(MobileCRM.UI.EntityForm, MobileCRM.ObservableObject);
@@ -4893,11 +5071,7 @@
4893
5071
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
4894
5072
  /// <param name="scope" type="Object">The scope for callbacks.</param>
4895
5073
  MobileCRM.bridge.requestObject("EntityForm", function (obj) {
4896
- if (callback.call(scope, obj) != false) {
4897
- var changed = obj.getChanged();
4898
- return changed;
4899
- }
4900
- return '';
5074
+ return obj.runCallback(callback, scope);
4901
5075
  }, errorCallback, scope);
4902
5076
  }
4903
5077
  MobileCRM.UI.EntityForm._callHandlers = function (event, data, context) {
@@ -5173,7 +5347,8 @@
5173
5347
  MobileCRM.Services.DocumentService.prototype._executeAction = function (action, callback, errorCallback, scope) {
5174
5348
  var params = {
5175
5349
  action: action,
5176
- maxImageSize: this.maxImageSize,
5350
+ maxImageSize: this.maxImageSize,
5351
+ maxUploadImageSize: this.maxUploadImageSize,
5177
5352
  recordQuality: this.recordQuality,
5178
5353
  allowChooseVideo: this.allowChooseVideo,
5179
5354
  allowMultipleFiles: this.allowMultipleFiles,
@@ -5230,15 +5405,23 @@
5230
5405
  /// <param name="scope" type="Object">The scope for callbacks.</param>
5231
5406
  this._executeAction(0x1000000, callback, errorCallback, scope);
5232
5407
  };
5408
+ MobileCRM.Services.DocumentService.prototype.selectMultipleFiles = function (callback, errorCallback, scope) {
5409
+ /// <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>
5410
+ /// <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>
5411
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
5412
+ /// <param name="scope" type="Object">The scope for callbacks.</param>
5413
+ this.allowMultipleFiles = true;
5414
+ this._executeAction(0x10000000, callback, errorCallback, scope);
5415
+ };
5233
5416
  MobileCRM.Services.DocumentService.prototype.loadFrom = function (callback, errorCallback, scope) {
5234
- /// <summary>[13.3.4] Asks the user to choose a file and calls the async callback with file info.</summary>
5417
+ /// <summary>[13.3.4]Asks the user to choose a file and calls the async callback with file info.</summary>
5235
5418
  /// <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>
5236
5419
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
5237
5420
  /// <param name="scope" type="Object">The scope for callbacks.</param>
5238
5421
  this._executeAction(0x0080, callback, errorCallback, scope);
5239
5422
  };
5240
5423
  MobileCRM.Services.DocumentService.prototype.loadFromMultiple = function (callback, errorCallback, scope) {
5241
- /// <summary>[13.3.4] Asks the user to choose a multiple files and calls the async callback with file info.</summary>
5424
+ /// <summary>[13.3.4]Asks the user to choose a multiple files and calls the async callback with file info.</summary>
5242
5425
  /// <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>
5243
5426
  /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
5244
5427
  /// <param name="scope" type="Object">The scope for callbacks.</param>