Skip to content

Commit fa48705

Browse files
authored
Merge pull request #192 from carfup/v1.4.0.1
V1.4.0.1
2 parents 737d6ed + 733249b commit fa48705

28 files changed

Lines changed: 9428 additions & 12197 deletions

File tree

AnyCompositeFields/AnyCompositeFIelds/ControlManifest.Input.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest>
3-
<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">
3+
<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">
44
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
55
<property name="FieldToAttachControl" display-name-key="FieldToAttachControl" description-key="Field to attach the control to" of-type-group="strings" usage="bound" required="true" />
66
<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" />

AnyCompositeFields/AnyCompositeFIelds/components/CompositeControl.tsx

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Stack, IStackStyles } from '@fluentui/react/lib/Stack';
55
import { Callout, ICalloutContentStyles, DirectionalHint } from '@fluentui/react/lib/Callout';
66
import { CompositeValue } from '../EntitiesDefinition';
77
import { IInputs } from '../generated/ManifestTypes';
8-
import { cpuUsage } from 'process';
98

109
export interface ICompositeControlProps {
1110
disabled : boolean;
@@ -16,18 +15,21 @@ export interface ICompositeControlProps {
1615
onClickedDone : (compositeValue? : CompositeValue) => void;
1716
context?: ComponentFramework.Context<IInputs>;
1817
separator : string;
18+
buttonDisabled : boolean;
1919
}
2020

2121
export interface IBCompositeControlState {
2222
showCallout: boolean,
2323
compositeValue : CompositeValue;
2424
disabled : boolean;
2525
visible : boolean;
26+
buttonDisabled : boolean;
2627
}
2728

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

3234
export default class CompositeControl extends React.Component<ICompositeControlProps, IBCompositeControlState> {
3335
constructor(props: ICompositeControlProps) {
@@ -36,15 +38,14 @@ export default class CompositeControl extends React.Component<ICompositeControlP
3638
showCallout : false,
3739
compositeValue : this.props.compositeValue,
3840
disabled : this.props.disabled,
39-
visible : this.props.visible
41+
visible : this.props.visible,
42+
buttonDisabled : this.props.buttonDisabled
4043
};
4144
}
4245

4346

44-
47+
4548
render(){
46-
const elements = ['fieldValue1', 'fieldValue2', 'fieldValue3', 'fieldValue4', 'fieldValue5', 'fieldValue6', 'fieldValue7', 'fieldValue8'];
47-
4849
return (
4950
<Stack horizontal id="acf_compositestack" styles={stackStyles}>
5051
<TextField
@@ -69,23 +70,24 @@ export default class CompositeControl extends React.Component<ICompositeControlP
6970
let element = this.state.compositeValue[value];
7071
const isMultiline = element.type === "SingleLine.TextArea" || element.type === "Multiple";
7172

72-
return element.attributes.LogicalName != undefined && <TextField
73-
value={element.raw!}
74-
label={element.attributes.DisplayName}
75-
id={"acf_"+value}
76-
onChange={this.onChangeField}
77-
onDoubleClick={this.onDoubleClick}
78-
disabled={this.state.disabled || element.disabled!}
79-
styles={textFieldStyles}
80-
multiline={isMultiline}
81-
autoAdjustHeight={isMultiline}
82-
required={element.attributes.RequiredLevel == 1 || element.attributes.RequiredLevel == 2}
83-
maxLength={element.attributes.MaxLength}
84-
iconProps={{ iconName: this.getIcon(element.type) }}
85-
/>
73+
return element.attributes.LogicalName != undefined &&
74+
<TextField
75+
value={element.raw!}
76+
label={element.attributes.DisplayName}
77+
id={"acf_"+value}
78+
onChange={this.onChangeField}
79+
onDoubleClick={this.onDoubleClick}
80+
disabled={this.state.disabled || element.disabled!}
81+
styles={textFieldStyles}
82+
multiline={isMultiline}
83+
autoAdjustHeight={isMultiline}
84+
required={element.attributes.RequiredLevel == 1 || element.attributes.RequiredLevel == 2}
85+
maxLength={element.attributes.MaxLength}
86+
iconProps={{ iconName: this.getIcon(element.type) }}
87+
/>
8688
})}
8789

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

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

