- {param.label}
+ {param.label}
|
diff --git a/force-app/main/default/lwc/simpliUIListViewsActionModal/simpliUIListViewsActionModal.js b/force-app/main/default/lwc/simpliUIListViewsActionModal/simpliUIListViewsActionModal.js
index 6be1529..066accb 100644
--- a/force-app/main/default/lwc/simpliUIListViewsActionModal/simpliUIListViewsActionModal.js
+++ b/force-app/main/default/lwc/simpliUIListViewsActionModal/simpliUIListViewsActionModal.js
@@ -1,5 +1,5 @@
-import { LightningElement, wire, track, api } from 'lwc';
-import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+/* eslint-disable no-console */
+import { LightningElement, track, api } from 'lwc';
import * as SLVHelper from 'c/simpliUIListViewsHelper';
//------------------------ LABELS ------------------------
@@ -21,14 +21,14 @@ export default class simpliUIListViewsActionModal extends LightningElement {
@api showModal; //indicates whether this modal dialog should be displayed or not.
@api actionApiName; //the action that was clicked on.
@api recordIds; //the record ids of the records to be updated
- @api virtual = false; //indicates whether the list view is displaying data virtually from another org.
+ @api virtual = false; //indicates whether the list view is displaying data virtually from another org.
@track recordCount; //the number of record Ids passed in. Only used in the UI.
@track listViewAction; //holds the action data for the provided action API name.
- @track hasParameters = true; //indicates whether the action has parameters
+ @track hasParameters = true; //indicates whether the action has parameters
@track requestDataMap = new Map(); //holds the map of field/value request data
- @track spinner = false; //identifies if the spinner should be displayed or not.
- @track isInitialized = false;
- @track calloutCount = 1; //indicates the number of callouts made for this component
+ @track spinner = false; //identifies if the spinner should be displayed or not.
+ @track isInitialized = false;
+ @track calloutCount = 1; //indicates the number of callouts made for this component
label = { Close, Value, Field_Name, Process, Cancel, Continue_Processing, Selected_Records_With, Action };
@@ -39,77 +39,68 @@ export default class simpliUIListViewsActionModal extends LightningElement {
renderedCallback() {
- if (this.showModal === true && !this.isInitialized && this.recordIds !== undefined)
- {
- var parsedIds = JSON.parse(this.recordIds);
- this.recordCount = parsedIds.length;
+ if (this.showModal === true && !this.isInitialized && this.recordIds !== undefined) {
+ const parsedIds = JSON.parse(this.recordIds);
+ this.recordCount = parsedIds.length;
- if (this.recordCount === 1)
- {
+ if (this.recordCount === 1) {
this.spinner = true;
console.log('simpliUIListViewsActionModal CALLOUT - getActionAndData - ' + this.calloutCount++);
- getListViewActionAndData({ actionName: this.actionApiName, dataIds: this.recordIds})
- .then(result => {
- console.log('getListViewActionAndData successfully called');
- this.listViewAction = result;
- this.hasParameters = this.listViewAction.hasDisplayParameters;
- this.spinner = false;
-
- this.listViewAction.displayParameters.forEach(element => {
-
- if (element.value !== null)
- {
- if (element.type === 'datetime' || element.type === 'date' || element.type === 'time')
- {
- this.requestDataMap.set(element.aPIName, element.uIValue);
- console.log('Setting UI key/value - ' + element.aPIName + '/' + element.uIValue);
- } else {
- this.requestDataMap.set(element.aPIName, element.value);
- console.log('Setting key/value - ' + element.aPIName + '/' + element.value);
- }
- }
- });
- })
- .catch(error => {
- console.log('Error Detected - ' + error.message + ' | ' + error.stackTrace);
- this.spinner = false;
- return;
- });
-
+ getListViewActionAndData({ actionName: this.actionApiName, dataIds: this.recordIds })
+ .then(result => {
+ console.log('getListViewActionAndData successfully called');
+ this.listViewAction = result;
+ this.hasParameters = this.listViewAction.hasDisplayParameters;
+
+ this.listViewAction.displayParameters.forEach(element => {
+
+ if (element.value !== null) {
+ if (element.type === 'datetime' || element.type === 'date' || element.type === 'time') {
+ this.requestDataMap.set(element.aPIName, element.uIValue);
+ console.log('Setting UI key/value - ' + element.aPIName + '/' + element.uIValue);
+ } else {
+ this.requestDataMap.set(element.aPIName, element.value);
+ console.log('Setting key/value - ' + element.aPIName + '/' + element.value);
+ }
+ }
+ });
+ })
+ .catch(error => {
+ console.log('Error Detected - ' + error.message + ' | ' + error.stackTrace);
+ }).finally(() => {
+ this.spinner = false;
+ });
+
} else {
this.spinner = true;
console.log('simpliUIListViewsActionModal CALLOUT - getListViewAction - ' + this.calloutCount++);
- getListViewAction({ actionName: this.actionApiName})
- .then(result => {
- console.log('getListViewAction successfully called');
- this.listViewAction = result;
- this.hasParameters = this.listViewAction.hasDisplayParameters;
- this.spinner = false;
- })
- .catch(error => {
- console.log('Error Detected - ' + error.message + ' | ' + error.stackTrace);
- this.spinner = false;
- return;
- });
+ getListViewAction({ actionName: this.actionApiName })
+ .then(result => {
+ console.log('getListViewAction successfully called');
+ this.listViewAction = result;
+ this.hasParameters = this.listViewAction.hasDisplayParameters;
+ })
+ .catch(error => {
+ console.log('Error Detected - ' + error.message + ' | ' + error.stackTrace);
+ }).finally(() => {
+ this.spinner = false;
+ });
}
-
this.isInitialized = true;
-
}
-
}
handleProcessClick() {
this.spinner = true;
- var resultStr;
- var valuesMap = new Map();
- var strValuesMap;
+ let resultStr;
+ let valuesMap = new Map();
+ let strValuesMap;
//get all the non-displayed parameters into the request data map
- this.listViewAction.nonDisplayParameters.forEach(element => {
+ this.listViewAction.nonDisplayParameters.forEach(element => {
this.requestDataMap.set(element.aPIName, element.value);
- });
+ });
//get all the externally named values into a JSON string
for (let [k, v] of this.requestDataMap) {
@@ -117,14 +108,14 @@ export default class simpliUIListViewsActionModal extends LightningElement {
valuesMap.set(k, v);
}
- strValuesMap = JSON.stringify( Array.from(valuesMap) );
+ strValuesMap = JSON.stringify(Array.from(valuesMap));
console.log('Action name - ' + this.actionApiName);
console.log('Data - ' + this.recordIds);
console.log('Field/Value - ' + strValuesMap);
if (this.virtual) {
- this.dispatchEvent(new CustomEvent('runaction', { detail: {action: this.listViewAction, valuesMap: strValuesMap }}));
+ this.dispatchEvent(new CustomEvent('runaction', { detail: { action: this.listViewAction, valuesMap: strValuesMap } }));
this.spinner = false;
this.recordCount = undefined;
this.isInitialized = false;
@@ -133,72 +124,72 @@ export default class simpliUIListViewsActionModal extends LightningElement {
}
console.log('simpliUIListViewsActionModal CALLOUT - processAction - ' + this.calloutCount++);
- processAction({ actionKey: this.actionApiName, dataIds: this.recordIds, valuesMap: strValuesMap})
+ processAction({ actionKey: this.actionApiName, dataIds: this.recordIds, valuesMap: strValuesMap })
.then(result => {
resultStr = result;
//get the status
let status = resultStr.substring(0, resultStr.indexOf(':'));
-
+
//get any associated message
- let message = resultStr.substring(resultStr.indexOf(':')+1);
+ let message = resultStr.substring(resultStr.indexOf(':') + 1);
if (message === '' && status === 'Ok') {
message = 'All records have been processed successfully.';
- } else if (message === '' && status != 'Ok') {
+ } else if (message === '' && status !== 'Ok') {
message = 'There was an error processing the records.';
}
if (status === 'Ok') {
- this.dispatchEvent(SLVHelper.createToast('success', '', this.listViewAction.label + ' Completed!', message, false));
- this.spinner = false;
+ this.dispatchEvent(SLVHelper.createToast('success', '', this.listViewAction.label + ' Completed!', message, false));
this.recordCount = undefined;
this.isInitialized = false;
this.listViewAction = undefined;
this.dispatchEvent(new CustomEvent('processed'));
-
+
} else {
- this.dispatchEvent(SLVHelper.createToast('error', '', 'Processing Error', message, false));
- this.spinner = false;
- return;
+ this.dispatchEvent(SLVHelper.createToast('error', '', 'Processing Error', message, false));
}
})
.catch(error => {
resultStr = undefined;
- this.dispatchEvent(SLVHelper.createToast('error', error, 'Processing Error', 'There was an error processing the records - ', true));
+ this.dispatchEvent(SLVHelper.createToast('error', error, 'Processing Error', 'There was an error processing the records - ', true));
+ }).finally(() => {
this.spinner = false;
- return;
- });
+ });
}
-
+
//called when a value is changed.
handleValueUpdate(event) {
+ try {
+ const { currentTarget, target, detail } = event;
+ //if data is coming in from a component
+ let fieldValue = '';
+ let fieldName = '';
+
+ //if data is coming in from a component
+ if (currentTarget?.dataset?.type === undefined) {
+ fieldValue = detail?.selectedValue ?? '';
+ fieldName = detail?.field ?? '';
- //if data is coming in from a component
- let fieldValue = '';
- let fieldName = '';
-
- //if data is coming in from a component
- if (event.currentTarget.dataset.type === undefined)
- {
- fieldValue = event.detail.selectedValue;
- fieldName = event.detail.field;
-
- } else {
- if (event.currentTarget.dataset.type === 'boolean') {
- if (event.target.checked === true) {
- fieldValue = 'true'; //have to turn boolean into string
- } else {
- fieldValue = 'false'
- }
- fieldName = event.currentTarget.dataset.field;
} else {
- fieldValue = event.target.value;
- fieldName = event.currentTarget.dataset.field;
+ if (currentTarget?.dataset?.type === 'boolean') {
+ if (target?.checked === true) {
+ fieldValue = 'true'; //have to turn boolean into string
+ } else {
+ fieldValue = 'false'
+ }
+ fieldName = currentTarget?.dataset?.field ?? '';
+ } else {
+ fieldValue = target?.value;
+ fieldName = currentTarget?.dataset?.field;
+ }
}
- }
- this.requestDataMap.set(fieldName, fieldValue);
- console.log('Value updated - ' + fieldName + ' - ' + fieldValue);
+ this.requestDataMap.set(fieldName, fieldValue);
+ console.log('Value updated - ' + fieldName + ' - ' + fieldValue);
+ } catch (error) {
+ SLVHelper.showErrorMessage(error);
+ }
}
handleCancelClick() {
diff --git a/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.css b/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.css
index f7b8c69..3ca903b 100644
--- a/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.css
+++ b/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.css
@@ -1,4 +1,4 @@
-.pageSpinnerHolder{
+.pageSpinnerHolder {
position: absolute;
}
@@ -14,4 +14,4 @@
margin-right: 2%;
margin-top: 20px;
margin-bottom: 20px;
-}
\ No newline at end of file
+}
diff --git a/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.html b/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.html
index 1cf7500..538bcf7 100644
--- a/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.html
+++ b/force-app/main/default/lwc/simpliUIListViewsAdmin/simpliUIListViewsAdmin.html
@@ -151,16 +151,16 @@
-
- | |