From 525a1d065caca1cc2c090c749f6a98cd4671f837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 13:25:58 +0200 Subject: [PATCH 01/13] Fix ACH payments with tokens --- .../ClientPortal/PaymentMethodController.php | 16 ++-- app/PaymentDrivers/StripePaymentDriver.php | 2 +- resources/lang/en/texts.php | 2 + .../gateways/stripe/ach/pay.blade.php | 77 +++++++++++-------- 4 files changed, 58 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 13556fdc5dcb..e57cc00007a2 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -44,8 +44,12 @@ class PaymentMethodController extends Controller { $gateway = auth()->user()->client->getCreditCardGateway(); - return $gateway->driver(auth()->user()->client)->authorizeView(GatewayType::CREDIT_CARD); + $data['gateway'] = $gateway; + return $gateway + ->driver(auth()->user()->client) + ->setPaymentMethod(GatewayType::BANK_TRANSFER) + ->authorizeView($data); } /** @@ -57,9 +61,11 @@ class PaymentMethodController extends Controller public function store(Request $request) { $gateway = auth()->user()->client->getCreditCardGateway(); - - return $gateway->driver(auth()->user()->client)->authorizeResponseView($request->all()); + return $gateway + ->driver(auth()->user()->client) + ->setPaymentMethod(GatewayType::BANK_TRANSFER) + ->authorizeResponse($request); } /** @@ -104,7 +110,7 @@ class PaymentMethodController extends Controller return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod('App\\PaymentDrivers\\Stripe\\ACH') + ->setPaymentMethod(GatewayType::BANK_TRANSFER) ->verificationView($payment_method); } @@ -114,7 +120,7 @@ class PaymentMethodController extends Controller return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod('App\\PaymentDrivers\\Stripe\\ACH') + ->setPaymentMethod(GatewayType::BANK_TRANSFER) ->processVerification($payment_method); } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index cff4ceda3e34..3e329e14ba1e 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -172,7 +172,7 @@ class StripePaymentDriver extends BasePaymentDriver * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function authorizeCreditCardResponse($request) + public function authorizeResponse($request) { return $this->payment_method->authorizeResponse($request); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 42c5f2bfaf78..5bb3764f9f5c 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3224,4 +3224,6 @@ return [ 'year_invalid' => 'Provided year is not valid.', 'if_you_need_help' => 'If you need help you can either post to our', + + 'bank_account_not_linked' => 'To pay with bank account, first you have to add it as payment method.', ]; diff --git a/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php index 46182a54c5d0..d4ffdf84a2fd 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php @@ -2,18 +2,20 @@ @section('meta_title', ctrans('texts.ach')) @section('body') -
- @csrf - @foreach($invoices as $invoice) - - @endforeach - - - - - - -
+ @if($token) +
+ @csrf + @foreach($invoices as $invoice) + + @endforeach + + + + + + +
+ @endif
@@ -29,27 +31,36 @@

-
-
- {{ ctrans('texts.payment_type') }} -
-
- {{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }}) -
-
-
-
- {{ ctrans('texts.amount') }} -
-
- {{ App\Utils\Number::formatMoney($amount, $client) }} -
-
-
- -
+ @if($token) +
+
+ {{ ctrans('texts.payment_type') }} +
+
+ {{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }}) +
+
+
+
+ {{ ctrans('texts.amount') }} +
+
+ {{ App\Utils\Number::formatMoney($amount, $client) }} +
+
+
+ +
+ @else +
+
+ {{ ctrans('texts.bank_account_not_linked') }} + {{ ctrans('texts.add_payment_method') }} +
+
+ @endif
From c2904d0c9277c6831f25cf2ca75da34c2c93776a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 14:20:45 +0200 Subject: [PATCH 02/13] Require password update if not set when confirming email --- .../Controllers/Traits/VerifiesUserEmail.php | 48 +++++++++++++++---- resources/lang/en/texts.php | 1 + .../auth/confirmation_with_password.blade.php | 43 +++++++++++++++++ routes/web.php | 1 + 4 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index 889d4dea5c55..5e34fc587e5d 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -15,6 +15,7 @@ namespace App\Http\Controllers\Traits; use App\Models\User; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; /** * Class VerifiesUserEmail @@ -30,20 +31,49 @@ trait VerifiesUserEmail */ public function confirm() { - if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->route('confirmation_code'))->first()) { - $user->email_verified_at = now(); - $user->confirmation_code = null; - $user->save(); + $user = User::where('confirmation_code', request()->confirmation_code)->first(); + + // if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->input('confirmation_code'))->first()) { - return $this->render('auth.confirmed', [ - 'root' => 'themes', - 'message' => ctrans('texts.security_confirmation'), - ]); + if (!$user) { + return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]); } + if (is_null($user->password) || empty($user->password)) { + return $this->render('auth.confirmation_with_password', ['root' => 'themes']); + } + + $user->email_verified_at = now(); + $user->confirmation_code = null; + $user->save(); + return $this->render('auth.confirmed', [ 'root' => 'themes', - 'message' => ctrans('texts.wrong_confirmation'), + 'message' => ctrans('texts.security_confirmation'), + ]); + } + + public function confirmWithPassword() + { + $user = User::where('confirmation_code', request()->confirmation_code)->first(); + + if (!$user) { + return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]); + } + + request()->validate([ + 'password' => ['required', 'min:6', 'confirmed'], + ]); + + $user->password = Hash::make(request()->password); + + $user->email_verified_at = now(); + $user->confirmation_code = null; + $user->save(); + + return $this->render('auth.confirmed', [ + 'root' => 'themes', + 'message' => ctrans('texts.security_confirmation'), ]); } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 42c5f2bfaf78..172cf2b155ce 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3224,4 +3224,5 @@ return [ 'year_invalid' => 'Provided year is not valid.', 'if_you_need_help' => 'If you need help you can either post to our', + 'update_password_on_confirm' => 'After updating your password, your account will be confirmed.', ]; diff --git a/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php b/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php new file mode 100644 index 000000000000..ac96e616a75c --- /dev/null +++ b/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php @@ -0,0 +1,43 @@ +@extends('portal.ninja2020.layout.clean') +@section('meta_title', ctrans('texts.set_password')) + +@section('body') +
+
+
+ Invoice Ninja logo +

{{ ctrans('texts.set_password') }}

+ {{ ctrans('texts.update_password_on_confirm') }} + +
+ @csrf +
+ + + @error('password') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('password_confirmation') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 08e26b71c171..b50df7e6e9b3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -30,4 +30,5 @@ Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('passw */ Route::group(['middleware' => ['url_db']], function () { Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm'); + Route::post('/user/confirm/{confirmation_code}', 'UserController@confirmWithPassword'); }); \ No newline at end of file From 81b544a4d1b1f703de67305d0836bf8cc0abe842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 14:22:29 +0200 Subject: [PATCH 03/13] Update labels --- .../themes/ninja2020/auth/confirmation_with_password.blade.php | 2 +- resources/views/themes/ninja2020/auth/passwords/reset.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php b/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php index ac96e616a75c..227b3824645d 100644 --- a/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php +++ b/resources/views/themes/ninja2020/auth/confirmation_with_password.blade.php @@ -23,7 +23,7 @@ @enderror
- + diff --git a/resources/views/themes/ninja2020/auth/passwords/reset.blade.php b/resources/views/themes/ninja2020/auth/passwords/reset.blade.php index deaa68e6e9d9..f59686661e99 100644 --- a/resources/views/themes/ninja2020/auth/passwords/reset.blade.php +++ b/resources/views/themes/ninja2020/auth/passwords/reset.blade.php @@ -38,7 +38,7 @@ @enderror
- + From b0234fd69a645c9bd408f0e46b37cc26269854ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 14:23:32 +0200 Subject: [PATCH 04/13] Update translation --- resources/lang/en/texts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 172cf2b155ce..2d55aa1dd634 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3224,5 +3224,5 @@ return [ 'year_invalid' => 'Provided year is not valid.', 'if_you_need_help' => 'If you need help you can either post to our', - 'update_password_on_confirm' => 'After updating your password, your account will be confirmed.', + 'update_password_on_confirm' => 'After updating password, your account will be confirmed.', ]; From 17ae8710fde36fda3d12365a5ef9ee436da0080e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 14:26:45 +0200 Subject: [PATCH 05/13] Add "reversed" translation --- resources/lang/en/texts.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 42c5f2bfaf78..74905738a86e 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3224,4 +3224,6 @@ return [ 'year_invalid' => 'Provided year is not valid.', 'if_you_need_help' => 'If you need help you can either post to our', + + 'reversed' => 'Reversed', ]; From e5fedfa20632c5fd1c5b6e47c57d148b66d06c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 15:16:40 +0200 Subject: [PATCH 06/13] Fix wrong route --- .../portal/ninja2020/components/livewire/quotes-table.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/portal/ninja2020/components/livewire/quotes-table.blade.php b/resources/views/portal/ninja2020/components/livewire/quotes-table.blade.php index eddeec9a1f44..5c7ef5f35286 100644 --- a/resources/views/portal/ninja2020/components/livewire/quotes-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/quotes-table.blade.php @@ -90,7 +90,7 @@ {!! App\Models\Quote::badgeForStatus($quote->status_id) !!} - + @lang('texts.view') From 829a7a2c1093e59fd8d6692c6539a5d3041630c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 15:20:15 +0200 Subject: [PATCH 07/13] Fix checkboxes for action selectors on invoices & quotes --- .../js/clients/invoices/action-selectors.js | 2 +- public/js/clients/quotes/action-selectors.js | 2 +- public/mix-manifest.json | 4 +- .../js/clients/invoices/action-selectors.js | 49 +++++++++++++------ .../js/clients/quotes/action-selectors.js | 49 +++++++++++++------ 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/public/js/clients/invoices/action-selectors.js b/public/js/clients/invoices/action-selectors.js index d51d2a3a147e..fe74ca68c27f 100644 --- a/public/js/clients/invoices/action-selectors.js +++ b/public/js/clients/invoices/action-selectors.js @@ -1,2 +1,2 @@ /*! For license information please see action-selectors.js.LICENSE.txt */ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=5)}({5:function(e,t,n){e.exports=n("Boob")},Boob:function(e,t){function n(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()}));var r=document.createElement("INPUT");r.setAttribute("name","invoices[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}}); \ No newline at end of file +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=5)}({5:function(e,t,n){e.exports=n("Boob")},Boob:function(e,t){function n(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})),!1!==e.checked){var r=document.createElement("INPUT");r.setAttribute("name","invoices[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}else{var o=document.querySelectorAll("input.child-hidden-input"),c=!0,u=!1,l=void 0;try{for(var i,a=o[Symbol.iterator]();!(c=(i=a.next()).done);c=!0){var d=i.value;d.value==e.dataset.value&&d.remove()}}catch(e){u=!0,l=e}finally{try{c||null==a.return||a.return()}finally{if(u)throw l}}}}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}}); \ No newline at end of file diff --git a/public/js/clients/quotes/action-selectors.js b/public/js/clients/quotes/action-selectors.js index a1c7356cdfa2..5ecdecd61c67 100644 --- a/public/js/clients/quotes/action-selectors.js +++ b/public/js/clients/quotes/action-selectors.js @@ -1,2 +1,2 @@ /*! For license information please see action-selectors.js.LICENSE.txt */ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=10)}({10:function(e,t,n){e.exports=n("ydWM")},ydWM:function(e,t){function n(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()}));var r=document.createElement("INPUT");r.setAttribute("name","quotes[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}}); \ No newline at end of file +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=10)}({10:function(e,t,n){e.exports=n("ydWM")},ydWM:function(e,t){function n(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})),!1!==e.checked){var r=document.createElement("INPUT");r.setAttribute("name","invoices[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}else{var o=document.querySelectorAll("input.child-hidden-input"),c=!0,u=!1,l=void 0;try{for(var i,a=o[Symbol.iterator]();!(c=(i=a.next()).done);c=!0){var d=i.value;d.value==e.dataset.value&&d.remove()}}catch(e){u=!0,l=e}finally{try{c||null==a.return||a.return()}finally{if(u)throw l}}}}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}}); \ No newline at end of file diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 99e4e2e9c95c..e307c87b5cff 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,7 +1,7 @@ { "/js/app.js": "/js/app.js?id=baf7fef12d5e65c3d9ff", "/css/app.css": "/css/app.css?id=369c7335c317e8ac0212", - "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=0632d6281202800e0921", + "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=d244486b16dc6f94a726", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=d7e708d66a9c769b4c6e", "/js/clients/payment_methods/authorize-ach.js": "/js/clients/payment_methods/authorize-ach.js?id=9e6495d9ae236b3cb5ad", "/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=3f6129bf10ff3bf20332", @@ -12,7 +12,7 @@ "/js/clients/payments/checkout.com.js": "/js/clients/payments/checkout.com.js?id=42d239882b80af83ad22", "/js/clients/payments/process.js": "/js/clients/payments/process.js?id=49b220081e0d7fa8140b", "/js/clients/payments/sofort.js": "/js/clients/payments/sofort.js?id=ff4ad07a93bd9fb327c1", - "/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=2fe0ad3e46ead2edb8c3", + "/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=b6b33ab51b58b51e1212", "/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=1c5d76fb5f98bd49f6c8", "/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=ba1182244cda0e0ffbeb", "/js/setup/setup.js": "/js/setup/setup.js?id=87653cfb4084aadea7a2", diff --git a/resources/js/clients/invoices/action-selectors.js b/resources/js/clients/invoices/action-selectors.js index 22d4795fbdd6..7f2792def0fb 100644 --- a/resources/js/clients/invoices/action-selectors.js +++ b/resources/js/clients/invoices/action-selectors.js @@ -10,48 +10,65 @@ class ActionSelectors { constructor() { - this.parentElement = document.querySelector(".form-check-parent"); - this.parentForm = document.getElementById("bulkActions"); + this.parentElement = document.querySelector('.form-check-parent'); + this.parentForm = document.getElementById('bulkActions'); } watchCheckboxes(parentElement) { - document.querySelectorAll(".form-check-child").forEach(child => { + document + .querySelectorAll('.child-hidden-input') + .forEach((element) => element.remove()); + + document.querySelectorAll('.form-check-child').forEach((child) => { if (parentElement.checked) { child.checked = parentElement.checked; - this.processChildItem(child, document.getElementById("bulkActions")); + this.processChildItem( + child, + document.getElementById('bulkActions') + ); } else { child.checked = false; document - .querySelectorAll(".child-hidden-input") - .forEach(element => element.remove()); + .querySelectorAll('.child-hidden-input') + .forEach((element) => element.remove()); } }); } processChildItem(element, parent, options = {}) { - if (options.hasOwnProperty("single")) { + if (options.hasOwnProperty('single')) { document - .querySelectorAll(".child-hidden-input") - .forEach(element => element.remove()); + .querySelectorAll('.child-hidden-input') + .forEach((element) => element.remove()); } - let _temp = document.createElement("INPUT"); + if (element.checked === false) { + let inputs = document.querySelectorAll('input.child-hidden-input'); - _temp.setAttribute("name", "invoices[]"); - _temp.setAttribute("value", element.dataset.value); - _temp.setAttribute("class", "child-hidden-input"); + for (let i of inputs) { + if (i.value == element.dataset.value) i.remove(); + } + + return; + } + + let _temp = document.createElement('INPUT'); + + _temp.setAttribute('name', 'invoices[]'); + _temp.setAttribute('value', element.dataset.value); + _temp.setAttribute('class', 'child-hidden-input'); _temp.hidden = true; parent.append(_temp); } handle() { - this.parentElement.addEventListener("click", () => { + this.parentElement.addEventListener('click', () => { this.watchCheckboxes(this.parentElement); }); - for (let child of document.querySelectorAll(".form-check-child")) { - child.addEventListener("click", () => { + for (let child of document.querySelectorAll('.form-check-child')) { + child.addEventListener('click', () => { this.processChildItem(child, this.parentForm); }); } diff --git a/resources/js/clients/quotes/action-selectors.js b/resources/js/clients/quotes/action-selectors.js index 751bad043125..7f2792def0fb 100644 --- a/resources/js/clients/quotes/action-selectors.js +++ b/resources/js/clients/quotes/action-selectors.js @@ -10,48 +10,65 @@ class ActionSelectors { constructor() { - this.parentElement = document.querySelector(".form-check-parent"); - this.parentForm = document.getElementById("bulkActions"); + this.parentElement = document.querySelector('.form-check-parent'); + this.parentForm = document.getElementById('bulkActions'); } watchCheckboxes(parentElement) { - document.querySelectorAll(".form-check-child").forEach(child => { + document + .querySelectorAll('.child-hidden-input') + .forEach((element) => element.remove()); + + document.querySelectorAll('.form-check-child').forEach((child) => { if (parentElement.checked) { child.checked = parentElement.checked; - this.processChildItem(child, document.getElementById("bulkActions")); + this.processChildItem( + child, + document.getElementById('bulkActions') + ); } else { child.checked = false; document - .querySelectorAll(".child-hidden-input") - .forEach(element => element.remove()); + .querySelectorAll('.child-hidden-input') + .forEach((element) => element.remove()); } }); } processChildItem(element, parent, options = {}) { - if (options.hasOwnProperty("single")) { + if (options.hasOwnProperty('single')) { document - .querySelectorAll(".child-hidden-input") - .forEach(element => element.remove()); + .querySelectorAll('.child-hidden-input') + .forEach((element) => element.remove()); } - let _temp = document.createElement("INPUT"); + if (element.checked === false) { + let inputs = document.querySelectorAll('input.child-hidden-input'); - _temp.setAttribute("name", "quotes[]"); - _temp.setAttribute("value", element.dataset.value); - _temp.setAttribute("class", "child-hidden-input"); + for (let i of inputs) { + if (i.value == element.dataset.value) i.remove(); + } + + return; + } + + let _temp = document.createElement('INPUT'); + + _temp.setAttribute('name', 'invoices[]'); + _temp.setAttribute('value', element.dataset.value); + _temp.setAttribute('class', 'child-hidden-input'); _temp.hidden = true; parent.append(_temp); } handle() { - this.parentElement.addEventListener("click", () => { + this.parentElement.addEventListener('click', () => { this.watchCheckboxes(this.parentElement); }); - for (let child of document.querySelectorAll(".form-check-child")) { - child.addEventListener("click", () => { + for (let child of document.querySelectorAll('.form-check-child')) { + child.addEventListener('click', () => { this.processChildItem(child, this.parentForm); }); } From 46b70d78af6bb507d123e4a87a2a79a38e4a8be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 26 Jun 2020 15:20:26 +0200 Subject: [PATCH 08/13] Share layout between quotes & invoices --- resources/views/portal/ninja2020/quotes/index.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/portal/ninja2020/quotes/index.blade.php b/resources/views/portal/ninja2020/quotes/index.blade.php index e2e452c0136b..0258c6c5eff5 100644 --- a/resources/views/portal/ninja2020/quotes/index.blade.php +++ b/resources/views/portal/ninja2020/quotes/index.blade.php @@ -13,7 +13,6 @@ @section('body')
- {{ ctrans('texts.with_selected') }}
@csrf