mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Rework redirect after bulk edit logic
This commit is contained in:
parent
73781e88d5
commit
753e482144
@ -1,5 +1,6 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Utils;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
|
||||||
@ -20,4 +21,20 @@ class BaseController extends Controller
|
|||||||
$this->layout = View::make($this->layout);
|
$this->layout = View::make($this->layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function returnBulk($entityType, $action, $ids)
|
||||||
|
{
|
||||||
|
$isDatatable = filter_var(request()->datatable, FILTER_VALIDATE_BOOLEAN);
|
||||||
|
$entityTypes = Utils::pluralizeEntityType($entityType);
|
||||||
|
|
||||||
|
if ($action == 'restore' && count($ids) == 1) {
|
||||||
|
return redirect("{$entityTypes}/" . $ids[0]);
|
||||||
|
} elseif ($isDatatable || ($action == 'archive' || $action == 'delete')) {
|
||||||
|
return redirect("{$entityTypes}");
|
||||||
|
} elseif (count($ids)) {
|
||||||
|
return redirect("{$entityTypes}/" . $ids[0]);
|
||||||
|
} else {
|
||||||
|
return redirect("{$entityTypes}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,10 +221,6 @@ class ClientController extends BaseController
|
|||||||
$message = Utils::pluralize($action.'d_client', $count);
|
$message = Utils::pluralize($action.'d_client', $count);
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
if ($action == 'restore' && $count == 1) {
|
return $this->returnBulk(ENTITY_CLIENT, $action, $ids);
|
||||||
return Redirect::to('clients/'.Utils::getFirst($ids));
|
|
||||||
} else {
|
|
||||||
return Redirect::to('clients');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ class ExpenseController extends BaseController
|
|||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect::to('expenses');
|
return $this->returnBulk($this->entityType, $action, $ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getViewModel()
|
private static function getViewModel()
|
||||||
|
@ -531,11 +531,7 @@ class InvoiceController extends BaseController
|
|||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'restore' && $count == 1) {
|
return $this->returnBulk($entityType, $action, $ids);
|
||||||
return Redirect::to("{$entityType}s/".Utils::getFirst($ids));
|
|
||||||
} else {
|
|
||||||
return Redirect::to("{$entityType}s");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convertQuote(InvoiceRequest $request)
|
public function convertQuote(InvoiceRequest $request)
|
||||||
@ -615,7 +611,7 @@ class InvoiceController extends BaseController
|
|||||||
public function checkInvoiceNumber()
|
public function checkInvoiceNumber()
|
||||||
{
|
{
|
||||||
$invoiceNumber = request()->invoice_number;
|
$invoiceNumber = request()->invoice_number;
|
||||||
|
|
||||||
$count = Invoice::scope()
|
$count = Invoice::scope()
|
||||||
->whereInvoiceNumber($invoiceNumber)
|
->whereInvoiceNumber($invoiceNumber)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
|
@ -154,11 +154,7 @@ class QuoteController extends BaseController
|
|||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'restore' && $count == 1) {
|
return $this->returnBulk(ENTITY_QUOTE, $action, $ids);
|
||||||
return Redirect::to('quotes/'.Utils::getFirst($ids));
|
|
||||||
} else {
|
|
||||||
return Redirect::to('quotes');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function approve($invitationKey)
|
public function approve($invitationKey)
|
||||||
|
@ -300,11 +300,7 @@ class TaskController extends BaseController
|
|||||||
$message = Utils::pluralize($action.'d_task', $count);
|
$message = Utils::pluralize($action.'d_task', $count);
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
if ($action == 'restore' && $count == 1) {
|
return $this->returnBulk($this->entityType, $action, $ids);
|
||||||
return Redirect::to('tasks/'.$ids[0].'/edit');
|
|
||||||
} else {
|
|
||||||
return Redirect::to('tasks');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class VendorController extends BaseController
|
|||||||
public function show(VendorRequest $request)
|
public function show(VendorRequest $request)
|
||||||
{
|
{
|
||||||
$vendor = $request->entity();
|
$vendor = $request->entity();
|
||||||
|
|
||||||
$actionLinks = [
|
$actionLinks = [
|
||||||
['label' => trans('texts.new_vendor'), 'url' => URL::to('/vendors/create/' . $vendor->public_id)]
|
['label' => trans('texts.new_vendor'), 'url' => URL::to('/vendors/create/' . $vendor->public_id)]
|
||||||
];
|
];
|
||||||
@ -185,10 +185,6 @@ class VendorController extends BaseController
|
|||||||
$message = Utils::pluralize($action.'d_vendor', $count);
|
$message = Utils::pluralize($action.'d_vendor', $count);
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
if ($action == 'restore' && $count == 1) {
|
return $this->returnBulk($this->entityType, $action, $ids);
|
||||||
return Redirect::to('vendors/' . Utils::getFirst($ids));
|
|
||||||
} else {
|
|
||||||
return Redirect::to('vendors');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
{!! Former::text('action') !!}
|
{!! Former::text('action') !!}
|
||||||
{!! Former::text('public_id') !!}
|
{!! Former::text('public_id') !!}
|
||||||
|
{!! Former::text('datatable')->value('true') !!}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@can('create', 'invoice')
|
@can('create', 'invoice')
|
||||||
@ -88,7 +89,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function submitForm(action) {
|
function submitForm(action) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user