Skip to content

Commit

Permalink
Merge pull request #195 from SFDO-Community/feature/supplies-bug-fix
Browse files Browse the repository at this point in the history
TRACTION-453 | Added namespace check before firing application event
  • Loading branch information
cwico authored Jun 30, 2020
2 parents 38af408 + 43fb98f commit f5b4912
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions force-app/main/default/aura/accountPicker/accountPicker.cmp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<aura:registerEvent name="setFacility" type="c:setFacilityEvent"/>

<!-- MARKUP -->
<c:appUtils aura:id="utils"></c:appUtils>

<div class="c-container" style="{! 'background-color: ' + v.cardBackgroundColor}">
<lightning:layout multipleRows="true" class="slds-box">
<lightning:layoutItem size="12" class="slds-p-around--x-small">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
component.set("v.divisions", null);
if(component.get("v.selectedDivision") != null) {
component.set("v.selectedDivision", null);
helper.fireFacilitySetEvent(component);
helper.handlefireFacilitySetEvent(component, helper);
}
},

Expand All @@ -39,7 +39,7 @@
handleHospitalChange: function (component, event, helper) {
if(component.get("v.selectedDivision") != null) {
component.set("v.selectedDivision", null);
helper.fireFacilitySetEvent(component);
helper.handlefireFacilitySetEvent(component, helper);
}
helper.getDivisions(component, event, helper);

Expand All @@ -52,6 +52,6 @@
* @param helper
*/
handleDivisionChange: function (component, event, helper) {
helper.fireFacilitySetEvent(component);
helper.handlefireFacilitySetEvent(component, helper);
},
})
28 changes: 27 additions & 1 deletion force-app/main/default/aura/accountPicker/accountPickerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Created by Heather Purvis on 2020-03-24.
*/
({
NAMESPACE : null,
/**
* @description Gets relevant accounts for each picklist for this user
* @param component
Expand Down Expand Up @@ -165,16 +166,40 @@
return options;
},

/**
* @description Fires an event containing the division selected up to the parent component
* @param component
*/
handlefireFacilitySetEvent: function (component, helper) {
if(typeof this.NAMESPACE === 'undefined') {
helper.getOrgNamespace(component, helper);
} else {
helper.fireFacilitySetEvent(component);
}
},

/**
* @description Fires an event containing the division selected up to the parent component
* @param component
*/
fireFacilitySetEvent: function (component) {
let setEvent = $A.get("e." + "c" + ":setFacilityEvent");
let setEvent = $A.get("e." + this.NAMESPACE + ":setFacilityEvent");
setEvent.setParams({ "facilityId" : component.get("v.selectedDivision" )});
setEvent.fire();
},

getOrgNamespace: function (component, helper) {
let utils = component.find('utils');
utils.getOrgNamespace().then(result => {
if (result) {
this.NAMESPACE = result;
} else {
this.NAMESPACE = 'c'
}
helper.fireFacilitySetEvent(component);
});
},

/**
* @description Displays a toast message of the given type, with given title and body
* @param title - Title of toast message
Expand All @@ -192,4 +217,5 @@

toastEvent.fire();
},

})

0 comments on commit f5b4912

Please sign in to comment.