From 11159f496aea3fa89e7dd66b5768eb3bacd538bd Mon Sep 17 00:00:00 2001 From: scottdurow Date: Sat, 21 Nov 2015 23:14:10 +0000 Subject: [PATCH] Support for CRM2016 Autocomplete methods --- SparkleXrmSource/SparkleXrm/SparkleXrm.csproj | 1 + .../Page/Ui/AutocompleteResultsSet.cs | 39 ++++++++++++++++ .../SparkleXrm/XrmImport/Page/Ui/Control.cs | 45 +++++++++++++++++++ .../Page/Ui/Data/Entity/Attribute.cs | 20 +++++++++ .../SparkleXrm/XrmImport/Utility.cs | 23 +++++++++- 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/AutocompleteResultsSet.cs diff --git a/SparkleXrmSource/SparkleXrm/SparkleXrm.csproj b/SparkleXrmSource/SparkleXrm/SparkleXrm.csproj index 4fce4749..9244d67a 100644 --- a/SparkleXrmSource/SparkleXrm/SparkleXrm.csproj +++ b/SparkleXrmSource/SparkleXrm/SparkleXrm.csproj @@ -164,6 +164,7 @@ + diff --git a/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/AutocompleteResultsSet.cs b/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/AutocompleteResultsSet.cs new file mode 100644 index 00000000..2906ba03 --- /dev/null +++ b/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/AutocompleteResultsSet.cs @@ -0,0 +1,39 @@ +// AutocompleteResults.cs +// + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace Xrm.XrmImport.Page.Ui +{ + [Imported] + [ScriptName("Object")] + [IgnoreNamespace] + public class AutocompleteResultSet + { + public List Results; + public AutocompleteAction Commands; + } + + [Imported] + [ScriptName("Object")] + [IgnoreNamespace] + public class AutocompleteResult + { + public string Id; + public string Icon; + public string[] Fields; + } + + [Imported] + [ScriptName("Object")] + [IgnoreNamespace] + public class AutocompleteAction + { + public string Id; + public string Icon; + public string Label; + public Action Action; + } +} diff --git a/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Control.cs b/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Control.cs index b278e320..754832d1 100644 --- a/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Control.cs +++ b/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Control.cs @@ -291,5 +291,50 @@ public void SetSrc(string src) public void SetVisible(bool visible) { } + + /// + /// Use this to add a function as an event handler for the keypress event so that the function is called when you type a character in the specific text or number field. + /// + /// The function will be added to the bottom of the event handler pipeline. The execution context is automatically set to be passed as the first parameter passed to event handler set using this method. + /// You should use reference to a named function rather than an anonymous function if you may later want to remove the event handler for the field. + public void AddOnKeyPress(ExecutionContextFunctionHandler keyPressFunction) + { + } + + /// + /// Use this to remove an event handler for a text or number field that you added using addOnKeyPress. + /// + /// If an anonymous function is set using addOnKeyPress, it can’t be removed using this method. + public void RemoveOnKeyPress(ExecutionContextFunctionHandler keyPressFunction) + { + } + + /// + /// Use this to manually fire an event handler that you created for a specific text or number field to be executed on the keypress event. + /// + public void FireOnKeyPress() + { + } + + /// + /// Retrieves the data value for an attribute + /// + /// Depends on type of attribute + public object GetValue() + { + + return null; + } + + + /// + /// Retrieves the data value for an attribute + /// + /// Depends on type of attribute + public T GetValue() + { + object o = new object(); + return (T)o; + } } } diff --git a/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Data/Entity/Attribute.cs b/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Data/Entity/Attribute.cs index 8276adbd..3884c11d 100644 --- a/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Data/Entity/Attribute.cs +++ b/SparkleXrmSource/SparkleXrm/XrmImport/Page/Ui/Data/Entity/Attribute.cs @@ -1,4 +1,5 @@ using System.Runtime.CompilerServices; +using Xrm.XrmImport.Page.Ui; namespace Xrm { @@ -382,5 +383,24 @@ public void SetValue(T value) { } + + /// + /// Use this to show up to 10 matching strings in a drop-down list as users press keys to type character + /// in a specific text field. You can also add a custom command with an icon at the bottom of the drop-down list. + /// On selecting an item in the drop-down list, the value in the text field changes to the selected item, + /// the drop-down list disappears, and the OnChange event for the text field is invoked. + /// + /// Object that defines the result set, which includes results and commands, to be displayed in the auto-completion drop-down list. + public void ShowAutoComplete(AutocompleteResultSet results) + { + + } + + /// + /// Use this function to hide the auto-completion drop-down list you configured for a specific text field. + /// + public void HideAutoComplete() + { + } } } diff --git a/SparkleXrmSource/SparkleXrm/XrmImport/Utility.cs b/SparkleXrmSource/SparkleXrm/XrmImport/Utility.cs index 54545928..824e4aed 100644 --- a/SparkleXrmSource/SparkleXrm/XrmImport/Utility.cs +++ b/SparkleXrmSource/SparkleXrm/XrmImport/Utility.cs @@ -17,7 +17,20 @@ public static object OpenEntityForm(string name, string id, object parameters) { return null; } - + /// + /// Opens an entity form + /// + /// The logical name of an entity + /// The string representation of a unique identifier or the record to open in the form. If not set, a form to create a new record is opened + /// A dictionary object that passes extra query string parameters to the form. Invalid query string parameters will cause an error + /// For Microsoft Dynamics CRM Online 2015 Update 1 or later use this optional parameter in the web application to control how the form opens. You can choose to open a form in a new window by passing a dictionary object with a Boolean openInNewWindow property set to true. + /// This parameter is ignored in CRM for tablets and CRM for phones. + /// This function provides a better developer experience than the process of manipulating the URL passed to the window.open method described in Open forms, views, dialogs and reports with a URL. Using this function also helps ensure that users are not prompted to log in again under certain circumstances. + [ScriptName("openEntityForm")] + public static object OpenEntityForm2(string name, string id, object parameters, OpenEntityFormOptions windowOptions) + { + return null; + } /// /// Opens an HTML web resource. /// @@ -79,4 +92,12 @@ public static string encodeURIComponent(string values) } } + + [Imported] + [IgnoreNamespace] + [ScriptName("Object")] + public class OpenEntityFormOptions + { + public bool OpenInNewWindow; + } } \ No newline at end of file