Skip to content

Commit

Permalink
Merge pull request #1611 from alexed1/AutoNav
Browse files Browse the repository at this point in the history
Auto nav
  • Loading branch information
alexed1 authored Jan 11, 2025
2 parents c009b79 + e28896e commit 482da17
Show file tree
Hide file tree
Showing 22 changed files with 360 additions and 0 deletions.
12 changes: 12 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/.forceignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
#

package.xml

# LWC configuration files
**/jsconfig.json
**/.eslintrc.json

# LWC Jest
**/__tests__/**
4 changes: 4 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
41 changes: 41 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ers_AutoNavigate_Refresh

Lightning Web Component for Flow Screens: **ers_AutoNavigate_Refresh**

Lightning Flow Builder Name: **Auto Navigate + Console Tab Refresh**

** This component is designed to be used on a FLow Screen when you need to refresh the console tabs and/or **
** automatically navigate to the previous or next screen. The refresh and navigation can be further controlled **
** by making this component conditionally visible so the action(s) will only occur when the conditional **
** visibility is true.**

Additional components packaged with this LWC:

Lightning Web Components: ers_AutoNavigate_RefreshCPE //TODO

**Documentation:** https://unofficialsf.com/TODO/

**Created by:** Eric Smith
**Date:** November 27, 2024

LinkedIn: https://www.linkedin.com/in/ericrsmith2
Salesforce: https://trailblazer.me/id/ericsmith
Blog: https://ericsplayground.wordpress.com/blog/
Twitter: https://twitter.com/esmith35

---

**You must install these components FIRST in order to install and use this component**


---

**Install ers_AutoNavigate_Refresh**
[Version 1.0.0 (Production or Developer)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fz9nQAA)
[Version 1.0.0 (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fz9nQAA)

---

# Release Notes

## 11/27/24 - Eric Smith - Version 1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"orgName": "Demo company",
"edition": "Developer",
"features": ["EnableSetPasswordInApi"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"mobileSettings": {
"enableS1EncryptedStoragePref2": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": ["@salesforce/eslint-plugin-aura"],
"extends": ["plugin:@salesforce/eslint-plugin-aura/recommended"],
"rules": {
"vars-on-top": "off",
"no-unused-expressions": "off"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": ["@salesforce/eslint-config-lwc/recommended"],
"overrides": [
{
"files": ["*.test.js"],
"rules": {
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
},
"env": {
"node": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>

</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* Lightning Web Component for Flow Screens: ers_AutoNavigate_Refresh
*
* This component is designed to be used on a Flow Screen when you need to refresh the console tabs and/or
* automatically navigate to the previous or next screen. The refresh and navigation can be further controlled
* by making this component conditionally visible so the action(s) will only occur when the conditional
* visibility is true.
*
* Additional components packaged with this LWC:
*
* Lightning Web Components: ers_AutoNavigate_RefreshCPE //TODO
* CREATED BY: Eric Smith
*
* VERSION: 1.0.0
* DATE: 11/27/2024
*
* RELEASE NOTES: https://github.com/alexed1/LightningFlowComponents/tree/master/flow_screen_components/ers_AutoNavigate_Refresh/README.md
*
**/

import { LightningElement, wire, api } from 'lwc';
import { FlowNavigationBackEvent, FlowNavigationNextEvent, FlowNavigationFinishEvent } from 'lightning/flowSupport';
import {
IsConsoleNavigation,
getFocusedTabInfo,
refreshTab
} from 'lightning/platformWorkspaceApi';

