Skip to content

Commit

Permalink
Merge pull request #192 from carfup/v1.4.0.1
Browse files Browse the repository at this point in the history
V1.4.0.1
  • Loading branch information
carfup authored Jan 12, 2024
2 parents 737d6ed + 733249b commit fa48705
Show file tree
Hide file tree
Showing 28 changed files with 9,428 additions and 12,197 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<control namespace="Carfup" constructor="AnyCompositeFIelds" version="0.0.82" display-name-key="Carfup.AnyCompositeFIelds" description-key="AnyCompositeFIelds will allow you to display any stack of fields as composite rendering." control-type="standard" preview-image="img/preview.png">
<control namespace="Carfup" constructor="AnyCompositeFIelds" version="0.1.0" display-name-key="Carfup.AnyCompositeFIelds" description-key="AnyCompositeFIelds will allow you to display any stack of fields as composite rendering." control-type="standard" preview-image="img/preview.png">
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
<property name="FieldToAttachControl" display-name-key="FieldToAttachControl" description-key="Field to attach the control to" of-type-group="strings" usage="bound" required="true" />
<property name="separator" display-name-key="Values separator" description-key="Separator to format the mapped values (for a space, put %20, for jump line, put CLRF)\rYou can also define a complex format using the following : field|CLRF|field|,|field|%20" of-type="SingleLine.Text" usage="input" required="true" default-value="%20" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Stack, IStackStyles } from '@fluentui/react/lib/Stack';
import { Callout, ICalloutContentStyles, DirectionalHint } from '@fluentui/react/lib/Callout';
import { CompositeValue } from '../EntitiesDefinition';
import { IInputs } from '../generated/ManifestTypes';
import { cpuUsage } from 'process';

export interface ICompositeControlProps {
disabled : boolean;
Expand All @@ -16,18 +15,21 @@ export interface ICompositeControlProps {
onClickedDone : (compositeValue? : CompositeValue) => void;
context?: ComponentFramework.Context<IInputs>;
separator : string;
buttonDisabled : boolean;
}

export interface IBCompositeControlState {
showCallout: boolean,
compositeValue : CompositeValue;
disabled : boolean;
visible : boolean;
buttonDisabled : boolean;
}

const stackStyles: Partial<IStackStyles> = { root: { width: "100%" } };
const textFieldStyles: Partial<ITextFieldStyles> = { root: { width: "100%" } };
const calloutStyles: Partial<ICalloutContentStyles> = { root: { width: "300px" } };
const elements = ['fieldValue1', 'fieldValue2', 'fieldValue3', 'fieldValue4', 'fieldValue5', 'fieldValue6', 'fieldValue7', 'fieldValue8'];

export default class CompositeControl extends React.Component<ICompositeControlProps, IBCompositeControlState> {
constructor(props: ICompositeControlProps) {
Expand All @@ -36,15 +38,14 @@ export default class CompositeControl extends React.Component<ICompositeControlP
showCallout : false,
compositeValue : this.props.compositeValue,
disabled : this.props.disabled,
visible : this.props.visible
visible : this.props.visible,
buttonDisabled : this.props.buttonDisabled
};
}



render(){
const elements = ['fieldValue1', 'fieldValue2', 'fieldValue3', 'fieldValue4', 'fieldValue5', 'fieldValue6', 'fieldValue7', 'fieldValue8'];

return (
<Stack horizontal id="acf_compositestack" styles={stackStyles}>
<TextField
Expand All @@ -69,23 +70,24 @@ export default class CompositeControl extends React.Component<ICompositeControlP
let element = this.state.compositeValue[value];
const isMultiline = element.type === "SingleLine.TextArea" || element.type === "Multiple";

return element.attributes.LogicalName != undefined && <TextField
value={element.raw!}
label={element.attributes.DisplayName}
id={"acf_"+value}
onChange={this.onChangeField}
onDoubleClick={this.onDoubleClick}
disabled={this.state.disabled || element.disabled!}
styles={textFieldStyles}
multiline={isMultiline}
autoAdjustHeight={isMultiline}
required={element.attributes.RequiredLevel == 1 || element.attributes.RequiredLevel == 2}
maxLength={element.attributes.MaxLength}
iconProps={{ iconName: this.getIcon(element.type) }}
/>
return element.attributes.LogicalName != undefined &&
<TextField
value={element.raw!}
label={element.attributes.DisplayName}
id={"acf_"+value}
onChange={this.onChangeField}
onDoubleClick={this.onDoubleClick}
disabled={this.state.disabled || element.disabled!}
styles={textFieldStyles}
multiline={isMultiline}
autoAdjustHeight={isMultiline}
required={element.attributes.RequiredLevel == 1 || element.attributes.RequiredLevel == 2}
maxLength={element.attributes.MaxLength}
iconProps={{ iconName: this.getIcon(element.type) }}
/>
})}

