HOW TO APPLY CORRECTLY THE FUNCTION ENABLED AND DISABLED ?
1.- The button will be disabled when the object custom XXXXX__c = 'Win' OR enable when the object custom XXXXX__c = 'Lose'.
* I have a method in class apex:
@AuraEnabled
public static Boolean getStageOpportunity(String recordId){
Set<Id> recordIds = new Set<Id>{recordId};
List<ContentDocumentLink> cdlkLista = [SELECT Id, LinkedEntityId, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN :recordIds];
Set<Id> oppIds = new Set<Id>();
for (ContentDocumentLink cdlk: cdlkLista) {
oppIds.add(cdlk.LinkedEntityId);
}
List<Opportunity> oppLista = [SELECT Id, Name, StageName FROM Opportunity WHERE Id = :oppIds];
Set<String> stageNameX = new Set<String>();
for (Opportunity oppEtapa : oppLista) {
stageNameX.add(oppEtapa.StageName);
}
Boolean btnDelete = false;
if (stageNameX.contains('Ganada')) {
btnDelete = true;
} else {
btnDelete = false;
}
return btnDelete;
}
* I have a function in Controller.js:
disableBtnDelete : function(component, event) {
var action = component.get("c.getStageOpportunity");
action.setCallback(this,function(response){
var state = response.getState();
if(state=='SUCCESS'){
var result = response.getReturnValue();
component.set("v.btnDeleteDisable",true);
// component.set("v.btnDeleteDisable",false);
}
});
$A.enqueueAction(action);
}
* I have a component.cmp:
<aura:component controller="gestionArchivosOppCtrl" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,lightning:availableForFlowScreens,force:appHostable,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="files" type="ContentDocument[]"/>
<aura:attribute name="recordId" type="String" />
<aura:attribute name="acceptFileTypes" type="String" />
<aura:attribute name="showFileHeader" type="Boolean" default="true" />
<aura:attribute name="fileHeaderText" type="String" default="Archivos" />
<aura:attribute name="uploadMultiple" type="Boolean" default="true"/>
<aura:attribute name="showSpinner" type="boolean" default="false"/>
<aura:attribute name="btnDeleteDisable" type="Boolean" default="false"/>
<div class="slds-card slds-card_boundary">
<!-- show or hide header -->
<aura:if isTrue="{!v.showFileHeader}">
<div class="slds-page-header">{!v.fileHeaderText}</div>
</aura:if>
<div class="slds-align_absolute-center">
<lightning:fileUpload multiple="{!v.uploadMultiple}"
accept="{!v.acceptFileTypes}"
recordId="{!v.recordId}"
onuploadfinished="{!c.uploadFinished}" />
</div>
<br/>
<div class="slds-form--compound">
<table class="slds-table slds-table--bordered">
<!-- hide the table header if file is empty -->
<aura:if isTrue="{!not(empty(v.files))}">
<thead>
<tr>
<th></th>
<th>Titulo</th>
<th>Tipo Archivo</th>
<th>Última Modificación</th>
<!-- <th>Propietario</th> -->
<th>Eliminar</th>
</tr>
</thead>
</aura:if>
<tbody>
<aura:iteration items="{!v.files}" var="f">
<tr>
<td></td>
<td>
<a href="javascript:void(0)" id="{!f.Id}" onclick="{!c.previewFile}">
{!f.Title}
</a>
</td>
<td>{!f.FileType}</td>
<td><lightning:formattedDateTime value="{!f.LastModifiedDate}" year="numeric" day="2-digit" month="long" hour="2-digit" minute="2-digit"></lightning:formattedDateTime></td>
<td>
<a href="javascript:void(0)" id="{!f.Id}" onclick="{!c.deleteSelectedFile}">
<lightning:buttonIcon iconName="utility:delete" alternativeText="Eliminar Archivo" />
</a>
</aura:set>
</aura:if>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
<!-- show spinner logo when needed -->
<aura:if isTrue="{!v.showSpinner}">
<div class="slds-spinner_container">
<div class="slds-spinner slds-spinner--medium" aria-hidden="false" role="alert">
<div class="slds-spinner__dot-a"></div>
<div class="slds-spinner__dot-b"></div>
</div>
</div>
</aura:if>
</div>
</div>
</aura:component>
<!-- <aura:component controller="gestionArchivosOppCtrl" implements="flexiPage:availableForAllPageTypes,force:appHostable"> -->
Hi Cristino,
try this
<aura:if isTrue="{!v.btnDeleteDisable)}">
<a href="javascript:void(0)" id="{!f.Id}" onclick="{!c.deleteSelectedFile}">
</aura:if>