Skip to content

Commit

Permalink
Merge pull request #137 from carfup/release
Browse files Browse the repository at this point in the history
Release v1.4.0.0
  • Loading branch information
carfup authored Sep 7, 2021
2 parents b6735ab + f3a4134 commit b065abc
Show file tree
Hide file tree
Showing 60 changed files with 22,222 additions and 472 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<control namespace="Carfup" constructor="AnyCompositeFIelds" version="0.0.78" 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.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">
<!-- 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 split the mapped values (for a space, put %20)" of-type="SingleLine.Text" usage="input" required="true" default-value="%20" />
<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" />
<property name="returnCompositeValue" display-name-key="Return the composite value ?" description-key="Do you want to retrieve the composite value ?" of-type="Enum" usage="input" required="true" default-value="true">
<value name="true" display-name-key="True" description-key="true">true</value>
<value name="false" display-name-key="False" description-key="false">false</value>
Expand All @@ -20,6 +20,8 @@
<type>SingleLine.Email</type>
<type>SingleLine.Text</type>
<type>SingleLine.Phone</type>
<type>SingleLine.TextArea</type>
<type>Multiple</type>
</type-group>
<!--
Property node's of-type attribute can be of-type-group attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ICompositeControlProps {
randNumber: number;
onClickedDone : (compositeValue? : CompositeValue) => void;
context?: ComponentFramework.Context<IInputs>;
separator : string;
}

export interface IBCompositeControlState {
Expand Down Expand Up @@ -52,6 +53,8 @@ export default class CompositeControl extends React.Component<ICompositeControlP
onClick={() => this.setState({ showCallout : true }) }
styles={textFieldStyles}
id={"acf_compositeFullValue"+this.props.randNumber}
multiline={this.props.separator.indexOf("CRLF") > 0}
autoAdjustHeight={true}
/>
{this.state.showCallout && (
<Callout
Expand Down
72 changes: 58 additions & 14 deletions AnyCompositeFields/AnyCompositeFIelds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
private notifyOutputChanged: () => void;
private _controlDiv : HTMLDivElement;
private _compositeComponent? : any;
private _formXML : string = "";

// Field properties
private _compositeValue : CompositeValue;
Expand Down Expand Up @@ -49,7 +50,7 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
container.setAttribute("visibility", "hidden");
}

this.buildControl(true);
this.buildControl();
}


Expand All @@ -61,7 +62,7 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
{
// Add code to update control view
this.getParams();
this.buildControl(false);
this.buildControl();
}

/**
Expand Down Expand Up @@ -99,15 +100,16 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
ReactDOM.unmountComponentAtNode(this._container);
}

private async buildControl(getFormXml: boolean){
private async buildControl(){
var _this = this;
if(getFormXml){
if(this._formXML === ""){
// @ts-ignore
var formGuid = this._context.factory._customControlProperties.personalizationConfiguration.formGuid.guid;

await this._context.webAPI.retrieveRecord("systemform", formGuid, "?$select=formxml,objecttypecode").then(
function success(form) {
_this.extractFieldsFromQVF(form.formxml);
_this._formXML = form.formxml;
_this.extractFieldsFromQVF();
}
);

Expand All @@ -116,16 +118,18 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
doneLabel : this._context.resources.getString("Done"),
disabled : this._context.mode.isControlDisabled,
visible : this._context.mode.isVisible,
separator : this._context.parameters.separator.raw!,
randNumber : Math.floor(Math.random()*(100-1+1)+1),
onClickedDone : (compositeValue? : CompositeValue) => {
this._compositeValue = compositeValue!;
this.notifyOutputChanged();
}
}

this._compositeComponent = ReactDOM.render(React.createElement(CompositeControl, optionsText), this._controlDiv);
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});
}
}
Expand All @@ -143,28 +147,68 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
this._compositeValue.fieldValue6 = this._context.parameters.field6;
this._compositeValue.fieldValue7 = this._context.parameters.field7;
this._compositeValue.fieldValue8 = this._context.parameters.field8;
this._compositeValue.separator = this._context.parameters.separator.raw! === "%20" ? " " : this._context.parameters.separator.raw!;
this._compositeValue.separator = this.getSeparator(this._context.parameters.separator.raw);
this._compositeValue.returnCompositeValue = (this._context.parameters.returnCompositeValue && this._context.parameters.returnCompositeValue.raw && this._context.parameters.returnCompositeValue.raw.toLowerCase() === "true") ? true : false;
this.buildFullValue();
}

private getSeparator(input: string | null): string {

switch(input){
case "%20" : return " ";
case "CRLF" : return "\r"
default: return input!
}
}

private buildFullValue(): void {
let arrayValues = [];
let fieldCount = 1;
let splitValue = this.getSeparator(this._context.parameters.separator.raw).split("|");
let finalValue = "";

for(let i = 1 ; i<9; i++){
// @ts-ignore
if(this._compositeValue["fieldValue"+i]!.raw!){
if(splitValue.length > 1){
for(let i = 0 ; i< splitValue.length; i++){
// @ts-ignore
arrayValues.push(this._compositeValue["fieldValue"+i].raw);
if(this._compositeValue["fieldValue"+fieldCount]!.raw! && splitValue[i] === "field"){
// @ts-ignore
arrayValues.push(this._compositeValue["fieldValue"+fieldCount].raw);
// @ts-ignore
finalValue += this._compositeValue["fieldValue"+fieldCount].raw;
fieldCount++;
}
else {
let separator = splitValue[i];
switch(separator){
case "%20" : separator = " "; break;
case "CRLF" : separator = "\r"; break;
}
arrayValues.push(this.getSeparator(splitValue[i]));
finalValue += separator;
}
}
}
else {
for(let i = 1 ; i<9; i++){
// @ts-ignore
if(this._compositeValue["fieldValue"+i]!.raw!){
// @ts-ignore
arrayValues.push(this._compositeValue["fieldValue"+i].raw);
}
}

finalValue = arrayValues.join(splitValue[0]);
}




this._compositeValue.fullValue = arrayValues.join(this._compositeValue.separator);
this._compositeValue.fullValue = finalValue;
}

private extractFieldsFromQVF(formXml : string): void{
private extractFieldsFromQVF(): void{

let xml = $.parseXML(formXml);
let xml = $.parseXML(this._formXML);
let xmlDetails = $(xml);
for(let i = 1 ; i<9; i++){
// @ts-ignore
Expand Down
Loading

0 comments on commit b065abc

Please sign in to comment.