| 1 |
<template> |
| 2 |
<div class="wpfnl-step__single-template" v-if="activeStep == step.step_type"> |
| 3 |
<div class="template-preview-image"> |
| 4 |
<div class="importar-loader" v-show="showLoader"> |
| 5 |
<span class="title-wrapper"> |
| 6 |
<span class="title">Importing Step</span> |
| 7 |
<span class="dot-wrapper"> |
| 8 |
<span class="dot-one">.</span> |
| 9 |
<span class="dot-two">.</span> |
| 10 |
<span class="dot-three">.</span> |
| 11 |
</span> |
| 12 |
</span> |
| 13 |
</div> |
| 14 |
|
| 15 |
<div class="step-image-wrapper" :style="{ backgroundImage: `url(${step.featured_image})` }"> |
| 16 |
<!-- <img :src="step.featured_image" alt="step template" class="template-img step-previw-img"> --> |
| 17 |
</div> |
| 18 |
</div> |
| 19 |
|
| 20 |
<div class="step-template-info"> |
| 21 |
<span class="title">{{step.title ? step.title.rendered : ''}}</span> |
| 22 |
<div class="template-action"> |
| 23 |
<a :href="step.link" target="_blank" class="step-btn preview"> preview </a> |
| 24 |
<a href="#" class="step-btn import wpfnl-import-step" :data-funnel-id="funnelID" @click="importStep"> import </a> |
| 25 |
</div> |
| 26 |
</div> |
| 27 |
</div> |
| 28 |
</template> |
| 29 |
<script> |
| 30 |
var j = jQuery.noConflict(); |
| 31 |
import apiFetch from "@wordpress/api-fetch"; |
| 32 |
export default { |
| 33 |
name: 'SingleStep', |
| 34 |
props: { |
| 35 |
step: Object, |
| 36 |
funnelID: String, |
| 37 |
activeStep: String, |
| 38 |
}, |
| 39 |
data: function () { |
| 40 |
return { |
| 41 |
showLoader : false, |
| 42 |
} |
| 43 |
}, |
| 44 |
methods: { |
| 45 |
importStep: function (e) { |
| 46 |
e.preventDefault(); |
| 47 |
j('.wpfnl-create-step_inner-content .not-clickable-overlay').show(); |
| 48 |
|
| 49 |
|
| 50 |
var that = this; |
| 51 |
this.showLoader = true; |
| 52 |
that.createStep( {'id' : this.step.id, 'step_type' : this.step.step_type, 'name' : this.step.title ? this.step.title.rendered : this.step.step_type}, this.funnelID, that); |
| 53 |
}, |
| 54 |
createStep: function (step, funnelID, that) { |
| 55 |
var that = this, |
| 56 |
payload = { |
| 57 |
'step' : step, |
| 58 |
'funnelID' : funnelID, |
| 59 |
'source' : 'remote' |
| 60 |
}; |
| 61 |
|
| 62 |
apiFetch({ |
| 63 |
path: `${window.WPFunnelVars.rest_api_url}wpfunnels/v1/steps/wpfunnel-import-step`, |
| 64 |
method: 'POST', |
| 65 |
data: payload |
| 66 |
}) |
| 67 |
.then(function(response) { |
| 68 |
that.showLoader = false; |
| 69 |
that.afterStepCreationRedirect(response.stepID, funnelID); |
| 70 |
}) |
| 71 |
.catch( function( response ) { |
| 72 |
that.showLoader = false; |
| 73 |
}); |
| 74 |
}, |
| 75 |
afterStepCreationRedirect: function (stepID, funnelID) { |
| 76 |
var payload = { |
| 77 |
'stepID' : stepID, |
| 78 |
'funnelID' : funnelID, |
| 79 |
'source' : 'remote', |
| 80 |
}; |
| 81 |
wpAjaxHelperRequest( "wpfunnel-after-step-creation", payload ) |
| 82 |
.success( function( response ) { |
| 83 |
window.location = response.redirectLink |
| 84 |
}) |
| 85 |
.error( function( response ) { |
| 86 |
console.log(response) |
| 87 |
}); |
| 88 |
}, |
| 89 |
} |
| 90 |
} |
| 91 |
</script> |
| 92 |
|