Permalink
Browse files

adding fallback widgets

  • Loading branch information...
mickle00 committed Apr 23, 2012
1 parent a7da8f0 commit 578d5f78567599f94846d8a72d420783e362d8fa
@@ -0,0 +1,10 @@
+public with sharing class CaseFallbackExtension {
+ public Case myCase{get;set;}
+
+ public CaseFallbackExtension (ApexPages.StandardController stdController) {
+ if (!Test.isRunningTest()) stdController.addFields(this.FIELDNAMES);
+ this.myCase = (Case) stdController.getRecord();
+ }
+
+ private List<String> FIELDNAMES = new List<String>{'Account.Fallback_Notes__c'};
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>23.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
@@ -3,21 +3,30 @@ public class CaseTransferController{
public Case myCase {get;set;}
public string transferReason {get;set;}
public String transferringToCaseTeam {get;set;}
+ public List<selectOption> caseTeamPicklistOptions;
+ public boolean validCaseTeamSelected;
+ public boolean caseTeamSelected {get;set;}
public CaseTransferController(ApexPages.StandardController stdController){
// Get fields without needing to query for them
// Hack to allow tests to run
if (!Test.isRunningTest()) stdController.addFields(this.FIELDNAMES);
this.myCase = (Case)stdController.getRecord();
+ validCaseTeamSelected = false;
+ caseTeamSelected = false;
+ transferringToCaseTeam = '';
}
public PageReference returnToCase(){
return new ApexPages.StandardController(myCase).View();
}
public PageReference transferCase(){
- this.createTransferredCase(myCase);
- return this.returnToCase();
+ this.changeCaseTeam();
+ if (this.validCaseTeamSelected){
+ this.createTransferredCase(myCase);
+ return this.returnToCase();
+ } return null;
}
public PageReference closeAndTransferCase(){
@@ -28,19 +37,35 @@ public class CaseTransferController{
}
public List<selectOption> getCaseTeamPicklistOptions() {
- List<selectOption> options = new List<selectOption>();
- String appendText;
- for (Case_Team__c myCaseTeam : getAllCaseTeams()) {
- appendText = myCaseTeam.Email__c == null ? '' : ' (' + myCaseTeam.Email__c + ')';
- options.add(new selectOption(myCaseTeam.Name, myCaseTeam.Name + appendText));
+ if (this.caseTeamPicklistOptions == null){
+ this.caseTeamPicklistOptions = new List<selectOption>();
+ this.caseTeamPicklistOptions.add(new selectOption('', '--Please Select a Team--'));
+ String appendText;
+ for (Case_Team__c myCaseTeam : getAllCaseTeams()) {
+ appendText = myCaseTeam.Email__c == null ? '' : ' (' + myCaseTeam.Email__c + ')';
+ this.caseTeamPicklistOptions.add(new selectOption(myCaseTeam.Name, myCaseTeam.Name + appendText));
+ }
}
- return options;
+ return this.caseTeamPicklistOptions;
}
/**
Move to CaseTeamClass???
**/
+ public void changeCaseTeam(){
+ this.caseTeamSelected = true;
+ if (this.transferringToCaseTeam != ''){
+ this.validCaseTeamSelected = true;
+ } else {
+ this.validCaseTeamSelected = false;
+ }
+ }
+ public boolean getValidCaseTeamSelected(){
+ if (this.caseTeamSelected) return validCaseTeamSelected;
+ return true;
+ }
+
public Map<String, Id> getCaseTeamToRecordTypeIdMap(){
if (this.caseTeamToRecordTypeIdMap == null){
this.caseTeamToRecordTypeIdMap = new Map<String, Id>();
@@ -9,6 +9,7 @@ public with sharing class ConnectionClass {
,PSG_Account_ID__c
,Type__c
,Status__c
+ ,ETP_Status__c
,Platform__c
,Go_Date__c
,LastModifiedDate
@@ -27,7 +28,7 @@ public with sharing class ConnectionClass {
public static List<Connection__c> getConnectionsByAccountId (Id accountId){
return [SELECT Id
- ,Account__c
+ ,Account__c
,Name
,Connectivity_System__c
,Connectivity_System__r.Connectivity_Vendor__r.Name
@@ -68,30 +69,30 @@ public with sharing class ConnectionClass {
// Check for updates before upserting. Since this is displayed with rollout steps, and notes,
public static void upsertConnection(Connection__c myConnection){
- if (myConnection.Id != null){
- Connection__c oldConnection = getConnection(myConnection.Id);
- if (oldConnection != myConnection) upsert myConnection;
- } else{
- insert myConnection;
- }
+ if (myConnection.Id != null){
+ Connection__c oldConnection = getConnection(myConnection.Id);
+ if (oldConnection != myConnection) upsert myConnection;
+ } else{
+ insert myConnection;
+ }
}
public void buildConnectionIntegrationKeys(List<Connection__c> myConnections, Map<Id, Connection__c> myOldConnectionMap){
this.accountIds = getAccountIds(myConnections);
this.accountActiveConnectionMap = getAccountActiveConnectionMap(accountIds);
for (Connection__c myConnection : myConnections){
- if (myConnection.Status__c == 'Connected'){
+ if (myConnection.Status__c == 'Connected'){
this.buildConnectionIntegrationKey(myConnection);
this.addActiveConnection(myConnection);
- } else {
- if (myOldConnectionMap != null){
- if (myOldConnectionMap.get(myConnection.Id).Status__c == 'Connected'){
- this.removeActiveConnection(myConnection);
- }
- }
- myConnection.Integration_Connection_Key__c = null;
- }
+ } else {
+ if (myOldConnectionMap != null){
+ if (myOldConnectionMap.get(myConnection.Id).Status__c == 'Connected'){
+ this.removeActiveConnection(myConnection);
+ }
+ }
+ myConnection.Integration_Connection_Key__c = null;
+ }
}
update this.accountActiveConnectionMap.values();
}
@@ -101,69 +102,69 @@ public with sharing class ConnectionClass {
this.accountActiveConnectionMap = getAccountActiveConnectionMap(accountIds);
for (Connection__c myDeletedConnection : myDeletedConnections){
- if (myDeletedConnection.Status__c == 'Connected'){
- this.removeActiveConnection(myDeletedConnection);
- }
+ if (myDeletedConnection.Status__c == 'Connected'){
+ this.removeActiveConnection(myDeletedConnection);
+ }
}
update this.accountActiveConnectionMap.values();
}
- /**
-
- PRIVATE METHODS
-
- **/
-
- private Map<Id, Account> accountActiveConnectionMap;
- private Set<Id> accountIds;
+ /**
+
+ PRIVATE METHODS
+
+ **/
+
+ private Map<Id, Account> accountActiveConnectionMap;
+ private Set<Id> accountIds;
private void buildConnectionIntegrationKey(Connection__c myConnection){
- String concatenator = ':';
- myConnection.Integration_Connection_Key__c = myConnection.PSG_Account_ID__c + concatenator
- + myConnection.Type__c + concatenator
- + myConnection.Platform__c;
+ String concatenator = ':';
+ myConnection.Integration_Connection_Key__c = myConnection.PSG_Account_ID__c + concatenator
+ + myConnection.Type__c + concatenator
+ + myConnection.Platform__c;
}
private void addActiveConnection(Connection__c myConnection){
- string activeConnectionKey = myConnection.Type__c + '-' + myConnection.Platform__c;
- Account myConnectionsAccount = this.accountActiveConnectionMap.get(myConnection.Account__c);
- if (myConnectionsAccount != null){
- if (myConnectionsAccount.Active_Connections__c != null){
- if (!myConnectionsAccount.Active_Connections__c.contains(activeConnectionKey)){
- myConnectionsAccount.Active_Connections__c = myConnectionsAccount.Active_Connections__c + ';'+ activeConnectionKey;
- }
- } else{
- myConnectionsAccount.Active_Connections__c = activeConnectionKey;
- }
- }
+ string activeConnectionKey = myConnection.Type__c + '-' + myConnection.Platform__c;
+ Account myConnectionsAccount = this.accountActiveConnectionMap.get(myConnection.Account__c);
+ if (myConnectionsAccount != null){
+ if (myConnectionsAccount.Active_Connections__c != null){
+ if (!myConnectionsAccount.Active_Connections__c.contains(activeConnectionKey)){
+ myConnectionsAccount.Active_Connections__c = myConnectionsAccount.Active_Connections__c + ';'+ activeConnectionKey;
+ }
+ } else{
+ myConnectionsAccount.Active_Connections__c = activeConnectionKey;
+ }
+ }
}
private void removeActiveConnection(Connection__c myConnection){
- string activeConnectionKey = myConnection.Type__c + '-' + myConnection.Platform__c;
- Account myConnectionsAccount = this.accountActiveConnectionMap.get(myConnection.Account__c);
- if (myConnectionsAccount != null){
- if (myConnectionsAccount.Active_Connections__c != null){
- if (myConnectionsAccount.Active_Connections__c.contains(activeConnectionKey)){
- myConnectionsAccount.Active_Connections__c = myConnectionsAccount.Active_Connections__c.replace(activeConnectionKey, '');
- }
- }
-
- }
+ string activeConnectionKey = myConnection.Type__c + '-' + myConnection.Platform__c;
+ Account myConnectionsAccount = this.accountActiveConnectionMap.get(myConnection.Account__c);
+ if (myConnectionsAccount != null){
+ if (myConnectionsAccount.Active_Connections__c != null){
+ if (myConnectionsAccount.Active_Connections__c.contains(activeConnectionKey)){
+ myConnectionsAccount.Active_Connections__c = myConnectionsAccount.Active_Connections__c.replace(activeConnectionKey, '');
+ }
+ }
+
+ }
}
private Set<Id> getAccountIds (List<Connection__c> myConnections){
- Set<Id> accountIds = new Set<Id>();
- for (Connection__c myConnection : myConnections){
- accountIds.add(myConnection.Account__c);
- }
- return accountIds;
+ Set<Id> accountIds = new Set<Id>();
+ for (Connection__c myConnection : myConnections){
+ accountIds.add(myConnection.Account__c);
+ }
+ return accountIds;
}
private Map<Id, Account> getAccountActiveConnectionMap(Set<Id> accountIds){
- return new Map<Id, Account> ([SELECT Id
- ,Active_Connections__c
- FROM Account
- WHERE Id IN : accountIds]);
+ return new Map<Id, Account> ([SELECT Id
+ ,Active_Connections__c
+ FROM Account
+ WHERE Id IN : accountIds]);
}
}
@@ -0,0 +1,12 @@
+public with sharing class GuestAccountExtension {
+
+ public Guest__c myGuest{get;set;}
+
+ public GuestAccountExtension (ApexPages.StandardController stdController) {
+ if (!Test.isRunningTest()) stdController.addFields(this.FIELDNAMES);
+ this.myGuest = (Guest__c) stdController.getRecord();
+ }
+
+ private List<String> FIELDNAMES = new List<String>{'Case__r.Account.Name'
+ ,'Case__r.Account.Fallback_Notes__c'};
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>23.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
@@ -0,0 +1,79 @@
+public with sharing class GuestMassUpdateExtension {
+
+ public List<Guest__c> openGuests;
+ List<GuestWrapper> myGuestWrappers;
+ public Guest__c guestTemplate;
+ public boolean allSelected {get;set;}
+
+ public GuestMassUpdateExtension (ApexPages.StandardSetController controller) {
+ controller.setPageSize(100);
+ this.allSelected = false;
+ }
+
+ public List<Guest__c> getOpenGuests(){
+ if (this.openGuests == null){
+ this.openGuests = new List<Guest__c>();
+ this.openGuests = [SELECT Id
+ ,Name
+ ,Expedia_Booking_ID__c
+ ,Status__c
+ ,Arrival_Date__c
+ FROM Guest__c
+ WHERE Case__c = :ApexPages.currentPage().getParameters().get('Id')
+ AND Closed__c = false
+ ORDER BY Arrival_Date__c ASC];
+ } return this.openGuests;
+ }
+
+ public void selectAll(){
+ if (this.allSelected){
+ for (GuestWrapper myGuestWrapper : this.getGuestWrappers()){
+ myGuestWrapper.isSelected = true;
+ }
+ } else {
+ for (GuestWrapper myGuestWrapper : this.getGuestWrappers()){
+ myGuestWrapper.isSelected = false;
+ }
+ }
+ }
+
+ public List<GuestWrapper> getGuestWrappers(){
+ if (this.myGuestWrappers == null){
+ this.myGuestWrappers = new List<GuestWrapper>();
+ for (Guest__c myGuest : this.getOpenGuests()){
+ GuestWrapper myGuestWrapper = new GuestWrapper(myGuest);
+ myGuestWrappers.add(myGuestWrapper);
+ }
+ } return this.myGuestWrappers;
+ }
+
+ public Guest__c getGuestTemplate(){
+ //TODO: Look at StandardSetController.getRecord()
+ //TODO: Scope RecordType
+ if (this.guestTemplate == null){
+ this.guestTemplate = new Guest__c(RecordTypeId = '012c00000008U8L');
+ } return this.guestTemplate;
+ }
+
+ public void updateAllGuests(){
+ for (GuestWrapper myGuestWrapper : this.myGuestWrappers){
+ if (myGuestWrapper.isSelected){
+ myGuestWrapper.myGuest.Status__c = this.guestTemplate.Status__c;
+ }
+ }
+ }
+
+ public PageReference cancel(){
+ return new ApexPages.StandardController(new Case(Id=ApexPages.currentPage().getParameters().get('Id'))).cancel();
+ }
+
+ public class GuestWrapper{
+ public Guest__c myGuest{get;set;}
+ public boolean isSelected{get;set;}
+
+ public GuestWrapper(Guest__c myGuest){
+ this.myGuest = myGuest;
+ this.isSelected = false;
+ }
+ }
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>24.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
Oops, something went wrong.

0 comments on commit 578d5f7

Please sign in to comment.