From 888276b032ad2e5edb40bd21c53118fd409b38e6 Mon Sep 17 00:00:00 2001 From: Igor Androsov Date: Tue, 26 Dec 2023 19:00:16 +0900 Subject: [PATCH] Add feature #44 Grant selector to editor, refactor selector methods to separate classes --- .../default/classes/GGW_ApplicationCtrl.cls | 146 +++++------------- .../classes/GGW_ApplicationCtrlTest.cls | 8 +- .../classes/GGW_ContentBlockSelector.cls | 32 ++++ .../GGW_ContentBlockSelector.cls-meta.xml | 5 + .../default/classes/GGW_ContentSelector.cls | 37 +++++ .../classes/GGW_ContentSelector.cls-meta.xml | 5 + .../classes/GGW_GrantApplicationWrapper.cls | 3 +- .../default/classes/GGW_SectionSelector.cls | 59 +++++++ .../classes/GGW_SectionSelector.cls-meta.xml | 5 + .../ggwGrantApplication.html | 126 +-------------- .../ggwGrantApplication.js | 5 +- .../ggwStaticNoDataCard.css | 1 + .../ggwStaticNoDataCard.html | 123 +++++++++++++++ .../ggwStaticNoDataCard.js | 8 + .../ggwStaticNoDataCard.js-meta.xml | 29 ++++ 15 files changed, 354 insertions(+), 238 deletions(-) create mode 100644 force-app/main/default/classes/GGW_ContentBlockSelector.cls create mode 100644 force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml create mode 100644 force-app/main/default/classes/GGW_ContentSelector.cls create mode 100644 force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml create mode 100644 force-app/main/default/classes/GGW_SectionSelector.cls create mode 100644 force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml create mode 100644 force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.css create mode 100644 force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.html create mode 100644 force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js create mode 100644 force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml diff --git a/force-app/main/default/classes/GGW_ApplicationCtrl.cls b/force-app/main/default/classes/GGW_ApplicationCtrl.cls index 768f443..01dbef3 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrl.cls +++ b/force-app/main/default/classes/GGW_ApplicationCtrl.cls @@ -15,22 +15,11 @@ public without sharing class GGW_ApplicationCtrl { @AuraEnabled public static GGW_GrantApplicationWrapper getApplication(String recordId){ String tempId = validateAppId(recordId); - - List appItems = querySelectedItemsByGrant(tempId); + List appItems = GGW_SectionSelector.querySelectedItemsByGrant(tempId); GGW_Grant_Application__c grant = GGW_ApplicationSelector.queryGrantApp(tempId); // Save current app state GGW_Util.saveGrantState(tempId); - - GGW_GrantApplicationWrapper app = new GGW_GrantApplicationWrapper(); - if(!appItems.isEmpty()){ - app.recordid = grant.Id; - app.logostate = grant.Include_Logo__c; - app.logodisplayurl = getValidLogoURL(grant); - app.name = appItems[0].Application_Name__c; - app.status = appItems[0].Grant_Application__r.Status__c; - app.unselectSectionList = getLeftoverSections(appItems); - app.selectedContentBlock = createContentBlockWrapperList(appItems); - } + GGW_GrantApplicationWrapper app = createGrantWrapper(grant, appItems); return app; } @AuraEnabled (cacheable=true) @@ -74,7 +63,7 @@ public without sharing class GGW_ApplicationCtrl { */ @AuraEnabled public static String createContentDistribution(String grantId, String cvid){ - ContentVersion file = getContentFile(cvid); + ContentVersion file = GGW_ContentSelector.getContentFile(cvid); // Creating ContentDistribution record ContentDistribution cdr = insertContentDistribution(file); if(cdr.Id == null){ @@ -82,7 +71,7 @@ public without sharing class GGW_ApplicationCtrl { } // After Distribution record need to get DistributionPublicUrl, ContentDownloadUrl // and update Grant record to use these for display - ContentDistribution cdURL = getContentDistributionById(cdr.Id); + ContentDistribution cdURL = GGW_ContentSelector.getContentDistributionById(cdr.Id); System.debug('## ContentDownloadUrl:'+cdURL.ContentDownloadUrl); System.debug('## DistributionPublicUrl: '+cdURL.DistributionPublicUrl); // Update Grant with new logo @@ -96,7 +85,7 @@ public without sharing class GGW_ApplicationCtrl { */ @AuraEnabled public static void saveSelectedSectionText(String itemid, String blockid){ - GGW_Content_Block__c cBlock = queryContentBlockById(blockid); + GGW_Content_Block__c cBlock = GGW_ContentBlockSelector.queryContentBlockById(blockid); // Construct selected Item to update GGW_Selected_Item__c item = new GGW_Selected_Item__c(); item.Id = itemid; @@ -114,7 +103,7 @@ public without sharing class GGW_ApplicationCtrl { */ @AuraEnabled public static GGW_SectionWrapper createNewSection(String name){ - GGW_Section__c maxOrder = findMaxOrderSection(); + GGW_Section__c maxOrder = GGW_SectionSelector.findMaxOrderSection(); GGW_Section__c s = new GGW_Section__c(); s.Name = name; s.Recommended__c = true; @@ -178,7 +167,7 @@ public without sharing class GGW_ApplicationCtrl { @AuraEnabled(cacheable=true) public static List getContentBlocks(String sectionId){ List cbwResultList = new List(); - List cbList = queryContentBlocksBySection(sectionId); + List cbList = GGW_ContentBlockSelector.queryContentBlocksBySection(sectionId); // Get map of block tags to display as badges Map> blockTags = getBlockTopics(); for(GGW_Content_Block__c c : cbList){ @@ -232,7 +221,7 @@ public without sharing class GGW_ApplicationCtrl { List swList = new List(); String lang = GGW_Util.getGrantLanguage(); Set setOfSectionsWithBlock = getBlocksForSection(); - List sectionList = querySectionsByLanguage(lang); + List sectionList = GGW_SectionSelector.querySectionsByLanguage(lang); for(GGW_Section__c s : sectionList){ GGW_SectionWrapper sw = new GGW_SectionWrapper(s,setOfSectionsWithBlock); swList.add(sw); @@ -244,7 +233,7 @@ public without sharing class GGW_ApplicationCtrl { public static List findSections(String searchKey) { List swList = new List(); if(searchKey != null && searchKey.length() > 0){ - List sectionList = querySectionsByName(searchKey); + List sectionList = GGW_SectionSelector.querySectionsByName(searchKey); for(GGW_Section__c s : sectionList){ GGW_SectionWrapper sw = new GGW_SectionWrapper(s); @@ -280,19 +269,39 @@ public without sharing class GGW_ApplicationCtrl { return GGW_Util.getSelectOptionFromPicklist(ggGtSteObj, ggGtStLanField, false); } - // -------------------------------- // -- END LWC Controller Methods -- // -------------------------------- + private static GGW_GrantApplicationWrapper createGrantWrapper(GGW_Grant_Application__c grant, List appItems){ + GGW_GrantApplicationWrapper app = new GGW_GrantApplicationWrapper(); + app.recordid = grant.Id; + app.logostate = grant.Include_Logo__c; + app.logodisplayurl = getValidLogoURL(grant); + app.status = grant.Status__c; + app.textname = grant.Name; + app.name = getValidApplicationNameLookupURL(appItems); // Link to standard record + app.unselectSectionList = getLeftoverSections(appItems); + app.selectedContentBlock = createContentBlockWrapperList(appItems); + return app; + } + private static String getValidApplicationNameLookupURL(List appItems){ + if(!appItems.isEmpty()){ + return appItems[0].Application_Name__c; + } + return null; + } private static void deleteImageLogo(String recordId){ + /* ContentDocumentLink cdl = [SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, Visibility, ShareType FROM ContentDocumentLink - WHERE LinkedEntityId =: recordId WITH SECURITY_ENFORCED]; + WHERE LinkedEntityId =: recordId WITH SECURITY_ENFORCED LIMIT 1]; ContentDistribution cntdistr = [SELECT Id, Name, ContentVersionId, ContentDocumentId, RelatedRecordId, ContentDownloadUrl FROM ContentDistribution - WHERE ContentDocumentId =: cdl.ContentDocumentId WITH SECURITY_ENFORCED]; - + WHERE ContentDocumentId =: cdl.ContentDocumentId WITH SECURITY_ENFORCED LIMIT 1]; + */ + ContentDocumentLink cdl = GGW_ContentSelector.getDocLinkByLinkedEntity(recordId); + ContentDistribution cntdistr = GGW_ContentSelector.getContentDistributionByDocId(cdl.ContentDocumentId); ContentDocument cd = new ContentDocument(); cd.Id = cdl.ContentDocumentId; if(Schema.sObjectType.ContentDistribution.isDeletable()){ @@ -357,20 +366,6 @@ public without sharing class GGW_ApplicationCtrl { } } } - private static ContentDistribution getContentDistributionById(Id cdid){ - ContentDistribution cdr = [SELECT Id, Name, ContentVersionId, - ContentDownloadUrl, DistributionPublicUrl - FROM ContentDistribution - WHERE Id =: cdid WITH SECURITY_ENFORCED LIMIT 1]; - return cdr; - } - // Query ContentVersion by id - private static ContentVersion getContentFile(String cvid){ - ContentVersion file = [SELECT Id, Title - FROM ContentVersion - WHERE Id =: cvid WITH SECURITY_ENFORCED]; - return file; - } private static ContentDistribution insertContentDistribution(ContentVersion file){ ContentDistribution cdr = new ContentDistribution( Name = file.Title, @@ -382,21 +377,6 @@ public without sharing class GGW_ApplicationCtrl { } return cdr; } - // Return section with max order to add next section - private static GGW_Section__c findMaxOrderSection(){ - List maxOrderList = [SELECT Sort_Order__c - FROM GGW_Section__c - WHERE Suggested__c = true WITH SECURITY_ENFORCED ORDER BY Sort_Order__c desc]; - GGW_Section__c maxOrder = null; - // Handle situation when Sort order is null - TODO MAY be good to require it - for(GGW_Section__c section : maxOrderList ){ - if(section.Sort_Order__c != null && section.Sort_Order__c > 0){ - maxOrder = section; // assigned MAX order object first found END LOOP here - break; // EXIT Loop - } - } - return maxOrder; - } // Fix for issue #67 WHne pkg installed omn fresh org NO sample section data defult sort to 1 // Use decimal insted on Integer a s fieds number ais decimal private static Decimal getSectionSortOrder(GGW_Section__c maxOrder){ @@ -419,7 +399,7 @@ public without sharing class GGW_ApplicationCtrl { } // Delete Grant selected section items that are not on the list to reorder function private static void cleanSelectedSections(List sectionList, String appId){ - List appItems = querySelectedItemsByGrant(appId); + List appItems = GGW_SectionSelector.querySelectedItemsByGrant(appId); Set sectionSet = new Set(sectionList); List removeItems = new List(); for(GGW_Selected_Item__c item : appItems){ @@ -447,7 +427,7 @@ public without sharing class GGW_ApplicationCtrl { List swList = new List(); Set setExcludeSections = getExcludeSectionSet(appItems); Set setOfSectionsWithBlock = getBlocksForSection(); - List sectionList = querySections(); + List sectionList = GGW_SectionSelector.querySections(); for(GGW_Section__c s : sectionList){ system.debug('## Left Section: '+s.Name+' ID: '+s.Id); @@ -468,7 +448,7 @@ public without sharing class GGW_ApplicationCtrl { } private static Set getBlocksForSection(){ Set s1 = new Set(); - List cbList = queryContentBlocks(); + List cbList = GGW_ContentBlockSelector.queryContentBlocks(); for(GGW_Content_Block__c c : cbList){ s1.add(c.Id); } @@ -529,38 +509,6 @@ public without sharing class GGW_ApplicationCtrl { } ///--- BASIC SELECTOR METHODS - public static List querySelectedItemsByGrant(String appId){ - List appItems = [SELECT Id, Application_Name__c, Grant_Application__c, GGW_Section__c, - Section_Name__c,Selected_Block__c, Sort_Order__c, Grant_Application__r.Status__c, - Selected_Block__r.Description__c, Text_Block__c, Language__c - FROM GGW_Selected_Item__c - WHERE Grant_Application__c =: appId WITH SECURITY_ENFORCED ORDER BY Sort_Order__c]; - return appItems; - } - - private static List querySectionsByLanguage(String lang){ - List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, - Sort_Order__c, Language__c - FROM GGW_Section__c - WHERE Suggested__c = true AND Language__c =: lang - WITH SECURITY_ENFORCED ORDER BY Sort_Order__c]; - return sectionList; - } - private static List querySections(){ - List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, - Sort_Order__c, Language__c - FROM GGW_Section__c WITH SECURITY_ENFORCED ORDER BY Sort_Order__c]; - return sectionList; - } - private static List querySectionsByName(String searchKey){ - String key = '%' + searchKey + '%'; - List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, - Sort_Order__c, Language__c - FROM GGW_Section__c - WHERE Name LIKE :key AND Suggested__c = false - WITH SECURITY_ENFORCED ORDER BY Sort_Order__c LIMIT 20]; - return sectionList; - } // Return list of TopicAssignments for ContentBlocks private static List queryTopicAssignments(){ @@ -570,27 +518,5 @@ public without sharing class GGW_ApplicationCtrl { return lst; } - // BLOCK Query - private static GGW_Content_Block__c queryContentBlockById(String blockid){ - GGW_Content_Block__c cBlock = [SELECT Id, Name, Description__c - FROM GGW_Content_Block__c - WHERE Id =: blockid WITH SECURITY_ENFORCED LIMIT 1]; - return cBlock; - } - private static List queryContentBlocksBySection(String sectionId){ - List cbList = [SELECT Id, Name, Description__c, Short_Description__c, - Section__c, Section__r.Name, CreatedDate, - Language__c - FROM GGW_Content_Block__c - WHERE Section__c =: sectionId WITH SECURITY_ENFORCED]; - return cbList; - } - private static List queryContentBlocks(){ - List cbList = [SELECT Id, Name, Description__c, Short_Description__c, - Section__c, Section__r.Name, CreatedDate, - Language__c - FROM GGW_Content_Block__c WITH SECURITY_ENFORCED ORDER BY Section__c]; - return cbList; - } } diff --git a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls index 0fc8da7..280eaba 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls +++ b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls @@ -253,7 +253,7 @@ public class GGW_ApplicationCtrlTest { } } GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('MyTest Grant Sections', sections); - List selItemList = GGW_ApplicationCtrl.querySelectedItemsByGrant(app.Id); + List selItemList = GGW_SectionSelector.querySelectedItemsByGrant(app.Id); //List selItemList = [SELECT Id, Name, GGW_Section__c,Grant_Application__c, Sort_Order__c // FROM GGW_Selected_Item__c WHERE Grant_Application__c =:app.Id]; String itemid = selItemList[0].Id; @@ -264,7 +264,7 @@ public class GGW_ApplicationCtrlTest { GGW_ApplicationCtrl.saveSelectedSectionText(itemid, bwList[0].recordid); Test.stopTest(); // assertion checks that item saved the Block text - List savedItemList = GGW_ApplicationCtrl.querySelectedItemsByGrant(app.Id); + List savedItemList = GGW_SectionSelector.querySelectedItemsByGrant(app.Id); System.assertEquals(blocktext, savedItemList[0].Text_Block__c, 'Block text did not match template'); } @isTest @@ -278,7 +278,7 @@ public class GGW_ApplicationCtrlTest { } } GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Grant App Order', sections); - List selItemList = GGW_ApplicationCtrl.querySelectedItemsByGrant(app.Id); + List selItemList = GGW_SectionSelector.querySelectedItemsByGrant(app.Id); // List of selected Iteam IDs - GGW_Selected_Item__c List itemList = new List(); // FLip order first/last @@ -293,7 +293,7 @@ public class GGW_ApplicationCtrlTest { GGW_ApplicationCtrl.reorderSections(itemList, app.Id); Test.stopTest(); // Check fliped order - List selOrderedList = GGW_ApplicationCtrl.querySelectedItemsByGrant(app.Id); + List selOrderedList = GGW_SectionSelector.querySelectedItemsByGrant(app.Id); System.assertEquals(last, selOrderedList[0].Id, 'Last seleected section item did not match expected'); System.assertEquals(first, selOrderedList[selOrderedList.size()-1].Id, 'First seleectd section item did not match selected'); } diff --git a/force-app/main/default/classes/GGW_ContentBlockSelector.cls b/force-app/main/default/classes/GGW_ContentBlockSelector.cls new file mode 100644 index 0000000..bab90dc --- /dev/null +++ b/force-app/main/default/classes/GGW_ContentBlockSelector.cls @@ -0,0 +1,32 @@ +/* + * 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_ContentBlockSelector Salesforce Content Block text data selector class support GGW. + * + */ +public with sharing class GGW_ContentBlockSelector { + public static GGW_Content_Block__c queryContentBlockById(String blockid){ + GGW_Content_Block__c cBlock = [SELECT Id, Name, Description__c + FROM GGW_Content_Block__c + WHERE Id =: blockid WITH SECURITY_ENFORCED LIMIT 1]; + return cBlock; + } + public static List queryContentBlocksBySection(String sectionId){ + List cbList = [SELECT Id, Name, Description__c, Short_Description__c, + Section__c, Section__r.Name, CreatedDate, + Language__c + FROM GGW_Content_Block__c + WHERE Section__c =: sectionId WITH SECURITY_ENFORCED]; + return cbList; + } + public static List queryContentBlocks(){ + List cbList = [SELECT Id, Name, Description__c, Short_Description__c, + Section__c, Section__r.Name, CreatedDate, + Language__c + FROM GGW_Content_Block__c WITH SECURITY_ENFORCED ORDER BY Section__c]; + return cbList; + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml b/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml new file mode 100644 index 0000000..642d054 --- /dev/null +++ b/force-app/main/default/classes/GGW_ContentBlockSelector.cls-meta.xml @@ -0,0 +1,5 @@ + + + 58.0 + Active + \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentSelector.cls b/force-app/main/default/classes/GGW_ContentSelector.cls new file mode 100644 index 0000000..ebbc560 --- /dev/null +++ b/force-app/main/default/classes/GGW_ContentSelector.cls @@ -0,0 +1,37 @@ +/* + * 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_ContentSelector Salesforce Content data selector class support GGW. + * + */ +public with sharing class GGW_ContentSelector { + public static ContentDocumentLink getDocLinkByLinkedEntity(String recordId) { + return [SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, Visibility, ShareType + FROM ContentDocumentLink + WHERE LinkedEntityId =: recordId WITH SECURITY_ENFORCED LIMIT 1]; + } + public static ContentDistribution getContentDistributionByDocId(String docId){ + return [SELECT Id, Name, ContentVersionId, ContentDocumentId, RelatedRecordId, ContentDownloadUrl + FROM ContentDistribution + WHERE ContentDocumentId =: docId WITH SECURITY_ENFORCED LIMIT 1]; + } + + public static ContentDistribution getContentDistributionById(Id cdid){ + ContentDistribution cdr = [SELECT Id, Name, ContentVersionId, + ContentDownloadUrl, DistributionPublicUrl + FROM ContentDistribution + WHERE Id =: cdid WITH SECURITY_ENFORCED LIMIT 1]; + return cdr; + } + // Query ContentVersion by id + public static ContentVersion getContentFile(String cvid){ + ContentVersion file = [SELECT Id, Title + FROM ContentVersion + WHERE Id =: cvid WITH SECURITY_ENFORCED]; + return file; + } + +} \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml b/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml new file mode 100644 index 0000000..642d054 --- /dev/null +++ b/force-app/main/default/classes/GGW_ContentSelector.cls-meta.xml @@ -0,0 +1,5 @@ + + + 58.0 + Active + \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls b/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls index 1d03dcf..a44c2b1 100644 --- a/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls +++ b/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls @@ -10,7 +10,8 @@ */ public class GGW_GrantApplicationWrapper { @AuraEnabled public String recordid; - @AuraEnabled public String name; + @AuraEnabled public String name; // This can hold a Lookup standard records URL link to Grant by Name + @AuraEnabled public String textname; // Save only grant name as text @AuraEnabled public String status; @AuraEnabled public String logodisplayurl; @AuraEnabled public Boolean logostate; diff --git a/force-app/main/default/classes/GGW_SectionSelector.cls b/force-app/main/default/classes/GGW_SectionSelector.cls new file mode 100644 index 0000000..9007b1c --- /dev/null +++ b/force-app/main/default/classes/GGW_SectionSelector.cls @@ -0,0 +1,59 @@ +/* + * 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_ContentSelector Grant Section data selector class support GGW. + * + */ +public with sharing class GGW_SectionSelector { + public static List querySelectedItemsByGrant(String appId){ + List appItems = [SELECT Id, Application_Name__c, Grant_Application__c, GGW_Section__c, + Section_Name__c,Selected_Block__c, Sort_Order__c, Grant_Application__r.Status__c, + Selected_Block__r.Description__c, Text_Block__c, Language__c + FROM GGW_Selected_Item__c + WHERE Grant_Application__c =: appId WITH SECURITY_ENFORCED ORDER BY Sort_Order__c]; + return appItems; + } + + public static List querySectionsByLanguage(String lang){ + List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, + Sort_Order__c, Language__c + FROM GGW_Section__c + WHERE Suggested__c = true AND Language__c =: lang + WITH SECURITY_ENFORCED ORDER BY Sort_Order__c]; + return sectionList; + } + public static List querySections(){ + List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, + Sort_Order__c, Language__c + FROM GGW_Section__c WITH SECURITY_ENFORCED ORDER BY Sort_Order__c]; + return sectionList; + } + public static List querySectionsByName(String searchKey){ + String key = '%' + searchKey + '%'; + List sectionList = [SELECT Id, Name, CreatedDate, Recommended__c, Suggested__c, + Sort_Order__c, Language__c + FROM GGW_Section__c + WHERE Name LIKE :key AND Suggested__c = false + WITH SECURITY_ENFORCED ORDER BY Sort_Order__c LIMIT 20]; + return sectionList; + } + // Return section with max order to add next section + public static GGW_Section__c findMaxOrderSection(){ + List maxOrderList = [SELECT Sort_Order__c + FROM GGW_Section__c + WHERE Suggested__c = true WITH SECURITY_ENFORCED ORDER BY Sort_Order__c desc]; + GGW_Section__c maxOrder = null; + // Handle situation when Sort order is null - TODO MAY be good to require it + for(GGW_Section__c section : maxOrderList ){ + if(section.Sort_Order__c != null && section.Sort_Order__c > 0){ + maxOrder = section; // assigned MAX order object first found END LOOP here + break; // EXIT Loop + } + } + return maxOrder; + } + +} \ No newline at end of file diff --git a/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml b/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml new file mode 100644 index 0000000..642d054 --- /dev/null +++ b/force-app/main/default/classes/GGW_SectionSelector.cls-meta.xml @@ -0,0 +1,5 @@ + + + 58.0 + Active + \ No newline at end of file diff --git a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html index c2f381c..8a42f8c 100644 --- a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html +++ b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html @@ -11,7 +11,7 @@

