From 8af187f5a41d795e22c9857b125f3b8268406aa4 Mon Sep 17 00:00:00 2001 From: Brian Dillingham Date: Sun, 18 Aug 2019 13:06:48 -0400 Subject: [PATCH 1/2] Navigate after triggering events --- dist/js/field.js | 2 +- resources/js/components/NovaButton.vue | 46 ++++++++++++-------------- webpack.mix.js | 2 +- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/dist/js/field.js b/dist/js/field.js index 60facd9..faadcb8 100644 --- a/dist/js/field.js +++ b/dist/js/field.js @@ -1 +1 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=function(t,e,n,r,o,i){var s,a=t=t||{},c=typeof t.default;"object"!==c&&"function"!==c||(s=t,a=t.default);var u,l="function"==typeof a?a.options:a;if(e&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0),n&&(l.functional=!0),o&&(l._scopeId=o),i?(u=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__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},l._ssrRegister=u):r&&(u=r),u){var f=l.functional,d=f?l.render:l.beforeCreate;f?(l._injectStyles=u,l.render=function(t,e){return u.call(e),d(t,e)}):l.beforeCreate=d?[].concat(d,u):[u]}return{esModule:s,exports:a,options:l}}},function(t,e,n){"use strict";n.d(e,"a",function(){return o});var r=function(){function t(t,e){for(var n=0;nn.parts.length&&(r.parts.length=n.parts.length)}else{var s=[];for(o=0;o=0,i=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(13),o)r.regeneratorRuntime=i;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";var n,r=Object.prototype,o=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag",u="object"==typeof t,l=e.regeneratorRuntime;if(l)u&&(t.exports=l);else{(l=e.regeneratorRuntime=u?t.exports:{}).wrap=x;var f="suspendedStart",d="suspendedYield",h="executing",p="completed",v={},m={};m[s]=function(){return this};var g=Object.getPrototypeOf,y=g&&g(g(S([])));y&&y!==r&&o.call(y,s)&&(m=y);var b=L.prototype=_.prototype=Object.create(m);C.prototype=b.constructor=L,L.constructor=C,L[c]=C.displayName="GeneratorFunction",l.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===C||"GeneratorFunction"===(e.displayName||e.name))},l.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,L):(t.__proto__=L,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(b),t},l.awrap=function(t){return{__await:t}},T(E.prototype),E.prototype[a]=function(){return this},l.AsyncIterator=E,l.async=function(t,e,n,r){var o=new E(x(t,e,n,r));return l.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},T(b),b[c]="Generator",b[s]=function(){return this},b.toString=function(){return"[object Generator]"},l.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},l.values=S,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return a.type="throw",a.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),N(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;N(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),v}}}function x(t,e,n,r){var o=e&&e.prototype instanceof _?e:_,i=Object.create(o.prototype),s=new R(r||[]);return i._invoke=function(t,e,n){var r=f;return function(o,i){if(r===h)throw new Error("Generator is already running");if(r===p){if("throw"===o)throw i;return j()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=k(s,n);if(a){if(a===v)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var c=w(t,e,n);if("normal"===c.type){if(r=n.done?p:d,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=p,n.method="throw",n.arg=c.arg)}}}(t,n,s),i}function w(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function _(){}function C(){}function L(){}function T(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function E(t){var e;this._invoke=function(n,r){function i(){return new Promise(function(e,i){!function e(n,r,i,s){var a=w(t[n],t,r);if("throw"!==a.type){var c=a.arg,u=c.value;return u&&"object"==typeof u&&o.call(u,"__await")?Promise.resolve(u.__await).then(function(t){e("next",t,i,s)},function(t){e("throw",t,i,s)}):Promise.resolve(u).then(function(t){c.value=t,i(c)},s)}s(a.arg)}(n,r,e,i)})}return e=e?e.then(i,i):i()}}function k(t,e){var r=t.iterator[e.method];if(r===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=w(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function M(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(M,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++rn.parts.length&&(r.parts.length=n.parts.length)}else{var s=[];for(o=0;o=0,i=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n(13),o)r.regeneratorRuntime=i;else try{delete r.regeneratorRuntime}catch(t){r.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";var n,r=Object.prototype,o=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag",u="object"==typeof t,l=e.regeneratorRuntime;if(l)u&&(t.exports=l);else{(l=e.regeneratorRuntime=u?t.exports:{}).wrap=x;var f="suspendedStart",d="suspendedYield",h="executing",p="completed",v={},m={};m[s]=function(){return this};var g=Object.getPrototypeOf,y=g&&g(g(S([])));y&&y!==r&&o.call(y,s)&&(m=y);var b=L.prototype=_.prototype=Object.create(m);C.prototype=b.constructor=L,L.constructor=C,L[c]=C.displayName="GeneratorFunction",l.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===C||"GeneratorFunction"===(e.displayName||e.name))},l.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,L):(t.__proto__=L,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(b),t},l.awrap=function(t){return{__await:t}},k(E.prototype),E.prototype[a]=function(){return this},l.AsyncIterator=E,l.async=function(t,e,n,r){var o=new E(x(t,e,n,r));return l.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},k(b),b[c]="Generator",b[s]=function(){return this},b.toString=function(){return"[object Generator]"},l.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},l.values=S,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(R),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return a.type="throw",a.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),R(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;R(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),v}}}function x(t,e,n,r){var o=e&&e.prototype instanceof _?e:_,i=Object.create(o.prototype),s=new M(r||[]);return i._invoke=function(t,e,n){var r=f;return function(o,i){if(r===h)throw new Error("Generator is already running");if(r===p){if("throw"===o)throw i;return j()}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var a=T(s,n);if(a){if(a===v)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var c=w(t,e,n);if("normal"===c.type){if(r=n.done?p:d,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=p,n.method="throw",n.arg=c.arg)}}}(t,n,s),i}function w(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function _(){}function C(){}function L(){}function k(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function E(t){var e;this._invoke=function(n,r){function i(){return new Promise(function(e,i){!function e(n,r,i,s){var a=w(t[n],t,r);if("throw"!==a.type){var c=a.arg,u=c.value;return u&&"object"==typeof u&&o.call(u,"__await")?Promise.resolve(u.__await).then(function(t){e("next",t,i,s)},function(t){e("throw",t,i,s)}):Promise.resolve(u).then(function(t){c.value=t,i(c)},s)}s(a.arg)}(n,r,e,i)})}return e=e?e.then(i,i):i()}}function T(t,e){var r=t.iterator[e.method];if(r===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=n,T(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=w(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r - - + - - - - + > @@ -73,6 +52,7 @@ export default { queue.remove(this.resourceId); this.$emit("success"); this.$emit("finished"); + this.navigate(); } catch (error) { this.error = true; this.loading = false; @@ -97,10 +77,23 @@ export default { event: this.field.event } ); + }, + navigate() { + if(this.field.type == 'route') { + this.$router.push(this.field.route); + } + + if(this.field.type == 'link') { + window.open(this.field.link.href, this.field.link.target); + } } }, computed: { buttonText: function() { + if(this.field.link && this.field.link.target == '_blank') { + return this.field.text; + } + if (this.error && this.field.errorText) { return this.field.errorText; } @@ -116,6 +109,9 @@ export default { return this.field.text; }, buttonClasses: function() { + if(this.field.link && this.field.link.target == '_blank') { + return this.field.classes; + } if (this.error && this.field.errorClasses.length) { return this.field.errorClasses + " text-center nova-button-error"; } diff --git a/webpack.mix.js b/webpack.mix.js index 15c1c9f..e831f70 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -1,3 +1,3 @@ let mix = require('laravel-mix') -mix.setPublicPath('dist').js('resources/js/field.js', 'js') +mix.setPublicPath('dist').js('resources/js/field.js', 'js') \ No newline at end of file From 649753aab51b003aeebe319a00de2dc27e56346c Mon Sep 17 00:00:00 2001 From: Brian Dillingham Date: Sun, 18 Aug 2019 13:10:41 -0400 Subject: [PATCH 2/2] Apply styleci fixes --- config/nova-button.php | 30 ++++----- src/Button.php | 91 +++++++++++++------------- src/Providers/FieldServiceProvider.php | 10 +-- 3 files changed, 66 insertions(+), 65 deletions(-) diff --git a/config/nova-button.php b/config/nova-button.php index ce160d5..5577309 100644 --- a/config/nova-button.php +++ b/config/nova-button.php @@ -12,13 +12,13 @@ */ 'defaults' => [ - 'style' => 'link-primary', + 'style' => 'link-primary', 'loadingStyle' => 'link-grey', - 'loadingText' => 'Loading', + 'loadingText' => 'Loading', 'successStyle' => 'link-success', - 'successText' => 'Success', - 'errorStyle' => 'link-danger', - 'errorText' => 'Failed', + 'successText' => 'Success', + 'errorStyle' => 'link-danger', + 'errorText' => 'Failed', ], /* @@ -37,25 +37,25 @@ 'success' => 'cursor-pointer btn btn-default bg-success text-white', 'primary' => 'cursor-pointer btn btn-default btn-primary', 'warning' => 'cursor-pointer btn btn-default bg-warning text-white', - 'danger' => 'cursor-pointer btn btn-default bg-danger text-white', - 'info' => 'cursor-pointer btn btn-default bg-info text-white', - 'grey' => 'cursor-pointer btn btn-default bg-60 text-white', + 'danger' => 'cursor-pointer btn btn-default bg-danger text-white', + 'info' => 'cursor-pointer btn btn-default bg-info text-white', + 'grey' => 'cursor-pointer btn btn-default bg-60 text-white', // Outline 'success-outline' => 'cursor-pointer btn btn-default border border-success text-success', 'primary-outline' => 'cursor-pointer btn btn-default border border-primary text-primary', 'warning-outline' => 'cursor-pointer btn btn-default border border-warning text-warning ', - 'danger-outline' => 'cursor-pointer btn btn-default border border-danger text-danger ', - 'info-outline' => 'cursor-pointer btn btn-default border border-info text-info ', - 'grey-outline' => 'cursor-pointer btn btn-default border border-60 text-80 ', + 'danger-outline' => 'cursor-pointer btn btn-default border border-danger text-danger ', + 'info-outline' => 'cursor-pointer btn btn-default border border-info text-info ', + 'grey-outline' => 'cursor-pointer btn btn-default border border-60 text-80 ', // Link 'success-link' => 'cursor-pointer dim inline-block text-success font-bold btn btn-link', 'primary-link' => 'cursor-pointer dim inline-block text-primary font-bold btn btn-link', 'warning-link' => 'cursor-pointer dim inline-block text-warning font-bold btn btn-link', - 'danger-link' => 'cursor-pointer dim inline-block text-danger font-bold btn btn-link', - 'info-link' => 'cursor-pointer dim inline-block text-info font-bold btn btn-link', - 'grey-link' => 'cursor-pointer dim inline-block text-80 font-bold btn btn-link', + 'danger-link' => 'cursor-pointer dim inline-block text-danger font-bold btn btn-link', + 'info-link' => 'cursor-pointer dim inline-block text-info font-bold btn btn-link', + 'grey-link' => 'cursor-pointer dim inline-block text-80 font-bold btn btn-link', // Custom 'custom' => 'bg-orange', - + ], ]; diff --git a/src/Button.php b/src/Button.php index 593ff21..5d0a9c8 100644 --- a/src/Button.php +++ b/src/Button.php @@ -3,17 +3,16 @@ namespace NovaButton; use Laravel\Nova\Fields\Field; -use Laravel\Nova\Filters\Filter; use Laravel\Nova\Resource; class Button extends Field { public $style = null; - + public $classes = []; public $reload = false; - + public $visible = true; public $showOnUpdate = false; @@ -37,13 +36,13 @@ class Button extends Field public $link = null; public $confirm = null; - + public $indexAlign = 'right'; public $errorText = null; - + public $errorClasses = null; - + public $loadingText = null; public $loadingClasses = null; @@ -65,35 +64,35 @@ public function resolve($resource, $attribute = null) { parent::resolve($resource, $attribute); - $this->classes[] = 'nova-button-' . strtolower(class_basename($resource)); + $this->classes[] = 'nova-button-'.strtolower(class_basename($resource)); $this->classes[] = array_get($this->config, "styles.{$this->style}"); $this->loadingClasses = array_get($this->config, "styles.{$this->loadingStyle}"); $this->successClasses = array_get($this->config, "styles.{$this->successStyle}"); $this->errorClasses = array_get($this->config, "styles.{$this->errorStyle}"); - + $this->withMeta([ - 'key' => $this->key, - 'type' => $this->type, - 'link' => $this->link, - 'text' => $this->text, - 'event' => $this->event, - 'label' => $this->label, - 'route' => $this->route, - 'reload' => $this->reload, - 'confirm' => $this->confirm, - 'visible' => $this->visible, - 'classes' => $this->classes, - 'indexName' => $this->indexName, - 'indexAlign' => $this->indexAlign, - 'errorText' => $this->errorText, - 'errorClasses' => $this->errorClasses, - 'successText' => $this->successText, + 'key' => $this->key, + 'type' => $this->type, + 'link' => $this->link, + 'text' => $this->text, + 'event' => $this->event, + 'label' => $this->label, + 'route' => $this->route, + 'reload' => $this->reload, + 'confirm' => $this->confirm, + 'visible' => $this->visible, + 'classes' => $this->classes, + 'indexName' => $this->indexName, + 'indexAlign' => $this->indexAlign, + 'errorText' => $this->errorText, + 'errorClasses' => $this->errorClasses, + 'successText' => $this->successText, 'successClasses' => $this->successClasses, - 'loadingText' => $this->loadingText, + 'loadingText' => $this->loadingText, 'loadingClasses' => $this->loadingClasses, ]); } - + public function style($style) { $this->style = $style; @@ -133,7 +132,7 @@ public function confirm($message1 = null, $message2 = null) { $this->confirm = [ 'title' => 'Confirmation', - 'body' => null + 'body' => null, ]; if ($message1 && $message2 == null) { @@ -207,7 +206,7 @@ public function label($label) public function index($namespace) { $this->route('index', [ - 'resourceName' => $this->normalizeResourceName($namespace) + 'resourceName' => $this->normalizeResourceName($namespace), ]); return $this; @@ -217,7 +216,7 @@ public function detail($namespace, $id) { $this->route('detail', [ 'resourceName' => $this->normalizeResourceName($namespace), - 'resourceId' => $id, + 'resourceId' => $id, ]); return $this; @@ -226,7 +225,7 @@ public function detail($namespace, $id) public function create($namespace) { $this->route('create', [ - 'resourceName' => $this->normalizeResourceName($namespace) + 'resourceName' => $this->normalizeResourceName($namespace), ]); return $this; @@ -236,7 +235,7 @@ public function edit($namespace, $id) { $this->route('edit', [ 'resourceName' => $this->normalizeResourceName($namespace), - 'resourceId' => $id, + 'resourceId' => $id, ]); return $this; @@ -246,7 +245,7 @@ public function lens($namespace, $key) { $this->route('lens', [ 'resourceName' => $this->normalizeResourceName($namespace), - 'lens' => $key + 'lens' => $key, ]); return $this; @@ -265,9 +264,9 @@ public function route($name, $params) $this->type = 'route'; $this->route = [ - 'name' => $name, + 'name' => $name, 'params' => $params, - 'query' => [], + 'query' => [], ]; return $this; @@ -276,17 +275,18 @@ public function route($name, $params) /** * Add filters to index view. * - * @param array $filters + * @param array $filters + * * @return $this */ public function withFilters(array $filters) { - $key = $this->route['params']['resourceName'] . '_filter'; + $key = $this->route['params']['resourceName'].'_filter'; $this->route['query'][$key] = base64_encode(json_encode(collect($filters)->map(function ($value, $key) { return [ 'class' => $key, - 'value' => $value + 'value' => $value, ]; })->values())); @@ -294,7 +294,8 @@ public function withFilters(array $filters) } /** - * @param string $namespace + * @param string $namespace + * * @return string */ protected function normalizeResourceName($namespace) @@ -306,13 +307,13 @@ protected function normalizeResourceName($namespace) public function addDefaultSettings() { $this->addLinkFallbacks(); - $this->style = array_get($this->config, "defaults.style", 'link-primary'); - $this->loadingText = array_get($this->config, "defaults.loadingText", 'Loading'); - $this->loadingStyle = array_get($this->config, "defaults.loadingStyle", str_replace('primary', 'grey', $this->style)); - $this->errorText = array_get($this->config, "defaults.errorText", 'Error!'); - $this->errorStyle = array_get($this->config, "defaults.errorStyle", str_replace('primary', 'danger', $this->style)); - $this->successText = array_get($this->config, "defaults.successText", 'Success!'); - $this->successStyle = array_get($this->config, "defaults.successStyle", str_replace('primary', 'success', $this->style)); + $this->style = array_get($this->config, 'defaults.style', 'link-primary'); + $this->loadingText = array_get($this->config, 'defaults.loadingText', 'Loading'); + $this->loadingStyle = array_get($this->config, 'defaults.loadingStyle', str_replace('primary', 'grey', $this->style)); + $this->errorText = array_get($this->config, 'defaults.errorText', 'Error!'); + $this->errorStyle = array_get($this->config, 'defaults.errorStyle', str_replace('primary', 'danger', $this->style)); + $this->successText = array_get($this->config, 'defaults.successText', 'Success!'); + $this->successStyle = array_get($this->config, 'defaults.successStyle', str_replace('primary', 'success', $this->style)); } public function addLinkFallbacks() diff --git a/src/Providers/FieldServiceProvider.php b/src/Providers/FieldServiceProvider.php index ed815d1..499263f 100644 --- a/src/Providers/FieldServiceProvider.php +++ b/src/Providers/FieldServiceProvider.php @@ -2,10 +2,10 @@ namespace NovaButton\Providers; -use Laravel\Nova\Nova; use Illuminate\Support\Facades\Route; -use Laravel\Nova\Events\ServingNova; use Illuminate\Support\ServiceProvider; +use Laravel\Nova\Events\ServingNova; +use Laravel\Nova\Nova; class FieldServiceProvider extends ServiceProvider { @@ -17,7 +17,7 @@ class FieldServiceProvider extends ServiceProvider public function boot() { $this->publishes([ - __DIR__.'/../../config/nova-button.php' => config_path('nova-button.php') + __DIR__.'/../../config/nova-button.php' => config_path('nova-button.php'), ], 'nova-button'); Nova::serving(function (ServingNova $event) { @@ -38,7 +38,7 @@ public function register() } /** - * Registers field routes + * Registers field routes. * * @return void */ @@ -46,6 +46,6 @@ private function registerRoutes() { Route::middleware(['nova']) ->prefix('nova-vendor/nova-button') - ->group(__DIR__ . '/../../routes/api.php'); + ->group(__DIR__.'/../../routes/api.php'); } }