export default class Ers_AutoNavigate_Refresh extends LightningElement {

@api
get navDirection() {
return this._navDirection;
}
set navDirection(value) {
if (value.toLowerCase() === "back" || value.toLowerCase() === "previous") {
this._navDirection = "back";
} else {
this._navDirection = "next";
}
}
_navDirection = "Next";

@api skipRefresh = false;

/* SYSTEM INPUTS */
@api availableActions = [];

rendered;

@wire(IsConsoleNavigation) isConsoleNavigation;

async refreshTab() {
if (!this.isConsoleNavigation) {
return;
}
const { tabId } = await getFocusedTabInfo();
await refreshTab(tabId, {
includeAllSubtabs: true
});
}

renderedCallback() {

if (this.rendered)
return;
this.rendered = true;

// Refresh Console Tab
if (!this.skipRefresh) {
this.refreshTab();
}

// Auto Navigate to Previous or Next Screen
if (this._navDirection === "back" && this.availableActions.find(action => action === 'BACK')) {
this.dispatchEvent(new FlowNavigationBackEvent());
} else {
if (this.availableActions.find(action => action === 'FINISH')) {
this.dispatchEvent(new FlowNavigationFinishEvent());
} else {
this.dispatchEvent(new FlowNavigationNextEvent());
}
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Auto Navigate + Console Tab Refresh</masterLabel>
<description>Flow screen component to refresh the console tab and auto-navigate Previous or Next/Finish - By Eric Smith</description>
<targets>
<target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__FlowScreen">
<property name="navDirection" label="Navigation Direction (Default Next)" type="String" role="inputOnly"
description="Next, Forward, Previous or Back" />
<property name="skipRefresh" label="Skip Console Tab Refresh? (Default False)" type="Boolean" role="inputOnly"
description="Set to True to skip the console tab refresh step" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
6 changes: 6 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');

module.exports = {
...jestConfig,
modulePathIgnorePatterns: ['<rootDir>/.localdevserver']
};
36 changes: 36 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/manifest/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<types>
<members>*</members>
<name>ApexPage</name>
</types>
<types>
<members>*</members>
<name>ApexTestSuite</name>
</types>
<types>
<members>*</members>
<name>ApexTrigger</name>
</types>
<types>
<members>*</members>
<name>AuraDefinitionBundle</name>
</types>
<types>
<members>*</members>
<name>LightningComponentBundle</name>
</types>
<types>
<members>*</members>
<name>StaticResource</name>
</types>
<version>62.0</version>
</Package>
41 changes: 41 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "salesforce-app",
"private": true,
"version": "1.0.0",
"description": "Salesforce App",
"scripts": {
"lint": "eslint **/{aura,lwc}/**/*.js",
"test": "npm run test:unit",
"test:unit": "sfdx-lwc-jest",
"test:unit:watch": "sfdx-lwc-jest --watch",
"test:unit:debug": "sfdx-lwc-jest --debug",
"test:unit:coverage": "sfdx-lwc-jest --coverage",
"prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
"prettier:verify": "prettier --check \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
"postinstall": "husky install",
"precommit": "lint-staged"
},
"devDependencies": {
"@lwc/eslint-plugin-lwc": "^1.1.2",
"@prettier/plugin-xml": "^3.2.2",
"@salesforce/eslint-config-lwc": "^3.2.3",
"@salesforce/eslint-plugin-aura": "^2.0.0",
"@salesforce/eslint-plugin-lightning": "^1.0.0",
"@salesforce/sfdx-lwc-jest": "^5.1.0",
"eslint": "^9.9.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^28.8.1",
"husky": "^9.1.5",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0",
"prettier-plugin-apex": "^2.0.1"
},
"lint-staged": {
"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}": [
"prettier --write"
],
"**/{aura,lwc}/**/*.js": [
"eslint"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
if "%1" neq "" set packageName=%1
@echo on
sfdx package:create -v lexhost --name "%packageName%" --path force-app --package-type Unlocked
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
if "%1" neq "" set version=%1
@echo on
sfdx package:version:create -v lexhost -w 20 -x -c -n %version%.0 -d force-app\
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
if "%1" neq "" set packageName=%1
if "%2" neq "" set version=%2
@echo on
sfdx package:version:report -v lexhost --package "%packageName%@%version%"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
if "%1" neq "" set packageName=%1
if "%2" neq "" set version=%2
@echo on
sfdx package:version:promote -v lexhost --package "%packageName%@%version%"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
if "%1" neq "" goto skipprompt
set /p packageName="Set Package Name: "
goto exit
:skipprompt
set packageName=%1
:exit
echo Package Name: %packageName%
@echo on
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
if "%1" neq "" goto skipprompt
set /p version="Set Version Number: "
goto exit
:skipprompt
set version=%1
:exit
echo Version: %version%
@echo on
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
echo Package Name: %packageName%
echo Version: %version%
@echo on
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Use .apex files to store anonymous Apex.
// You can execute anonymous Apex in VS Code by selecting the
// apex text and running the command:
// SFDX: Execute Anonymous Apex with Currently Selected Text
// You can also execute the entire file by running the command:
// SFDX: Execute Anonymous Apex with Editor Contents

string tempvar = 'Enter_your_name_here';
System.debug('Hello World!');
System.debug('My name is ' + tempvar);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Use .soql files to store SOQL queries.
// You can execute queries in VS Code by selecting the
// query text and running the command:
// SFDX: Execute SOQL Query with Currently Selected Text

SELECT Id, Name FROM Account
20 changes: 20 additions & 0 deletions flow_screen_components/AutoNavigate_Refresh/sfdx-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"packageDirectories": [
{
"path": "force-app",
"default": true,
"package": "AutoNavigate_Refresh",
"versionName": "ver 0.1",
"versionNumber": "0.1.0.NEXT",
"versionDescription": ""
}
],
"name": "AutoNavigate_Refresh",
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "62.0",
"packageAliases": {
"AutoNavigate_Refresh": "0Ho5G000000sXuZSAU",
"[email protected]": "04t5G000004fz9nQAA"
}
}

0 comments on commit 482da17

Please sign in to comment.