Last active
July 13, 2018 16:13
-
-
Save DominikAngerer/d8461c21d9ae476d8629320448a87c86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Fieldtype = { | |
mixins: [window.Storyblok.plugin], | |
template: `<div><button class="uk-button uk-width-1-1" v-on:click="publishToProduction">Publish to Production</button></div>`, | |
methods: { | |
initWith() { | |
return { | |
plugin: 'publish-to-production' | |
} | |
}, | |
pluginCreated() { | |
console.log('plugin:created') | |
}, | |
publishToProduction() { | |
// Send actual request to rebuild your website (after X websites where published) | |
alert('Send actual request to rebuild your website (after X websites where published)') | |
var data = null; | |
var xhr = new XMLHttpRequest(); | |
xhr.withCredentials = true; | |
xhr.addEventListener("readystatechange", function () { | |
if (this.readyState === 4) { | |
console.log(this.responseText); | |
} | |
}); | |
xhr.open("GET", "https://YOUR_ENDPOINT"); | |
xhr.setRequestHeader("cache-control", "no-cache"); | |
xhr.send(data); | |
} | |
}, | |
watch: { | |
'model': { | |
handler: function (value) { | |
this.$emit('changed-model', value); | |
}, | |
deep: true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment