-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from SFDO-Community/feature/indicator-builder
Level set work between standard interface branches
- Loading branch information
Showing
45 changed files
with
2,066 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,4 @@ package.xml | |
**/profiles/** | ||
**/settings/** | ||
**/Account/** | ||
**/Contact/** | ||
|
||
**/unpackaged/** | ||
**/Contact/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
force-app/main/default/lwc/indicatorBuilder/__tests__/indicatorBuilder.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createElement } from 'lwc'; | ||
import IndicatorBuilder from 'c/indicatorBuilder'; | ||
|
||
describe('c-indicator-builder', () => { | ||
afterEach(() => { | ||
// The jsdom instance is shared across test cases in a single file so reset the DOM | ||
while (document.body.firstChild) { | ||
document.body.removeChild(document.body.firstChild); | ||
} | ||
}); | ||
|
||
it('TODO: test case generated by CLI command, please fill in test logic', () => { | ||
// Arrange | ||
const element = createElement('c-indicator-builder', { | ||
is: IndicatorBuilder | ||
}); | ||
|
||
// Act | ||
document.body.appendChild(element); | ||
|
||
// Assert | ||
// const div = element.shadowRoot.querySelector('div'); | ||
expect(1).toBe(1); | ||
}); | ||
}); |
80 changes: 80 additions & 0 deletions
80
force-app/main/default/lwc/indicatorBuilderExtension/indicatorBuilderExtension.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<template> | ||
<template lwc:if={activeVariant}> | ||
<div class="slds-grid slds-gutters"> | ||
<div class="slds-col slds-size_3-of-4 slds-grid slds-wrap slds-border_right"> | ||
<div class="variantDesign slds-col slds-size_1-of-1 slds-p-bottom_x-small"> | ||
<p class="slds-text-heading_small">Design</p> | ||
<lightning-input label="Indicator Label" value={activeVariant.label} data-property="label" | ||
oncommit={handleVariantPropertyChange}></lightning-input> | ||
<lightning-combobox label="Select Icon Source" options={iconSourceOptions} | ||
value={activeVariant.iconSource} dropdown-alignment="auto" data-property="iconSource" | ||
onchange={handleVariantPropertyChange}></lightning-combobox> | ||
<div class="iconSourceInputs"> | ||
<template lwc:if={iconSourceIs.sldsIcon}> | ||
<c-fsc_combobox label="Select Icon" options={iconOptions} icon-size="small" | ||
value={activeVariant.sourceValue} data-property="sourceValue" | ||
onchange={handleVariantPropertyChange}></c-fsc_combobox> | ||
</template> | ||
<template lwc:elseif={iconSourceIs.url}> | ||
<lightning-input label="Enter URL" value={activeVariant.sourceValue} | ||
data-property="sourceValue" onchange={handleVariantPropertyChange}></lightning-input> | ||
</template> | ||
<template lwc:elseif={iconSourceIs.staticResource}> | ||
<lightning-input label="Select Static Resource" value={activeVariant.sourceValue} | ||
data-property="sourceValue" onchange={handleVariantPropertyChange}></lightning-input> | ||
</template> | ||
<template lwc:elseif={iconSourceIs.staticText}> | ||
<lightning-input label="Enter Static Text" value={activeVariant.sourceValue} | ||
class="slds-p-top_xxx-small" data-property="sourceValue" | ||
onchange={handleVariantPropertyChange}></lightning-input> | ||
</template> | ||
<lightning-input label="Hover Text" value={activeVariant.hoverText} data-property="hoverText" | ||
onchange={handleVariantPropertyChange}></lightning-input> | ||
<template lwc:if={showColourOption}> | ||
<lightning-input label="Override Colours" type="checkbox" data-property="overrideColours" | ||
checked={activeVariant.overrideColours} | ||
onchange={handleVariantPropertyChange}></lightning-input> | ||
</template> | ||
<template lwc:if={showColourSelectors}> | ||
<lightning-input label="Select Foreground Colour" type="color" | ||
data-property="foregroundColour" value={activeVariant.foregroundColour} | ||
onchange={handleVariantPropertyChange}></lightning-input> | ||
<lightning-input label="Select Background Colour" type="color" | ||
data-property="backgroundColour" value={activeVariant.backgroundColour} | ||
onchange={handleVariantPropertyChange}></lightning-input> | ||
</template> | ||
|
||
</div> | ||
</div> | ||
<template lwc:if={activeVariant.isExtension}> | ||
<div class="variantLogic slds-col slds-size_1-of-1 slds-p-top_x-small"> | ||
<p class="slds-text-heading_small">Extension Logic</p> | ||
<lightning-combobox label="Show When Field:" options={activeWhenToDisplayOptions} | ||
value={activeVariant.whenToDisplay} data-property="whenToDisplay" | ||
onchange={handleVariantPropertyChange} dropdown-alignment="auto"></lightning-combobox> | ||
<template lwc:if={filterTypeIs.text}> | ||
<lightning-input label="Text"></lightning-input> | ||
</template> | ||
<template lwc:elseif={filterTypeIs.number}> | ||
<lightning-input label="Number" type="number"></lightning-input> | ||
</template> | ||
<template lwc:elseif={filterTypeIs.numericRange}> | ||
<lightning-input label="Greater Than or Equal To" type="number"></lightning-input> | ||
<lightning-input label="Less Than" type="number"></lightning-input> | ||
</template> | ||
</div> | ||
</template> | ||
</div> | ||
<div> | ||
<h2 class="slds-text-heading_small slds-col">Preview</h2> | ||
<div class="slds-col"> | ||
<c-indicator-bundle-item icon-source={activeVariant.iconSource} | ||
source-value={activeVariant.sourceValue} ind-size="large" | ||
ind-foreground-color={activeVariant.foregroundColour} | ||
ind-background-color={activeVariant.backgroundColour} ind-hover-text={activeVariant.hoverText}> | ||
</c-indicator-bundle-item> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
</template> |
87 changes: 87 additions & 0 deletions
87
force-app/main/default/lwc/indicatorBuilderExtension/indicatorBuilderExtension.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { LightningElement, api, track } from 'lwc'; | ||
|
||
const FIELD_TYPE_CATEGORIES = { | ||
TEXT: ['Reference', 'Address', 'Email', 'Location', 'Phone', 'Picklist', 'ComboBox', 'MultiPicklist', 'String', 'TextArea', 'EncryptedString', 'URL'], | ||
NUMERIC: ['Currency', 'Number', 'Percent', 'Integer', 'Double', 'Int', 'Long'], | ||
DATE: ['Date', 'DateTime', 'Time'], | ||
BOOLEAN: ['Boolean'], | ||
} | ||
|
||
export default class IndicatorBuilderExtension extends LightningElement { | ||
@api indicator = {}; | ||
@api activeVariant = {}; | ||
@api iconOptions = []; | ||
|
||
get activeVariantString() { | ||
return JSON.stringify(this.activeVariant); | ||
} | ||
|
||
get iconSourceIs() { | ||
return { [this.activeVariant.iconSource]: true } | ||
} | ||
|
||
get filterTypeIs() { | ||
let matchingOption = this.whenToDisplayOptions.find(option => option.value == this.activeVariant.whenToDisplay); | ||
return matchingOption ? { [matchingOption.showMatch]: true } : {}; | ||
} | ||
|
||
get showColourOption() { | ||
return this.iconSourceIs.sldsIcon; | ||
} | ||
get showColourSelectors() { | ||
return this.iconSourceIs.staticText || (this.showColourOption && this.activeVariant.overrideColours); | ||
} | ||
|
||
get activeWhenToDisplayOptions() { | ||
return this.whenToDisplayOptions.filter(option => option.fieldTypes.includes(this.indicator.fieldType)); | ||
} | ||
|
||
iconSourceOptions = [ | ||
{ label: 'Lightning Icon', value: 'sldsIcon' }, | ||
{ label: 'Static Text', value: 'staticText' }, | ||
{ label: 'URL', value: 'url' }, | ||
{ label: 'Static Resource', value: 'staticResource' }, | ||
]; | ||
|
||
whenToDisplayOptions = [ | ||
// { label: 'Is not blank', value: 'notBlank', fieldTypes: [...FIELD_TYPE_CATEGORIES.TEXT, ...FIELD_TYPE_CATEGORIES.NUMERIC, ...FIELD_TYPE_CATEGORIES.DATE] }, | ||
// { label: 'Is blank', value: 'isBlank', fieldTypes: [...FIELD_TYPE_CATEGORIES.TEXT, ...FIELD_TYPE_CATEGORIES.NUMERIC, ...FIELD_TYPE_CATEGORIES.DATE] }, | ||
{ label: 'Contains text', value: 'containsText', fieldTypes: FIELD_TYPE_CATEGORIES.TEXT, showMatch: 'text' }, | ||
{ label: 'Equals', value: 'equalsText', fieldTypes: FIELD_TYPE_CATEGORIES.TEXT, showMatch: 'text' }, | ||
{ label: 'Equals', value: 'equalsNumber', fieldTypes: [...FIELD_TYPE_CATEGORIES.NUMERIC, ...FIELD_TYPE_CATEGORIES.DATE], showMatch: 'number' }, | ||
{ label: 'Is greater than', value: 'greaterThan', fieldTypes: [...FIELD_TYPE_CATEGORIES.NUMERIC, ...FIELD_TYPE_CATEGORIES.DATE], showMatch: 'number' }, | ||
{ label: 'Is less than', value: 'lessThan', fieldTypes: [...FIELD_TYPE_CATEGORIES.NUMERIC, ...FIELD_TYPE_CATEGORIES.DATE], showMatch: 'number' }, | ||
{ label: 'Is within range', value: 'inRange', fieldTypes: [...FIELD_TYPE_CATEGORIES.NUMERIC, ...FIELD_TYPE_CATEGORIES.DATE], showMatch: 'numericRange' }, | ||
{ label: 'Is true', value: 'isTrue', fieldTypes: FIELD_TYPE_CATEGORIES.BOOLEAN, showMatch: 'boolean' }, | ||
{ label: 'Is false', value: 'isFalse', fieldTypes: FIELD_TYPE_CATEGORIES.BOOLEAN, showMatch: 'boolean' }, | ||
]; | ||
|
||
connectedCallback() { | ||
} | ||
|
||
handleVariantPropertyChange(event) { | ||
if (event.currentTarget.dataset.property) { | ||
let target = event.currentTarget; | ||
let tagName = target.tagName.toLowerCase(); | ||
let value; | ||
if (tagName === 'c-icon-selector') { | ||
value = event.detail; | ||
} else if (target.type === 'checkbox') { | ||
value = target.checked; | ||
} else if (tagName === 'lightning-combobox') { | ||
value = event.detail.value; | ||
} else { | ||
value = target.value; | ||
} | ||
|
||
let variant = { ...this.activeVariant }; | ||
|
||
variant[target.dataset.property] = value; | ||
if (target.dataset.property === 'iconSource') { | ||
variant.sourceValue = null; | ||
} | ||
|
||
this.dispatchEvent(new CustomEvent('variantchange', { detail: variant })); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/lwc/indicatorBuilderExtension/indicatorBuilderExtension.js-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>61.0</apiVersion> | ||
<isExposed>false</isExposed> | ||
</LightningComponentBundle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 13 additions & 11 deletions
24
force-app/main/default/lwc/indicatorBundleItem/indicatorBundleItem.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<template> | ||
<template if:false={record}> | ||
<lightning-avatar | ||
size={indSize} | ||
variant={indShape} | ||
initials={indText} | ||
src={indImage} | ||
fallback-icon-name={indIcon} | ||
alternative-text={indHoverText} | ||
class={indClass}> | ||
</lightning-avatar> | ||
</template> | ||
<div class="slds-var-m-bottom_x-small slds-float_left"> | ||
<template if:false={record}> | ||
<lightning-avatar | ||
size={indSize} | ||
variant={indShape} | ||
initials={indText} | ||
src={indImage} | ||
fallback-icon-name={indIcon} | ||
alternative-text={indHoverText} | ||
class={indClass}> | ||
</lightning-avatar> | ||
</template> | ||
</div> | ||
</template> |
Oops, something went wrong.