Skip to content

Commit

Permalink
Merge pull request #1477 from alexed1/DrawLineFix_1.0.1
Browse files Browse the repository at this point in the history
Bug Fix for validate error
  • Loading branch information
alexed1 authored Nov 14, 2023
2 parents 5432811 + 3dd107c commit 97373ea
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*
* Lightning Web Components: fsc_drawLineCPE
*
* 11/13/23 - Eric Smith - Version 1.0.1
* Bug Fixes: Line thickness attribute was causing an error when other components on the same screen had validation errors
*
* CREATED BY: Eric Smith
*
* VERSION: 1.0.0
Expand All @@ -26,7 +29,7 @@ export default class Fsc_drawLine extends LightningElement {
// Component Input Attributes
@api marginTop;
@api marginBottom;
@api thickness;
@api thickness='';
@api color;
@api vCard;
Expand All @@ -40,7 +43,7 @@ export default class Fsc_drawLine extends LightningElement {
}
get styleThickness() {
return (this.thickness) ? this.thickness : '1';
return (this.thickness) ? this.thickness : '1px';
}
get styleColor() {
Expand All @@ -52,11 +55,16 @@ export default class Fsc_drawLine extends LightningElement {
}

get lineStyle() {
return `border-width: ${this.styleThickness}px;border-color: ${this.styleColor};`;
return `border-width: ${this.styleThickness};border-color: ${this.styleColor};`;
}

get displayVCard() {
return (this.vCard === true) ? true : false;
}

// @api validate(){
// console.log("Draw Line entering validate: vCard=" + this.vCard);
// return { isValid: true };
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<masterLabel>Draw a Line</masterLabel>
<description>Similar to horizontalRule, use this component to add a line to a Flow Screen or Lightning Record Page - By Eric Smith</description>
<apiVersion>57.0</apiVersion>
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowScreen</target>
Expand All @@ -16,8 +16,8 @@
description="Size selection for the top margin (Default = none)"/>
<property name="marginBottom" type="String" label="Bottom Margin" default="xx-small"
description="Size selection for the bottom margin (Default = xx-small)"/>
<property name="thickness" type="String" label="Line Thickness" default="1"
description="Number of pixels for the line thickness (Default = 1)"/>
<property name="thickness" type="String" label="Line Thickness" default="1px"
description="Number of pixels for the line thickness (Default = 1px)"/>
<property name="color" type="String" label="Line Color" default="Gray"
description="Color code for the line (Default = Gray)"/>
</targetConfig>
Expand All @@ -28,8 +28,8 @@
<property name="marginBottom" type="String" label="Bottom Margin" default="large"
datasource="none,xxx-small,xx-small,x-small,small,medium,large,x-large,xx-large"
description="Size selection for the bottom margin (Default = large)"/>
<property name="thickness" type="String" label="Line Thickness" default="1"
description="Number of pixels for the line thickness (Default = 1)"/>
<property name="thickness" type="String" label="Line Thickness" default="1px"
description="Number of pixels for the line thickness (Default = 1px)"/>
<property name="color" type="String" label="Line Color" default="Gray"
description="Color code for the line (Default = Gray)"/>
<property name="vCard" type="Boolean" label="Display as vCard?" default="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<lightning-slider
name="select_thickness"
label={inputValues.thickness.label}
value={inputValues.thickness.value}
value={thicknessPixels}
min="1"
max="30"
step="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
* Attributes are available for vetical margins, color and thickness.
*
* This component is packaged as part of the unofficialsf.com FlowScreenComponentsBasePack
*
* 11/13/23 - Eric Smith - Version 1.0.1
* Bug Fixes: Line thickness attribute was causing an error when other components on the same screen had validation errors
*
* CREATED BY: Eric Smith
*
* VERSION: 1.0.0
*
* DATE: 4/11/2023
*
*
*
**/

import { LightningElement, api, track } from 'lwc';

const VERSION_NUMBER = "1.0.0";
const VERSION_NUMBER = "1.0.1";

const defaults = {
inputAttributePrefix: "select_",
Expand Down Expand Up @@ -53,6 +57,10 @@ export default class Fsc_drawLineCPE extends LightningElement {
return this.inputValues['thickness'].value;
}

get thicknessPixels() {
return this.inputValues['thickness'].value.slice(0,-2);
}

get styleColor() {
return this.inputValues['color'].value;
}
Expand All @@ -62,7 +70,7 @@ export default class Fsc_drawLineCPE extends LightningElement {
}

get lineStyle() {
return `border-width: ${this.styleThickness}px;border-color: ${this.styleColor};`;
return `border-width: ${this.styleThickness};border-color: ${this.styleColor};`;
}

// Define any banner overrides you want to use (see fsc_flowBanner.js)
Expand Down Expand Up @@ -149,11 +157,11 @@ export default class Fsc_drawLineCPE extends LightningElement {
helpText: "Size selection for the bottom margin (Default = xx-small)"
},
thickness: {
value: "1",
value: "1px",
valueDataType: null,
isCollection: false,
label: "Line Thickness",
helpText: "Number of pixels for the line thickness (Default = 1)"
helpText: "Number of pixels for the line thickness (Default = 1px)"
},
color: {
value: "#808080",
Expand Down Expand Up @@ -262,9 +270,12 @@ export default class Fsc_drawLineCPE extends LightningElement {
curInputParam.valueDataType;

// Handle any internal value settings based on attribute values here
// if (curInputParam.name == 'objectName') {
// this.selectedSObject = curInputParam.value;
// }
if (curInputParam.name == "thickness") {
if (this.inputValues[curInputParam.name].value.toString().slice(-1) != "x") {
this.inputValues[curInputParam.name].value += "px";
this.inputValues[curInputParam.name].valueDataType = "String";
}
}

}
if (curInputParam.isError) {
Expand Down Expand Up @@ -318,8 +329,8 @@ export default class Fsc_drawLineCPE extends LightningElement {
defaults.inputAttributePrefix,
""
);
let newValue = event.detail.value;
this.dispatchFlowValueChangeEvent(changedAttribute, newValue, "Number");
let newValue = event.detail.value.toString() + "px";
this.dispatchFlowValueChangeEvent(changedAttribute, newValue, "String");
}

handleFlowComboboxValueChange(event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>57.0</apiVersion>
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Draw Line CPE</masterLabel>
<description>CPE for the fsc_drawLine LWC</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ export default class FlowButtonBar extends LightningElement {
// Don't unselect a button if it is both required and the only selected button
if (!this.required || this.values.length > 1)
this.values.splice(curIndex, 1);
if (!this.multiselect) {
this.value = clickedValue;
}
} else {
if (this.multiselect) {
this.values.push(clickedValue);
Expand Down Expand Up @@ -329,4 +332,4 @@ export default class FlowButtonBar extends LightningElement {
}
}
*/
}
}

0 comments on commit 97373ea

Please sign in to comment.