Lightning Component:
<aura:component controller="CpqRecallQuoteApprovalController" implements="flexipage:availableForAllPageTypes,force:appHostable,force:lightningQuickActionWithoutHeader,force:hasRecordId">
<aura:attribute name="isSpinner" type="boolean" default="false"/>
<aura:handler event="aura:waiting" action="{!c.handleShowSpinner}"/>
<aura:handler event="aura:doneWaiting" action="{!c.handleHideSpinner}"/>
<aura:html tag="style">
.cuf-content {
padding: 0 0rem !important;
}
.slds-p-around--medium {
padding: 0rem !important;
}
.slds-modal__content{
overflow-y:hidden !important;
height:unset !important;
max-height:unset !important;
}
</aura:html>
<div class="modal-header slds-modal__header slds-size_1-of-1">
<h4 class="title slds-text-heading--medium" >Recall Approval</h4>
</div>
<!-- MODAL BODY / INPUT FORM -->
<div class="slds-modal__content slds-p-around--x-small slds-align_absolute-center slds-size_1-of-1 slds-is-relative" aura:id="modalbody" id="modalbody">
<center>
<b>This will allow you to edit the quote but will require the quote to be approved again.<br/>
Do you wish to continue?
</b>
</center>
</div>
<div class="modal-footer slds-modal__footer slds-size_1-of-1">
<div class="forceChangeRecordTypeFooter">
<ui:button class="slds-button slds-button_neutral" disabled="{!v.isSpinner}" label="Cancel" press="{!c.cancel}" />
<ui:button class="slds-button slds-button--brand" disabled="{!v.isSpinner}" label="{!v.isSpinner == true ? 'Ok...' : 'Ok'}" press="{!c.proceedToRecall}"/>
</div>
</div>
</aura:component>
Lightning JS Controller:
({
cancel: function(component, event, helper) {
$A.get("e.force:closeQuickAction").fire();
},
proceedToRecall: function(component, event, helper) {
var action = component.get("c.onRecall");
action.setParams({"quoteId" : component.get("v.recordId")});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
console.log(response.getReturnValue());
$A.get('e.force:refreshView').fire();
$A.get("e.force:closeQuickAction").fire();
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
}
}
else {
console.log("Unknown error");
}
});
$A.enqueueAction(action);
},
//Call by aura:waiting event
handleShowSpinner: function(component, event, helper) {
component.set("v.isSpinner", true);
},
//Call by aura:doneWaiting event
handleHideSpinner : function(component,event,helper){
component.set("v.isSpinner", false);
}
})
Apex Controller:
public class CpqRecallQuoteApprovalController {
/*
* This method will call get triggered on Recall approval button in Lightning Component
*/
@AuraEnabled
public static void onRecall(String quoteId) {
if (quoteId != null) {
SBAA.ApprovalAPI.recall(quoteId, SBAA__Approval__c.Quote__c);
}
}
}
<aura:component controller="CpqRecallQuoteApprovalController" implements="flexipage:availableForAllPageTypes,force:appHostable,force:lightningQuickActionWithoutHeader,force:hasRecordId">
<aura:attribute name="isSpinner" type="boolean" default="false"/>
<aura:handler event="aura:waiting" action="{!c.handleShowSpinner}"/>
<aura:handler event="aura:doneWaiting" action="{!c.handleHideSpinner}"/>
<aura:html tag="style">
.cuf-content {
padding: 0 0rem !important;
}
.slds-p-around--medium {
padding: 0rem !important;
}
.slds-modal__content{
overflow-y:hidden !important;
height:unset !important;
max-height:unset !important;
}
</aura:html>
<div class="modal-header slds-modal__header slds-size_1-of-1">
<h4 class="title slds-text-heading--medium" >Recall Approval</h4>
</div>
<!-- MODAL BODY / INPUT FORM -->
<div class="slds-modal__content slds-p-around--x-small slds-align_absolute-center slds-size_1-of-1 slds-is-relative" aura:id="modalbody" id="modalbody">
<center>
<b>This will allow you to edit the quote but will require the quote to be approved again.<br/>
Do you wish to continue?
</b>
</center>
</div>
<div class="modal-footer slds-modal__footer slds-size_1-of-1">
<div class="forceChangeRecordTypeFooter">
<ui:button class="slds-button slds-button_neutral" disabled="{!v.isSpinner}" label="Cancel" press="{!c.cancel}" />
<ui:button class="slds-button slds-button--brand" disabled="{!v.isSpinner}" label="{!v.isSpinner == true ? 'Ok...' : 'Ok'}" press="{!c.proceedToRecall}"/>
</div>
</div>
</aura:component>
Lightning JS Controller:
({
cancel: function(component, event, helper) {
$A.get("e.force:closeQuickAction").fire();
},
proceedToRecall: function(component, event, helper) {
var action = component.get("c.onRecall");
action.setParams({"quoteId" : component.get("v.recordId")});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
console.log(response.getReturnValue());
$A.get('e.force:refreshView').fire();
$A.get("e.force:closeQuickAction").fire();
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
}
}
else {
console.log("Unknown error");
}
});
$A.enqueueAction(action);
},
//Call by aura:waiting event
handleShowSpinner: function(component, event, helper) {
component.set("v.isSpinner", true);
},
//Call by aura:doneWaiting event
handleHideSpinner : function(component,event,helper){
component.set("v.isSpinner", false);
}
})
Apex Controller:
public class CpqRecallQuoteApprovalController {
/*
* This method will call get triggered on Recall approval button in Lightning Component
*/
@AuraEnabled
public static void onRecall(String quoteId) {
if (quoteId != null) {
SBAA.ApprovalAPI.recall(quoteId, SBAA__Approval__c.Quote__c);
}
}
}
No comments:
Post a Comment