diff --git a/resources/assets/js/mixins/global.js b/resources/assets/js/mixins/global.js index 6a6d1e46f..1e7f15f3c 100644 --- a/resources/assets/js/mixins/global.js +++ b/resources/assets/js/mixins/global.js @@ -702,5 +702,54 @@ export default { // always executed }); }, + + onModalAddNew(url) { + let modal = { + modal: true, + title: '', + html: '', + buttons:{} + }; + + Promise.resolve(window.axios.get(url)).then(response => { + if (response.data.success) { + modal.title = response.data.title; + modal.html = response.data.html; + modal.buttons = response.data.buttons; + + this.component = Vue.component('add-new-component', (resolve, reject) => { + resolve({ + template: '
', + + mixins: [ + Global + ], + + data: function () { + return { + form:{}, + modal: modal, + } + }, + + methods: { + onSubmit(event) { + this.$emit('submit', event); + event.submit(); + }, + + onCancel() { + this.modal.show = false; + this.modal.html = null; + }, + } + }) + }) + } + }) + .catch(e => { + this.errors.push(e); + }) + }, } }