Skip to content

Commit

Permalink
Merge f012808 into feature/238
Browse files Browse the repository at this point in the history
  • Loading branch information
salesforce-org-metaci[bot] committed Nov 21, 2023
2 parents 7d60e0f + f012808 commit 703c340
Show file tree
Hide file tree
Showing 77 changed files with 1,330 additions and 511 deletions.
1 change: 1 addition & 0 deletions StaticResourceSources/npsp-slds/npsp-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ input.lookupInput {
input.lookupInputSLDS {
width: 100%;
margin-right: -30px !important;
border-color: #747474 !important;
}
body .dateInput input[type="text"], .slds-vf-scope .dateInput input[type="text"] {
margin-left: 0;
Expand Down
5 changes: 4 additions & 1 deletion force-app/main/default/classes/ACCT_ViewOverride_CTRL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public with sharing class ACCT_ViewOverride_CTRL {
public ACCT_ViewOverride_CTRL (ApexPages.StandardController controller)
{
//get the account with the npe01__one2oneContact__c field for use in the rederict if necessary
List <Account> accounts = [select id, npe01__one2oneContact__c, npe01__SYSTEM_AccountType__c from Account where id = :ApexPages.currentPage().getParameters().get('id')];
// WITH SECURITY_ENFORCED isn't really necessary, but it won't hurt anything and should pass automated
// security checks
List <Account> accounts = [select id, npe01__one2oneContact__c, npe01__SYSTEM_AccountType__c
from Account where id = :ApexPages.currentPage().getParameters().get('id') WITH SECURITY_ENFORCED];
if (accounts.size() > 0)
{
account = accounts[0];
Expand Down
80 changes: 79 additions & 1 deletion force-app/main/default/classes/ALLO_ManageAllocations_CTRL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,65 @@ public with sharing class ALLO_ManageAllocations_CTRL {
set;
}

private Boolean canCreate {
get {
if (this.canCreate == null) {
this.canCreate = this.checkCreate();
}

return this.canCreate;
}
set;
}

private Boolean canDelete {
get {
if (this.canDelete == null) {
this.canDelete = this.checkDelete();
}

return this.canDelete;
}
set;
}

private Boolean canUpdate {
get {
if (this.canUpdate == null) {
this.canUpdate = this.checkUpdate();
}

return this.canUpdate;
}
set;
}

private Set<SObjectField> getFieldsForFLSCheck() {
Set<SObjectField> objectFields = new Set<SObjectField>();

objectFields.add(Allocation__c.Amount__c.getDescribe().getSobjectField());
objectFields.add(Allocation__c.Percent__c.getDescribe().getSobjectField());
objectFields.add(Allocation__c.General_Accounting_Unit__c.getDescribe().getSobjectField());

for(Schema.FieldSetMember additionalField : additionalAllocationFields) {
objectFields.add(additionalField.getSObjectField());
}

return objectFields;
}

private Boolean checkCreate() {
return UTIL_Permissions.getInstance().canCreate(Allocation__c.SObjectType, fieldsForFLSCheck);
}

private Boolean checkDelete() {
return UTIL_Permissions.getInstance().canDelete(Allocation__c.SObjectType);
}

private Boolean checkUpdate() {
return UTIL_Permissions.getInstance().canUpdate(Allocation__c.SObjectType, fieldsForFLSCheck);
}

public String getNamespace() {
return UTIL_Namespace.getComponentNamespace();
}
Expand All @@ -69,6 +128,16 @@ public with sharing class ALLO_ManageAllocations_CTRL {
set;
}

private Set<SObjectField> fieldsForFLSCheck {
get {
if (fieldsForFLSCheck == null) {
fieldsForFLSCheck = getFieldsForFLSCheck();
}
return fieldsForFLSCheck;
}
set;
}

/** @description List of allocations to delete when the user clicks Save.*/
public list<Allocation__c> allocationsToBeDeleted = new list<Allocation__c>();
/** @description The id of the parent object; Opportunity, Campaign, or Recurring Donation.*/
Expand Down Expand Up @@ -295,6 +364,9 @@ public with sharing class ALLO_ManageAllocations_CTRL {
Savepoint sp = Database.setSavepoint();
try {
if (!allocationsToBeDeleted.isEmpty()) {
if (!canDelete) {
UTIL_AuraEnabledCommon.throwAuraHandledException(System.Label.commonAccessErrorMessage);
}
TDTM_ProcessControl.setRecursionFlag(TDTM_ProcessControl.flag.ALLOC, false);
delete allocationsToBeDeleted;

Expand All @@ -309,11 +381,17 @@ public with sharing class ALLO_ManageAllocations_CTRL {
}

if (!listAlloForUpdate.isEmpty()) {
if (!canUpdate) {
UTIL_AuraEnabledCommon.throwAuraHandledException(System.Label.commonAccessErrorMessage);
}
TDTM_ProcessControl.setRecursionFlag(TDTM_ProcessControl.flag.ALLOC, false);
update listAlloForUpdate;
}

if (!listAlloForInsert.isEmpty()) {
if (!canCreate) {
UTIL_AuraEnabledCommon.throwAuraHandledException(System.Label.commonAccessErrorMessage);
}
TDTM_ProcessControl.setRecursionFlag(TDTM_ProcessControl.flag.ALLOC, false);
insert listAlloForInsert;
}
Expand Down Expand Up @@ -354,7 +432,7 @@ public with sharing class ALLO_ManageAllocations_CTRL {
new ApexPages.Message(
ApexPages.Severity.WARNING,
String.format(
System.Label.exceptionDeletePermission,
System.Label.commonAccessErrorMessage,
new String[]{UTIL_Describe.getObjectLabel(UTIL_Namespace.StrTokenNSPrefix('Allocation__c'))})));

}
Expand Down
201 changes: 10 additions & 191 deletions force-app/main/default/classes/BDE_BatchEntry_CTRL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -110,91 +110,22 @@ public with sharing class BDE_BatchEntry_CTRL {
* @return void
*/
public void initializeBatchEntry(){

bdec = UTIL_CustomSettingsFacade.getBDESettings();

//no defaults yet loaded, create one
if (bdec == null){
bdec = new Batch_Data_Entry_Settings__c();
UTIL_DMLService.insertRecord(bdec);
}

BDE_BatchDataEntry bde = new BDE_BatchDataEntry(objname);

if (!bde.getStatusMessage().contains(bde.getFailureMessage())){
BDE_BatchDataEntry bde = new BDE_BatchDataEntry(objname);
if (!bde.getStatusMessage().contains(bde.getFailureMessage())){
objname = bde.getObjectName();

if(objname!=null) {
batchLookupField = bde.getBatchLookupFieldname();
displayBatchSection = bde.getSaveBatch();
displayRecInfoSection = true;

String pluralName = UTIL_Describe.getObjectDescribe(objname).getLabelPlural();
pageSubtitle = pluralName;

entryFieldList = new list<EntryField>();

for (string fn : bde.getEntryFieldList())
entryFieldList.add(new EntryField(objname, fn));

listFieldList = bde.getListFieldList();
itemList = new list<BatchItem>();

if (displayBatchSection) {
// create the batch if it is new
if (batch.id == null) {
batch.name = pluralName + ' ' + system.today().format();
batch.object_name__c = objName;
// we will insert this in the load event
}
else {
string q = bde.getQueryString();
q += ' where ' + batchLookupField + ' = \'' + batch.id + '\'';

list<sobject> existingsobjs = database.query(q);

if (!existingsobjs.isEmpty()){

//if its opps and npsp, query for the ocrs
//so we can properly backfill the objects in the batch items
if (existingsobjs[0].getSobjectType() == Opportunity.Sobjecttype){
ocrlookup = new map<id, OpportunityContactRole>();
list<OpportunityContactRole> ocrlist = [select id, OpportunityID, ContactID from OpportunityContactRole where OpportunityID IN :existingsobjs and isPrimary = true];
for (OpportunityContactRole ocr : ocrlist){
ocrlookup.put(ocr.OpportunityID, ocr);
}
}
}

for (sObject existing : existingsobjs) {
itemList.add(new BatchItem(this, existing));
}
}
}

currentItem = new BatchItem(this);
}
}
else{
objectSettingsList = new List<SelectOption>();
map<string, string> mapBDE = BDE_BatchDataEntry.mapDevNameToLabelBDEObjects();
for(String strDevName : mapBDE.keySet()) {
objectSettingsList.add(new SelectOption(strDevName, mapBDE.get(strDevName)));
}

pageSubtitle = 'Batch Data Entry Home';
displaySettingsSection = true;
displayBatchSection = false;
displayRecInfoSection = false;
}
}
else{
}
}
else{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, bde.getStatusMessage()));
displaySettingsSection = false;
displayBatchSection = false;
displayRecInfoSection = false;
}
}
}

private void requeryItem(BatchItem item) {

BDE_BatchDataEntry bde = new BDE_BatchDataEntry(objname);
Expand Down Expand Up @@ -290,14 +221,7 @@ public with sharing class BDE_BatchEntry_CTRL {
myDad.currentItem = this;
return null;
}

public pageReference deleteItem() {
// delete this item from the list
myDad.deleteItem(sobj);
return null;

}


//automatic donation naming
public string createName(){
string namestring = '';
Expand Down Expand Up @@ -327,91 +251,7 @@ public with sharing class BDE_BatchEntry_CTRL {

/***** OTHER CONTROLLER METHODS ******/

/*******************************************************************************************************
* @description actionMethod to save the batch detail information
* @return null
*/
public pageReference saveBatch() {
Savepoint sp = Database.setSavepoint();
try {
TDTM_Runnable.DmlWrapper dmlWrapper = new TDTM_Runnable.DmlWrapper();
// if we are using batch, save the batch
if (displayBatchSection && itemList!=null) {
batch.number_of_items__c = itemList.size();

if (batch.id == null)
dmlWrapper.objectsToInsert.add(batch);
else
dmlWrapper.objectsToUpdate.add(batch);
}
TDTM_TriggerHandler.processDML(dmlWrapper);

} catch(Exception e) {
Database.rollback(sp);
ERR_Handler.processError(e, ERR_Handler_API.Context.BDE);
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
return null;
}
/*******************************************************************************************************
* @description actionMethod to save the current batch item
* @return null
*/
public pageReference save() {
Savepoint sp = Database.setSavepoint();

try {
if (currentItem.sobj.id != null) {
if(currentItem.sobj.getSObjectType() == Opportunity.Sobjecttype){
currentItem.sobj.put('npe01__Contact_ID_for_Role__c', currentItem.npspocr.ContactID);
currentItem.sobj.put(UTIL_Namespace.StrTokenNSPrefix('Primary_Contact__c'), currentItem.npspocr.ContactID);
}

//update the name in case values have changed
if(currentItem.sobj.getSObjectType() == Opportunity.Sobjecttype && (bdec.Opportunity_Naming__c == true || (bdec.Allow_Blank_Opportunity_Names__c == false && currentItem.sobj.get('Name') == null))){
currentItem.sobj.put('Name', currentItem.createName());
}

UTIL_DMLService.updateRecord(currentItem.sobj);
} else {
if(currentItem.sobj.getSObjectType() == Opportunity.Sobjecttype){
currentItem.sobj.put('npe01__Contact_ID_for_Role__c', currentItem.npspocr.ContactID);
currentItem.sobj.put(UTIL_Namespace.StrTokenNSPrefix('Primary_Contact__c'), currentItem.npspocr.ContactID);
}

//use automatic opp naming
if(currentItem.sobj.getSObjectType() == Opportunity.Sobjecttype && (bdec.Opportunity_Naming__c == true || (bdec.Allow_Blank_Opportunity_Names__c == false && currentItem.sobj.get('Name') == null))){
currentItem.sobj.put('Name', currentItem.createName());
}

if (itemList.isEmpty()) {
itemList.add(currentItem);
saveBatch();
//we can't guarantee a lookup field when running tests
//so skip this line when in a test context
//if (!test.isRunningTest()) DJH: OK to assume Opportunity has batch__c
currentItem.sobj.put(batchLookupField, batch.Id);

UTIL_DMLService.insertRecord(currentItem.sobj);
}
else {
UTIL_DMLService.insertRecord(currentItem.sobj);
itemList.add(0, currentItem);
}
}
saveBatch();

// update the current item, in case any triggers modified values we will display.
requeryItem(currentItem);
currentItem = new BatchItem(this);
return null;
} catch(Exception e) {
Database.rollback(sp);
ERR_Handler.processError(e, ERR_Handler_API.Context.BDE);
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
return null;
}
/*******************************************************************************************************
* @description actionMethod to clear the current batch item
* @return null
Expand All @@ -420,28 +260,7 @@ public with sharing class BDE_BatchEntry_CTRL {
currentItem = new BatchItem(this);
return null;
}
/*******************************************************************************************************
* @description actionMethod to delete sobject related to the batch item and remove the item from the list
* @param sobj the sObject to delete
* @return void
*/
public void deleteItem(sobject sobj) {
Savepoint sp = Database.setSavepoint();
try {
delete sobj;
for (integer i = 0; i < itemList.size(); i++) {
if (itemList[i].sobj.id == sobj.id) {
itemList.remove(i);
break;
}
}
saveBatch();
} catch(Exception e) {
Database.rollback(sp);
ERR_Handler.processError(e, ERR_Handler_API.Context.BDE);
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
}

/*******************************************************************************************************
* @description actionMethod to open the batch entry page with selected object
* @return pageReference (Batch Entry Page)
Expand Down
Loading

0 comments on commit 703c340

Please sign in to comment.