diff --git a/force-app/main/default/classes/GGW_ApplicationCtrl.cls b/force-app/main/default/classes/GGW_ApplicationCtrl.cls index 0513d19..af7bd77 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrl.cls +++ b/force-app/main/default/classes/GGW_ApplicationCtrl.cls @@ -24,6 +24,7 @@ public without sharing class GGW_ApplicationCtrl { 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; @@ -32,7 +33,52 @@ public without sharing class GGW_ApplicationCtrl { } return app; } + // Delete logo file from grant + @AuraEnabled + public static String deleteLogo(String recordId){ + GGW_Grant_Application__c app = new GGW_Grant_Application__c(); + app.Id = recordId; + app.DistributionPublicUrl__c = null; // Logo public URL + app.Logo_Download_Url__c = null; // Logo display URL + app.Include_Logo__c = false; + // Check object CRUD + if(Schema.sObjectType.GGW_Grant_Application__c.isUpdateable()){ + update app; + } + // Find and delete content file and related records + deleteImageLogo(recordId); + return 'Logo image deleted'; + } + // Include or exclude logo image into grant application + @AuraEnabled + public static String includeLogo(String recordId, Boolean state){ + GGW_Grant_Application__c app = new GGW_Grant_Application__c(); + app.Id = recordId; + app.Include_Logo__c = state; + if(Schema.sObjectType.GGW_Grant_Application__c.isUpdateable()){ + update app; + } + return 'Application logo updated'; + } + private static void deleteImageLogo(String recordId){ + ContentDocumentLink cdl = [SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, Visibility, ShareType + FROM ContentDocumentLink + WHERE LinkedEntityId =: recordId WITH SECURITY_ENFORCED]; + + ContentDistribution cntdistr = [SELECT Id, Name, ContentVersionId, ContentDocumentId, RelatedRecordId, ContentDownloadUrl + FROM ContentDistribution + WHERE ContentDocumentId =: cdl.ContentDocumentId WITH SECURITY_ENFORCED]; + + ContentDocument cd = new ContentDocument(); + cd.Id = cdl.ContentDocumentId; + if(Schema.sObjectType.ContentDistribution.isDeletable()){ + delete cntdistr; + } + if(Schema.sObjectType.ContentDocument.isDeletable()){ + delete cd; + } + } private static String getValidLogoURL(GGW_Grant_Application__c grant){ String logourl = null; if(grant != null && grant.Logo_Download_Url__c != null){ @@ -286,15 +332,6 @@ public without sharing class GGW_ApplicationCtrl { } */ - // Utility selector method - 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; - } /** * Method to create a new ContentBlock add to section as part a library to later reuse * on other Grant applications. @@ -518,6 +555,15 @@ 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 diff --git a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls index 3e87083..0fc8da7 100644 --- a/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls +++ b/force-app/main/default/classes/GGW_ApplicationCtrlTest.cls @@ -15,6 +15,123 @@ public class GGW_ApplicationCtrlTest { GGW_TestDataFactory.createGrantContentTestData(); } + @isTest + static void includeLogoTest(){ + // Query all suggested sections + List lst = GGW_ApplicationCtrl.getSections(); + List sections = new List(); + for (GGW_SectionWrapper gww : lst){ + if(gww.selected){ + sections.add(gww.recordid); + } + } + + GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('MyTest Grant', sections); + + Test.startTest(); + String msg = GGW_ApplicationCtrl.includeLogo(app.Id, true); + Test.stopTest(); + + System.assertEquals('Application logo updated', msg, 'Invalid message returnd for Logo include into Grant'); + GGW_GrantApplicationWrapper grant = GGW_ApplicationCtrl.getApplication(app.Id); + System.assertEquals(app.Id, grant.recordid, 'Invalid grant application Id'); + System.assertEquals(true, grant.logostate, 'Logo include state is not valid'); + } + static void excludeLogoTest(){ + // Query all suggested sections + List lst = GGW_ApplicationCtrl.getSections(); + List sections = new List(); + for (GGW_SectionWrapper gww : lst){ + if(gww.selected){ + sections.add(gww.recordid); + } + } + + GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('MyTest Grant', sections); + + Test.startTest(); + String msg = GGW_ApplicationCtrl.includeLogo(app.Id, false); + Test.stopTest(); + + System.assertEquals('Application logo updated', msg, 'Invalid message returnd for Logo include into Grant'); + GGW_GrantApplicationWrapper grant = GGW_ApplicationCtrl.getApplication(app.Id); + System.assertEquals(app.Id, grant.recordid, 'Invalid grant application Id'); + System.assertEquals(false, grant.logostate, 'Logo exclude state is not valid'); + } + + @isTest + static void deleteLogoTest(){ + // Query all suggested sections + List lst = GGW_ApplicationCtrl.getSections(); + List sections = new List(); + for (GGW_SectionWrapper gww : lst){ + if(gww.selected){ + sections.add(gww.recordid); + } + } + GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Grant Logo delete Test', sections); + + //ContentDocument cdoc = new ContentDocument(); + //cdoc.Title = 'Grant test logo'; + //insert cdoc; + + ContentVersion cvo = new Contentversion(); + //cvo.ContentDocumentId = cdoc.Id; + cvo.Title = 'Test Content file'; + cvo.PathOnClient = 'test'; + cvo.VersionData = EncodingUtil.base64Decode('Unit Test Attachment Body'); + //List cvl = new List(); + //cvl.add(cvo); + insert cvo; + + ContentVersion cvtmp = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id =: cvo.Id]; + // Create content document Link + ContentDocumentLink cdl = new ContentDocumentLink(); + cdl.LinkedEntityId = app.Id; + cdl.ContentDocumentId = cvtmp.ContentDocumentId; + insert cdl; + + String downloadURL = GGW_ApplicationCtrl.createContentDistribution(app.Id, cvo.Id); + + Test.startTest(); + String result = GGW_ApplicationCtrl.deleteLogo(app.Id); + + Test.stopTest(); + System.assertEquals('Logo image deleted', result, 'Logo delete is not valid'); + + } + @isTest + static void createContentDistributionTest(){ + // Query all suggested sections + List lst = GGW_ApplicationCtrl.getSections(); + List sections = new List(); + for (GGW_SectionWrapper gww : lst){ + if(gww.selected){ + sections.add(gww.recordid); + } + } + GGW_Grant_Application__c app = GGW_ApplicationCtrl.newGrant('Content Distribution Test', sections); + ContentVersion cvo = new Contentversion(); + cvo.Title = 'Test Content file'; + cvo.PathOnClient = 'test'; + cvo.VersionData = EncodingUtil.base64Decode('Unit Test Attachment Body'); + insert cvo; + ContentVersion cvtmp = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id =: cvo.Id]; + // Create content document Link + ContentDocumentLink cdl = new ContentDocumentLink(); + cdl.LinkedEntityId = app.Id; + cdl.ContentDocumentId = cvtmp.ContentDocumentId; + insert cdl; + + Test.startTest(); + String downloadURL = GGW_ApplicationCtrl.createContentDistribution(app.Id, cvo.Id); + Test.stopTest(); + + System.assertNotEquals(null, downloadURL, 'Contenet distribution is invalid'); + GGW_GrantApplicationWrapper grant = GGW_ApplicationCtrl.getApplication(app.Id); + System.assertEquals(downloadURL, grant.logodisplayurl, 'Logo download URL is not valid'); + + } @isTest static void testNewGrant(){ // Query all suggested sections diff --git a/force-app/main/default/classes/GGW_ExportCtrl.cls b/force-app/main/default/classes/GGW_ExportCtrl.cls index 89393cd..2e464a8 100644 --- a/force-app/main/default/classes/GGW_ExportCtrl.cls +++ b/force-app/main/default/classes/GGW_ExportCtrl.cls @@ -11,10 +11,12 @@ public without sharing class GGW_ExportCtrl { public String recordId {get; set;} public String appName {get;set;} public String logoURL {get; set;} + public Boolean isDisplayLogo {get; set;} public List items {get; set;} private final GGW_Grant_Application__c app; public GGW_ExportCtrl(ApexPages.StandardController stdController) { + this.isDisplayLogo = false; this.app = (GGW_Grant_Application__c)stdController.getRecord(); if(this.app != null && this.app.Id != null){ this.recordId = this.app.Id; @@ -36,6 +38,9 @@ public without sharing class GGW_ExportCtrl { GGW_Grant_Application__c app = GGW_Util.queryGrantApp(this.recordId.escapeHtml4()); if(app != null && app.Logo_Download_Url__c != null){ this.logoURL = app.Logo_Download_Url__c; + if(app.Include_Logo__c == true){ + this.isDisplayLogo = true; + } } this.items = GGW_Util.getSelectedItems(this.recordId.escapeHtml4()); diff --git a/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls b/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls index 6b49593..1d03dcf 100644 --- a/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls +++ b/force-app/main/default/classes/GGW_GrantApplicationWrapper.cls @@ -13,6 +13,7 @@ public class GGW_GrantApplicationWrapper { @AuraEnabled public String name; @AuraEnabled public String status; @AuraEnabled public String logodisplayurl; + @AuraEnabled public Boolean logostate; @AuraEnabled public String language; @AuraEnabled public List unselectSectionList; // Used to add new sections to Grant @AuraEnabled public List selectedContentBlock; // Include Section and Text block diff --git a/force-app/main/default/classes/GGW_Util.cls b/force-app/main/default/classes/GGW_Util.cls index 66e8423..64fe3fd 100644 --- a/force-app/main/default/classes/GGW_Util.cls +++ b/force-app/main/default/classes/GGW_Util.cls @@ -25,7 +25,7 @@ public without sharing class GGW_Util { } 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 + DistributionPublicUrl__c, Status__c, Description__c, Language__c, Include_Logo__c FROM GGW_Grant_Application__c WHERE Id =: appId WITH SECURITY_ENFORCED LIMIT 1]; } diff --git a/force-app/main/default/layouts/GGW_Grant_Application__c-Grant Application Layout.layout-meta.xml b/force-app/main/default/layouts/GGW_Grant_Application__c-Grant Application Layout.layout-meta.xml index 1543308..11d4490 100644 --- a/force-app/main/default/layouts/GGW_Grant_Application__c-Grant Application Layout.layout-meta.xml +++ b/force-app/main/default/layouts/GGW_Grant_Application__c-Grant Application Layout.layout-meta.xml @@ -25,21 +25,25 @@ Edit - Logo_Download_Url__c + Language__c + + Edit - DistributionPublicUrl__c + OwnerId Edit - Language__c + Include_Logo__c - - Edit - OwnerId + Logo_Download_Url__c + + + Edit + DistributionPublicUrl__c @@ -107,7 +111,7 @@ false false - 00h0R000008ilih + 00h01000002bd1h 4 0 Default diff --git a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html index de3387e..7b3f437 100644 --- a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html +++ b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.html @@ -60,7 +60,32 @@

