Skip to content

Commit f9d9fda

Browse files
committed
Init
0 parents  commit f9d9fda

38 files changed

+1071
-0
lines changed

.eslintignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**/lwc/**/*.css
2+
**/lwc/**/*.html
3+
**/lwc/**/*.json
4+
**/lwc/**/*.svg
5+
**/lwc/**/*.xml
6+
**/aura/**/*.auradoc
7+
**/aura/**/*.cmp
8+
**/aura/**/*.css
9+
**/aura/**/*.design
10+
**/aura/**/*.evt
11+
**/aura/**/*.json
12+
**/aura/**/*.svg
13+
**/aura/**/*.tokens
14+
**/aura/**/*.xml
15+
**/aura/**/*.app
16+
.sfdx

.forceignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
2+
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
3+
#
4+
5+
package.xml
6+
7+
# LWC configuration files
8+
**/jsconfig.json
9+
**/.eslintrc.json
10+
11+
# LWC Jest
12+
**/__tests__/**

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This file is used for Git repositories to specify intentionally untracked files that Git should ignore.
2+
# If you are not using git, you can delete this file. For more information see: https://git-scm.com/docs/gitignore
3+
# For useful gitignore templates see: https://github.com/github/gitignore
4+
5+
# Salesforce cache
6+
.sf/
7+
.sfdx/
8+
.localdevserver/
9+
deploy-options.json
10+
IlluminatedCloud/
11+
# LWC VSCode autocomplete
12+
**/lwc/jsconfig.json
13+
*.iml
14+
# LWC Jest coverage reports
15+
coverage/
16+
17+
# Logs
18+
logs
19+
*.log
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
24+
# Dependency directories
25+
node_modules/
26+
27+
# Eslint cache
28+
.eslintcache
29+
30+
# MacOS system files
31+
.DS_Store
32+
33+
# Windows system files
34+
Thumbs.db
35+
ehthumbs.db
36+
[Dd]esktop.ini
37+
$RECYCLE.BIN/
38+
39+
# Local environment variables
40+
.env
41+
42+
# Python Salesforce Functions
43+
**/__pycache__/
44+
**/.venv/
45+
**/venv/
46+
47+
# Added by Illuminated Cloud
48+
/IlluminatedCloud/
49+
/out/
50+
target/

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/illuminatedCloud.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/All_Tests.xml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Object Filter LWC
2+
Provides a dynamic multi-filter component for any object.
3+
4+
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t7Q000000YyymQAC">
5+
<img alt="Deploy to Salesforce" src="https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/deploy.png">
6+
</a>
7+
8+
### Attributes
9+
- object-api-name attribute is required, default is "Account". If using in record detail page, it will be the record object api name of the page automatically.
10+
- title attribute is optional, default is "Filters".
11+
```javascript
12+
<c-object-filter
13+
object-api-name="Account"
14+
title="Filters">
15+
</c-object-filter>
16+
```
17+
### Invocable methods
18+
- getFilterState() - return the FilterState object of the component.
19+
- Example of the FilterState object as JSON:
20+
```json
21+
{
22+
"filterList":[
23+
{
24+
"id":1679649831842,
25+
"index":1,
26+
"field":{
27+
"apiName":"Amount",
28+
"labelName":"Amount",
29+
"type":"CURRENCY"
30+
},
31+
"operator":">",
32+
"operatorValue":"12"
33+
},
34+
{
35+
"id":1679649886747,
36+
"index":2,
37+
"field":{
38+
"apiName":"Name",
39+
"labelName":"Name",
40+
"type":"STRING"
41+
},
42+
"operator":"contain",
43+
"operatorValue":"test"
44+
}
45+
],
46+
"filterString":"Amount > 12 AND Name like '%test%'",
47+
"logicalCondition":"AND",
48+
"customLogicalCondition":"1 AND 2"
49+
}
50+
```
51+
- loadFilterState(filterState) - load the FilterState object to the component.
52+
- getQueryFilterString() - return the filterString value of the component.
53+
## Images
54+
![img.png](/documantation/images/objectFilterEmpty.png)
55+
![img.png](/documantation/images/objectFilterSelectField.png)
56+
![img.png](/documantation/images/objectFilterWithOperator.png)
57+
![img.png ](/documantation/images/objectFilterUpdate.png)
58+
![img.png](/documantation/images/objectFilterUpdate.png)
59+
![img.png](/documantation/images/objectFilterCustomCondition.png)