99+
private checkIfRequiredFieldEmpty = () : void => {
100+
let disabled = false;
101+
102+
elements.forEach((x : string) => {
103+
// @ts-ignore
104+
let element = this.state.compositeValue[x];
105+
if(element.attributes.RequiredLevel == 2 && (element.raw == undefined || element.raw == ""))
106+
disabled = true;
107+
108+
});
109+
110+
this.setState({ buttonDisabled : disabled });
111+
}
112+
97113
/**
98114
* Ability to auto hide the callout on desktop and manually done on mobile
99115
* @param ev
@@ -116,6 +132,8 @@ export default class CompositeControl extends React.Component<ICompositeControlP
116132
// @ts-ignore
117133
compositeValue[target].raw = newValue!;
118134
this.setState({compositeValue : compositeValue});
135+
136+
this.checkIfRequiredFieldEmpty();
119137
}
120138

121139
/**

AnyCompositeFields/AnyCompositeFIelds/index.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,36 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
120120
visible : this._context.mode.isVisible,
121121
separator : this._context.parameters.separator.raw!,
122122
randNumber : Math.floor(Math.random()*(100-1+1)+1),
123+
buttonDisabled : this.checkIfRequiredFieldEmpty(),
123124
onClickedDone : (compositeValue? : CompositeValue) => {
124125
this._compositeValue = compositeValue!;
126+
this.buildFullValue();
125127
this.notifyOutputChanged();
126128
}
127129
}
128130

129-
ReactDOM.render(React.createElement(CompositeControl, optionsText), this._controlDiv);
131+
this._compositeComponent = ReactDOM.render(React.createElement(CompositeControl, optionsText), this._controlDiv);
130132
}
131133
else {
132134
_this.extractFieldsFromQVF();
133135
this._compositeComponent.setState({compositeValue : this._compositeValue, disabled : this._context.mode.isControlDisabled, visible : this._context.mode.isVisible});
134136
}
135137
}
136138

139+
private checkIfRequiredFieldEmpty = () : boolean => {
140+
let disabled = false;
141+
const elements = ['fieldValue1', 'fieldValue2', 'fieldValue3', 'fieldValue4', 'fieldValue5', 'fieldValue6', 'fieldValue7', 'fieldValue8'];
142+
elements.forEach((x) => {
143+
// @ts-ignore
144+
let element = this._compositeValue[x];
145+
if(element.attributes.RequiredLevel == 2 && element.raw == undefined)
146+
disabled = true;
147+
148+
});
149+
150+
return disabled;
151+
}
152+
137153
/**
138154
* Retrieve all parameters of the PCF control
139155
*/
@@ -177,6 +193,10 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
177193
finalValue += this._compositeValue["fieldValue"+fieldCount].raw;
178194
fieldCount++;
179195
}
196+
// @ts-ignore
197+
else if(this._compositeValue["fieldValue"+fieldCount]!.raw == null && splitValue[i] === "field"){
198+
// do nothing
199+
}
180200
else {
181201
let separator = splitValue[i];
182202
switch(separator){
@@ -200,9 +220,6 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
200220
finalValue = arrayValues.join(splitValue[0]);
201221
}
202222

203-
204-
205-
206223
this._compositeValue.fullValue = finalValue;
207224
}
208225

BICValidator/BicValidator/ControlManifest.Input.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest>
3-
<control namespace="Carfup" constructor="BicValidator" version="0.1.13" display-name-key="Carfup.BicValidator" description-key="BicValidator description" control-type="standard">
3+
<control namespace="Carfup" constructor="BicValidator" version="0.1.14" display-name-key="Carfup.BicValidator" description-key="BicValidator description" control-type="standard">
44
<!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
55
<property name="BICValue" display-name-key="BICValidator_BICValue" description-key="BIC field value" of-type="SingleLine.Text" usage="bound" required="true" />
66
<property name="IsValid" display-name-key="BICValidator_IsValid" description-key="Is BIC valid" of-type="TwoOptions" usage="bound" required="false" />

BICValidator/BicValidator/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class BicValidator implements ComponentFramework.StandardControl<IInputs,
8383
this._valueElement.removeAttribute("disabled");
8484
}
8585

86-
this.valueChanged(null, true);
86+
//this.valueChanged(null, true);
8787
}
8888

8989
/**

Carfup_PCFControls/Carfup_PCFControls.cdsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<ProjectReference Include="..\QuickEditForm\QuickEditForm.pcfproj" />
4848
<ProjectReference Include="..\QuickEditFormLookup\QuickEditFormLookup.pcfproj" />
4949
<ProjectReference Include="..\AnyCompositeFields\AnyCompositeFields.pcfproj" />
50+
<ProjectReference Include="..\EasyRollup\EasyRollupField.pcfproj" />
5051
</ItemGroup>
5152

5253
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />

Carfup_PCFControls/Other/Solution.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<LocalizedName description="Carfup_PCFControls" languagecode="1033" />
99
</LocalizedNames>
1010
<Descriptions />
11-
<Version>1.4.0.0</Version>
11+
<Version>1.4.0.1</Version>
1212
<!-- Solution Package Type: Unmanaged(0)/Managed(1)/Both(2)-->
1313
<Managed>2</Managed>
1414
<Publisher>

EasyRollup/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# generated directory
7+
**/generated
8+
9+
# output directory
10+
/out
11+
12+
# msbuild output directories
13+
/bin
14+
/obj
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest>
3+
<control namespace="Carfup" constructor="EasyRollupField" version="0.0.10" display-name-key="Carfup.EasyRollup" description-key="EasyRollup description" control-type="virtual">
4+
<property name="FieldToAttachControl" display-name-key="FieldToAttachControl" description-key="FieldToAttachControl" of-type-group="numbers" usage="bound" required="true" />
5+
<property name="RollupField" display-name-key="RollupField Logical Name" description-key="RollupField Logical Name" of-type="SingleLine.Text" usage="input" required="true" />
6+
<type-group name="numbers">
7+
<type>Currency</type>
8+
<type>FP</type>
9+
<type>Whole.None</type>
10+
<type>Decimal</type>
11+
<type>SingleLine.Text</type>
12+
</type-group>
13+
<resources>
14+
<code path="index.ts" order="1" />
15+
<platform-library name="React" version="16.8.6" />
16+
<platform-library name="Fluent" version="9.4.0" />
17+
</resources>
18+
<feature-usage>
19+
<uses-feature name="WebAPI" required="true" />
20+
<uses-feature name="Utility" required="true" />
21+
</feature-usage>
22+
</control>
23+
</manifest>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { IInputs } from "./generated/ManifestTypes";
2+
3+
export class EntityReferenceDef{
4+
public Id:string;
5+
public Name:string;
6+
public EntityName: string;
7+
public EntitySetName: string | null;
8+
}
9+
10+
export interface IRollupFieldControlProps {
11+
context : ComponentFramework.Context<IInputs>,
12+
entityRef : EntityReferenceDef,
13+
rollupField : string,
14+
clientUrl : string
15+
}

0 commit comments

Comments
 (0)