- + + @@ -76,7 +101,7 @@

selected-item-id={sec.selecteditem} sectioncount={sec.sectioncount} sortorder={sec.sortorder} - onselectedtext={hanldeSelectedTextChange} + onselectedtext={handleSelectedTextChange} ondeletesection={handleDeleteSection} key={sec.value} > diff --git a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js index f8e6643..d164fab 100644 --- a/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js +++ b/force-app/main/default/lwc/ggwGrantApplication/ggwGrantApplication.js @@ -8,13 +8,10 @@ import { LightningElement ,wire , api, track } from "lwc"; import { CloseActionScreenEvent } from 'lightning/actions'; import { CurrentPageReference, NavigationMixin } from 'lightning/navigation'; import getApplication from '@salesforce/apex/GGW_ApplicationCtrl.getApplication'; +import includeLogo from '@salesforce/apex/GGW_ApplicationCtrl.includeLogo'; +import deleteLogo from '@salesforce/apex/GGW_ApplicationCtrl.deleteLogo'; import createContentDistribution from '@salesforce/apex/GGW_ApplicationCtrl.createContentDistribution'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; -//import { updateRecord } from 'lightning/uiRecordApi'; -//import { getRecord } from 'lightning/uiRecordApi'; -//import ID_FIELD from '@salesforce/schema/GGW_Grant_Application__c.Id'; -//import GRANTNAME_FIELD from '@salesforce/schema/GGW_Grant_Application__c.Name'; -//import {refreshApex} from '@salesforce/apex'; const GRANT_TITLE = 'Grant Application'; const GRANT_TITLE_HEADER = 'Grant Application:'; @@ -27,6 +24,8 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen @api grantName; @api contentDownloadUrl;// = 'https://data-drive-2030-dev-ed.file.force.com/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Png&versionId=0680R000001qFvW&operationContext=DELIVERY&contentId=05T0R0000069df5&page=0&d=/a/0R0000008lyn/kf5IDPjQuijS940z47u73Rnb2zSvfmkdSXUpc5S2oSU&oid=00D0R000000nmUQ&dpt=null&viewId='; @api language = 'en_US'; + @track logoState = false; // Exclude or include logo + @track showLogoButtons = false; noLogoDisplay = true; // Display empty avatar instead of logo displayTitle; status; @@ -46,6 +45,24 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen showCard = true; // Display Editor card if data grant exists ELSE show illustration @track grantRecordPage = GRANT_RECORD_PAGE_URL; @track currentPageReference; + + showToastSuccess(msg){ + const evt = new ShowToastEvent({ + title: this._title, + message: msg, + variant: 'success', + }); + this.dispatchEvent(evt); + } + showToastError(msg){ + const evt = new ShowToastEvent({ + title: this._title, + message: msg, + variant: 'error', + }); + this.dispatchEvent(evt); + } + @wire(CurrentPageReference) setCurrentPageReference(currentPageReference) { this.currentPageReference = currentPageReference; @@ -59,10 +76,44 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.displayGrantCard(); this.queryGrantApplication(); } + + handleLogoSelectorClick() { + this.logoState = !this.logoState; + includeLogo({recordId: this.recordId, state: this.logoState}) + .then((data) => { + console.log(`Logo state was updated ${this.logoState}`); + this.error = undefined; + this.showToastSuccess(`${data} ${this.logoState ? 'included' : 'excluded'}`); + }) + .catch((error) => { + console.log(error); + this.error = error; + this.showToastError('Logo selection error.'); + }); + } + + handleLogoDelete(event){ + deleteLogo({recordId: this.recordId}) + .then((data) => { + console.log(`Logo file was deleted`); + this.error = undefined; + this.logoState = false; // OFF Include button on editor page + this.showLogoButtons = false; // remove logo manage buttons + this.noLogoDisplay = true; + this.showToastSuccess(data); + }) + .catch((error) => { + console.log(error); + this.error = error; + this.showToastError('Logo file delete error.'); + }); + } + reloadSections(){ this.queryGrantApplication(); } + displayGrantCard(){ if(this.recordId != null){ this.showCard = true; // SHo current Grant @@ -70,10 +121,12 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.showCard = false; // Display Illustration NO Grant Data yet } } + closeModal() { this.dispatchEvent(new CloseActionScreenEvent()); this.openModal = false; } + // This methods used for Logo image uploads accept only png or jpg files get acceptedFormats() { return ['.jpg', '.png']; } @@ -91,9 +144,10 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen createContentDistribution({grantId: this.recordId, cvid: uploadedFiles[0].contentVersionId}) .then((data) => { console.log('URL: '+data); - alert('IMAGE URL: ' + data); + //alert('IMAGE URL: ' + data); this.contentDownloadUrl = data; this.noLogoDisplay = false; + this.showLogoButtons = true; this.error = undefined; }) .catch((error) => { @@ -101,8 +155,8 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.error = error; this.noLogoDisplay = true; }); - } + handleExportMenuSelect(event){ const selectedItemValue = event.detail.value; console.log('## handleExportMenuSelect: '+selectedItemValue); @@ -115,8 +169,8 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen if(selectedItemValue == 'exportHTML'){ this.exportGrantVFHTML(); } - } + exportGrantVFHTML(){ this[NavigationMixin.Navigate]({ type: 'standard__navItemPage', @@ -128,8 +182,8 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen c__format: 'html' // Need this state object to pass parameters in LEX } // LEX will strip all parameters such as recordID so must add c__recordId }); - } + exportGrantVFWord(){ // Tab name - Grant Preview Word this[NavigationMixin.Navigate]({ @@ -138,15 +192,14 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen apiName: 'Grant_Preview_Word' }, state: { - c__recordId: this.recordId // Need this state object to pass parameters in LEX + c__recordId: this.recordId, // Need this state object to pass parameters in LEX + c__format: 'word' } // LEX will strip all parameters such as recordID so must add c__recordId }); - } - exportGrantVFPdf(){ - //this.grantPageURL = '/apex/GGW_GrantPreview?c__recordId='+this.recordId; - //this.openVFPExportModal = true; + exportGrantVFPdf(){ + // Tab Name - Grant_Preview_PDF this[NavigationMixin.Navigate]({ type: 'standard__navItemPage', attributes: { @@ -157,29 +210,61 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen c__format: 'pdf' } // LEX will strip all parameters such as recordID so must add c__recordId }); -/* - this[NavigationMixin.GenerateUrl]({ - type: 'standard__webPage', - attributes: { - url: this.grantPageURL - } - }).then(generatedUrl => { - window.open(generatedUrl); - }); -*/ } + closePDFModal(){ this.openVFPExportModal = false; } - - queryGrantApplication(){ + + setLogoDisplay(logoUrl){ + if (logoUrl != null){ + this.contentDownloadUrl = logoUrl; // load display URL logo + this.noLogoDisplay = false; + this.showLogoButtons = true; + }else{ + this.noLogoDisplay = true; + this.showLogoButtons = false; + } + } + + setDisplayTitle(name){ + if(name){ + this.displayTitle = ` ${GRANT_TITLE_HEADER} ${name}`; + }else{ + this.displayTitle = GRANT_TITLE_ERROR; + } + } + + setSectionsFromArray(selectedContentBlock){ + if (selectedContentBlock){ + this.sectioncount = selectedContentBlock.length; + for(var i = 0; i < selectedContentBlock.length; i++) { + var item = selectedContentBlock[i]; + var tmpText = item.displaytext ? item.displaytext : 'Text placeholder'; // Set text value condition for null + this.sections = [...this.sections ,{label: item.sectionname, + displaytitle: '['+item.sortorder+'] ' + item.sectionname, + value: item.sectionid, // sfid for Section record + appid: this.recordId, // Id for Grant Application record + hasblocks: true, + sectioncount: this.sectioncount, // pass number of sections to LWC for sorting + sortorder: item.sortorder, + selecteditem: item.selecteditemid, + blockid: item.recordid, // sfid for Content Block record + textblock: tmpText} ]; + + console.log(`Text: ${item.displaytext}`); + } + // Save temp section value + this.currentSections = this.sections; + } + } + + queryGrantApplication() { // --- Need this timeout delay to allow record ID from Quick Action on record page to be set // For some crazy reason LEX/LWC does not init record ID fast enough to init this call setTimeout(() => { console.log(`queryGrantApplication: Init App with ID: ${this.recordId}`); - //this.displayTitle = 'Grant Application: ' + this.grant.data ? this.grant.data.fields.Name.value : null; - - // Change to call imperative insted of wire for data refreshes + // Change to call imperative instead of wire for data refreshes getApplication({recordId: this.recordId}) .then((data) => { console.log(`queryGrantApplication: Grant Name: ${data.name}`); @@ -187,47 +272,17 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.currentSections = []; this.recordId = data.recordid; // reset record ID from data in some navi patterns URL parameters can be null this.grantName = data.name; - // Init recrd page URL + this.logoState = data.logostate; + // Init record page URL this.grantRecordPage = `${GRANT_RECORD_PAGE_URL}${this.recordId}/view`; - - // Conditianal display of logo if it is available or show empty placeholder image - if (data.logodisplayurl != null){ - this.contentDownloadUrl = data.logodisplayurl; // load display URL logo - this.noLogoDisplay = false; - }else{ - this.noLogoDisplay = true; - } - this.displayGrantCard(); // nadle UX display fo main card or illustration NO Data - if(data.name){ - this.displayTitle = ` ${GRANT_TITLE_HEADER} ${data.name}`; - }else{ - this.displayTitle = GRANT_TITLE_ERROR; - } + // Conditional display of logo if it is available or show empty placeholder image + this.setLogoDisplay(data.logodisplayurl); + this.displayGrantCard(); // handle UX display fo main card or illustration NO Data + this.setDisplayTitle(data.name) this.status = data.status; - - if (data.selectedContentBlock){ - this.sectioncount = data.selectedContentBlock.length; - for(var i=0; i { console.log(error); @@ -236,12 +291,13 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.displayTitle = GRANT_TITLE_ERROR; }); }, 5); - } + } + // when the component is first initialized assign an initial value to sections and other Grant App variables connectedCallback() { this.queryGrantApplication(); - //this.sections = this.currentSections; } + handleDeleteSection(){ // Section - selected item data has been deleted by Section component action // here we only refresh UI/UX @@ -249,45 +305,27 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.queryGrantApplication(); this.sections = this.currentSections; } + // Open section Modal to reorder reorderSections(){ - console.log('REORDER MODAL for App: '+this.recordId); + console.log(`REORDER MODAL for App: ${this.recordId}`); this.openModal = true; } - hanldeSelectedTextChange(event){ + handleSelectedTextChange(event){ //this.textBlock = event.detail; - console.log('hanldeSelectedTextChange: Section:'+event.detail.section+' TXT: '+event.detail.text+' BlockID:'+event.detail.blockid); - // Display toaster message - /* - const evt = new ShowToastEvent({ - title: this._title, - message: 'Section:'+event.detail.section+' TXT: '+event.detail.text+' BlockID:'+event.detail.blockid, - variant: this.variant, - }); - this.dispatchEvent(evt); - */ + console.log(`handleSelectedTextChange: Section: ${event.detail.section} TXT: ${event.detail.text} BlockID: ${event.detail.blockid}`); } updateGrant(){ - /* - console.log('Show Text Block:'+this.sections[0].textblock); - // Display toaster message - const evt = new ShowToastEvent({ - title: this._title, - message: 'Show Text Block:'+this.sections[0].textblock, - variant: this.variant, - }); - this.dispatchEvent(evt); - */ this.closeModal(); } // Order section change handleSectionOrderChange(event){ // TODO There strange problem refresh of section list is late even data is reloaded - // Modal Action box still not refresh, for now solve close box repoen will show new order. - console.log('handleSectionOrderChange: ORDER Change event:'+this.recordId); + // Modal Action box still not refresh, for now workaround close box reopen will show new order. + console.log(`handleSectionOrderChange: ORDER Change event: ${this.recordId}`); // Arange new order sections on UI on client side // refreshApex(this.handleLoad()); // Close modal @@ -295,93 +333,10 @@ export default class GgwGrantApplication extends NavigationMixin(LightningElemen this.closeModal(); if(event.detail.items){ // Display toaster message if data was updated - const evt = new ShowToastEvent({ - title: this._title, - message: 'Updated grant sections order or add new section', - variant: this.variant, - }); - this.dispatchEvent(evt); + showToastSuccess(`Updated grant sections order or add new section`); } // Reload data this.queryGrantApplication(); this.sections = this.currentSections; } - - /* This standard call is replaced by Apex method getApplication with related blocks sections. - @wire(getRecord, {recordId: '$recordId',fields: [GRANTNAME_FIELD]}) - wireGrantApp({error,data}){ - if (data) { - console.log('Grant Name: '+data.fields.Name.value); - this.grantName = data.fields.Name.value; - this.displayTitle = 'Grant Application: ' + data.fields.Name.value; - this.error = undefined; - }else if(error){ - console.log(error); - this.error = error; - //this.sections = undefined; - }else{ - // eslint-disable-next-line no-console - console.log('unknown error'); - } - } - */ - - -/* -- Need to to update data and cache=true does not fit here swicth using connected Callback with a GACKy Hack - @wire(getApplication, {recordId: '$recordId'}) - wireApplication({error,data}){ - if (data) { - console.log('Grant Name: '+data.name); - this.grantName = data.name; - this.displayTitle = 'Grant Application: ' + data.name; - this.status = data.status; - if (data.selectedContentBlock){ - for(var i=0; i + + Include_Logo__c + false + This boolean TRU/FALSE field indicates if log be included or not in final application + false + This boolean TRU/FALSE field indicates if log be included or not in final application + + false + Checkbox + diff --git a/force-app/main/default/pages/GGW_GrantPreview.page b/force-app/main/default/pages/GGW_GrantPreview.page index 91526ae..1143f8c 100644 --- a/force-app/main/default/pages/GGW_GrantPreview.page +++ b/force-app/main/default/pages/GGW_GrantPreview.page @@ -10,8 +10,11 @@ - Grant Logo -
+ + Grant Logo +
+
+

