Skip to content

Commit

Permalink
Update to support usage of this PCF Control Multiple times on the sam…
Browse files Browse the repository at this point in the history
…e form
  • Loading branch information
NielsMinnee committed Mar 10, 2021
1 parent 2a2bc64 commit 9c76881
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 351 deletions.
2 changes: 1 addition & 1 deletion NNDropdown/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest>
<control namespace="Controls" constructor="NNDropdown" version="0.0.92" display-name-key="NNDropdown" description-key="NN Relation converted into a Multiselect Dropdown" control-type="standard">
<control namespace="Controls" constructor="NNDropdown" version="0.0.94" display-name-key="NNDropdown" description-key="NN Relation converted into a Multiselect Dropdown" control-type="standard">
<!--external-service-usage node declares whether this 3rd party PCF control is using external service or not, if yes, this control will be considered as premium and please also add the external domain it is using.
If it is not using any external service, please set the enabled="false" and DO NOT add any domain below. The "enabled" will be true by default.
Example1:
Expand Down
21 changes: 9 additions & 12 deletions NNDropdown/operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import ReactDOM = require("react-dom");
import React = require("react");
import * as dropdown from './fluentUIDropdown';

export let globals: Globals;
export let setting: Setting;

export async function _sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

export function _writeLog(message: string, data?: any) {
if (globals.enableLogging) {
if (true) { //Needs to be set back to a shared value. Had issue when the control was on the form multiple times. Settings/Globals were mixed.
console.log(message, data);
}
}
Expand Down Expand Up @@ -150,22 +147,22 @@ export function _disAssociateRecord(context: ComponentFramework.Context<IInputs>

export async function _execute(context: ComponentFramework.Context<IInputs>, container: HTMLDivElement) {

globals = _processGlobals(context);
_writeLog("Retrieved and Set Globals", globals);
const _globals = _processGlobals(context);
_writeLog("Retrieved and Set Globals", _globals);

setting = _proccessSetting(context);
_writeLog("Retrieved Settings", setting);
const _setting = _proccessSetting(context);
_writeLog("Retrieved Settings", _setting);

if (setting.primaryEntityId) {
if (_setting.primaryEntityId) {

const dropDownData: DropDownData = {
allOptions: await _getAvailableOptions(context, setting),
selectedOptions: await _currentOptions(context, setting),
allOptions: await _getAvailableOptions(context, _setting),
selectedOptions: await _currentOptions(context, _setting),
}

_writeLog("Retrieved DropdownData", dropDownData);

ReactDOM.render(React.createElement(dropdown.NNDropdownControl, { context: context, setting: setting, dropdowndata: dropDownData }), container);
ReactDOM.render(React.createElement(dropdown.NNDropdownControl, { context: context, setting: _setting, dropdowndata: dropDownData }), container);
}
else {
const msg = <div>This record hasn't been created yet. To enable this control, create the record.</div>;
Expand Down
Loading

0 comments on commit 9c76881

Please sign in to comment.