@php
$templateComponents = $whatsAppTemplateData['components'];
$templateButtons = Arr::first($templateComponents, function ($value, $key) {
return $value['type'] == 'BUTTONS';
});
@endphp
index + 1 }}' : {
buttonType : '{{ $templateComponentButton['type'] }}',
buttonIndex : {{ $loop->index + 1 }}
},
@endforeach
@endif
},
}, addWhatsAppButtonOption : function(buttonType) {
{{-- let uniqueBtnId = _.uniqueId(); --}}
let uniqueBtnId = _.size(this.customButtons.data) + 1;
this.customButtons.data[uniqueBtnId] = {
buttonType : buttonType,
buttonIndex : uniqueBtnId
};
this.buttonModels[uniqueBtnId] = {
'text_value': '',
'example_value': '',
};
this.customButtons.totalButtonsUsed++;
if((buttonType == 'URL_BUTTON') || (buttonType == 'DYNAMIC_URL_BUTTON')) {
this.customButtons.buttonUsesByTypes['URL_BUTTON']++;
} else if((buttonType == 'COPY_CODE')) {
this.customButtons.buttonUsesByTypes['COPY_CODE']++;
} else if((buttonType == 'VOICE_CALL')) {
this.customButtons.buttonUsesByTypes['VOICE_CALL']++;
} else if((buttonType == 'PHONE_NUMBER')) {
this.customButtons.buttonUsesByTypes['PHONE_NUMBER']++;
}
}, deleteWhatsAppButtonOption : function(buttonIndex) {
let buttonType = this.customButtons.data[buttonIndex]['buttonType'];
if((buttonType == 'URL_BUTTON') || (buttonType == 'DYNAMIC_URL_BUTTON')) {
this.customButtons.buttonUsesByTypes['URL_BUTTON']--;
} else if((buttonType == 'COPY_CODE')) {
this.customButtons.buttonUsesByTypes['COPY_CODE']-- ;
} else if((buttonType == 'VOICE_CALL')) {
this.customButtons.buttonUsesByTypes['VOICE_CALL']-- ;
} else if((buttonType == 'PHONE_NUMBER')) {
this.customButtons.buttonUsesByTypes['PHONE_NUMBER']-- ;
}
delete this.customButtons.data[buttonIndex];
delete this.buttonModels[buttonIndex];
this.customButtons.totalButtonsUsed--;
}}">