Files
1sonhador 8542395fbe Add public campaign analytics functionality
- Add PublicCampaignsController for public campaign analytics
- Add public routes for /public/analytics/{slug} and /api/campaigns/{slug}
- Add public campaign analytics view with charts and KPIs
- Support for campaign sharing via custom slugs
- Real-time analytics with ApexCharts integration
2025-10-15 00:30:00 +01:00

1 line
3.8 KiB
JavaScript

export default()=>({currentStep:0,totalSteps:0,progress:0,isFormValid:!1,init(){console.log("formWizard component initialized"),this.setupFormWizard(),this.setupFileUpload()},setupFormWizard(){document.querySelectorAll(".form-steps").forEach(e=>{this.setupForm(e)})},setupForm(e){const t=e.querySelectorAll('button[data-bs-toggle="pill"]');this.totalSteps=t.length,e.querySelectorAll(".nexttab").forEach(t=>{t.addEventListener("click",()=>{this.nextStep(e,t)})}),e.querySelectorAll(".previestab").forEach(t=>{t.addEventListener("click",()=>{this.previousStep(e,t)})}),t.forEach((t,o)=>{t.setAttribute("data-position",o),t.addEventListener("click",()=>{this.goToStep(e,t,o)})}),this.updateProgressBar()},nextStep(e,t){e.classList.add("was-validated");const o=e.querySelector(".tab-pane.show").querySelectorAll(".form-control");let r=!0;if(o.forEach(e=>{e.value.length>0?"email"===e.type?/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e.value)||(r=!1):e.hasAttribute("required")&&""===e.value.trim()&&(r=!1):e.hasAttribute("required")&&(r=!1)}),r){const o=t.getAttribute("data-nexttab"),r=document.getElementById(o);r&&(r.click(),e.classList.remove("was-validated"),this.currentStep++,this.updateProgressBar())}},previousStep(e,t){const o=t.getAttribute("data-previous"),r=document.getElementById(o);if(r){const t=e.querySelectorAll(".custom-nav .done"),o=t.length;for(let e=o-1;e<o;e++)t[e]&&t[e].classList.remove("done");r.click(),this.currentStep--,this.updateProgressBar()}},goToStep(e,t,o){e.classList.remove("was-validated");const r=document.getElementById("custom-progress-bar");if(r){const e=o/(r.querySelectorAll("li").length-1)*100,t=r.querySelector(".progress-bar");t&&(t.style.width=e+"%")}e.querySelectorAll(".custom-nav .done").forEach(e=>{e.classList.remove("done")});const i=e.querySelectorAll('button[data-bs-toggle="pill"]');for(let e=0;e<=o;e++)i[e].classList.contains("active")||i[e].classList.add("done");this.currentStep=o,this.updateProgressBar()},updateProgressBar(){this.totalSteps>0&&(this.progress=this.currentStep/(this.totalSteps-1)*100)},setupFileUpload(){const e=document.querySelector("#profile-img-file-input");e&&e.addEventListener("change",e=>{const t=e.target.files[0],o=document.querySelector(".user-profile-image");if(t&&o){const e=new FileReader;e.onload=function(e){o.src=e.target.result},e.readAsDataURL(t)}}),this.setupDropzone(),this.setupFilePond()},setupDropzone(){const e=document.querySelector("#dropzone-preview-list");if(e&&"undefined"!=typeof Dropzone){e.id="";const t=e.parentNode.innerHTML;e.parentNode.removeChild(e),new Dropzone(".dropzone",{url:"https://httpbin.org/post",method:"post",previewTemplate:t,previewsContainer:"#dropzone-preview"})}},setupFilePond(){if("undefined"!=typeof FilePond){"undefined"!=typeof FilePondPluginFileEncode&&FilePond.registerPlugin(FilePondPluginFileEncode,FilePondPluginFileValidateSize,FilePondPluginImageExifOrientation,FilePondPluginImagePreview),document.querySelectorAll("input.filepond-input-multiple").forEach(e=>{FilePond.create(e)});const e=document.querySelector(".filepond-input-circle");e&&FilePond.create(e,{labelIdle:'Drag & Drop your picture or <span class="filepond--label-action">Browse</span>',imagePreviewHeight:170,imageCropAspectRatio:"1:1",imageResizeTargetWidth:200,imageResizeTargetHeight:200,stylePanelLayout:"compact circle",styleLoadIndicatorPosition:"center bottom",styleProgressIndicatorPosition:"right bottom",styleButtonRemoveItemPosition:"left bottom",styleButtonProcessItemPosition:"right bottom"})}},validateCurrentStep(e){const t=e.querySelector(".tab-pane.show").querySelectorAll(".form-control[required]");let o=!0;return t.forEach(e=>{""===e.value.trim()?(o=!1,e.classList.add("is-invalid")):e.classList.remove("is-invalid")}),o},submitForm(e){const t=document.getElementById(e);return!(!t||!this.validateCurrentStep(t)||(console.log("Form submitted successfully"),0))}});