├── Images └── Configuration_AddDependency.gif ├── LICENSE └── README.md /Images/Configuration_AddDependency.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndrewButenko/ABDialogs/HEAD/Images/Configuration_AddDependency.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Andrew Butenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AB Dialogs 2 | AB Dialogs is a managed solution that provides the developer a configurable wrapper and convenient way to open dialogs in the new UCI interface of Dataverse and process results of the call. 3 | 4 | Here is the list of steps you need to perform in order to use this dialog in your Model-Driven Apps: 5 | 1. Download and install [the latest release](/../../releases/download/1.0.0.0/ABDialogs_1_0_0_0_managed.zip) of ABDialogs solution 6 | 1. Prepare your "Dialog Configuration" object that has the following structure: 7 | ```typescript 8 | //This is high-level settings 9 | interface DialogSettings { 10 | //Header that will be shown at the top of the dialog, required 11 | DialogHeaderText: string; 12 | //It's possible to have multistep dialogs and TabSettings has to contain all 13 | //of the step available, required 14 | TabSettings: TabSetting[]; 15 | //Height of the dialog window, default value - 300 16 | height?: number; 17 | //Width of the dialog window, default value - 400 18 | width?: number; 19 | } 20 | 21 | //This is a setting description of the particular tab 22 | interface TabSetting { 23 | //Helper information that will be shown on top of fields, optional 24 | TabHeaderText?: string; 25 | //Settings for all of the fields available on the step, required 26 | FieldSettings: FieldSetting[]; 27 | } 28 | 29 | //This is a setting description of the particular field 30 | interface FieldSetting { 31 | //Name of the particular dialog input, should be unique across the dialog 32 | //settings, required 33 | Name: string; 34 | //Label that will be shown beside the field, required 35 | Label: string; 36 | //Type of the field/input that will be rendered, any other type will be rendered 37 | //just as a label, required 38 | FieldType: "string" | "wholenumber" | "date" | "boolean" | "choice" | "choices"; 39 | //Initial value of the field, optional 40 | Value: any; 41 | //Array that contains value/label pairs used in "boolean", "choice" and "choices" 42 | //types of fields, required for mentioned types, ignored for other 43 | ChoiceValues?: ChoiceValue[]; 44 | //UI formatting used for "boolean" type of field, "checkbox" is used by default, optional 45 | BooleanStyle?: "checkbox" | "radio" | "toggle"; 46 | //UI formatting of "string" field that allows to enter information in multi-line format, 47 | //1 is used by default, ignored for other than "string" types 48 | LinesNumber?: number; 49 | } 50 | 51 | interface ChoiceValue { 52 | //Value used 53 | Value: any; 54 | //Display Label 55 | Label: string; 56 | } 57 | ``` 58 | 1. Call **AB.Dialogs.open** function to open the dialog. This function returns the promise. 59 | When a user closes the dialog using the "X" button or "Cancel" button, the promise is resolved with **null** value and returns the object with all values selected in dialog otherwise. 60 | 61 | Here is an example of JavaScript webresource that is used to show 2-Tabs Dialog with 2 inputs each: 62 | 63 | ```javascript 64 | var AB = AB || {}; 65 | AB.DialogDemo = (function () { 66 | 67 | function openDialog() { 68 | var dialogParameters = { 69 | DialogHeaderText: "Custom Header Here", 70 | Tabs: [{ 71 | TabHeaderText: "This is Text Header", 72 | FieldSettings: [ 73 | { 74 | FieldType: "string", 75 | Label: "Text Field Label", 76 | Name: "text1", 77 | Value: "Initial Value of Text Field", 78 | }, { 79 | FieldType: "date", 80 | Label: "Date Field", 81 | Name: "date1", 82 | Value: new Date() 83 | }]},{ 84 | FieldSettings: [{ 85 | FieldType: "boolean", 86 | Label: "Two Values Select", 87 | Name: "bool2", 88 | Value: false, 89 | BooleanStyle: "toggle", 90 | ChoiceValues: [{ 91 | Value: false, 92 | Label: "False is selected" 93 | }, { 94 | Value: true, 95 | Label: "True is selected" 96 | }] 97 | }, { 98 | FieldType: "choices", 99 | Label: "Dropdown", 100 | Name: "dd1", 101 | Value: undefined, 102 | ChoiceValues: [1, 2, 3, 4].map(function(o) {return { Value: o, Label: 'Option ' + o }}) 103 | } 104 | ] 105 | }] 106 | }; 107 | 108 | AB.Dialogs.open(dialogParameters).then(function(result){ 109 | console.log(result); 110 | }, Xrm.Navigation.openAlertDialog) 111 | } 112 | 113 | return { 114 | openDialog: openDialog 115 | }; 116 | })(); 117 | ``` 118 | 1. Add the dependency on "ab_/Dialogs/Dialog.js" webresource to the JS webresource you plan to open the dialog from: 119 | ![Add Dependency](./Images/Configuration_AddDependency.gif) 120 | 121 | If a user leaves text and datetime field unchanged, sets the boolean field to true and selects "Option 2" and "Option 3" in choices control here is the object that will be returned to the callback: 122 | ```json 123 | { 124 | "text1": "Initial Value of Text Field", 125 | "date1": "2021-05-12T07:09:16.197Z",//DateTime fields are returned as DateTime fields, no need to include additional parsing 126 | "bool2": true, 127 | "dd1": [2, 3] 128 | } 129 | ``` --------------------------------------------------------------------------------