Skip to content

Commit

Permalink
optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
brasov2de committed May 6, 2022
1 parent c23448d commit 34b4760
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
11 changes: 6 additions & 5 deletions Control/ColorfulOptionset/ColorfulOptionsetControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ interface IColorfulOptionsetProperties {


//export default class ColorfulOptionsetControl extends React.Component<IColorfulOptionsetProperties, {}> {
export const ColorfulOptionsetControl = React.memo(({rawOptions, selectedKey, onChange, isDisabled, defaultValue, config}:IColorfulOptionsetProperties): JSX.Element =>{
console.log("Entered control");
//export const ColorfulOptionsetControl = ({rawOptions, selectedKey, onChange, isDisabled, defaultValue, config}:IColorfulOptionsetProperties): JSX.Element =>{
export const ColorfulOptionsetControl = React.memo(({rawOptions, selectedKey, onChange, isDisabled, defaultValue, config}:IColorfulOptionsetProperties): JSX.Element =>{
console.log("%cEntered control", "color:red");
const allOptions = [{Label: "--Select--", Value: -1, Color: "transparent"}, ...rawOptions];
let options = allOptions.map((option : ComponentFramework.PropertyHelper.OptionMetadata ) => ({key: option.Value, text : option.Label, data: {color: option.Color}}) )
if(config.sortBy==="TEXT"){
Expand Down Expand Up @@ -96,14 +97,14 @@ const _onRenderTitle = (options: IDropdownOption[] | undefined): JSX.Element =>
/>
);

}, (prev, next)=> {
});
/*, (prev, next)=> {
return prev.rawOptions === next.rawOptions
&& prev.selectedKey === next.selectedKey
&& prev.isDisabled===next.isDisabled
&& prev.defaultValue===next.defaultValue
&& prev.config===next.config;
})

}) */



Expand Down
2 changes: 1 addition & 1 deletion Control/ColorfulOptionset/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="ORBIS" constructor="ColorfulOptionset" version="0.0.7" display-name-key="ORBIS.ColorfulOptionset" description-key="ColorfulOptionset description" control-type="virtual">
<control namespace="ORBIS" constructor="ColorfulOptionset" version="0.0.8" display-name-key="ORBIS.ColorfulOptionset" description-key="ColorfulOptionset description" control-type="virtual">
<property name="optionsInput" display-name-key="OptionSet" description-key="OptionSet" of-type="OptionSet" usage="bound" required="true" />
<property name="icon" display-name-key="Icon" description-key="Icon" of-type="SingleLine.Text" usage="input" required="false" />
<property name="sortBy" display-name-key="Sort by" description-key="Sort by" of-type="Enum" usage="input" required="true" >
Expand Down
12 changes: 7 additions & 5 deletions Control/ColorfulOptionset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ export class ColorfulOptionset implements ComponentFramework.ReactControl<IInput

}

private onChange = (newValue: number |null) => {
this.currentValue = newValue;
this.notifyOutputChanged();
};

private renderControl(context: ComponentFramework.Context<IInputs>) : React.ReactElement {
console.log("entered renderControl in index.ts")
console.log("entered renderControl in index.ts", context.updatedProperties);

this.isDisabled = context.mode.isControlDisabled;
this.currentValue = context.parameters.optionsInput.raw;
let params = {
rawOptions: context.parameters.optionsInput.attributes!.Options,
selectedKey: this.currentValue,
onChange: (newValue: number |null) => {
this.currentValue = newValue;
this.notifyOutputChanged();
},
onChange: this.onChange,
isDisabled : this.isDisabled,
defaultValue : this.defaultValue,
config: this.config ?? this.parseIconConfig("CircleShapeSolid", context.parameters.icon?.raw ?? undefined, context.parameters.sortBy.raw)
Expand Down

0 comments on commit 34b4760

Please sign in to comment.