{!appName}

diff --git a/force-app/main/default/pages/GGW_GrantPreviewPdf.page b/force-app/main/default/pages/GGW_GrantPreviewPdf.page index 81a9bd3..be0e14d 100644 --- a/force-app/main/default/pages/GGW_GrantPreviewPdf.page +++ b/force-app/main/default/pages/GGW_GrantPreviewPdf.page @@ -9,9 +9,10 @@ - - Grant Logo -
+ + Grant Logo +
+

{!appName}

diff --git a/force-app/main/default/pages/GGW_GrantPreviewWord.page b/force-app/main/default/pages/GGW_GrantPreviewWord.page index 2ffac2e..d34f682 100644 --- a/force-app/main/default/pages/GGW_GrantPreviewWord.page +++ b/force-app/main/default/pages/GGW_GrantPreviewWord.page @@ -10,8 +10,10 @@ - Grant Logo -
+ + Grant Logo +
+

{!appName} diff --git a/force-app/main/default/permissionsets/GGW_User_Permissions.permissionset-meta.xml b/force-app/main/default/permissionsets/GGW_User_Permissions.permissionset-meta.xml index 8d4f235..58e86a0 100644 --- a/force-app/main/default/permissionsets/GGW_User_Permissions.permissionset-meta.xml +++ b/force-app/main/default/permissionsets/GGW_User_Permissions.permissionset-meta.xml @@ -127,6 +127,11 @@ GGW_Grant_Application__c.DistributionPublicUrl__c true + + true + GGW_Grant_Application__c.Include_Logo__c + true + true GGW_Grant_Application__c.Language__c