diff --git a/dist/js/card.js b/dist/js/card.js index 5e67e15fd7..93b5de0434 100644 --- a/dist/js/card.js +++ b/dist/js/card.js @@ -1 +1 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(6)},function(t,e,r){Nova.booting(function(t,e){t.component("nova-import-card",r(2))})},function(t,e,r){var n=r(3)(r(4),r(5),!1,null,null,null);t.exports=n.exports},function(t,e){t.exports=function(t,e,r,n,s,o){var i,a=t=t||{},l=typeof t.default;"object"!==l&&"function"!==l||(i=t,a=t.default);var c,f="function"==typeof a?a.options:a;if(e&&(f.render=e.render,f.staticRenderFns=e.staticRenderFns,f._compiled=!0),r&&(f.functional=!0),s&&(f._scopeId=s),o?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},f._ssrRegister=c):n&&(c=n),c){var u=f.functional,p=u?f.render:f.beforeCreate;u?(f._injectStyles=c,f.render=function(t,e){return c.call(e),p(t,e)}):f.beforeCreate=p?[].concat(p,c):[c]}return{esModule:i,exports:a,options:f}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={props:["card"],data:function(){return{fileName:"",file:null,label:"no file selected",working:!1,errors:null}},mounted:function(){},methods:{fileChange:function(t){var e=t.target.value.match(/[^\\/]*$/)[0];this.fileName=e,this.file=this.$refs.fileField.files[0]},processImport:function(){var t=this;this.working=!0;var e=new FormData;e.append("file",this.file),Nova.request().post("/nova-vendor/sparclex/nova-import-card/endpoint/"+this.card.resource,e).then(function(e){var r=e.data;t.$toasted.success(r.message),t.$parent.$parent.$parent.$parent.getResources()}).catch(function(e){var r=e.response;t.errors=r.data.errors}).finally(function(){return t.working=!1})}},computed:{currentLabel:function(){return this.fileName||this.label},firstError:function(){return this.errors?this.errors[Object.keys(this.errors)[0]][0]:null}}}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("card",{staticClass:"flex flex-col"},[r("div",{staticClass:"px-3 py-3"},[r("h1",{staticClass:"text-xl font-light"},[t._v("Import "+t._s(this.card.resourceLabel))]),t._v(" "),r("form",{on:{submit:function(e){return e.preventDefault(),t.processImport(e)}}},[r("div",{staticClass:"py-4"},[r("span",{staticClass:"form-file mr-4"},[r("input",{ref:"fileField",staticClass:"form-file-input",attrs:{type:"file",id:"import-file",name:"name"},on:{change:t.fileChange}}),t._v(" "),r("label",{staticClass:"form-file-btn btn btn-default btn-primary",attrs:{for:"import-file"}},[t._v("\n "+t._s(t.__("Choose File"))+"\n ")])]),t._v(" "),r("span",{staticClass:"text-gray-50"},[t._v("\n "+t._s(t.currentLabel)+"\n ")])]),t._v(" "),r("div",{staticClass:"flex"},[t.errors?r("div",[r("p",{staticClass:"text-danger"},[t._v(t._s(t.firstError))])]):t._e(),t._v(" "),r("button",{staticClass:"btn btn-default btn-primary ml-auto",attrs:{disabled:t.working,type:"submit"}},[t.working?r("loader",{attrs:{width:"30"}}):r("span",[t._v(t._s(t.__("Import")))])],1)])])])])},staticRenderFns:[]}},function(t,e){}]); \ No newline at end of file +!function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1),t.exports=r(6)},function(t,e,r){Nova.booting(function(t){t.component("nova-import-card",r(2))})},function(t,e,r){var n=r(3)(r(4),r(5),!1,null,null,null);t.exports=n.exports},function(t,e){t.exports=function(t,e,r,n,s,o){var i,a=t=t||{},l=typeof t.default;"object"!==l&&"function"!==l||(i=t,a=t.default);var c,f="function"==typeof a?a.options:a;if(e&&(f.render=e.render,f.staticRenderFns=e.staticRenderFns,f._compiled=!0),r&&(f.functional=!0),s&&(f._scopeId=s),o?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},f._ssrRegister=c):n&&(c=n),c){var u=f.functional,p=u?f.render:f.beforeCreate;u?(f._injectStyles=c,f.render=function(t,e){return c.call(e),p(t,e)}):f.beforeCreate=p?[].concat(p,c):[c]}return{esModule:i,exports:a,options:f}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={props:["card"],data:function(){return{fileName:"",file:null,label:"no file selected",working:!1,errors:null}},mounted:function(){},methods:{fileChange:function(t){var e=t.target.value.match(/[^\\/]*$/)[0];this.fileName=e,this.file=this.$refs.fileField.files[0]},processImport:function(){var t=this;this.working=!0;var e=new FormData;e.append("file",this.file),Nova.request().post("/nova-vendor/sparclex/nova-import-card/endpoint/"+this.card.resource,e).then(function(e){var r=e.data;t.$toasted.success(r.message),t.$parent.$parent.$parent.$parent.getResources()}).catch(function(e){var r=e.response;t.errors=r.data.errors}).finally(function(){return t.working=!1})}},computed:{currentLabel:function(){return this.fileName||this.label},firstError:function(){return this.errors?this.errors[Object.keys(this.errors)[0]][0]:null}}}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("card",{staticClass:"flex flex-col"},[r("div",{staticClass:"px-3 py-3"},[r("h1",{staticClass:"text-xl font-light"},[t._v("Import "+t._s(this.card.resourceLabel))]),t._v(" "),r("form",{on:{submit:function(e){return e.preventDefault(),t.processImport(e)}}},[r("div",{staticClass:"py-4"},[r("span",{staticClass:"form-file mr-4"},[r("input",{ref:"fileField",staticClass:"form-file-input",attrs:{type:"file",id:"import-file",name:"name"},on:{change:t.fileChange}}),t._v(" "),r("label",{staticClass:"form-file-btn btn btn-default btn-primary",attrs:{for:"import-file"}},[t._v("\n "+t._s(t.__("Choose File"))+"\n ")])]),t._v(" "),r("span",{staticClass:"text-gray-50"},[t._v("\n "+t._s(t.currentLabel)+"\n ")])]),t._v(" "),r("div",{staticClass:"flex"},[t.errors?r("div",[r("p",{staticClass:"text-danger"},[t._v(t._s(t.firstError))])]):t._e(),t._v(" "),r("button",{staticClass:"btn btn-default btn-primary ml-auto",attrs:{disabled:t.working,type:"submit"}},[t.working?r("loader",{attrs:{width:"30"}}):r("span",[t._v(t._s(t.__("Import")))])],1)])])])])},staticRenderFns:[]}},function(t,e){}]); \ No newline at end of file diff --git a/package.json b/package.json index fb91be33c1..49303dfdc7 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,18 @@ "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 --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "check-format": "prettier --list-different 'resources/**/*.{css,js,vue}'", + "format": "prettier --write 'resources/**/*.{css,js,vue}'", + "lint": "eslint resources/js --fix --ext js,vue" }, "devDependencies": { "cross-env": "^5.0.0", - "laravel-mix": "^1.0" + "laravel-mix": "^1.0", + "prettier": "^1.14.2", + "eslint": "^4.19.1", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-vue": "^4.4.0" }, "dependencies": { "vue": "^2.5.0" diff --git a/resources/js/card.js b/resources/js/card.js index ef203ff6b6..2b5b2700eb 100644 --- a/resources/js/card.js +++ b/resources/js/card.js @@ -1,3 +1,3 @@ -Nova.booting((Vue, router) => { +Nova.booting(Vue => { Vue.component('nova-import-card', require('./components/Card')); -}) +}); diff --git a/resources/js/components/Card.vue b/resources/js/components/Card.vue index f9b343fb95..e31a090acd 100644 --- a/resources/js/components/Card.vue +++ b/resources/js/components/Card.vue @@ -6,12 +6,12 @@