Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work up to 9/18/2019 #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ project:
name: Salesforce-Class-Registration
package:
name: Salesforce-Class-Registration
api_version: '45.0'
api_version: '46.0'
dependencies:
- github: https://github.com/SalesforceFoundation/Cumulus
- github: https://github.com/SalesforceFoundation/Volunteers-for-Salesforce


109 changes: 81 additions & 28 deletions src/classes/C501_CTRL_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class C501_CTRL_ClassReg_CreateAcct {
public Account schoolNameText {get; set;}
public Boolean dontKnowId {get; set;}
public Boolean noAllergies {get; set;}
public Boolean noMedication {get; set;}
public Boolean noSpecialNeeds {get; set;}

public Map<String,List<SelectOption> > fieldSetPicklistOptions {get; set;}
public Map<String,String[]> siteMultiPicklistReturnValues {get; set;}
Expand Down Expand Up @@ -47,9 +49,12 @@ public class C501_CTRL_ClassReg_CreateAcct {
public Boolean noSchool {get; set;}
public Boolean noGrade {get; set;}
public Boolean noWaiver {get; set;}
public Boolean noMedAuth {get; set;}
public Boolean noStuID {get; set;}
public Boolean noAllergyResp {get; set;}
private String RegType {get; set;}
public Boolean noMedResp {get; set;}
public Boolean noSpecialResp {get; set;}

public List<SelectOption> schoolList {
get {
Expand Down Expand Up @@ -130,10 +135,15 @@ public class C501_CTRL_ClassReg_CreateAcct {
noSchool = false;
noGrade = false;
noWaiver = false;
noMedAuth = false;
dontKnowId = false;
noStuID = false;
noAllergyResp = false;
noMedication = false;
noMedResp = false;
needPickup = false;
noSpecialResp = false;
noSpecialNeeds = false;
schoolregion = '';
errorClassesForPicklists = '';

Expand Down Expand Up @@ -164,7 +174,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
Schema.SObjectField f = fsm.getSObjectField();
Schema.DescribeFieldResult dfr = f.getDescribe();
if(dfr.getType() == Schema.DisplayType.MultiPicklist ){
List<SelectOption> picklistOptionsForField = getFieldsPicklistOptions(f,'Account');
List<SelectOption> picklistOptionsForField = getFieldsPicklistOptions(f,'Account',language);
fieldSetPicklistOptions.put( dfr.getName(), picklistOptionsForField );
siteMultiPicklistReturnValues.put( dfr.getName(), new String[]{} );
siteMultiPicklistErrorStatus.put( dfr.getName(), false);
Expand All @@ -174,7 +184,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
Schema.SObjectField f = fsm.getSObjectField();
Schema.DescribeFieldResult dfr = f.getDescribe();
if(dfr.getType() == Schema.DisplayType.MultiPicklist ){
List<SelectOption> picklistOptionsForField = getFieldsPicklistOptions(f,'Contact');
List<SelectOption> picklistOptionsForField = getFieldsPicklistOptions(f,'Contact',language);
fieldSetPicklistOptions.put( dfr.getName(), picklistOptionsForField );
siteMultiPicklistReturnValues.put( dfr.getName(), new String[]{} );
siteMultiPicklistErrorStatus.put( dfr.getName(), false);
Expand All @@ -184,7 +194,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
Schema.SObjectField f = fsm.getSObjectField();
Schema.DescribeFieldResult dfr = f.getDescribe();
if(dfr.getType() == Schema.DisplayType.MultiPicklist ){
List<SelectOption> picklistOptionsForField = getFieldsPicklistOptions(f,'Contact');
List<SelectOption> picklistOptionsForField = getFieldsPicklistOptions(f,'Contact',language);
fieldSetPicklistOptions.put( dfr.getName(), picklistOptionsForField );
siteMultiPicklistReturnValues.put( dfr.getName(), new String[]{} );
siteMultiPicklistErrorStatus.put( dfr.getName(), false);
Expand Down Expand Up @@ -243,6 +253,12 @@ public class C501_CTRL_ClassReg_CreateAcct {
passValidation = false;
} else {
noStuId = false;
// populate the checkbox that tells TBG they can get permission to ask the school for the ID
if(dontKnowId && term.Student_School_ID__c == null){
term.Permission_to_get_student_ID__c = true;
} else if(!dontKnowId && term.Student_School_ID__c != null){
term.Permission_to_get_student_ID__c = false;
}
}

if(child.Allergies__c == null && noAllergies == false){
Expand All @@ -253,6 +269,22 @@ public class C501_CTRL_ClassReg_CreateAcct {
noAllergyResp = false;
}

if(child.Medication__c == null && noMedication == false){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_NoMedsError ) );
noMedResp = true;
passValidation = false;
} else {
noMedResp = false;
}

if(child.Student_Special_Needs__c == null && noSpecialNeeds == false){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_NoSpecialNeedsError ) );
noSpecialResp = true;
passValidation = false;
} else {
noSpecialResp = false;
}

if(child.Student_Transportation__c == 'Will receive a ride' && (child.Authorized_Pickup_1_Name__c == null || child.Authorized_Pickup_1_Phone__c == null || child.Authorized_Pickup_1_Relationship__c == null ) ){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_PickUpChildError ) );
needPickup = true;
Expand All @@ -274,6 +306,16 @@ public class C501_CTRL_ClassReg_CreateAcct {
noWaiver = false;
}

if(term.Authorization_to_treat_minor__c == false){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,Label.C501_RegSite_TreatRequired) );
noMedAuth = true;
passValidation = false;
} else {
noMedAuth = false;
}



Boolean phoneFail = false;

// Phone number validation
Expand Down Expand Up @@ -375,36 +417,35 @@ public class C501_CTRL_ClassReg_CreateAcct {
}
system.debug( 'SchoolName after validation attempts: ' + schoolName );

if(passValidation == true){
errorClassesForPicklists = '';
// make sure they checked something in each of the required picklists
for(String key : siteMultiPicklistReturnValues.keySet() ){
if(/*key != 'Family_Status__c' && */siteMultiPicklistReturnValues.get(key).size() == 0 ){
passValidation = false;
if(String.isEmpty(errorClassesForPicklists)){
errorClassesForPicklists = ' .picklist' + key;
} else {
errorClassesForPicklists = errorClassesForPicklists + ', .picklist' + key;
}
siteMultiPicklistErrorStatus.put( key, true);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, Label.C501_Classreg_CheckBoxes ) );
//if(passValidation == true){
errorClassesForPicklists = '';
// make sure they checked something in each of the required picklists
for(String key : siteMultiPicklistReturnValues.keySet() ){
if(/*key != 'Family_Status__c' && */siteMultiPicklistReturnValues.get(key).size() == 0 ){
passValidation = false;
if(String.isEmpty(errorClassesForPicklists)){
errorClassesForPicklists = ' .picklist' + key;
} else {
siteMultiPicklistErrorStatus.put( key, false);
errorClassesForPicklists = errorClassesForPicklists + ', .picklist' + key;
}
siteMultiPicklistErrorStatus.put( key, true);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, Label.C501_Classreg_CheckBoxes ) );
} else {
siteMultiPicklistErrorStatus.put( key, false);
}
}
//}

if(passValidation == false){
system.debug('Failed Validation :( ');
return null;
}

// Convert all of the values in the Checklist value sets to the correct picklist values on the correct record
loopThroughFieldsetAndSetValues(child,childFieldSet);
loopThroughFieldsetAndSetValues(parent,parentFieldSet);
loopThroughFieldsetAndSetValues(family,hhFieldSet);

if(passValidation == false){
system.debug('Failed Validation :( ');
return null;
}

insert family;

parent.npe01__Preferred_Email__c = 'Personal';
Expand Down Expand Up @@ -439,6 +480,7 @@ public class C501_CTRL_ClassReg_CreateAcct {

term.School_Year__c = C501_UTIL_ClassRegUtilities.currentSchoolYear( Date.today() );
term.C501_Sign_Up_Source__c = 'Online';
term.C501_Form_Completion_Language__c = language;

insert term;
if(parent.MobilePhone != null && parent.MobilePhone != '' ){
Expand Down Expand Up @@ -517,9 +559,8 @@ public class C501_CTRL_ClassReg_CreateAcct {
List<SelectOption> regions = new List<SelectOption>();

// include these nice regions automatically
regions.add(new SelectOption( '', Label.C501_ClassReg_PlzSelectOne ) );
regions.add(new SelectOption( 'East Bay', Label.C501_ClassReg_eastBay ) );
regions.add(new SelectOption( 'South Bay', Label.C501_ClassReg_southBay ) );
regions.add(new SelectOption( '', Label.C501_ClassReg_PlzSelectOne ) );
regions.add(new SelectOption( 'California', Label.C501_RegSite_California ) );
regions.add(new SelectOption( 'Seattle', Label.C501_ClassReg_seattleArea ) );
regions.add(new SelectOption( 'DC', Label.C501_ClassReg_dcArea ) );

Expand All @@ -530,14 +571,26 @@ public class C501_CTRL_ClassReg_CreateAcct {
return regions;
}

public static List<SelectOption> getFieldsPicklistOptions(Schema.SObjectField field,String objectName){
public static List<SelectOption> getFieldsPicklistOptions(Schema.SObjectField field,String objectName, String language){

List<SelectOption> picklistOptions = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult = field.getDescribe();

list<schema.picklistentry> values = fieldResult.getPickListValues();
list<schema.picklistentry> values = fieldResult.getPickListValues();

/*if(!String.isEmpty(language) && language != 'en_US' ){
// is not english
//Schema.
} else {
// return English picklist
for (Schema.PicklistEntry p : values){
picklistOptions.add(new SelectOption(p.getLabel(), p.getValue()));
}
}*/

// return English picklist values
for (Schema.PicklistEntry p : values){
picklistOptions.add(new SelectOption(p.getLabel(), p.getValue()));
picklistOptions.add(new SelectOption(p.getLabel(), p.getValue()));
}


Expand Down
4 changes: 2 additions & 2 deletions src/classes/C501_CTRL_ClassReg_Login.cls
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class C501_CTRL_ClassReg_Login {
}

public PageReference sendCodeWOacct(){
String identityInput = C501_UTIL_ClassRegUtilities.cleanInputGeneric(identityInput);
identityInput = C501_UTIL_ClassRegUtilities.cleanInputGeneric(identityInput);
if(identityInput == null){
pageStatus = 'lookup-fail';
return null;
Expand Down Expand Up @@ -82,4 +82,4 @@ public class C501_CTRL_ClassReg_Login {
}
}

}
}
3 changes: 3 additions & 0 deletions src/classes/C501_TEST_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ public class C501_TEST_ClassReg_CreateAcct {
controller.grade = '10';
controller.schoolName = school.Id;
controller.term.Waiver__c = true;
controller.term.Authorization_to_treat_minor__c = true;

controller.term.Student_School_ID__c = 'abc123';
controller.noAllergies = true;
controller.noSpecialNeeds = true;
controller.noMedication = true;
controller.child.Student_Transportation__c = 'Will receive a ride';
controller.child.Authorized_Pickup_1_Name__c = 'Test friend';
controller.child.Authorized_Pickup_1_Phone__c = '(206) 234-5678';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ To do: field to calculate the grade...
** {! $ObjectType.Contact.Fields['Allergies__c'].inlineHelpText } **
<apex:outputText value="{!relatedTo.Student__r.Allergies__c }" />

** {! $ObjectType.Contact.Fields['Medication__c'].inlineHelpText } **
<apex:outputText value="{!relatedTo.Student__r.Medication__c }" />

**{! $ObjectType.Contact.Fields['Race__c'].inlineHelpText }**
<apex:outputText value="{!IF(relatedTo.Student__r.Race__c =='', $Label.C501_RegSite_NotProvided,relatedTo.Student__r.Race__c)}" />

Expand Down
Loading