<DefaultButton text={this.props.doneLabel} onClick={this.onClick} style={{marginTop:'10px',alignSelf: "flex-end"}}/>
<DefaultButton text={this.props.doneLabel} disabled={this.state.buttonDisabled} onClick={this.onClick} style={{marginTop:'10px',alignSelf: "flex-end"}}/>
</Stack>

</Callout>
Expand All @@ -94,6 +96,20 @@ export default class CompositeControl extends React.Component<ICompositeControlP
);
}

private checkIfRequiredFieldEmpty = () : void => {
let disabled = false;

elements.forEach((x : string) => {
// @ts-ignore
let element = this.state.compositeValue[x];
if(element.attributes.RequiredLevel == 2 && (element.raw == undefined || element.raw == ""))
disabled = true;

});

this.setState({ buttonDisabled : disabled });
}

/**
* Ability to auto hide the callout on desktop and manually done on mobile
* @param ev
Expand All @@ -116,6 +132,8 @@ export default class CompositeControl extends React.Component<ICompositeControlP
// @ts-ignore
compositeValue[target].raw = newValue!;
this.setState({compositeValue : compositeValue});

this.checkIfRequiredFieldEmpty();
}

/**
Expand Down
25 changes: 21 additions & 4 deletions AnyCompositeFields/AnyCompositeFIelds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,36 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
visible : this._context.mode.isVisible,
separator : this._context.parameters.separator.raw!,
randNumber : Math.floor(Math.random()*(100-1+1)+1),
buttonDisabled : this.checkIfRequiredFieldEmpty(),
onClickedDone : (compositeValue? : CompositeValue) => {
this._compositeValue = compositeValue!;
this.buildFullValue();
this.notifyOutputChanged();
}
}

ReactDOM.render(React.createElement(CompositeControl, optionsText), this._controlDiv);
this._compositeComponent = ReactDOM.render(React.createElement(CompositeControl, optionsText), this._controlDiv);
}
else {
_this.extractFieldsFromQVF();
this._compositeComponent.setState({compositeValue : this._compositeValue, disabled : this._context.mode.isControlDisabled, visible : this._context.mode.isVisible});
}
}

private checkIfRequiredFieldEmpty = () : boolean => {
let disabled = false;
const elements = ['fieldValue1', 'fieldValue2', 'fieldValue3', 'fieldValue4', 'fieldValue5', 'fieldValue6', 'fieldValue7', 'fieldValue8'];
elements.forEach((x) => {
// @ts-ignore
let element = this._compositeValue[x];
if(element.attributes.RequiredLevel == 2 && element.raw == undefined)
disabled = true;

});

return disabled;
}

/**
* Retrieve all parameters of the PCF control
*/
Expand Down Expand Up @@ -177,6 +193,10 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
finalValue += this._compositeValue["fieldValue"+fieldCount].raw;
fieldCount++;
}
// @ts-ignore
else if(this._compositeValue["fieldValue"+fieldCount]!.raw == null && splitValue[i] === "field"){
// do nothing
}
else {
let separator = splitValue[i];
switch(separator){
Expand All @@ -200,9 +220,6 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
finalValue = arrayValues.join(splitValue[0]);
}




this._compositeValue.fullValue = finalValue;
}

