forked from SFDO-Community/GrantGuides
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add grant selector to editor for USer changing grant app without navi…
…gation to tabs
- Loading branch information
Showing
10 changed files
with
371 additions
and
280 deletions.
There are no files selected for viewing
480 changes: 226 additions & 254 deletions
480
force-app/main/default/classes/GGW_ApplicationCtrl.cls
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
force-app/main/default/classes/GGW_ApplicationSelector.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2022, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* GGW_ApplicationSelector SOQL Query class support GGW. | ||
* | ||
*/ | ||
public with sharing class GGW_ApplicationSelector { | ||
public static List<GGW_Grant_Application__c> getGrantApplications(){ | ||
return [SELECT Id, Name, Application_Name__c, Logo_Download_Url__c, | ||
DistributionPublicUrl__c, Status__c, Description__c, | ||
Language__c, Include_Logo__c | ||
FROM GGW_Grant_Application__c | ||
WITH SECURITY_ENFORCED]; | ||
} | ||
|
||
public static GGW_Grant_Application__c queryGrantApp(String appId){ | ||
return [SELECT Id, Name, Application_Name__c, Logo_Download_Url__c, | ||
DistributionPublicUrl__c, Status__c, Description__c, | ||
Language__c, Include_Logo__c | ||
FROM GGW_Grant_Application__c | ||
WHERE Id =: appId WITH SECURITY_ENFORCED LIMIT 1]; | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/GGW_ApplicationSelector.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
67 changes: 67 additions & 0 deletions
67
force-app/main/default/classes/GGW_ApplicationSelectorTest.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright (c) 2022, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
* This class contains unit tests for validating the behavior of Apex classes | ||
* and triggers. | ||
* | ||
* Unit tests are class methods that verify whether a particular piece | ||
* of code is working properly. Unit test methods take no arguments, | ||
* commit no data to the database, and are flagged with the testMethod | ||
* keyword in the method definition. | ||
* | ||
* All test methods in an org are executed whenever Apex code is deployed | ||
* to a production org to confirm correctness, ensure code | ||
* coverage, and prevent regressions. All Apex classes are | ||
* required to have at least 75% code coverage in order to be deployed | ||
* to a production org. In addition, all triggers must have some code coverage. | ||
* | ||
* The @isTest class annotation indicates this class only contains test | ||
* methods. Classes defined with the @isTest annotation do not count against | ||
* the org size limit for all Apex scripts. | ||
* | ||
* See the Apex Language Reference for more information about Testing and Code Coverage. | ||
*/ | ||
@isTest | ||
private class GGW_ApplicationSelectorTest { | ||
|
||
@isTest | ||
static void testQueryGrantApp(){ | ||
// Query all suggested sections | ||
List<GGW_SectionWrapper> lst = GGW_ApplicationCtrl.getSections(); | ||
List<String> sections = new List<String>(); | ||
for (GGW_SectionWrapper gww : lst){ | ||
if(gww.selected){ | ||
sections.add(gww.recordid); | ||
} | ||
} | ||
GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Grant App', sections); | ||
|
||
Test.startTest(); | ||
GGW_Grant_Application__c grant = GGW_ApplicationSelector.queryGrantApp(app.Id); | ||
Test.stopTest(); | ||
System.assertEquals(grant.Name, 'Grant App', 'Could not create a new grant application'); | ||
|
||
} | ||
@isTest | ||
static void getGrantApplicationsTest(){ | ||
// Query all suggested sections | ||
List<GGW_SectionWrapper> lst = GGW_ApplicationCtrl.getSections(); | ||
List<String> sections = new List<String>(); | ||
for (GGW_SectionWrapper gww : lst){ | ||
if(gww.selected){ | ||
sections.add(gww.recordid); | ||
} | ||
} | ||
// Create 2 grants with same sections top test list | ||
GGW_ApplicationCtrl.newGrant('Grant App 1', sections); | ||
GGW_ApplicationCtrl.newGrant('Grant App 2', sections); | ||
|
||
Test.startTest(); | ||
List<GGW_Grant_Application__c> grantList = GGW_ApplicationSelector.getGrantApplications(); | ||
Test.stopTest(); | ||
System.assertEquals(2, grantList.size(), 'Query grant application invalid'); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/GGW_ApplicationSelectorTest.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters