-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TOLK-2253: Frilanstolk skal bare ha tilgang til oppdrag de er tildelt…
… (ikke reservert) (#1725) * Fikset formatering * Flyttet logikk rundt tilgangsstyring ved sletting av Assigned Resource til riktig klasse * Endring delingslogikk så tilgang bare blir gitt når status er tildelt (Dispatched) * Update HOT_ServiceAppointmentsSharingSrvTest.cls * Update HOT_WageClaimServiceTest.cls * Flyttet Test.startTest for å fordele limits bedre. --------- Co-authored-by: Edvard Brekke <[email protected]>
- Loading branch information
1 parent
c628a1a
commit 2f25f27
Showing
10 changed files
with
351 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
force-app/main/accessControl/classes/HOT_ServiceAppointmentAccessHandler.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
public without sharing class HOT_ServiceAppointmentAccessHandler extends MyTriggers { | ||
public override void onAfterUpdate(Map<Id, sObject> triggerOldMap) { | ||
List<Id> serviceAppointmentsWithUpdatedStatusDispatched = new List<Id>(); | ||
|
||
for (ServiceAppointment sa : (List<ServiceAppointment>) records) { | ||
ServiceAppointment oldRecord = (ServiceAppointment) triggerOldMap.get(sa.Id); | ||
if (sa.Status != oldRecord.Status && sa.Status == 'Dispatched') { | ||
serviceAppointmentsWithUpdatedStatusDispatched.add(sa.Id); | ||
} | ||
} | ||
|
||
Map<Id, Id> apppointmentByAssignment = new Map<Id, Id>(); | ||
Map<Id, Id> resourceToAddByAssignment = new Map<Id, Id>(); | ||
|
||
for (AssignedResource ar : [ | ||
SELECT Id, ServiceAppointmentId, ServiceResourceId | ||
FROM AssignedResource | ||
WHERE ServiceAppointmentId IN :serviceAppointmentsWithUpdatedStatusDispatched | ||
]) { | ||
apppointmentByAssignment.put(ar.Id, ar.ServiceAppointmentId); | ||
resourceToAddByAssignment.put(ar.Id, ar.ServiceResourceId); | ||
} | ||
|
||
if (serviceAppointmentsWithUpdatedStatusDispatched.size() > 0) { | ||
update HOT_AssignedResourceAccessHandler.setRecalculateManualSharingFlagOnServiceAppointment( | ||
serviceAppointmentsWithUpdatedStatusDispatched | ||
); | ||
HOT_ServiceAppointmentsSharingService.grantAccess(apppointmentByAssignment, resourceToAddByAssignment); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/accessControl/classes/HOT_ServiceAppointmentAccessHandler.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.