Expand Down
2 changes: 1 addition & 1 deletion BICValidator/BicValidator/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="Carfup" constructor="BicValidator" version="0.1.13" display-name-key="Carfup.BicValidator" description-key="BicValidator description" control-type="standard">
<control namespace="Carfup" constructor="BicValidator" version="0.1.14" display-name-key="Carfup.BicValidator" description-key="BicValidator description" control-type="standard">
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
<property name="BICValue" display-name-key="BICValidator_BICValue" description-key="BIC field value" of-type="SingleLine.Text" usage="bound" required="true" />
<property name="IsValid" display-name-key="BICValidator_IsValid" description-key="Is BIC valid" of-type="TwoOptions" usage="bound" required="false" />
Expand Down
2 changes: 1 addition & 1 deletion BICValidator/BicValidator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class BicValidator implements ComponentFramework.StandardControl<IInputs,
this._valueElement.removeAttribute("disabled");
}

this.valueChanged(null, true);
//this.valueChanged(null, true);
}

/**
Expand Down
1 change: 1 addition & 0 deletions Carfup_PCFControls/Carfup_PCFControls.cdsproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<ProjectReference Include="..\QuickEditForm\QuickEditForm.pcfproj" />
<ProjectReference Include="..\QuickEditFormLookup\QuickEditFormLookup.pcfproj" />
<ProjectReference Include="..\AnyCompositeFields\AnyCompositeFields.pcfproj" />
<ProjectReference Include="..\EasyRollup\EasyRollupField.pcfproj" />
</ItemGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
Expand Down
2 changes: 1 addition & 1 deletion Carfup_PCFControls/Other/Solution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<LocalizedName description="Carfup_PCFControls" languagecode="1033" />
</LocalizedNames>
<Descriptions />
<Version>1.4.0.0</Version>
<Version>1.4.0.1</Version>
<!-- Solution Package Type: Unmanaged(0)/Managed(1)/Both(2)-->
<Managed>2</Managed>
<Publisher>
Expand Down
14 changes: 14 additions & 0 deletions EasyRollup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# generated directory
**/generated

# output directory
/out

# msbuild output directories
/bin
/obj
23 changes: 23 additions & 0 deletions EasyRollup/EasyRollup/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<control namespace="Carfup" constructor="EasyRollupField" version="0.0.10" display-name-key="Carfup.EasyRollup" description-key="EasyRollup description" control-type="virtual">
<property name="FieldToAttachControl" display-name-key="FieldToAttachControl" description-key="FieldToAttachControl" of-type-group="numbers" usage="bound" required="true" />
<property name="RollupField" display-name-key="RollupField Logical Name" description-key="RollupField Logical Name" of-type="SingleLine.Text" usage="input" required="true" />
<type-group name="numbers">
<type>Currency</type>
<type>FP</type>
<type>Whole.None</type>
<type>Decimal</type>
<type>SingleLine.Text</type>
</type-group>
<resources>
<code path="index.ts" order="1" />
<platform-library name="React" version="16.8.6" />
<platform-library name="Fluent" version="9.4.0" />
</resources>
<feature-usage>
<uses-feature name="WebAPI" required="true" />
<uses-feature name="Utility" required="true" />
</feature-usage>
</control>
</manifest>
15 changes: 15 additions & 0 deletions EasyRollup/EasyRollup/EntitiesDefinition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IInputs } from "./generated/ManifestTypes";

export class EntityReferenceDef{
public Id:string;
public Name:string;
public EntityName: string;
public EntitySetName: string | null;
}

export interface IRollupFieldControlProps {
context : ComponentFramework.Context<IInputs>,
entityRef : EntityReferenceDef,
rollupField : string,
clientUrl : string
}
Loading

0 comments on commit fa48705

Please sign in to comment.