All files / src/components ValidationScreen.vue

89.47% Statements 17/19
100% Branches 0/0
50% Functions 1/2
89.47% Lines 17/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81  2x                 5x                 18x 18x 18x 18x 18x 1x 1x       1x 1x   18x       5x 5x   5x 5x 5x                                                                              
<script>
import runAjax from '../mixins/runAjax.js';
 
export default {
    name: 'ValidationScreen',
    mixins: [runAjax],
    props: {
        header: {type: String, default: ''},
    },
    data() {
        return {
            validationContent: '',
            loading: true
        };
    },
    computed: {
    },
    methods: {
        stripScripts(s) {
            const div = document.createElement('div');
            div.innerHTML = s;
            const scripts = div.getElementsByTagName('script');
            let i = scripts.length;
            while (i--) {
                let scriptContent = scripts[i].innerHTML;
                let cleanScript = document.createElement('pre');
                cleanScript.innerHTML = `[script]
${scriptContent}
[/script]`;
                scripts[i].parentNode.appendChild(cleanScript);
                scripts[i].parentNode.removeChild(scripts[i]);
            }
            return div.innerHTML;
        },
    },
    created(){
        let collecionURI = window.EmailTemplateData.validatorUrl;
        this.$_get(collecionURI, {type: this.$store.state.currentTemplateType, lang: this.$store.state.activeLanguage}, 'html').then(
            (result) => { 
                this.$log.log(result);
                this.validationContent = result.data;
                this.loading = false;
            },
            (error) => {
                this.$log.error(error);
                this.loading = false;
            }
        );
    }
}
</script>
 
<template>
    <div class="container-fluid scoped-visible-container">
        <div class="row" id="emailtemplates--validation-header" v-if="header != ''">
            <h3>{{header}}</h3>
        </div>
        <div class="row">
            <transition type="fade">
                <div class="scoped-contains-email-validation" v-html="stripScripts(validationContent)" v-show="!loading" />
            </transition>
            <transition type="fade">
                <loader-widget id="validate-template-loader" v-show="loading"/>
            </transition>
        </div>
    </div>
</template>
 
 
<style lang="scss" scoped>
.scoped-visible-container {
    height:98%;
    overflow: auto;
    margin: 1% 0;
    padding: 15px;
}
.scoped-contains-email-validation {
    min-height:40vh;
}
</style>