- {displayTitle} + {grantName}

@@ -134,126 +134,10 @@

diff --git a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js index 8f1f98f..c8981dd 100644 --- a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js +++ b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js @@ -17,6 +17,7 @@ import { ShowToastEvent } from 'lightning/platformShowToastEvent'; const GRANT_TITLE = 'Grant Application'; const GRANT_TITLE_HEADER = 'Grant Application:'; const GRANT_TITLE_ERROR = 'Grant Application do not exist, please create new or select existing grant.'; +const GRANT_TITLE_LOOKUP_ERROR = 'Grant Application do not contain sections, please add sections to grant using Reorder.'; const GRANT_RECORD_PAGE_URL = '/lightning/r/GGW_Grant_Application__c/'; // Add record ID export default class GgwGrantApplication extends NavigationMixin(LightningElement) { @@ -259,7 +260,7 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen if(name){ this.displayTitle = ` ${GRANT_TITLE_HEADER} ${name}`; }else{ - this.displayTitle = GRANT_TITLE_ERROR; + this.displayTitle = GRANT_TITLE_LOOKUP_ERROR; } } @@ -299,7 +300,7 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.sections = []; // Clear to reload this.currentSections = []; this.recordId = data.recordid; // reset record ID from data in some navi patterns URL parameters can be null - this.grantName = data.name; + this.grantName = data.textname; this.logoState = data.logostate; // Init record page URL this.grantRecordPage = `${GRANT_RECORD_PAGE_URL}${this.recordId}/view`; diff --git a/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.css b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.css new file mode 100644 index 0000000..598daca --- /dev/null +++ b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.css @@ -0,0 +1 @@ +h1 {} \ No newline at end of file diff --git a/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.html b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.html new file mode 100644 index 0000000..f7bd5f4 --- /dev/null +++ b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.html @@ -0,0 +1,123 @@ + + \ No newline at end of file diff --git a/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js new file mode 100644 index 0000000..08cf0b2 --- /dev/null +++ b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js @@ -0,0 +1,8 @@ +import { LightningElement , api } from "lwc"; +export default class GgwStaticNoDataCard extends LightningElement { + @api + recordId; + @api + objectApiName; + @api displayTitle; +} \ No newline at end of file diff --git a/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml new file mode 100644 index 0000000..936a043 --- /dev/null +++ b/force-app/main/default/lwc/ggwStaticNoDataCard/ggwStaticNoDataCard.js-meta.xml @@ -0,0 +1,29 @@ + + 52.0 + true + Ggw static no data card + + lightning__AppPage + lightning__HomePage + lightning__RecordPage + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file