Skip to content

Commit

Permalink
Merge pull request #61 from carfup/revert-60-acf_phonehandling
Browse files Browse the repository at this point in the history
Revert "Acf phonehandling" - has to be merged on release first !
  • Loading branch information
carfup authored Sep 1, 2020
2 parents 387375a + 3f77a09 commit a7d7d8c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 223 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.75" 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.72" 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" />
Expand All @@ -20,9 +20,6 @@
<type>SingleLine.Email</type>
<type>SingleLine.Text</type>
<type>SingleLine.Phone</type>
<type>SingleLine.TextArea</type>
<type>SingleLine.URL</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 @@ -4,8 +4,6 @@ import { TextField, ITextFieldStyles } from '@fluentui/react/lib/TextField';
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 @@ -14,7 +12,6 @@ export interface ICompositeControlProps {
doneLabel : string;
randNumber: number;
onClickedDone : (compositeValue? : CompositeValue) => void;
context?: ComponentFramework.Context<IInputs>;
}

export interface IBCompositeControlState {
Expand Down Expand Up @@ -56,29 +53,24 @@ export default class CompositeControl extends React.Component<ICompositeControlP
{this.state.showCallout && (
<Callout
target={"#acf_compositeFullValue"+this.props.randNumber}
onDismiss={this.onDismissCallout}
onDismiss={() => this.setState({ showCallout : false }) }
styles={calloutStyles}
directionalHint={DirectionalHint.topCenter}
>
<Stack style={{margin : "10px"}}>
{elements.map((value, index) => {
// @ts-ignore
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) }}
/>
})}

Expand All @@ -91,12 +83,6 @@ export default class CompositeControl extends React.Component<ICompositeControlP
);
}

private onDismissCallout = (ev?: any) : void => {
if(this.props.context?.client.getClient() !== "Mobile"){
this.setState({ showCallout : false });
}
}

private onChangeField = (event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string | undefined) : void => {
// @ts-ignore
let target = event.target.id.replace('acf_', '');
Expand All @@ -113,47 +99,6 @@ export default class CompositeControl extends React.Component<ICompositeControlP
this.props.onClickedDone(this.state.compositeValue);
}

private onDoubleClick = (event: React.MouseEvent<HTMLInputElement | HTMLTextAreaElement, MouseEvent>) : void => {
// @ts-ignore
let target = event.target.id.replace('acf_', '');
const compositeValue = {...this.state}.compositeValue;
// @ts-ignore
var contextInfo = this.props.context?.mode.contextInfo;
// @ts-ignore
switch(compositeValue[target].type){
case "SingleLine.Phone":
// @ts-ignore
const currentValue : any = compositeValue[target].raw!;
this.props.context?.navigation.openUrl(`tel:${currentValue}`);
this.props.context?.navigation.openForm({
entityName : "phonecall",
createFromEntity : {
// @ts-ignore
id : contextInfo.entityId,
// @ts-ignore
entityType : contextInfo.entityTypeName,
// @ts-ignore
name : contextInfo.entityRecordName
}
});
this.setState({showCallout : false});
break;
case "SingleLine.URL":
// @ts-ignore
const currentValue : any = compositeValue[target].raw!;
this.props.context?.navigation.openUrl(`${currentValue}`);
break;
case "SingleLine.Email":
// @ts-ignore
const currentValue : any = compositeValue[target].raw!;
this.props.context?.navigation.openUrl(`mailto:${currentValue}`);
break;
default :
return;
}

}

private buildFullValue = (compositeValue : CompositeValue) : void => {
let arrayValues = [];

Expand All @@ -170,23 +115,5 @@ export default class CompositeControl extends React.Component<ICompositeControlP

this.setState({compositeValue : compositeValue});
}

private getIcon = (type: string) : string => {
let icon = "";

switch(type){
case "SingleLine.Phone" :
icon = "Phone";
break;
case "SingleLine.URL":
icon = "Globe";
break;
case "SingleLine.Email":
icon = "EditMail";
break;
}

return icon;
}
};

1 change: 0 additions & 1 deletion AnyCompositeFields/AnyCompositeFIelds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export class AnyCompositeFIelds implements ComponentFramework.StandardControl<II
);

let optionsText = {
context : this._context,
compositeValue : this._compositeValue,
doneLabel : this._context.resources.getString("Done"),
disabled : this._context.mode.isControlDisabled,
Expand Down
1 change: 0 additions & 1 deletion QuickEditForm/QuickEditForm/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<value name="true" display-name-key="True" description-key="true">true</value>
<value name="false" display-name-key="False" description-key="false">false</value>
</property>
<property name="NumberOfColumn" display-name-key="Number of columns" description-key="Ability to split the fields in several columns" of-type="Whole.None" usage="input" required="false" default-value="1"/>
<!--
Property node's of-type attribute can be of-type-group attribute.
Example:
Expand Down
2 changes: 0 additions & 2 deletions QuickEditForm/QuickEditForm/EntitiesDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export class EntityReferenceInfo{
public Id:string;
public Name:string;
public Attributes?: any;
public SchemaName?: string;
public QuickCreateEnabled?: boolean;
}

export class EntityReferenceIdName{
Expand Down
9 changes: 1 addition & 8 deletions QuickEditForm/QuickEditForm/components/MessageBarControl.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as React from 'react';
import {MessageBar, MessageBarType } from '@fluentui/react/lib/MessageBar';
import { MessageBarButton } from '@fluentui/react/lib/Button';


export interface IMessageProps {
messageType? : MessageBarType;
messageText? : string;
showMessageBar : boolean;
onClickQuickCreate: () => void;
showQuickCreateButton?: boolean;
}

export interface IMessageState {
Expand Down Expand Up @@ -36,11 +34,6 @@ export default class MessageBarControl extends React.Component<IMessageProps, IM
<div style={{marginTop: "5px"}}>
{this.state.showMessageBar &&
<MessageBar
actions={this.state.messageType == MessageBarType.info && this.props.showQuickCreateButton ? <div>
<MessageBarButton
onClick={this.props.onClickQuickCreate} >Open Quick Create Form
</MessageBarButton>
</div> : undefined}
messageBarType={this.state.messageType}
isMultiline={false}
dismissButtonAriaLabel="Close"
Expand Down
13 changes: 4 additions & 9 deletions QuickEditForm/QuickEditForm/components/TextFieldControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class TextFieldControl extends React.Component<ITextFieldControlP
super(props);
this.state = {
fieldDefinition: this.props.fieldDefinition,
type: props.icon === "NumberField" || props.icon === "Money" ? "number": "text",
type: props.icon === "Money" ? "number": "text",
};
}

Expand Down Expand Up @@ -69,15 +69,10 @@ export default class TextFieldControl extends React.Component<ITextFieldControlP
}

private grabValueFromFieldDefinition = (fieldDef : DataFieldDefinition | undefined) : string => {
let result = "";
if(this.state.fieldDefinition?.fieldValue?.Name != undefined) {
result = this.state.fieldDefinition?.fieldValue?.Name;
}
else {
result = this.state.fieldDefinition?.fieldValue;
}
if(this.state.fieldDefinition?.fieldValue?.Name !== undefined)
return this.state.fieldDefinition?.fieldValue?.Name;

return result;
return this.state.fieldDefinition?.fieldValue;
}

private onDoubleClick = (event: React.MouseEvent<HTMLInputElement | HTMLTextAreaElement, MouseEvent>) : void => {
Expand Down
Loading

0 comments on commit a7d7d8c

Please sign in to comment.