From 4e622c09505c1ba602593679aeec08538a913ad5 Mon Sep 17 00:00:00 2001 From: Levi Olson Date: Sat, 22 Feb 2020 21:03:12 -0600 Subject: [PATCH] Adding components --- force-app/main/default/lwc/jsconfig.json | 9 ++++ .../myActionComponent/myActionComponent.html | 32 +++++++++++ .../myActionComponent/myActionComponent.js | 53 +++++++++++++++++++ .../myActionComponent.js-meta.xml | 6 +++ .../myCustomComponent/myCustomComponent.html | 16 +++--- .../myCustomComponent/myCustomComponent.js | 24 ++++++++- 6 files changed, 131 insertions(+), 9 deletions(-) create mode 100755 force-app/main/default/lwc/myActionComponent/myActionComponent.html create mode 100755 force-app/main/default/lwc/myActionComponent/myActionComponent.js create mode 100755 force-app/main/default/lwc/myActionComponent/myActionComponent.js-meta.xml diff --git a/force-app/main/default/lwc/jsconfig.json b/force-app/main/default/lwc/jsconfig.json index e901923..1d5e093 100644 --- a/force-app/main/default/lwc/jsconfig.json +++ b/force-app/main/default/lwc/jsconfig.json @@ -3,12 +3,21 @@ "experimentalDecorators": true, "baseUrl": ".", "paths": { + "c/customLayout": [ + "customLayout/customLayout.js" + ], "c/helloWorld": [ "helloWorld/helloWorld.js" ], + "c/myActionComponent": [ + "myActionComponent/myActionComponent.js" + ], "c/myCustomComponent": [ "myCustomComponent/myCustomComponent.js" ], + "c/myOmniComponentInBaseClass": [ + "myOmniComponentInBaseClass/myOmniComponentInBaseClass.js" + ], "c/myTextComponent": [ "myTextComponent/myTextComponent.js" ] diff --git a/force-app/main/default/lwc/myActionComponent/myActionComponent.html b/force-app/main/default/lwc/myActionComponent/myActionComponent.html new file mode 100755 index 0000000..3f2080f --- /dev/null +++ b/force-app/main/default/lwc/myActionComponent/myActionComponent.html @@ -0,0 +1,32 @@ + diff --git a/force-app/main/default/lwc/myActionComponent/myActionComponent.js b/force-app/main/default/lwc/myActionComponent/myActionComponent.js new file mode 100755 index 0000000..490fce1 --- /dev/null +++ b/force-app/main/default/lwc/myActionComponent/myActionComponent.js @@ -0,0 +1,53 @@ +import tmpl from './myActionComponent.html'; +import { LightningElement, track } from 'lwc'; +import { OmniscriptBaseMixin } from 'vlocity_cmt/omniscriptBaseMixin'; + +export default class MyActionComponent extends OmniscriptBaseMixin(LightningElement) { + @track url; + @track query = JSON.stringify({ + datasource: { + type: "query", + value: { + query: "SELECT Id, name FROM Contact LIMIT 1" + } + }, + url: "/${data[0].Id}", + target: "_blank", + parameters: {}, + navigate: false + }); + + connectedCallback() { + console.log('MyActionComponent - Connected'); + } + + render() { + return tmpl; + } + + fetchData(evt) { + let action = evt.target; + let def = JSON.parse(this.query); + action.definition = this.query; + action.triggerAction(); + } + // I'm passing these properties down to the navigate-action via + // attributes. + onSuccessCallback(evt) { + let result = evt.detail.result; + this._targetType = "Record"; + this._targetId = result[0].Id; + + // Because we're setting the attribute values via attributes, + // we need to give the ui a chance to re-render. + Promise.resolve().then(() => { + this.url = result[0].attributes.url; + }); + } + + onErrorCallback(error) { + console.log(error); + } + + +} diff --git a/force-app/main/default/lwc/myActionComponent/myActionComponent.js-meta.xml b/force-app/main/default/lwc/myActionComponent/myActionComponent.js-meta.xml new file mode 100755 index 0000000..e645336 --- /dev/null +++ b/force-app/main/default/lwc/myActionComponent/myActionComponent.js-meta.xml @@ -0,0 +1,6 @@ + + + 47.0 + true + vlocity_cmt + diff --git a/force-app/main/default/lwc/myCustomComponent/myCustomComponent.html b/force-app/main/default/lwc/myCustomComponent/myCustomComponent.html index b662fc3..c895caa 100755 --- a/force-app/main/default/lwc/myCustomComponent/myCustomComponent.html +++ b/force-app/main/default/lwc/myCustomComponent/myCustomComponent.html @@ -1,9 +1,11 @@ diff --git a/force-app/main/default/lwc/myCustomComponent/myCustomComponent.js b/force-app/main/default/lwc/myCustomComponent/myCustomComponent.js index ce6439c..2c2df1b 100755 --- a/force-app/main/default/lwc/myCustomComponent/myCustomComponent.js +++ b/force-app/main/default/lwc/myCustomComponent/myCustomComponent.js @@ -1,10 +1,30 @@ -import { LightningElement } from 'lwc'; -import pubsub from 'vlocity_cmt/pubsub'; +import { LightningElement, track } from 'lwc'; import { OmniscriptBaseMixin } from 'vlocity_cmt/omniscriptBaseMixin'; export default class MyCustomComponent extends OmniscriptBaseMixin(LightningElement) { + @track layout; + @track theme; + @track parentClass; + connectedCallback() { console.log("MyCustomComponent - Connected"); + + this.layout = this.getAttribute('data-omni-layout'); // returns lightning or newport + this.theme = this.layout === 'lightning' ? 'slds' : 'nds'; // we can now use theme={theme} in html + this.parentClass = this.layout === 'lightning' ? 'slds-grid slds-wrap' : 'nds-grid nds-wrap'; + + try { + console.log("MyCustomComponent - this:", this); + console.log("MyCustomComponent - this.omniScriptHeaderDef:", JSON.parse(JSON.stringify(this.omniScriptHeaderDef))); + console.log("MyCustomComponent - this.omniResume:", JSON.parse(JSON.stringify(this.omniResume))); + console.log("MyCustomComponent - this.omniSeedJson:", JSON.parse(JSON.stringify(this.omniSeedJson))); + console.log("MyCustomComponent - this.omniJsonDef:", JSON.parse(JSON.stringify(this.omniJsonDef))); + console.log("MyCustomComponent - this.omniJsonData:", JSON.parse(JSON.stringify(this.omniJsonData))); + // console.log("MyCustomComponent - this.omniLayout:", JSON.parse(JSON.stringify(this.omniLayout))); + } catch (e) { + console.debug("Error Parsing: ", e); + + } } handleBlur(evt) {