config/project-scratch-def.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"orgName": "SOQLFilterLWC",
3+
"edition": "Developer",
4+
"features": ["EnableSetPasswordInApi"],
5+
"settings": {
6+
"lightningExperienceSettings": {
7+
"enableS1DesktopEnabled": true
8+
},
9+
"mobileSettings": {
10+
"enableS1EncryptedStoragePref2": false
11+
}
12+
}
13+
}
Loading
35.5 KB
Loading
12.1 KB
Loading
35.9 KB
Loading
47.4 KB
Loading
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plugins": ["@salesforce/eslint-plugin-aura"],
3+
"extends": ["plugin:@salesforce/eslint-plugin-aura/recommended"],
4+
"rules": {
5+
"vars-on-top": "off",
6+
"no-unused-expressions": "off"
7+
}
8+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
public with sharing class ObjectFilterController {
2+
/**
3+
* Returns a list of FieldResponse objects for a given sObject and boolean parameter
4+
* indicating whether to include formula fields or not.
5+
*
6+
* @param sObjectApiName the API name of the sObject to retrieve fields for (required))
7+
* @return List of FieldResponse objects representing the fields of the given sObject
8+
*/
9+
@AuraEnabled(Cacheable = true)
10+
public static List<FieldResponse> getFieldsBySobjectApiName(String sObjectApiName){
11+
if(sObjectApiName == null || sObjectApiName == ''){
12+
throw new AuraHandledException('sObjectApiName cannot be null to get fields');
13+
}
14+
try{
15+
List<SObjectField> sObjectFields = getAllFieldsForSObjectType(sObjectApiName);
16+
List<FieldResponse> fields = new List<FieldResponse>();
17+
for(SObjectField sObjectField: sObjectFields){
18+
DescribeFieldResult fieldResult = sObjectField.getDescribe();
19+
fields.add(new FieldResponse(fieldResult.getLabel(),fieldResult.getName(),fieldResult.getType().name()));
20+
}
21+
fields.sort();
22+
return fields;
23+
}catch (Exception e) {
24+
throw new AuraHandledException('Error getting fields for ' + sObjectApiName+': '+e.getMessage());
25+
}
26+
}
27+
/**
28+
The getAllFieldsForSObjectType method is used to retrieve a list of all fields for a specific SObject.
29+
@param sObjectTypeName The name of the SObject for which the fields should be retrieved.
30+
@return A list of SObjectField objects that represent the fields for the SObject.
31+
*/
32+
public static List<Schema.SObjectField> getAllFieldsForSObjectType(String sObjectTypeName) {
33+
SObjectType type = Schema.getGlobalDescribe().get(sObjectTypeName);
34+
Map<String, Schema.SObjectField> sObjectFields = type.getDescribe().fields.getMap();
35+
return sObjectFields.values();
36+
}
37+
public class FieldResponse implements Comparable{
38+
@AuraEnabled public String labelName;
39+
@AuraEnabled public String apiName;
40+
@AuraEnabled public String type;
41+
42+
public FieldResponse(String labelName, String apiName, String type) {
43+
this.labelName = labelName;
44+
this.apiName = apiName;
45+
this.type = type;
46+
}
47+
48+
public Integer compareTo(Object fieldResponseObject) {
49+
Integer comparison = 0;
50+
FieldResponse fieldResponseToCompare = (FieldResponse) fieldResponseObject;
51+
if (this.labelName > fieldResponseToCompare.labelName) {
52+
comparison = 1;
53+
} else if (this.labelName < fieldResponseToCompare.labelName) {
54+
comparison = -1;
55+
}
56+
return comparison;
57+
}
58+
}
59+
60+
61+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>57.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@IsTest
2+
public class ObjectFilterControllerTest {
3+
4+
@IsTest
5+
public static void testGetFieldsBySobjectApiName() {
6+
List<ObjectFilterController.FieldResponse> fields = ObjectFilterController.getFieldsBySobjectApiName('Account');
7+
8+
Assert.isTrue(fields.size() > 0);
9+
10+
for (ObjectFilterController.FieldResponse field : fields) {
11+
Assert.isNotNull(field.apiName);
12+
Assert.isNotNull(field.labelName);
13+
Assert.isNotNull(field.type);
14+
}
15+
}
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>57.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": ["@salesforce/eslint-config-lwc/recommended"],
3+
"overrides": [
4+
{
5+
"files": ["*.test.js"],
6+
"rules": {
7+
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
8+
},
9+
"env": {
10+
"node": true
11+
}
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)