diff --git a/content/00-welcome/04-test.txt b/content/00-welcome/04-test.txt deleted file mode 100644 index 7beec68..0000000 --- a/content/00-welcome/04-test.txt +++ /dev/null @@ -1 +0,0 @@ -["# test","Content mit neuem Stuff"] \ No newline at end of file diff --git a/content/00-welcome/04-test.yaml b/content/00-welcome/04-test.yaml deleted file mode 100644 index 3acc487..0000000 --- a/content/00-welcome/04-test.yaml +++ /dev/null @@ -1,9 +0,0 @@ -meta: - title: '' - description: '' - owner: trendschau - author: 'Sebastian Schürmanns' - created: '2020-12-08' - time: 20-33-08 - navtitle: test - modified: '2020-12-08' diff --git a/system/author/js/vue-blox.js b/system/author/js/vue-blox.js index 5f07a3e..41353cc 100644 --- a/system/author/js/vue-blox.js +++ b/system/author/js/vue-blox.js @@ -1597,45 +1597,36 @@ const imageComponent = Vue.component('image-component', { self.imgpreview = e.target.result; - /* load image to server */ - var url = self.$root.$data.root + '/api/v1/image'; - - var params = { + myaxios.post('/api/v1/image',{ 'url': document.getElementById("path").value, 'image': e.target.result, 'name': imageFile.name, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; + }) + .then(function (response) { + + self.load = false; + self.$parent.activatePage(); - var method = 'POST'; - - sendJson(function(response, httpStatus) - { + self.imgmeta = true; + self.imgfile = response.data.name; + self.$emit('updatedMarkdown', '![]('+ response.data.name +')'); + }) + .catch(function (error) + { + /* if(httpStatus == 400) { self.activatePage(); publishController.errors.message = "Looks like you are logged out. Please login and try again."; } - if(response) - { - self.load = false; - self.$parent.activatePage(); - - var result = JSON.parse(response); - - if(result.errors) - { - publishController.errors.message = result.errors; - } - else - { - self.imgmeta = true; - self.imgfile = result.name; - self.$emit('updatedMarkdown', '![]('+ result.name +')'); - } - } - }, method, url, params); + */ + if(error.response.data.errors.message) + { + publishController.errors.message = error.response.data.errors.message; + } + }); } } } @@ -1788,47 +1779,30 @@ const fileComponent = Vue.component('file-component', { reader.readAsDataURL(uploadedFile); reader.onload = function(e) { - /* load file to server */ - var url = self.$root.$data.root + '/api/v1/file'; - - var params = { + myaxios.post('/api/v1/file',{ 'url': document.getElementById("path").value, 'file': e.target.result, 'name': uploadedFile.name, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; - - var method = 'POST'; - - sendJson(function(response, httpStatus) - { - if(httpStatus == 400) - { - self.activatePage(); - publishController.errors.message = "Looks like you are logged out. Please login and try again."; - } - if(response) - { - self.load = false; - self.$parent.activatePage(); + }) + .then(function (response) { + self.load = false; + self.$parent.activatePage(); - var result = JSON.parse(response); - - if(result.errors) - { - publishController.errors.message = result.errors; - } - else - { - self.filemeta = true; - self.filetitle = result.info.title; - self.fileextension = result.info.extension; - self.fileurl = result.info.url; - self.createmarkdown(); - } - } - }, method, url, params); + self.filemeta = true; + self.filetitle = response.data.info.title; + self.fileextension = response.data.info.extension; + self.fileurl = response.data.info.url; + self.createmarkdown(); + }) + .catch(function (error) + { + if(error.response.data.errors.message) + { + publishController.errors.message = error.response.data.errors.message; + } + }); } } } @@ -1875,82 +1849,63 @@ let editor = new Vue({ publishController.visual = true; - var self = this; - - var url = this.root + '/api/v1/article/html'; - - var params = { + var self = this; + + myaxios.post('/api/v1/article/html',{ 'url': document.getElementById("path").value, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; - - var method = 'POST'; + }) + .then(function (response) { + + var contenthtml = response.data.data; + self.title = contenthtml[0]; + self.html = contenthtml; + var initialcontent = document.getElementById("initial-content"); + + initialcontent.parentNode.removeChild(initialcontent); + + }) + .catch(function (error) + { + if(error.response) + { + self.errors.title = error.response.errors; + } + }); - sendJson(function(response, httpStatus) - { - if(httpStatus == 400) - { - } - if(response) - { - var result = JSON.parse(response); - - if(result.errors) - { - self.errors.title = result.errors; - } - else - { - var contenthtml = result.data; - self.title = contenthtml[0]; - self.html = contenthtml; - var initialcontent = document.getElementById("initial-content"); - initialcontent.parentNode.removeChild(initialcontent); - } - } - }, method, url, params); - - var url = this.root + '/api/v1/article/markdown'; - - sendJson(function(response, httpStatus) - { - if(httpStatus == 400) - { - } - if(response) - { - var result = JSON.parse(response); - - if(result.errors) - { - self.errors.title = result.errors; - } - else - { - self.markdown = result.data; + myaxios.post('/api/v1/article/markdown',{ + 'url': document.getElementById("path").value, + 'csrf_name': document.getElementById("csrf_name").value, + 'csrf_value': document.getElementById("csrf_value").value, + }) + .then(function (response) { + + self.markdown = response.data.data; - /* activate math plugin */ - - if (typeof renderMathInElement === "function") { - self.$nextTick(function () { - renderMathInElement(document.getElementById("blox")); - }); - } + /* activate math plugin */ + if (typeof renderMathInElement === "function") { + self.$nextTick(function () { + renderMathInElement(document.getElementById("blox")); + }); + } - /* check for youtube videos */ - if (typeof typemillUtilities !== "undefined") - { - setTimeout(function(){ - self.$nextTick(function () - { - typemillUtilities.start(); - }); - }, 200); - } - } + /* check for youtube videos */ + if (typeof typemillUtilities !== "undefined") { + setTimeout(function(){ + self.$nextTick(function () { + typemillUtilities.start(); + }); + }, 200); } - }, method, url, params); + }) + .catch(function (error) + { + if(error.response) + { + self.errors.title = error.response.errors; + } + }); }, methods: { onStart: function() @@ -1959,60 +1914,51 @@ let editor = new Vue({ }, moveBlock: function(evt) { + publishController.errors.message = false; - var params = { + var self = this; + + myaxios.put('/api/v1/moveblock',{ 'url': document.getElementById("path").value, 'old_index': evt.oldIndex, 'new_index': evt.newIndex, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; - publishController.errors.message = false; - - var url = this.root + '/api/v1/moveblock'; - var self = this; - - var method = 'PUT'; - - sendJson(function(response, httpStatus) - { - if(httpStatus == 400) - { - } - if(response) - { + }) + .then(function (response) { - var result = JSON.parse(response); + self.freeze = false; + + self.markdown = response.data.markdown; + self.blockMarkdown = ''; + self.blockType = ''; - if(result.errors) - { - publishController.errors.message = result.errors; - publishController.publishDisabled = false; - } - else - { - self.freeze = false; - - self.markdown = result.markdown; - self.blockMarkdown = ''; - self.blockType = ''; - - if(result.toc) - { - self.html.splice(result.toc.id, 1, result.toc); - } - - publishController.publishDisabled = false; - publishController.publishResult = ""; - - /* update the navigation and mark navigation item as modified */ - navi.getNavi(); - - /* update the math if plugin is there */ - self.checkMath(params.new_index+1); - } + if(response.data.toc) + { + self.html.splice(response.data.toc.id, 1, response.data.toc); } - }, method, url, params); + + publishController.publishDisabled = false; + publishController.publishResult = ""; + + /* update the navigation and mark navigation item as modified */ + navi.getNavi(); + + /* update the math if plugin is there */ + self.checkMath(params.new_index+1); + }) + .catch(function (error) + { + publishController.publishDisabled = false; + if(error.response.data.message) + { + publishController.errors.message = error.response.data.message; + } + if(error.response.data.errors.message) + { + publishController.errors.message = error.response.data.errors.message; + } + }); }, setData: function(event, blocktype, body) { diff --git a/system/author/js/vue-navi.js b/system/author/js/vue-navi.js index 9295876..eb19963 100644 --- a/system/author/js/vue-navi.js +++ b/system/author/js/vue-navi.js @@ -28,7 +28,19 @@ const navcomponent = Vue.component('navigation', { }, onEnd : function(evt) { - var locator = { + if(evt.from.parentNode.id == evt.to.parentNode.id && evt.oldIndex == evt.newIndex) + { + return + } + + evt.item.classList.add("load"); + + var self = this; + + self.$root.$data.freeze = true; + self.errors = {title: false, content: false, message: false}; + + myaxios.post('/api/v1/article/sort',{ 'item_id': evt.item.id, 'parent_id_from': evt.from.parentNode.id, 'parent_id_to': evt.to.parentNode.id, @@ -38,49 +50,32 @@ const navcomponent = Vue.component('navigation', { 'url': document.getElementById("path").value, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; + }) + .then(function (response) { - if(locator.parent_id_from == locator.parent_id_to && locator.index_old == locator.index_new) - { - return - } - - evt.item.classList.add("load"); - - var self = this; - - self.$root.$data.freeze = true; - self.errors = {title: false, content: false, message: false}; - - var url = this.root + '/api/v1/article/sort'; - var method = 'POST'; - - sendJson(function(response, httpStatus) - { - if(response) - { - self.$root.$data.freeze = false; - var result = JSON.parse(response); + self.$root.$data.freeze = false; - if(result.errors) - { - publishController.errors.message = result.errors; - } - if(result.url) - { - window.location.replace(result.url); - } - if(result.data) - { - evt.item.classList.remove("load"); - self.$root.$data.items = result.data; - } + if(response.data.url) + { + window.location.replace(response.data.url); } - }, method, url, locator ); + if(response.data.data) + { + evt.item.classList.remove("load"); + self.$root.$data.items = response.data.data; + } + }) + .catch(function (error) + { + if(error.response.data.errors.message) + { + publishController.errors.message = error.response.data.errors; + } + }); }, getUrl : function(root, url) { - return root + '/tm/content/' + this.$root.$data.editormode + url + return root + '/tm/content/' + this.$root.$data.editormode + url; }, getLevel : function(level) { @@ -140,49 +135,42 @@ const navcomponent = Vue.component('navigation', { return; } - var newItem = { + var self = this; + + self.$root.$data.freeze = true; + self.errors = {title: false, content: false, message: false}; + + myaxios.post('/api/v1/article',{ 'folder_id': this.$el.id, 'item_name': this.newItem, 'type': type, 'url': document.getElementById("path").value, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; - - /* evt.item.classList.add("load"); */ - - var self = this; - - self.$root.$data.freeze = true; - self.errors = {title: false, content: false, message: false}; - - var url = this.root + '/api/v1/article'; - var method = 'POST'; + }) + .then(function (response) { - sendJson(function(response, httpStatus) - { - if(response) - { - self.$root.$data.freeze = false; - var result = JSON.parse(response); + self.$root.$data.freeze = false; - if(result.errors) - { - publishController.errors.message = result.errors; - } - if(result.url) - { - window.location.replace(result.url); - } - if(result.data) - { - // evt.item.classList.remove("load"); - self.$root.$data.items = result.data; - self.newItem = ''; - self.showForm = false; - } + if(response.data.url) + { + window.location.replace(response.data.url); } - }, method, url, newItem ); + if(response.data.data) + { + // evt.item.classList.remove("load"); + self.$root.$data.items = response.data.data; + self.newItem = ''; + self.showForm = false; + } + }) + .catch(function (error) + { + if(error.response.data.errors) + { + publishController.errors.message = error.response.data.errors; + } + }); }, } }) @@ -247,45 +235,37 @@ let navi = new Vue({ return; } - var newItem = { + self = this; + + self.freeze = true; + self.errors = {title: false, content: false, message: false}; + + myaxios.post('/api/v1/baseitem',{ 'item_name': this.newItem, 'type': type, 'url': document.getElementById("path").value, 'csrf_name': document.getElementById("csrf_name").value, 'csrf_value': document.getElementById("csrf_value").value, - }; - - var self = this; - - self.freeze = true; - self.errors = {title: false, content: false, message: false}; - - var url = this.root + '/api/v1/baseitem'; - var method = 'POST'; - - sendJson(function(response, httpStatus) - { - if(response) - { - self.freeze = false; - var result = JSON.parse(response); + }) + .then(function (response) { + + self.freeze = false; - if(result.errors) - { - publishController.errors.message = result.errors; - } - if(result.url) - { - window.location.replace(result.url); - } - if(result.data) - { - self.items = result.data; - self.newItem = ''; - self.showForm = false; - } + if(response.data.url) + { + window.location.replace(response.data.url); } - }, method, url, newItem ); + if(response.data.data) + { + self.items = response.data.data; + self.newItem = ''; + self.showForm = false; + } + }) + .catch(function (error) + { + publishController.errors.message = error.response.data.errors; + }); }, getNavi: function() { @@ -297,28 +277,34 @@ let navi = new Vue({ self.errors = {title: false, content: false, message: false}; var activeItem = document.getElementById("path").value; + var url = this.root + '/api/v1/navigation?url=' + activeItem; var method = 'GET'; - sendJson(function(response, httpStatus) - { - if(response) + myaxios.get('/api/v1/navigation',{ + params: { + 'url': activeItem, + 'csrf_name': document.getElementById("csrf_name").value, + 'csrf_value': document.getElementById("csrf_value").value, + } + }) + .then(function (response) { + + self.freeze = false; + if(response.data.data) { - self.freeze = false; - var result = JSON.parse(response); - - if(result.errors) - { - publishController.errors.message = result.errors; - } - if(result.data) - { - self.items = result.data; - self.newItem = ''; - self.homepage = result.homepage; - } + self.items = response.data.data; + self.newItem = ''; + self.homepage = response.data.homepage; } - }, method, url, activeItem ); + }) + .catch(function (error) + { + if(error.response.data.errors) + { + publishController.errors.message = error.response.data.errors; + } + }); } } }) \ No newline at end of file diff --git a/system/author/js/vue-publishcontroller.js b/system/author/js/vue-publishcontroller.js index 29508ba..b8f440c 100644 --- a/system/author/js/vue-publishcontroller.js +++ b/system/author/js/vue-publishcontroller.js @@ -2,189 +2,138 @@ let publishController = new Vue({ delimiters: ['${', '}'], el: '#publishController', data: { - root: document.getElementById("main").dataset.url, + root: document.getElementById("main").dataset.url, form: { - title: false, - content: false, - url: document.getElementById("path").value, - csrf_name: document.getElementById("csrf_name").value, - csrf_value: document.getElementById("csrf_value").value, + title: false, + content: false, + url: document.getElementById("path").value, + csrf_name: document.getElementById("csrf_name").value, + csrf_value: document.getElementById("csrf_value").value, }, errors:{ - message: false, + message: false, }, - modalWindow: false, - modalType: false, - draftDisabled: true, - publishDisabled: document.getElementById("publishController").dataset.drafted ? false : true, - deleteDisabled: false, - draftResult: "", - publishResult: "", - discardResult: "", - deleteResult: "", - publishStatus: document.getElementById("publishController").dataset.published ? false : true, - publishLabel: document.getElementById("publishController").dataset.published ? "online" : "offline", + modalWindow: false, + modalType: false, + draftDisabled: true, + publishDisabled: document.getElementById("publishController").dataset.drafted ? false : true, + deleteDisabled: false, + draftResult: "", + publishResult: "", + discardResult: "", + deleteResult: "", + publishStatus: document.getElementById("publishController").dataset.published ? false : true, + publishLabel: document.getElementById("publishController").dataset.published ? "online" : "offline", publishLabelMobile: document.getElementById("publishController").dataset.published ? "ON" : "OFF", - raw: false, - visual: false, + raw: false, + visual: false, }, methods: { - publishDraft: function(e){ - var self = this; - self.errors.message = false; - editor.errors = {title: false, content: false}; - - self.publishResult = "load"; - self.publishDisabled = "disabled"; + handleErrors: function(error){ - var url = this.root + '/api/v1/article/publish'; - var method = 'POST'; - this.form.raw = this.raw; + /* if there are custom error messages */ + if(error.response.data.errors) + { + this.publishDisabled = false; + this.publishResult = "fail"; + + if(error.response.data.errors.message){ this.errors.message = error.response.data.errors.message }; + if(error.response.data.errors.title){ editor.errors.title = error.response.data.errors.title[0] }; + if(error.response.data.errors.content){ editor.errors.content = error.response.data.errors.content[0] }; + } + else if(error.response.status == 400) + { + this.publishDisabled = false; + this.publishResult = "fail"; + this.errors.message = "You are probably logged out. Please backup your changes, login and then try again." + } + else if(error.response.status != 200) + { + self.publishDisabled = false; + self.publishResult = "fail"; + self.errors.message = "Something went wrong, please refresh the page and try again." + } + }, + publishDraft: function(e){ + + this.errors.message = false; + editor.errors = {title: false, content: false}; + + this.publishResult = "load"; + this.publishDisabled = "disabled"; + + this.form.raw = this.raw; if(this.form.raw) { - this.form.title = editor.form.title; - this.form.content = editor.form.content; + this.form.title = editor.form.title; + this.form.content = editor.form.content; } - sendJson(function(response, httpStatus) - { - if(httpStatus == 400) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "You are probably logged out. Please backup your changes, login and then try again." - } - else if(response) - { - var result = JSON.parse(response); - - if(result.errors) - { - self.publishDisabled = false; - self.publishResult = "fail"; - - if(result.errors.title){ editor.errors.title = result.errors.title[0] }; - if(result.errors.content){ editor.errors.content = result.errors.content[0] }; - if(result.errors.message){ self.errors.message = result.errors.message }; - } - else - { - if(result.meta) - { - meta.formData = result.meta; - } - - self.draftDisabled = "disabled"; - self.publishResult = "success"; - self.publishStatus = false; - self.publishLabel = "online"; - self.publishLabelMobile = "ON"; - navi.getNavi(); - } - } - else if(httpStatus != 200) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "Something went wrong, please refresh the page and try again." - } - }, method, url, this.form ); - }, - discardDraft: function(e) { var self = this; - self.errors.message = false; - editor.errors = {title: false, content: false}; - - self.discardResult = "load"; - self.publishDisabled = "disabled"; + myaxios.post('/api/v1/article/publish',self.form) + .then(function (response) { + if(response.data.meta) + { + meta.formData = response.data.meta; + } - var url = self.root + '/api/v1/article/discard'; - var method = 'DELETE'; - - sendJson(function(response, httpStatus) + self.draftDisabled = "disabled"; + self.publishResult = "success"; + self.publishStatus = false; + self.publishLabel = "online"; + self.publishLabelMobile = "ON"; + navi.getNavi(); + }) + .catch(function (error) { - if(httpStatus == 400) - { - self.publishDisabled = false; - self.discardResult = "fail"; - self.errors.message = "You are probably logged out. Please backup your changes, login and then try again." - } - else if(response) - { - var result = JSON.parse(response); + self.handleErrors(error); + }); + }, + discardDraft: function(e) { - if(result.errors) - { - self.publishDisabled = false; - self.discardResult = "fail"; - if(result.errors.title){ editor.errors.title = result.errors.title[0] } - if(result.errors.content){ editor.errors.content = result.errors.content[0] } - if(result.errors.message){ self.errors.message = result.errors.message } - } - else - { - window.location.replace(result.url); - } - } - else if(httpStatus != 200) - { - self.publishDisabled = false; - self.discardResult = "fail"; - self.errors.message = "Something went wrong, please refresh the page and try again." - } + this.errors.message = false; + editor.errors = {title: false, content: false}; + + this.discardResult = "load"; + this.publishDisabled = "disabled"; - }, method, url, this.form); + myaxios.delete('/api/v1/article/discard',{ + data: this.form + }) + .then(function (response) + { + window.location.replace(response.data.url); + }) + .catch(function (error) + { + self.handleErrors(error); + }); }, saveDraft: function(e){ - var self = this; - self.errors.message = false; - editor.errors = {title: false, content: false}; + this.errors.message = false; + editor.errors = {title: false, content: false}; - self.draftDisabled = "disabled"; - self.draftResult = "load"; - - var url = this.root + '/api/v1/article'; - var method = 'PUT'; - - this.form.title = editor.form.title; - this.form.content = editor.form.content; - - sendJson(function(response, httpStatus) - { - if(httpStatus == 400) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "You are probably logged out. Please backup your changes, login and then try again." - } - else if(response) - { - var result = JSON.parse(response); - - if(result.errors) - { - self.draftDisabled = false; - self.draftResult = 'fail'; + this.draftResult = "load"; + this.draftDisabled = "disabled"; - if(result.errors.title){ editor.errors.title = result.errors.title[0]; }; - if(result.errors.content){ editor.errors.content = result.errors.content[0] }; - if(result.errors.message){ self.errors.message = result.errors.message; }; - } - else - { - self.draftResult = 'success'; - navi.getNavi(); - } - } - else if(httpStatus != 200) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "Something went wrong, please refresh the page and try again." - } - }, method, url, this.form ); + this.form.title = editor.form.title; + this.form.content = editor.form.content; + + var self = this; + + myaxios.put('/api/v1/article',self.form) + .then(function (response) { + self.draftResult = 'success'; + navi.getNavi(); + }) + .catch(function (error) + { + self.draftDisabled = false; + self.draftResult = 'fail'; + self.handleErrors(error); + }); }, depublishArticle: function(e){ @@ -194,98 +143,63 @@ let publishController = new Vue({ return; } - var self = this; - self.errors.message = false; - editor.errors = {title: false, content: false}; + this.errors.message = false; + editor.errors = {title: false, content: false}; - self.publishStatus = "disabled"; + this.publishStatus = "disabled"; - var url = this.root + '/api/v1/article/unpublish'; - var method = 'DELETE'; - - sendJson(function(response, httpStatus) + var self = this; + + myaxios.delete('/api/v1/article/unpublish',{ + data: self.form + }) + .then(function (response) + { + self.publishResult = ""; + self.publishLabel = "offline"; + self.publishLabelMobile = "OFF"; + self.publishDisabled = false; + navi.getNavi(); + }) + .catch(function (error) { - if(httpStatus == 400) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "You are probably logged out. Please backup your changes, login and then try again." - } - else if(response) - { - var result = JSON.parse(response); - - if(result.errors) - { - self.publishStatus = false; - if(result.errors.message){ self.errors.message = result.errors.message }; - } - else - { - self.publishResult = ""; - self.publishLabel = "offline"; - self.publishLabelMobile = "OFF"; - self.publishDisabled = false; - navi.getNavi(); - } - } - else if(httpStatus != 200) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "Something went wrong, please refresh the page and try again."; - } - }, method, url, this.form ); + self.publishStatus = false; + self.handleErrors(error); + }); }, deleteArticle: function(e){ - var self = this; - self.errors.message = false; - editor.errors = {title: false, content: false}; + this.errors.message = false; + editor.errors = {title: false, content: false}; - self.deleteDisabled = "disabled"; - self.deleteResult = "load"; + this.deleteDisabled = "disabled"; + this.deleteResult = "load"; - var url = this.root + '/api/v1/article'; - var method = 'DELETE'; + var self = this; - sendJson(function(response, httpStatus) + myaxios.delete('/api/v1/article',{ + data: self.form + }) + .then(function (response) + { + self.modalWindow = false; + if(response.data.url) + { + window.location.replace(response.data.url); + } + }) + .catch(function (error) { - if(httpStatus == 400) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "You are probably logged out. Please backup your changes, login and then try again." - } - else if(response) - { - var result = JSON.parse(response); - - self.modalWindow = false; - - if(httpStatus != 200) - { - self.publishDisabled = false; - self.publishResult = "fail"; - self.errors.message = "Something went wrong, please refresh the page and try again."; - } - if(result.errors) - { - if(result.errors.message){ self.errors.message = result.errors.message }; - } - else if(result.url) - { - window.location.replace(result.url); - } - } - }, method, url, this.form ); + self.publishStatus = false; + self.handleErrors(error); + }); }, showModal: function(type){ - this.modalType = type; - this.modalWindow = true; + this.modalType = type; + this.modalWindow = true; }, hideModal: function(type){ - this.modalWindow = false; - this.modalType = false; + this.modalWindow = false; + this.modalType = false; }, } }); \ No newline at end of file