Skip to content

Commit

Permalink
Merge branch 'feature/248__bdi_dataImportDelete' into feature/248
Browse files Browse the repository at this point in the history
  • Loading branch information
lparrott committed Sep 25, 2023
2 parents e75a03c + 97c5ada commit 5f5fd86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions force-app/main/default/classes/BDI_DataImportDeleteBTN_CTRL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public with sharing class BDI_DataImportDeleteBTN_CTRL {
public Boolean canDelete {
get {
if(this.canDelete == null) {
this.canDelete = this.checkDelete();
this.canDelete = this.checkDelete();
}
return this.canDelete;
}
Expand All @@ -65,8 +65,8 @@ public with sharing class BDI_DataImportDeleteBTN_CTRL {
* @return PageReference Page specified in 'retURL' parameter or Home page
*/
public PageReference buttonClick() {
if (!checkDelete()) {
displayDeleteError();
if (!checkRead() || !checkDelete()) {
displayAccessError();
return null;
}

Expand All @@ -91,11 +91,16 @@ public with sharing class BDI_DataImportDeleteBTN_CTRL {
return UTIL_Permissions.getInstance().canDelete(DataImport__c.SObjectType);
}

private void displayDeleteError() {
public Boolean checkRead() {
Set<SObjectField> findFields = new Set<SObjectField>{DataImport__c.Status__c.getDescribe().getSobjectField()};
return UTIL_Permissions.getInstance().canRead(DataImport__c.SObjectType, findFields);
}

private void displayAccessError() {
ApexPages.addMessage(new ApexPages.Message(
ApexPages.Severity.ERROR,
String.format(
System.Label.exceptionDeletePermission,
System.Label.commonAccessErrorMessage,
new List<String>{ SObjectType.DataImport__c.getLabel() })));
}

Expand Down Expand Up @@ -138,7 +143,7 @@ public with sharing class BDI_DataImportDeleteBTN_CTRL {
delete dataImports;
return close();
} else {
displayDeleteError();
displayAccessError();
return null;
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class BDI_DataImportDeleteBTN_TEST {
testPageErrorMessageDisplayOnDeleteActionException(
'TestDeleteAllDataImportRecordsBtnExceptionMessageDisplay',
BDI_DataImportDeleteBTN_CTRL.ACTION_DELETE_ALL,
String.format(System.Label.exceptionDeletePermission, new List<String>{ SObjectType.DataImport__c.getLabel() }),
String.format(System.Label.commonAccessErrorMessage, new List<String>{ SObjectType.DataImport__c.getLabel() }),
false
);
}
Expand Down

0 comments on commit 5f5fd86

Please sign in to comment.