diff --git a/src/package.json b/src/package.json index a505d086..53fb5bca 100644 --- a/src/package.json +++ b/src/package.json @@ -1,28 +1,29 @@ { - "private": true, - "scripts": { - "dev": "npm run development", - "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch": "npm run development -- --watch", - "watch-poll": "npm run watch -- --watch-poll", - "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", - "prod": "npm run production", - "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" - }, - "devDependencies": { - "axios": "^0.19", - "bootstrap": "^4.3.1", - "cross-env": "^5.1", - "jquery": "^3.4.1", - "laravel-mix": "^4.0.7", - "lodash": "^4.17.13", - "popper.js": "^1.12", - "resolve-url-loader": "^2.3.1", - "sass": "^1.15.2", - "sass-loader": "^7.1.0", - "vue": "^2.5.17", - "vue-router": "^3.1.3", - "vue-template-compiler": "^2.6.10", - "vuex": "^3.1.1" - } + "private": true, + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "npm run development -- --watch", + "watch-poll": "npm run watch -- --watch-poll", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + }, + "devDependencies": { + "axios": "^0.19", + "bootstrap": "^4.3.1", + "cross-env": "^5.1", + "jquery": "^3.4.1", + "laravel-mix": "^4.0.7", + "lodash": "^4.17.13", + "popper.js": "^1.12", + "resolve-url-loader": "^2.3.1", + "sass": "^1.15.2", + "sass-loader": "^7.1.0", + "vue": "^2.5.17", + "vue-router": "^3.1.3", + "vue-template-compiler": "^2.6.10", + "vuex": "^3.1.1", + "@deveodk/vue-toastr": "^1.1.0" + } } diff --git a/src/resources/js/app.js b/src/resources/js/app.js index ba5998c8..ed9013b0 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -1,18 +1,81 @@ /** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */ -require('./bootstrap'); +require('./bootstrap') -window.Vue = require('vue'); +window.Vue = require('vue') -import router from '../vue/js/routes.js'; +import router from '../vue/js/routes.js' import AppComponent from '../vue/components/App' const app = new Vue({ + el: '#app', components: { AppComponent }, - router -}).$mount('#app'); + router, + methods: { + clearFormValidation: form => { + $(form).find('.is-invalid').removeClass('is-invalid') + $(form).find('.invalid-feedback').remove() + } + }, + mounted() { + this.$root.$on('clearFormValidation', (form) => { + this.clearFormValidation(form) + }) + } +}) + +import VueToastr from '@deveodk/vue-toastr' +// You need a specific loader for CSS files like https://github.com/webpack/css-loader +// If you would like custom styling of the toastr the css file can be replaced +import '@deveodk/vue-toastr/dist/@deveodk/vue-toastr.css' + +Vue.use(VueToastr, { + defaultPosition: 'toast-bottom-right', + defaultTimeout: 50000 +}) + +// Add a response interceptor for general/validation error handler +window.axios.interceptors.response.use(response => { + // Do nothing + return response + }, error => { + console.log(error.response) + + var error_msg + + if (error.response && error.response.status == 422) { + error_msg = "Form validation error" + + $.each(error.response.data.errors || {}, (idx, msg) => { + $('form').each((i, form) => { + const input_name = ($(form).data('validation-prefix') || '') + idx + const input = $('#' + input_name) + + if (input.length) { + input.addClass('is-invalid') + .parent().append($('
Data: {{ data }}
Sign up to start your free month.
-We sent out a confirmation code to PHONE/EMAIL. Enter the code we sent you, or click the link in the message.
-Create your Kolab identity (you can choose additional addresses later).
-