From 93bedcdf5b7e365c6c3e36effbcef5a414cba331 Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Thu, 3 Oct 2024 13:08:04 +0200 Subject: [PATCH 01/20] refactor: ajax-login --- .../app/components/ajax-login/ajax-login.js | 72 -------------- .../app/components/ajax-login/ajax-login.vue | 93 +++++++++++++++++++ resources/js/app/pages/modules/view.vue | 3 +- 3 files changed, 95 insertions(+), 73 deletions(-) delete mode 100644 resources/js/app/components/ajax-login/ajax-login.js create mode 100644 resources/js/app/components/ajax-login/ajax-login.vue diff --git a/resources/js/app/components/ajax-login/ajax-login.js b/resources/js/app/components/ajax-login/ajax-login.js deleted file mode 100644 index fb2b06bdc..000000000 --- a/resources/js/app/components/ajax-login/ajax-login.js +++ /dev/null @@ -1,72 +0,0 @@ -import Vue from 'vue'; - -export const AjaxLogin = Vue.extend({ - - template: ` - - `, - name: 'AjaxLogin', - - props: { - headerText: { - type: String, - default: null, - }, - message: { - type: String, - default: null, - }, - }, - - data() { - return { - isOpen: false, - url: `${BEDITA.base}/login`, - }; - }, - - mounted() { - window.addEventListener('message', this.checkLogin); - this.isOpen = true; - }, - - methods: { - checkLogin(message) { - if (message.data !== 'login') { - return; - } - - this.$emit('login'); - this.close(); - }, - - close() { - this.isOpen = false; - window.removeEventListener('message', this.checkLogin); - - if (this.$el.parentNode) { - this.$el.parentNode.removeChild(this.$el); - } - - this.$destroy(); - } - }, -}); diff --git a/resources/js/app/components/ajax-login/ajax-login.vue b/resources/js/app/components/ajax-login/ajax-login.vue new file mode 100644 index 000000000..cb60dd554 --- /dev/null +++ b/resources/js/app/components/ajax-login/ajax-login.vue @@ -0,0 +1,93 @@ +