From afb6e6b05a7bc5d701bb28fc9f15148d2e89ee87 Mon Sep 17 00:00:00 2001 From: Jeff Kranz <40637750+jkranz-rk@users.noreply.github.com> Date: Fri, 23 Sep 2022 00:16:23 -0500 Subject: [PATCH] Jkranz rk/issue18 (#19) (#20) * Setting "Show Description" toggle to False in CPE doesn't save attribute to Flow Properties Fixes #18 See discussion on issue. Flow Builder Runtime will send Strings instead of Boolean values to CPE, so this update transforms those strings to Booleans, and then back again. Also changed the approach, using "hideDescription" with a default of False instead of "showDescription" with a default of True. Bad practice to use true as default for Element attributes, so flipped that. This is an "under the hood" change, as CPE UI still presents as "Show Description" because from the User perspective, it feels more natural to be active when you are showing the descriptions, and then toggle off to hide * Added an icon. Pretty! * Created a separate scratch org def file for spinning up a test install during package testing * bump to v0.3! --- README.md | 2 +- config/project-scratch-installtesting.json | 5 ++ sfdx-project.json | 16 ++++-- .../classes/RecordTypePickerController.cls | 2 + src/main/default/lwc/cpeHelper/cpeHelper.js | 22 ++++++-- .../lwc/recordTypePicker/recordTypePicker.js | 30 ++++++----- .../recordTypePicker.js-meta.xml | 20 +++++--- .../recordTypeRadioGroup.html | 4 +- .../recordTypeVisualPicker.html | 2 +- .../recordTypePickerCpe.html | 2 +- .../recordTypePickerCpe.js | 50 ++++++++++++++++--- .../recordTypePickerCpeInputs.html | 5 +- .../recordTypePickerCpeInputs.js | 9 +++- 13 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 config/project-scratch-installtesting.json diff --git a/README.md b/README.md index c14af6c..c4b91db 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ NOTE ABOUT THE TEST DIRECTORY: the "test" directory is _not_ needed for sandbox ## Latest Released Unlocked Package Install URL -`/packaging/installPackage.apexp?p0=04t4x000000RUUUAA4` +`/packaging/installPackage.apexp?p0=04t4x000000RqyHAAS` ## Display Types diff --git a/config/project-scratch-installtesting.json b/config/project-scratch-installtesting.json new file mode 100644 index 0000000..7dd49eb --- /dev/null +++ b/config/project-scratch-installtesting.json @@ -0,0 +1,5 @@ +{ + "orgName": "RecordType Picker Install Testing", + "edition": "Enterprise", + "features": [] + } \ No newline at end of file diff --git a/sfdx-project.json b/sfdx-project.json index 9d74b8a..c8a114c 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -4,8 +4,8 @@ "path": "src", "default": true, "package": "Record Type Picker", - "versionName": "ver 0.1", - "versionNumber": "0.1.0.NEXT", + "versionName": "ver 0.3", + "versionNumber": "0.3.0.NEXT", "unpackagedMetadata": { "path": "tests" }, @@ -13,14 +13,16 @@ "permissionSets": [ "RecordTypePickerPermissionsTesting" ] - } + }, + "releaseNotesUrl": "https://github.com/jkranz-rk/RecordTypePicker", + "postInstallUrl": "https://github.com/jkranz-rk/RecordTypePicker" }, { "path": "tests" } ], "name": "RecordTypePicker", - "namespace": "", + "namespace": "rtp", "sfdcLoginUrl": "https://login.salesforce.com", "sourceApiVersion": "55.0", "packageAliases": { @@ -28,6 +30,10 @@ "Record Type Picker@0.1.0-1-feature/unlockedpackaging": "04t4x000000RUQ2AAO", "Record Type Picker@0.1.0-2-feature/unlockedpackaging": "04t4x000000RUQ7AAO", "Record Type Picker@0.1.0-3-feature/unlockedpackaging": "04t4x000000RUQCAA4", - "Record Type Picker@0.1.0-2": "04t4x000000RUUUAA4" + "Record Type Picker@0.1.0-2": "04t4x000000RUUUAA4", + "Record Type Picker@0.2.0-2": "04t4x000000RqffAAC", + "Record Type Picker@0.2.0-3": "04t4x000000RqfkAAC", + "Record Type Picker@0.2.0-4": "04t4x000000RqyCAAS", + "Record Type Picker@0.3.0-1": "04t4x000000RqyHAAS" } } \ No newline at end of file diff --git a/src/main/default/classes/RecordTypePickerController.cls b/src/main/default/classes/RecordTypePickerController.cls index 41b214a..2b9287f 100644 --- a/src/main/default/classes/RecordTypePickerController.cls +++ b/src/main/default/classes/RecordTypePickerController.cls @@ -40,6 +40,8 @@ global with sharing class RecordTypePickerController { @InvocableMethod( label='Record Types for Running User' description='Input an Object\'s API name, returns a collection of Record Types that are available to the running user' + category='Record Types' + iconName='slds:standard:relationship' ) /** */ diff --git a/src/main/default/lwc/cpeHelper/cpeHelper.js b/src/main/default/lwc/cpeHelper/cpeHelper.js index 310e38b..4e8008f 100644 --- a/src/main/default/lwc/cpeHelper/cpeHelper.js +++ b/src/main/default/lwc/cpeHelper/cpeHelper.js @@ -33,6 +33,20 @@ const flowConstants = { } }; +const convertBooleanFlowToReal = (boolVal) => { + if (boolVal === '$GlobalConstant.True') { + return true; + } else if (boolVal === '$GlobalConstant.False') { + return false; + } else { + return boolVal; + } +}; + +const convertBooleanRealToFlow = (boolVal) => { + return boolVal ? '$GlobalConstant.True' : '$GlobalConstant.False'; +}; + const defaultProperties = { objectApiName : { name : 'objectApiName', @@ -49,9 +63,9 @@ const defaultProperties = { value : 'picker', valueDataType : 'String' }, - showDescription : { - name : 'showDescription', - value : true, + hideDescriptions : { + name : 'hideDescriptions', + value : false, valueDataType : 'Boolean' }, autoNavigateNext : { @@ -61,4 +75,4 @@ const defaultProperties = { } }; -export {notifyPropertyChange, flowConstants, defaultProperties}; \ No newline at end of file +export {notifyPropertyChange, flowConstants, defaultProperties, convertBooleanFlowToReal, convertBooleanRealToFlow}; \ No newline at end of file diff --git a/src/main/default/lwc/recordTypePicker/recordTypePicker.js b/src/main/default/lwc/recordTypePicker/recordTypePicker.js index 7e3d46d..8847463 100644 --- a/src/main/default/lwc/recordTypePicker/recordTypePicker.js +++ b/src/main/default/lwc/recordTypePicker/recordTypePicker.js @@ -15,16 +15,17 @@ export default class RecordTypePicker extends LightningElement { @api availableRecordTypes; @api objectApiName; - @api label; + + @api get label(){ return this._label; } set label(val){ this._label = val; } - _label = 'Select a RecordType'; + _label = 'Select a Record Type'; - @api autoNavigateNext; + @api get autoNavigateNext(){ return this._autoNavigateNext; } @@ -33,16 +34,16 @@ export default class RecordTypePicker extends LightningElement { } _autoNavigateNext = false; - @api showDescription; - get showDescription(){ - return this._showDescription; + @api + get hideDescriptions(){ + return this._hideDescriptions; } - set showDescription(val){ - this._showDescription = val; + set hideDescriptions(val){ + this._hideDescriptions = val; } - _showDescription = true; + _hideDescriptions; - @api displayType; + @api get displayType(){ return this._displayType; } @@ -51,7 +52,7 @@ export default class RecordTypePicker extends LightningElement { } _displayType = 'picker'; - @api mode; + @api get mode(){ return this._mode; } @@ -60,6 +61,10 @@ export default class RecordTypePicker extends LightningElement { } _mode = 'live'; + // deprecated in favor of hideDescriptions, since we want the default + // value to be `True`, its a bad practice to set boolean defaults to `True` + @api showDescription; + _error; _selectedValue; @@ -108,7 +113,7 @@ export default class RecordTypePicker extends LightningElement { }; get picklistOptions(){ - if (this.showDescription){ + if (!this.hideDescriptions){ return this.availableRecordTypes.map((rt) => { return { value: rt.Id, @@ -124,7 +129,6 @@ export default class RecordTypePicker extends LightningElement { }; }); } - } handleChange(event){ diff --git a/src/main/default/lwc/recordTypePicker/recordTypePicker.js-meta.xml b/src/main/default/lwc/recordTypePicker/recordTypePicker.js-meta.xml index aa35e14..a075182 100644 --- a/src/main/default/lwc/recordTypePicker/recordTypePicker.js-meta.xml +++ b/src/main/default/lwc/recordTypePicker/recordTypePicker.js-meta.xml @@ -10,7 +10,7 @@ + configurationEditor="rtp-record-type-picker-cpe"> + \ No newline at end of file diff --git a/src/main/default/lwc/recordTypePicker/recordTypeRadioGroup.html b/src/main/default/lwc/recordTypePicker/recordTypeRadioGroup.html index 9811eb8..b879176 100644 --- a/src/main/default/lwc/recordTypePicker/recordTypeRadioGroup.html +++ b/src/main/default/lwc/recordTypePicker/recordTypeRadioGroup.html @@ -9,7 +9,7 @@