mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
d9d3ff27ae
|
@ -1484,35 +1484,57 @@ class Helper
|
|||
}
|
||||
|
||||
|
||||
static public function getRedirectOption($request, $id, $table, $asset_id = null)
|
||||
static public function getRedirectOption($request, $id, $table, $item_id = null)
|
||||
{
|
||||
|
||||
$redirect_option = Session::get('redirect_option');
|
||||
$checkout_to_type = Session::get('checkout_to_type');
|
||||
|
||||
//return to index
|
||||
if ($redirect_option == '0') {
|
||||
// return to index
|
||||
if ($redirect_option == 'index') {
|
||||
switch ($table) {
|
||||
case "Assets":
|
||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return route('hardware.index');
|
||||
case "Users":
|
||||
return route('users.index');
|
||||
case "Licenses":
|
||||
return route('licenses.index');
|
||||
case "Accessories":
|
||||
return route('accessories.index');
|
||||
case "Components":
|
||||
return route('components.index');
|
||||
case "Consumables":
|
||||
return route('consumables.index');
|
||||
}
|
||||
}
|
||||
//return to thing being assigned
|
||||
if ($redirect_option == '1') {
|
||||
|
||||
// return to thing being assigned
|
||||
if ($redirect_option == 'item') {
|
||||
switch ($table) {
|
||||
case "Assets":
|
||||
return redirect()->route('hardware.show', $id ? $id : $asset_id)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return route('hardware.show', $id ?? $item_id);
|
||||
case "Users":
|
||||
return route('users.show', $id ?? $item_id);
|
||||
case "Licenses":
|
||||
return route('licenses.show', $id ?? $item_id);
|
||||
case "Accessories":
|
||||
return route('accessories.show', $id ?? $item_id);
|
||||
case "Components":
|
||||
return route('components.show', $id ?? $item_id);
|
||||
case "Consumables":
|
||||
return route('consumables.show', $id ?? $item_id);
|
||||
}
|
||||
}
|
||||
//return to thing being assigned to
|
||||
if ($redirect_option == '2') {
|
||||
|
||||
// return to assignment target
|
||||
if ($redirect_option == 'target') {
|
||||
switch ($checkout_to_type) {
|
||||
case 'user':
|
||||
return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return route('users.show', ['user' => $request->assigned_user]);
|
||||
case 'location':
|
||||
return redirect()->route('locations.show', $request->assigned_location)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return route('locations.show', ['location' => $request->assigned_location]);
|
||||
case 'asset':
|
||||
return redirect()->route('hardware.show', $request->assigned_asset)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return route('hardware.show', ['hardware' => $request->assigned_asset]);
|
||||
}
|
||||
}
|
||||
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'));
|
||||
|
|
|
@ -79,10 +79,11 @@ class AccessoriesController extends Controller
|
|||
|
||||
$accessory = $request->handleImages($accessory);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
// Was the accessory created?
|
||||
if ($accessory->save()) {
|
||||
// Redirect to the new accessory page
|
||||
return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.create.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))->with('success', trans('admin/accessories/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($accessory->getErrors());
|
||||
|
@ -176,9 +177,10 @@ class AccessoriesController extends Controller
|
|||
|
||||
$accessory = $request->handleImages($accessory);
|
||||
|
||||
// Was the accessory updated?
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($accessory->save()) {
|
||||
return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.update.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))->with('success', trans('admin/accessories/message.update.success'));
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Accessories;
|
||||
|
||||
use App\Events\CheckoutableCheckedIn;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\User;
|
||||
|
@ -63,7 +64,9 @@ class AccessoryCheckinController extends Controller
|
|||
|
||||
event(new CheckoutableCheckedIn($accessory, User::find($return_to), auth()->user(), $request->input('note'), $checkin_at));
|
||||
|
||||
return redirect()->route('accessories.show', $accessory->id)->with('success', trans('admin/accessories/message.checkin.success'));
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))->with('success', trans('admin/accessories/message.checkin.success'));
|
||||
}
|
||||
// Redirect to the accessory management page with error
|
||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkin.error'));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Accessories;
|
||||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\AccessoryCheckoutRequest;
|
||||
use App\Models\Accessory;
|
||||
|
@ -78,8 +79,15 @@ class AccessoryCheckoutController extends Controller
|
|||
}
|
||||
event(new CheckoutableCheckedOut($accessory, $user, auth()->user(), $request->input('note')));
|
||||
|
||||
// Set this as user since we only allow checkout to user for this item type
|
||||
$request->request->add(['checkout_to_type' => 'user']);
|
||||
$request->request->add(['assigned_user' => $user->id]);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
|
||||
// Redirect to the new accessory page
|
||||
return redirect()->route('accessories.index')
|
||||
return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))
|
||||
->with('success', trans('admin/accessories/message.checkout.success'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ use App\Models\Asset;
|
|||
use App\Models\CheckoutAcceptance;
|
||||
use App\Models\LicenseSeat;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use \Illuminate\Contracts\View\View;
|
||||
use \Illuminate\Http\RedirectResponse;
|
||||
|
@ -83,7 +82,6 @@ class AssetCheckinController extends Controller
|
|||
}
|
||||
|
||||
$asset->expected_checkin = null;
|
||||
//$asset->last_checkout = null;
|
||||
$asset->last_checkin = now();
|
||||
$asset->assignedTo()->disassociate($asset);
|
||||
$asset->accepted = null;
|
||||
|
@ -128,12 +126,12 @@ class AssetCheckinController extends Controller
|
|||
$acceptance->delete();
|
||||
});
|
||||
|
||||
Session::put('redirect_option', $request->get('redirect_option'));
|
||||
// Was the asset updated?
|
||||
session()->put('redirect_option', $request->get('redirect_option'));
|
||||
|
||||
if ($asset->save()) {
|
||||
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues));
|
||||
return Helper::getRedirectOption($asset, $assetId, 'Assets');
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))->with('success', trans('admin/hardware/message.checkin.success'));
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.error').$asset->getErrors());
|
||||
|
|
|
@ -109,10 +109,11 @@ class AssetCheckoutController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
Session::put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {
|
||||
return Helper::getRedirectOption($request, $assetId, 'Assets');
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
|
||||
->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error').$asset->getErrors());
|
||||
|
|
|
@ -204,8 +204,12 @@ class AssetsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
|
||||
if ($success) {
|
||||
return redirect()->route('hardware.index')
|
||||
|
||||
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
|
||||
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', ['hardware' => $asset->id]), 'id', 'tag' => e($asset->asset_tag)]));
|
||||
|
||||
|
||||
|
@ -289,6 +293,7 @@ class AssetsController extends Controller
|
|||
*/
|
||||
public function update(ImageUploadRequest $request, $assetId = null) : RedirectResponse
|
||||
{
|
||||
|
||||
// Check if the asset exists
|
||||
if (! $asset = Asset::find($assetId)) {
|
||||
// Redirect to the asset management page with error
|
||||
|
@ -331,7 +336,7 @@ class AssetsController extends Controller
|
|||
|
||||
$status = Statuslabel::find($asset->status_id);
|
||||
|
||||
if($status->archived){
|
||||
if ($status && $status->archived) {
|
||||
$asset->assigned_to = null;
|
||||
}
|
||||
|
||||
|
@ -350,14 +355,26 @@ class AssetsController extends Controller
|
|||
}
|
||||
|
||||
// Update the asset data
|
||||
$asset_tag = $request->input('asset_tags');
|
||||
|
||||
$serial = $request->input('serials');
|
||||
$asset->serial = $request->input('serials');
|
||||
|
||||
if (is_array($request->input('serials'))) {
|
||||
$asset->serial = $serial[1];
|
||||
}
|
||||
|
||||
$asset->name = $request->input('name');
|
||||
$asset->serial = $serial[1];
|
||||
$asset->company_id = Company::getIdForCurrentUser($request->input('company_id'));
|
||||
$asset->model_id = $request->input('model_id');
|
||||
$asset->order_number = $request->input('order_number');
|
||||
$asset->asset_tag = $asset_tag[1];
|
||||
|
||||
$asset_tags = $request->input('asset_tags');
|
||||
$asset->asset_tag = $request->input('asset_tags');
|
||||
|
||||
if (is_array($request->input('asset_tags'))) {
|
||||
$asset->asset_tag = $asset_tags[1];
|
||||
}
|
||||
|
||||
$asset->notes = $request->input('notes');
|
||||
|
||||
$asset = $request->handleImages($asset);
|
||||
|
@ -369,6 +386,7 @@ class AssetsController extends Controller
|
|||
$model = AssetModel::find($request->get('model_id'));
|
||||
if (($model) && ($model->fieldset)) {
|
||||
foreach ($model->fieldset->fields as $field) {
|
||||
|
||||
if ($field->field_encrypted == '1') {
|
||||
if (Gate::allows('admin')) {
|
||||
if (is_array($request->input($field->db_column))) {
|
||||
|
@ -387,9 +405,10 @@ class AssetsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
if ($asset->save()) {
|
||||
return redirect()->route('hardware.show', $assetId)
|
||||
return redirect()->to(Helper::getRedirectOption($request, $assetId, 'Assets'))
|
||||
->with('success', trans('admin/hardware/message.update.success'));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Components;
|
|||
|
||||
use App\Events\CheckoutableCheckedIn;
|
||||
use App\Events\ComponentCheckedIn;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Component;
|
||||
|
@ -96,12 +97,10 @@ class ComponentCheckinController extends Controller
|
|||
$asset = Asset::find($component_assets->asset_id);
|
||||
|
||||
event(new CheckoutableCheckedIn($component, $asset, auth()->user(), $request->input('note'), Carbon::now()));
|
||||
if ($backto == 'asset'){
|
||||
return redirect()->route('hardware.show', $asset->id)->with('success',
|
||||
trans('admin/components/message.checkin.success'));
|
||||
}
|
||||
|
||||
return redirect()->route('components.index')->with('success',
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success',
|
||||
trans('admin/components/message.checkin.success'));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Components;
|
|||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Events\ComponentCheckedOut;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Component;
|
||||
|
@ -93,14 +94,14 @@ class ComponentCheckoutController extends Controller
|
|||
->withInput();
|
||||
}
|
||||
|
||||
// Check if the user exists
|
||||
// Check if the asset exists
|
||||
$asset = Asset::find($request->input('asset_id'));
|
||||
|
||||
// Update the component data
|
||||
$component->asset_id = $request->input('asset_id');
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'user_id' => auth()->user(),
|
||||
'user_id' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'assigned_qty' => $request->input('assigned_qty'),
|
||||
'asset_id' => $request->input('asset_id'),
|
||||
|
@ -109,6 +110,11 @@ class ComponentCheckoutController extends Controller
|
|||
|
||||
event(new CheckoutableCheckedOut($component, $asset, auth()->user(), $request->input('note')));
|
||||
|
||||
return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success'));
|
||||
$request->request->add(['checkout_to_type' => 'asset']);
|
||||
$request->request->add(['assigned_asset' => $asset->id]);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.checkout.success'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,8 +86,10 @@ class ComponentsController extends Controller
|
|||
|
||||
$component = $request->handleImages($component);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($component->save()) {
|
||||
return redirect()->route('components.index')->with('success', trans('admin/components/message.create.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($component->getErrors());
|
||||
|
@ -160,8 +162,10 @@ class ComponentsController extends Controller
|
|||
|
||||
$component = $request->handleImages($component);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($component->save()) {
|
||||
return redirect()->route('components.index')->with('success', trans('admin/components/message.update.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($component->getErrors());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Consumables;
|
||||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\User;
|
||||
|
@ -33,7 +34,7 @@ class ConsumableCheckoutController extends Controller
|
|||
// Make sure there is at least one available to checkout
|
||||
if ($consumable->numRemaining() <= 0){
|
||||
return redirect()->route('consumables.index')
|
||||
->with('error', trans('admin/consumables/message.checkout.unavailable'));
|
||||
->with('error', trans('admin/consumables/message.checkout.unavailable', ['requested' => 1, 'remaining' => $consumable->numRemaining()]));
|
||||
}
|
||||
|
||||
// Return the checkout view
|
||||
|
@ -76,7 +77,7 @@ class ConsumableCheckoutController extends Controller
|
|||
|
||||
// Make sure there is at least one available to checkout
|
||||
if ($consumable->numRemaining() <= 0 || $quantity > $consumable->numRemaining()) {
|
||||
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.checkout.unavailable'));
|
||||
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.checkout.unavailable', ['requested' => $quantity, 'remaining' => $consumable->numRemaining() ]));
|
||||
}
|
||||
|
||||
$admin_user = auth()->user();
|
||||
|
@ -101,7 +102,13 @@ class ConsumableCheckoutController extends Controller
|
|||
}
|
||||
event(new CheckoutableCheckedOut($consumable, $user, auth()->user(), $request->input('note')));
|
||||
|
||||
$request->request->add(['checkout_to_type' => 'user']);
|
||||
$request->request->add(['assigned_user' => $user->id]);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
|
||||
// Redirect to the new consumable page
|
||||
return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.checkout.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.checkout.success'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,8 +87,10 @@ class ConsumablesController extends Controller
|
|||
|
||||
$consumable = $request->handleImages($consumable);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($consumable->save()) {
|
||||
return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.create.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($consumable->getErrors());
|
||||
|
@ -160,8 +162,10 @@ class ConsumablesController extends Controller
|
|||
|
||||
$consumable = $request->handleImages($consumable);
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($consumable->save()) {
|
||||
return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.update.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($consumable->getErrors());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Licenses;
|
||||
|
||||
use App\Events\CheckoutableCheckedIn;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
|
@ -100,15 +101,15 @@ class LicenseCheckinController extends Controller
|
|||
$licenseSeat->asset_id = null;
|
||||
$licenseSeat->notes = $request->input('notes');
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
|
||||
// Was the asset updated?
|
||||
if ($licenseSeat->save()) {
|
||||
event(new CheckoutableCheckedIn($licenseSeat, $return_to, auth()->user(), $request->input('notes')));
|
||||
|
||||
if ($backTo == 'user') {
|
||||
return redirect()->route('users.show', $return_to->id)->with('success', trans('admin/licenses/message.checkin.success'));
|
||||
}
|
||||
|
||||
return redirect()->route('licenses.show', $licenseSeat->license_id)->with('success', trans('admin/licenses/message.checkin.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.checkin.success'));
|
||||
}
|
||||
|
||||
// Redirect to the license page with error
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Licenses;
|
||||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\LicenseCheckoutRequest;
|
||||
use App\Models\Accessory;
|
||||
|
@ -81,10 +82,27 @@ class LicenseCheckoutController extends Controller
|
|||
|
||||
|
||||
$checkoutMethod = 'checkoutTo'.ucwords(request('checkout_to_type'));
|
||||
if ($this->$checkoutMethod($licenseSeat)) {
|
||||
return redirect()->route('licenses.index')->with('success', trans('admin/licenses/message.checkout.success'));
|
||||
|
||||
if ($request->filled('asset_id')) {
|
||||
|
||||
$checkoutTarget = $this->checkoutToAsset($licenseSeat);
|
||||
$request->request->add(['assigned_asset' => $checkoutTarget->id]);
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => 'asset']);
|
||||
|
||||
} elseif ($request->filled('assigned_to')) {
|
||||
$checkoutTarget = $this->checkoutToUser($licenseSeat);
|
||||
$request->request->add(['assigned_user' => $checkoutTarget->id]);
|
||||
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => 'user']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($checkoutTarget) {
|
||||
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.checkout.success'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return redirect()->route('licenses.index')->with('error', trans('Something went wrong handling this checkout.'));
|
||||
}
|
||||
|
||||
|
@ -120,8 +138,7 @@ class LicenseCheckoutController extends Controller
|
|||
}
|
||||
if ($licenseSeat->save()) {
|
||||
event(new CheckoutableCheckedOut($licenseSeat, $target, auth()->user(), request('notes')));
|
||||
|
||||
return true;
|
||||
return $target;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -137,8 +154,7 @@ class LicenseCheckoutController extends Controller
|
|||
|
||||
if ($licenseSeat->save()) {
|
||||
event(new CheckoutableCheckedOut($licenseSeat, $target, auth()->user(), request('notes')));
|
||||
|
||||
return true;
|
||||
return $target;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -102,8 +102,10 @@ class LicensesController extends Controller
|
|||
$license->user_id = Auth::id();
|
||||
$license->min_amt = $request->input('min_amt');
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($license->save()) {
|
||||
return redirect()->route('licenses.index')->with('success', trans('admin/licenses/message.create.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.create.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($license->getErrors());
|
||||
|
@ -180,8 +182,10 @@ class LicensesController extends Controller
|
|||
$license->category_id = $request->input('category_id');
|
||||
$license->min_amt = $request->input('min_amt');
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($license->save()) {
|
||||
return redirect()->route('licenses.show', ['license' => $licenseId])->with('success', trans('admin/licenses/message.update.success'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.update.success'));
|
||||
}
|
||||
// If we can't adjust the number of seats, the error is flashed to the session by the event handler in License.php
|
||||
return redirect()->back()->withInput()->withErrors($license->getErrors());
|
||||
|
|
|
@ -133,6 +133,8 @@ class UsersController extends Controller
|
|||
// we have to invoke the
|
||||
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($user->save()) {
|
||||
if ($request->filled('groups')) {
|
||||
$user->groups()->sync($request->input('groups'));
|
||||
|
@ -152,7 +154,7 @@ class UsersController extends Controller
|
|||
$user->notify(new WelcomeNotification($data));
|
||||
}
|
||||
|
||||
return redirect()->route('users.index')->with('success', trans('admin/users/message.success.create'));
|
||||
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))->with('success', trans('admin/users/message.success.create'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($user->getErrors());
|
||||
|
@ -309,10 +311,11 @@ class UsersController extends Controller
|
|||
|
||||
// Handle uploaded avatar
|
||||
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
if ($user->save()) {
|
||||
// Redirect to the user page
|
||||
return redirect()->route('users.index')
|
||||
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
|
||||
->with('success', trans('admin/users/message.success.update'));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,15 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\Supplier;
|
||||
|
||||
|
@ -97,5 +102,16 @@ class ComponentFactory extends Factory
|
|||
});
|
||||
}
|
||||
|
||||
public function checkedOutToAsset(Asset $asset = null)
|
||||
{
|
||||
return $this->afterCreating(function (Component $component) use ($asset) {
|
||||
$component->assets()->attach($component->id, [
|
||||
'component_id' => $component->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'user_id' => 1,
|
||||
'asset_id' => $asset->id ?? Asset::factory()->create()->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,11 +71,15 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i>
|
||||
{{ trans('general.checkin') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="accessories.index"
|
||||
:button_label="trans('general.checkin')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.accessories')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.accessory')]),
|
||||
|
||||
]"
|
||||
/>
|
||||
|
||||
|
||||
</div> <!-- .box.box-default -->
|
||||
|
|
|
@ -114,10 +114,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" id="submit_button" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkout') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="accessories.index"
|
||||
:button_label="trans('general.checkout')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.accessories')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.accessory')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_checked_out_to'),
|
||||
|
||||
]"
|
||||
/>
|
||||
</div> <!-- .box.box-default -->
|
||||
</form>
|
||||
</div> <!-- .col-md-9-->
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
'helpPosition' => 'right',
|
||||
'helpText' => trans('help.accessories'),
|
||||
'formAction' => (isset($item->id)) ? route('accessories.update', ['accessory' => $item->id]) : route('accessories.store'),
|
||||
'index_route' => 'accessories.index',
|
||||
'options' => [
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'accessories']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.accessory')]),
|
||||
]
|
||||
])
|
||||
|
||||
{{-- Page content --}}
|
||||
|
|
38
resources/views/blade/redirect_submit_options.blade.php
Normal file
38
resources/views/blade/redirect_submit_options.blade.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<!-- begin redirect submit options -->
|
||||
@props([
|
||||
'index_route',
|
||||
'button_label',
|
||||
'disabled_select' => false,
|
||||
'options' => [],
|
||||
])
|
||||
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3">
|
||||
<a class="btn btn-link" href="{{ $index_route ? route($index_route) : url()->previous() }}">{{ trans('button.cancel') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9 text-right">
|
||||
<div class="btn-group text-left">
|
||||
|
||||
@if (($options) && (count($options) > 0))
|
||||
<select class="redirect-options form-control select2" data-minimum-results-for-search="Infinity" name="redirect_option" style="min-width: 250px"{{ ($disabled_select ? ' disabled' : '') }}>
|
||||
@foreach ($options as $key => $value)
|
||||
<option value="{{ $key }}"{{ Session::get('redirect_option') == $key ? ' selected' : ''}}>
|
||||
{{ $value }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
|
||||
<button type="submit" class="btn btn-primary pull-right{{ ($disabled_select ? ' disabled' : '') }}" style="margin-left:5px; border-radius: 3px;"{!! ($disabled_select ? ' data-tooltip="true" title="'.trans('admin/hardware/general.edit').'" disabled' : '') !!}>
|
||||
<i class="fas fa-check icon-white" aria-hidden="true"></i>
|
||||
{{ $button_label }}
|
||||
</button>
|
||||
|
||||
</div><!-- /.btn-group -->
|
||||
</div><!-- /.col-md-9 -->
|
||||
</div><!-- /.row -->
|
||||
</div> <!-- /.box-footer -->
|
||||
<!-- end redirect submit options -->
|
|
@ -56,10 +56,14 @@
|
|||
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ route('components.index') }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkin') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="components.index"
|
||||
:button_label="trans('general.checkin')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.components')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.component')]),
|
||||
]"
|
||||
/>
|
||||
</div> <!-- /.box-->
|
||||
</form>
|
||||
</div> <!-- /.col-md-7-->
|
||||
|
|
|
@ -54,10 +54,16 @@
|
|||
|
||||
|
||||
</div> <!-- .BOX-BODY-->
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" id="submit_button" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkout') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="components.index"
|
||||
:button_label="trans('general.checkout')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.components')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.component')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_checked_out_to'),
|
||||
|
||||
]"
|
||||
/>
|
||||
</div> <!-- .box-default-->
|
||||
</form>
|
||||
</div> <!-- .col-md-9-->
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
'helpPosition' => 'right',
|
||||
'helpText' => trans('help.components'),
|
||||
'formAction' => (isset($item->id)) ? route('components.update', ['component' => $item->id]) : route('components.store'),
|
||||
'index_route' => 'components.index',
|
||||
'options' => [
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'components']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.component')]),
|
||||
]
|
||||
|
||||
])
|
||||
|
||||
|
|
|
@ -106,10 +106,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div> <!-- .box-body -->
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ route('consumables.show', ['consumable'=> $consumable->id]) }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" id="submit_button" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkout') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="consumables.index"
|
||||
:button_label="trans('general.checkout')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.consumables')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.consumable')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_checked_out_to'),
|
||||
]"/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
'helpPosition' => 'right',
|
||||
'helpText' => trans('help.consumables'),
|
||||
'formAction' => (isset($item->id)) ? route('consumables.update', ['consumable' => $item->id]) : route('consumables.store'),
|
||||
'index_route' => 'consumables.index',
|
||||
'options' => [
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'consumables']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.consumable')]),
|
||||
]
|
||||
])
|
||||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
|
|
|
@ -2,132 +2,144 @@
|
|||
|
||||
{{-- Page title --}}
|
||||
@section('title')
|
||||
{{ trans('admin/hardware/general.checkin') }}
|
||||
@parent
|
||||
{{ trans('admin/hardware/general.checkin') }}
|
||||
@parent
|
||||
@stop
|
||||
|
||||
{{-- Page content --}}
|
||||
@section('content')
|
||||
<style>
|
||||
<style>
|
||||
|
||||
.input-group {
|
||||
padding-left: 0px !important;
|
||||
}
|
||||
</style>
|
||||
.input-group {
|
||||
padding-left: 0px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="row"><!-- .row -->
|
||||
<!-- left column -->
|
||||
<div class="col-md-7 col-sm-11 col-xs-12 col-md-offset-2">
|
||||
<div class="box box-default"><!-- .box-default -->
|
||||
<div class="box-header with-border"><!-- .box-header -->
|
||||
<h2 class="box-title">
|
||||
{{ trans('admin/hardware/form.tag') }}
|
||||
{{ $asset->asset_tag }}
|
||||
</h2>
|
||||
</div><!-- /.box-header -->
|
||||
<div class="row"><!-- .row -->
|
||||
<!-- left column -->
|
||||
<div class="col-md-7 col-sm-11 col-xs-12 col-md-offset-2">
|
||||
<div class="box box-default"><!-- .box-default -->
|
||||
<div class="box-header with-border"><!-- .box-header -->
|
||||
<h2 class="box-title">
|
||||
{{ trans('admin/hardware/form.tag') }}
|
||||
{{ $asset->asset_tag }}
|
||||
</h2>
|
||||
</div><!-- /.box-header -->
|
||||
|
||||
<div class="box-body"><!-- .box-body -->
|
||||
<div class="col-md-12"><!-- .col-md-12 -->
|
||||
<div class="box-body"><!-- .box-body -->
|
||||
<div class="col-md-12"><!-- .col-md-12 -->
|
||||
|
||||
@if ($backto == 'user')
|
||||
<form class="form-horizontal" method="post" action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id, 'backto'=>'user')) }}" autocomplete="off">
|
||||
@else
|
||||
<form class="form-horizontal" method="post" action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id)) }}" autocomplete="off">
|
||||
@endif
|
||||
{{csrf_field()}}
|
||||
@if ($backto == 'user')
|
||||
<form class="form-horizontal" method="post"
|
||||
action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id, 'backto'=>'user')) }}"
|
||||
autocomplete="off">
|
||||
@else
|
||||
<form class="form-horizontal" method="post"
|
||||
action="{{ route('hardware.checkin.store', array('assetId'=> $asset->id)) }}"
|
||||
autocomplete="off">
|
||||
@endif
|
||||
{{csrf_field()}}
|
||||
|
||||
<!-- AssetModel name -->
|
||||
<div class="form-group">
|
||||
<label for="model" class="col-sm-3 control-label">
|
||||
{{ trans('admin/hardware/form.model') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<!-- AssetModel name -->
|
||||
<div class="form-group">
|
||||
<label for="model" class="col-sm-3 control-label">
|
||||
{{ trans('admin/hardware/form.model') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
|
||||
<p class="form-control-static">
|
||||
@if (($asset->model) && ($asset->model->name))
|
||||
{{ $asset->model->name }}
|
||||
@else
|
||||
<span class="text-danger text-bold">
|
||||
<p class="form-control-static">
|
||||
@if (($asset->model) && ($asset->model->name))
|
||||
{{ $asset->model->name }}
|
||||
@else
|
||||
<span class="text-danger text-bold">
|
||||
<i class="fas fa-exclamation-triangle" aria-hidden="true"></i>
|
||||
{{ trans('admin/hardware/general.model_invalid')}}
|
||||
</span>
|
||||
{{ trans('admin/hardware/general.model_invalid_fix')}}
|
||||
<a href="{{ route('hardware.edit', $asset->id) }}">
|
||||
<strong>{{ trans('admin/hardware/general.edit') }}</strong>
|
||||
</a>
|
||||
@endif
|
||||
</p>
|
||||
{{ trans('admin/hardware/general.model_invalid_fix')}}
|
||||
<a href="{{ route('hardware.edit', $asset->id) }}">
|
||||
<strong>{{ trans('admin/hardware/general.edit') }}</strong>
|
||||
</a>
|
||||
@endif
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Asset Name -->
|
||||
<div class="form-group {{ $errors->has('name') ? 'error' : '' }}">
|
||||
<label for="name" class="col-sm-3 control-label">
|
||||
{{ trans('general.name') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" type="text" name="name" aria-label="name" id="name" value="{{ old('name', $asset->name) }}"/>
|
||||
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Asset Name -->
|
||||
<div class="form-group {{ $errors->has('name') ? 'error' : '' }}">
|
||||
<label for="name" class="col-sm-3 control-label">
|
||||
{{ trans('general.name') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" type="text" name="name" aria-label="name"
|
||||
id="name" value="{{ old('name', $asset->name) }}"/>
|
||||
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Status -->
|
||||
<div class="form-group {{ $errors->has('status_id') ? 'error' : '' }}">
|
||||
<label for="status_id" class="col-sm-3 control-label">
|
||||
{{ trans('admin/hardware/form.status') }}
|
||||
</label>
|
||||
<div class="col-md-8 required">
|
||||
{{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','id' =>'modal-statuslabel_types', 'aria-label'=>'status_id')) }}
|
||||
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Status -->
|
||||
<div class="form-group {{ $errors->has('status_id') ? 'error' : '' }}">
|
||||
<label for="status_id" class="col-sm-3 control-label">
|
||||
{{ trans('admin/hardware/form.status') }}
|
||||
</label>
|
||||
<div class="col-md-8 required">
|
||||
{{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','id' =>'modal-statuslabel_types', 'aria-label'=>'status_id')) }}
|
||||
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id', 'help_text' => ($asset->defaultLoc) ? trans('general.checkin_to_diff_location', ['default_location' => $asset->defaultLoc->name]) : null, 'hide_location_radio' => true])
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id', 'help_text' => ($asset->defaultLoc) ? trans('general.checkin_to_diff_location', ['default_location' => $asset->defaultLoc->name]) : null, 'hide_location_radio' => true])
|
||||
|
||||
<!-- Checkout/Checkin Date -->
|
||||
<div class="form-group{{ $errors->has('checkin_at') ? ' has-error' : '' }}">
|
||||
<label for="checkin_at" class="col-sm-3 control-label">
|
||||
{{ trans('admin/hardware/form.checkin_date') }}
|
||||
</label>
|
||||
<!-- Checkout/Checkin Date -->
|
||||
<div class="form-group{{ $errors->has('checkin_at') ? ' has-error' : '' }}">
|
||||
<label for="checkin_at" class="col-sm-3 control-label">
|
||||
{{ trans('admin/hardware/form.checkin_date') }}
|
||||
</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="input-group col-md-5 required">
|
||||
<div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true">
|
||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="checkin_at" id="checkin_at" value="{{ old('checkin_at', date('Y-m-d')) }}">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
||||
</div>
|
||||
{!! $errors->first('checkin_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="input-group col-md-5 required">
|
||||
<div class="input-group date" data-provide="datepicker"
|
||||
data-date-format="yyyy-mm-dd" data-autoclose="true">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="{{ trans('general.select_date') }}"
|
||||
name="checkin_at" id="checkin_at"
|
||||
value="{{ old('checkin_at', date('Y-m-d')) }}">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar"
|
||||
aria-hidden="true"></i></span>
|
||||
</div>
|
||||
{!! $errors->first('checkin_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Note -->
|
||||
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
|
||||
<label for="note" class="col-sm-3 control-label">
|
||||
{{ trans('general.notes') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<textarea class="col-md-6 form-control" id="note" name="note">{{ old('note', $asset->note) }}</textarea>
|
||||
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Note -->
|
||||
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
|
||||
<label for="note" class="col-sm-3 control-label">
|
||||
{{ trans('general.notes') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<textarea class="col-md-6 form-control" id="note"
|
||||
name="note">{{ old('note', $asset->note) }}</textarea>
|
||||
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
</div> <!--/.box-body-->
|
||||
</div> <!--/.box-body-->
|
||||
|
||||
@include ('partials.forms.redirect_submit_options',
|
||||
[
|
||||
'route' => 'hardware.index',
|
||||
'table_name' => $table_name,
|
||||
'type'=> ($asset->model ? $asset->model->name : trans('general.asset_model')),
|
||||
'checkin' => true
|
||||
])
|
||||
</form>
|
||||
<x-redirect_submit_options
|
||||
index_route="hardware.index"
|
||||
:button_label="trans('general.checkout')"
|
||||
:disabled_select="!$asset->model"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||
]"
|
||||
/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@stop
|
|
@ -25,7 +25,7 @@
|
|||
<h2 class="box-title"> {{ trans('admin/hardware/form.tag') }} {{ $asset->asset_tag }}</h2>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{csrf_field()}}
|
||||
{{csrf_field()}}
|
||||
@if ($asset->company && $asset->company->name)
|
||||
<div class="form-group">
|
||||
<label for="company" class="col-md-3 control-label">
|
||||
|
@ -70,7 +70,8 @@
|
|||
</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<input class="form-control" type="text" name="name" id="name" value="{{ old('name', $asset->name) }}" tabindex="1">
|
||||
<input class="form-control" type="text" name="name" id="name"
|
||||
value="{{ old('name', $asset->name) }}" tabindex="1">
|
||||
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -86,26 +87,30 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true'])
|
||||
@include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true'])
|
||||
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_user', 'required'=>'true'])
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_user', 'required'=>'true'])
|
||||
|
||||
<!-- We have to pass unselect here so that we don't default to the asset that's being checked out. We want that asset to be pre-selected everywhere else. -->
|
||||
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.asset'), 'fieldname' => 'assigned_asset', 'unselect' => 'true', 'style' => 'display:none;', 'required'=>'true'])
|
||||
<!-- We have to pass unselect here so that we don't default to the asset that's being checked out. We want that asset to be pre-selected everywhere else. -->
|
||||
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.asset'), 'fieldname' => 'assigned_asset', 'unselect' => 'true', 'style' => 'display:none;', 'required'=>'true'])
|
||||
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required'=>'true'])
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required'=>'true'])
|
||||
|
||||
|
||||
|
||||
<!-- Checkout/Checkin Date -->
|
||||
<!-- Checkout/Checkin Date -->
|
||||
<div class="form-group {{ $errors->has('checkout_at') ? 'error' : '' }}">
|
||||
<label for="checkout_at" class="col-md-3 control-label">
|
||||
{{ trans('admin/hardware/form.checkout_date') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<div class="input-group date col-md-7" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-end-date="0d" data-date-clear-btn="true">
|
||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="checkout_at" id="checkout_at" value="{{ old('checkout_at', date('Y-m-d')) }}">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
||||
<div class="input-group date col-md-7" data-provide="datepicker"
|
||||
data-date-format="yyyy-mm-dd" data-date-end-date="0d" data-date-clear-btn="true">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="{{ trans('general.select_date') }}" name="checkout_at"
|
||||
id="checkout_at" value="{{ old('checkout_at', date('Y-m-d')) }}">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar"
|
||||
aria-hidden="true"></i></span>
|
||||
</div>
|
||||
{!! $errors->first('checkout_at', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
|
@ -118,9 +123,13 @@
|
|||
</label>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="input-group date col-md-7" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-start-date="0d" data-date-clear-btn="true">
|
||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="expected_checkin" id="expected_checkin" value="{{ old('expected_checkin') }}">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
||||
<div class="input-group date col-md-7" data-provide="datepicker"
|
||||
data-date-format="yyyy-mm-dd" data-date-start-date="0d" data-date-clear-btn="true">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="{{ trans('general.select_date') }}" name="expected_checkin"
|
||||
id="expected_checkin" value="{{ old('expected_checkin') }}">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar"
|
||||
aria-hidden="true"></i></span>
|
||||
</div>
|
||||
{!! $errors->first('expected_checkin', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
|
@ -132,7 +141,8 @@
|
|||
{{ trans('general.notes') }}
|
||||
</label>
|
||||
<div class="col-md-8">
|
||||
<textarea class="col-md-6 form-control" id="note" name="note">{{ old('note', $asset->note) }}</textarea>
|
||||
<textarea class="col-md-6 form-control" id="note"
|
||||
name="note">{{ old('note', $asset->note) }}</textarea>
|
||||
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -164,13 +174,19 @@
|
|||
@endif
|
||||
|
||||
</div> <!--/.box-body-->
|
||||
@include ('partials.forms.redirect_submit_options',
|
||||
[
|
||||
'route' => 'hardware.index',
|
||||
'table_name' => $table_name,
|
||||
'type'=> ($asset->model ? $asset->model->name : trans('general.asset_model')),
|
||||
'checkin' => false
|
||||
])
|
||||
|
||||
<x-redirect_submit_options
|
||||
index_route="hardware.index"
|
||||
:button_label="trans('general.checkout')"
|
||||
:disabled_select="!$asset->model"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_checked_out_to'),
|
||||
|
||||
]"
|
||||
/>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div> <!--/.col-md-7-->
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
'helpText' => trans('help.assets'),
|
||||
'helpPosition' => 'right',
|
||||
'formAction' => ($item->id) ? route('hardware.update', ['hardware' => $item->id]) : route('hardware.store'),
|
||||
'index_route' => 'hardware.index',
|
||||
'options' => [
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'assets']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||
]
|
||||
])
|
||||
|
||||
|
||||
|
@ -130,8 +135,6 @@
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- byod checkbox -->
|
||||
<div class="form-group">
|
||||
<div class="col-md-7 col-md-offset-3">
|
||||
|
|
|
@ -66,7 +66,11 @@
|
|||
<!-- CSRF Token -->
|
||||
{{ csrf_field() }}
|
||||
@yield('inputFields')
|
||||
@include('partials.forms.edit.submit')
|
||||
<x-redirect_submit_options
|
||||
:index_route="$index_route ?? null"
|
||||
:button_label="trans('general.save')"
|
||||
:options="$options ?? []"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div> <!-- ./box-body -->
|
||||
|
|
|
@ -56,10 +56,14 @@
|
|||
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ route('licenses.index') }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkin') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="licenses.index"
|
||||
:button_label="trans('general.checkin')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.licenses')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.license')]),
|
||||
]"
|
||||
/>
|
||||
</div> <!-- /.box-->
|
||||
</form>
|
||||
</div> <!-- /.col-md-7-->
|
||||
|
|
|
@ -105,10 +105,15 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ route('licenses.index') }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkout') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="licenses.index"
|
||||
:button_label="trans('general.checkout')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.licenses')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.license')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_checked_out_to'),
|
||||
]"
|
||||
/>
|
||||
</div> <!-- /.box-->
|
||||
</form>
|
||||
</div> <!-- /.col-md-7-->
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
'updateText' => trans('admin/licenses/form.update'),
|
||||
'topSubmit' => true,
|
||||
'formAction' => ($item->id) ? route('licenses.update', ['license' => $item->id]) : route('licenses.store'),
|
||||
'index_route' => 'licenses.index',
|
||||
'options' => [
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'licenses']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.license')]),
|
||||
]
|
||||
])
|
||||
|
||||
{{-- Page content --}}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<!-- begin redirect submit options -->
|
||||
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3">
|
||||
<a class="btn btn-link" href="{{ route($route) }}">{{ trans('button.cancel') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9 text-right">
|
||||
<div class="btn-group text-left">
|
||||
|
||||
<select class="redirect-options form-control select2" data-minimum-results-for-search="Infinity" name="redirect_option" style="min-width: 200px"{{ (!$asset->model ? ' disabled' : '') }}>
|
||||
|
||||
<option {{ (Session::get('redirect_option')=="0" || (Session::get('redirect_option')=="2" && $checkin)) ? 'selected' : '' }} value="0">
|
||||
{{ trans('admin/hardware/form.redirect_to_all', ['type' => $table_name]) }}
|
||||
</option>
|
||||
<option {{ Session::get('redirect_option')=="1" ? 'selected' : ''}} value="1">
|
||||
{{ trans('admin/hardware/form.redirect_to_type', ['type' => $type]) }}
|
||||
</option>
|
||||
<option {{ Session::get('redirect_option')=="2" && !$checkin ? 'selected' : ''}}{{ $checkin ? 'hidden disabled' : '' }} value="2" >
|
||||
{{ !$checkin ? trans('admin/hardware/form.redirect_to_checked_out_to') : '' }}
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
<button type="submit" class="btn btn-primary pull-right{{ (!$asset->model ? ' disabled' : '') }}" style="margin-left:5px; border-radius: 3px;"{!! (!$asset->model ? ' data-tooltip="true" title="'.trans('admin/hardware/general.edit').'" disabled' : '') !!}>
|
||||
<i class="fas fa-check icon-white" aria-hidden="true"></i>
|
||||
{{ $checkin ? trans('general.checkin') : trans('general.checkout') }}
|
||||
</button>
|
||||
|
||||
</div><!-- /.btn-group -->
|
||||
</div><!-- /.col-md-9 -->
|
||||
</div><!-- /.row -->
|
||||
</div> <!-- /.box-footer -->
|
||||
<!-- end redirect submit options -->
|
|
@ -596,9 +596,14 @@
|
|||
</table>
|
||||
</div><!-- /.tab-pane -->
|
||||
</div><!-- /.tab-content -->
|
||||
<div class="box-footer text-right">
|
||||
<button type="submit" accesskey="s" class="btn btn-primary"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.save') }}</button>
|
||||
</div>
|
||||
<x-redirect_submit_options
|
||||
index_route="users.index"
|
||||
:button_label="trans('general.save')"
|
||||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'users']),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
|
||||
]"
|
||||
/>
|
||||
</div><!-- nav-tabs-custom -->
|
||||
</form>
|
||||
</div> <!--/col-md-8-->
|
||||
|
|
|
@ -3,17 +3,65 @@
|
|||
namespace Feature\Assets\Ui;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\StatusLabel;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EditAssetTest extends TestCase
|
||||
{
|
||||
|
||||
public function testPermissionRequiredToViewLicense()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get(route('hardware.edit', $asset))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testPageCanBeAccessed(): void
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
$user = User::factory()->editAssets()->create();
|
||||
$response = $this->actingAs($user)->get(route('hardware.edit', $asset->id));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function testAssetEditPostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$asset = Asset::factory()->assignedToUser()->create();
|
||||
|
||||
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
|
||||
->from(route('hardware.edit', $asset))
|
||||
->put(route('hardware.update', $asset),
|
||||
[
|
||||
'redirect_option' => 'index',
|
||||
'name' => 'New name',
|
||||
'asset_tags' => 'New Asset Tag',
|
||||
'status_id' => StatusLabel::factory()->create()->id,
|
||||
'model_id' => AssetModel::factory()->create()->id,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('hardware.index'));
|
||||
$this->assertDatabaseHas('assets', ['asset_tag' => 'New Asset Tag']);
|
||||
}
|
||||
public function testAssetEditPostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
|
||||
->from(route('hardware.edit', $asset))
|
||||
->put(route('hardware.update', $asset), [
|
||||
'redirect_option' => 'item',
|
||||
'name' => 'New name',
|
||||
'asset_tags' => 'New Asset Tag',
|
||||
'status_id' => StatusLabel::factory()->create()->id,
|
||||
'model_id' => AssetModel::factory()->create()->id,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
||||
|
||||
$this->assertDatabaseHas('assets', ['asset_tag' => 'New Asset Tag']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -196,4 +196,31 @@ class AssetCheckinTest extends TestCase
|
|||
->assertSessionHas('error')
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
||||
}
|
||||
|
||||
public function testAssetCheckinPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$asset = Asset::factory()->assignedToUser()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.index'))
|
||||
->post(route('hardware.checkin.store', $asset), [
|
||||
'redirect_option' => 'index',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('hardware.index'));
|
||||
}
|
||||
|
||||
public function testAssetCheckinPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$asset = Asset::factory()->assignedToUser()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.index'))
|
||||
->post(route('hardware.checkin.store', $asset), [
|
||||
'redirect_option' => 'item',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
||||
}
|
||||
}
|
||||
|
|
51
tests/Feature/Checkins/Ui/ComponentCheckinTest.php
Normal file
51
tests/Feature/Checkins/Ui/ComponentCheckinTest.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Checkins\Ui;
|
||||
|
||||
use App\Models\Component;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ComponentCheckinTest extends TestCase
|
||||
{
|
||||
public function testCheckingInComponentRequiresCorrectPermission()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->post(route('components.checkin.store', [
|
||||
'componentID' => Component::factory()->checkedOutToAsset()->create()->id,
|
||||
]))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
|
||||
public function testComponentCheckinPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$component = Component::factory()->checkedOutToAsset()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('components.index'))
|
||||
->post(route('components.checkin.store', $component), [
|
||||
'redirect_option' => 'index',
|
||||
'checkin_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('components.index'));
|
||||
}
|
||||
|
||||
public function testComponentCheckinPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$component = Component::factory()->checkedOutToAsset()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('components.index'))
|
||||
->post(route('components.checkin.store', $component), [
|
||||
'redirect_option' => 'item',
|
||||
'checkin_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('components.show', ['component' => $component->id]));
|
||||
}
|
||||
|
||||
|
||||
}
|
21
tests/Feature/Checkins/Ui/LicenseCheckinTest.php
Normal file
21
tests/Feature/Checkins/Ui/LicenseCheckinTest.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Checkins\Ui;
|
||||
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LicenseCheckinTest extends TestCase
|
||||
{
|
||||
public function testCheckingInLicenseRequiresCorrectPermission()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->post(route('licenses.checkin.save', [
|
||||
'licenseId' => LicenseSeat::factory()->assignedToUser()->create()->id,
|
||||
]))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -140,4 +140,51 @@ class AccessoryCheckoutTest extends TestCase
|
|||
'Log entry either does not exist or there are more than expected'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAccessoryCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$accessory = Accessory::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('accessories.index'))
|
||||
->post(route('accessories.checkout.store', $accessory), [
|
||||
'assigned_to' => User::factory()->create()->id,
|
||||
'redirect_option' => 'index',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('accessories.index'));
|
||||
}
|
||||
|
||||
public function testAccessoryCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$accessory = Accessory::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('accessories.index'))
|
||||
->post(route('accessories.checkout.store' , $accessory), [
|
||||
'assigned_to' => User::factory()->create()->id,
|
||||
'redirect_option' => 'item',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('accessories.show', ['accessory' => $accessory->id]));
|
||||
}
|
||||
|
||||
public function testAccessoryCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$accessory = Accessory::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('accessories.index'))
|
||||
->post(route('accessories.checkout.store' , $accessory), [
|
||||
'assigned_to' => $user->id,
|
||||
'redirect_option' => 'target',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.show', ['user' => $user]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Feature\Checkouts\Ui;
|
||||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Company;
|
||||
use App\Models\LicenseSeat;
|
||||
|
@ -251,20 +252,85 @@ class AssetCheckoutTest extends TestCase
|
|||
->assertRedirect(route('hardware.show',['hardware' => $asset->id]));
|
||||
}
|
||||
|
||||
public function testAssetCheckoutPagePostIsRedirectedIfModelIsInvalid()
|
||||
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
$asset->model_id = 0;
|
||||
$asset->forceSave();
|
||||
$user = User::factory()->create();
|
||||
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.checkout.create', $asset))
|
||||
->post(route('hardware.checkout.store', $asset), [
|
||||
'checkout_to_type' => 'user',
|
||||
'assigned_user' => $user->id,
|
||||
'assigned_user' => User::factory()->create()->id,
|
||||
'redirect_option' => 'index',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHas('error')
|
||||
->assertRedirect(route('hardware.index'));
|
||||
}
|
||||
|
||||
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.checkout.create', $asset))
|
||||
->post(route('hardware.checkout.store' , $asset), [
|
||||
'checkout_to_type' => 'user',
|
||||
'assigned_user' => User::factory()->create()->id,
|
||||
'redirect_option' => 'item',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
||||
}
|
||||
|
||||
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.checkout.create', $asset))
|
||||
->post(route('hardware.checkout.store' , $asset), [
|
||||
'checkout_to_type' => 'user',
|
||||
'assigned_user' => $user->id,
|
||||
'redirect_option' => 'target',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.show', ['user' => $user]));
|
||||
}
|
||||
|
||||
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsAssetTarget()
|
||||
{
|
||||
$target = Asset::factory()->create();
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.checkout.create', $asset))
|
||||
->post(route('hardware.checkout.store' , $asset), [
|
||||
'checkout_to_type' => 'asset',
|
||||
'assigned_asset' => $target->id,
|
||||
'redirect_option' => 'target',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $target]));
|
||||
}
|
||||
|
||||
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsLocationTarget()
|
||||
{
|
||||
$target = Location::factory()->create();
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('hardware.checkout.create', $asset))
|
||||
->post(route('hardware.checkout.store' , $asset), [
|
||||
'checkout_to_type' => 'location',
|
||||
'assigned_location' => $target->id,
|
||||
'redirect_option' => 'target',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('locations.show', ['location' => $target]));
|
||||
}
|
||||
}
|
||||
|
|
68
tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
Normal file
68
tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Checkins\Ui;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\Component;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ComponentCheckoutTest extends TestCase
|
||||
{
|
||||
public function testCheckingOutComponentRequiresCorrectPermission()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->post(route('components.checkout.store', [
|
||||
'componentID' => Component::factory()->checkedOutToAsset()->create()->id,
|
||||
]))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$component = Component::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('components.index'))
|
||||
->post(route('components.checkout.store', $component), [
|
||||
'asset_id' => Asset::factory()->create()->id,
|
||||
'redirect_option' => 'index',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('components.index'));
|
||||
}
|
||||
|
||||
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$component = Component::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('components.index'))
|
||||
->post(route('components.checkout.store' , $component), [
|
||||
'asset_id' => Asset::factory()->create()->id,
|
||||
'redirect_option' => 'item',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('components.show', ['component' => $component->id]));
|
||||
}
|
||||
|
||||
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
$component = Component::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('components.index'))
|
||||
->post(route('components.checkout.store' , $component), [
|
||||
'asset_id' => $asset->id,
|
||||
'redirect_option' => 'target',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $asset]));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
namespace Tests\Feature\Checkouts\Ui;
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Component;
|
||||
use App\Models\Consumable;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckoutConsumableNotification;
|
||||
|
@ -90,4 +92,51 @@ class ConsumableCheckoutTest extends TestCase
|
|||
'Log entry either does not exist or there are more than expected'
|
||||
);
|
||||
}
|
||||
|
||||
public function testConsumableCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$consumable = Consumable::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('consumables.index'))
|
||||
->post(route('consumables.checkout.store', $consumable), [
|
||||
'assigned_to' => User::factory()->create()->id,
|
||||
'redirect_option' => 'index',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('consumables.index'));
|
||||
}
|
||||
|
||||
public function testConsumableCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$consumable = Consumable::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('consumables.index'))
|
||||
->post(route('consumables.checkout.store' , $consumable), [
|
||||
'assigned_to' => User::factory()->create()->id,
|
||||
'redirect_option' => 'item',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('consumables.show', ['consumable' => $consumable->id]));
|
||||
}
|
||||
|
||||
public function testConsumableCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$consumable = Consumable::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('components.index'))
|
||||
->post(route('consumables.checkout.store' , $consumable), [
|
||||
'assigned_to' => $user->id,
|
||||
'redirect_option' => 'target',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.show', ['user' => $user]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,4 +56,62 @@ class LicenseCheckoutTest extends TestCase
|
|||
'note' => 'oh hi there',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||
{
|
||||
$license = License::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('licenses.checkout', ['licenseId' => $license->id]))
|
||||
->post(route('licenses.checkout', ['licenseId' => $license->id]), [
|
||||
'assigned_to' => User::factory()->create()->id,
|
||||
'redirect_option' => 'index',
|
||||
'assigned_qty' => 1,
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('licenses.index'));
|
||||
}
|
||||
|
||||
public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||
{
|
||||
$license = License::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('licenses.checkout', ['licenseId' => $license->id]))
|
||||
->post(route('licenses.checkout' , ['licenseId' => $license->id]), [
|
||||
'assigned_to' => User::factory()->create()->id,
|
||||
'redirect_option' => 'item',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('licenses.show', ['license' => $license->id]));
|
||||
}
|
||||
|
||||
public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$license = License::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('licenses.checkout', ['licenseId' => $license->id]))
|
||||
->post(route('licenses.checkout' , $license), [
|
||||
'assigned_to' => $user->id,
|
||||
'redirect_option' => 'target',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.show', ['user' => $user->id]));
|
||||
}
|
||||
public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsAssetTarget()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
$license = License::factory()->create();
|
||||
|
||||
$this->actingAs(User::factory()->admin()->create())
|
||||
->from(route('licenses.checkout', ['licenseId' => $license->id]))
|
||||
->post(route('licenses.checkout' , $license), [
|
||||
'asset_id' => $asset->id,
|
||||
'redirect_option' => 'target',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,46 +31,135 @@ class HelperTest extends TestCase
|
|||
public function testGetRedirectOptionMethod()
|
||||
{
|
||||
$test_data = [
|
||||
'Option 2: redirect for user assigned to ' => [
|
||||
'Option target: redirect for user assigned to ' => [
|
||||
'request' =>(object) ['assigned_user' => 22],
|
||||
'id' => 1,
|
||||
'checkout_to_type' => 'user',
|
||||
'redirect_option' => 2,
|
||||
'redirect_option' => 'target',
|
||||
'table' => 'Assets',
|
||||
'route' => route('users.show', 22),
|
||||
],
|
||||
'Option 2: redirect location assigned to ' => [
|
||||
'Option target: redirect location assigned to ' => [
|
||||
'request' =>(object) ['assigned_location' => 10],
|
||||
'id' => 2,
|
||||
'checkout_to_type' => 'location',
|
||||
'redirect_option' => 2,
|
||||
'redirect_option' => 'target',
|
||||
'table' => 'Locations',
|
||||
'route' => route('locations.show', 10),
|
||||
],
|
||||
'Option 2: redirect back to asset assigned to ' => [
|
||||
'Option target: redirect back to asset assigned to ' => [
|
||||
'request' =>(object) ['assigned_asset' => 101],
|
||||
'id' => 3,
|
||||
'checkout_to_type' => 'asset',
|
||||
'redirect_option' => 2,
|
||||
'redirect_option' => 'target',
|
||||
'table' => 'Assets',
|
||||
'route' => route('hardware.show', 101),
|
||||
],
|
||||
'Option 1: redirect back to asset ' => [
|
||||
'Option item: redirect back to asset ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => 999,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 1,
|
||||
'redirect_option' => 'item',
|
||||
'table' => 'Assets',
|
||||
'route' => route('hardware.show', 999),
|
||||
],
|
||||
'Option 0: redirect back to index ' => [
|
||||
'Option index: redirect back to asset index ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => null,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 0,
|
||||
'redirect_option' => 'index',
|
||||
'table' => 'Assets',
|
||||
'route' => route('hardware.index'),
|
||||
],
|
||||
|
||||
'Option item: redirect back to user ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => 999,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'item',
|
||||
'table' => 'Users',
|
||||
'route' => route('users.show', 999),
|
||||
],
|
||||
|
||||
'Option index: redirect back to user index ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => null,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'index',
|
||||
'table' => 'Users',
|
||||
'route' => route('users.index'),
|
||||
],
|
||||
|
||||
'Option item: redirect back to license ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => 999,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'item',
|
||||
'table' => 'Licenses',
|
||||
'route' => route('licenses.show', 999),
|
||||
],
|
||||
|
||||
'Option index: redirect back to license index ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => null,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'index',
|
||||
'table' => 'Licenses',
|
||||
'route' => route('licenses.index'),
|
||||
],
|
||||
|
||||
'Option item: redirect back to accessory list ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => 999,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'item',
|
||||
'table' => 'Accessories',
|
||||
'route' => route('accessories.show', 999),
|
||||
],
|
||||
|
||||
'Option index: redirect back to accessory index ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => null,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'index',
|
||||
'table' => 'Accessories',
|
||||
'route' => route('accessories.index'),
|
||||
],
|
||||
'Option item: redirect back to consumable ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => 999,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'item',
|
||||
'table' => 'Consumables',
|
||||
'route' => route('consumables.show', 999),
|
||||
],
|
||||
|
||||
'Option index: redirect back to consumables index ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => null,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'index',
|
||||
'table' => 'Consumables',
|
||||
'route' => route('consumables.index'),
|
||||
],
|
||||
|
||||
'Option item: redirect back to component ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => 999,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'item',
|
||||
'table' => 'Components',
|
||||
'route' => route('components.show', 999),
|
||||
],
|
||||
|
||||
'Option index: redirect back to component index ' => [
|
||||
'request' =>(object) ['assigned_asset' => null],
|
||||
'id' => null,
|
||||
'checkout_to_type' => null,
|
||||
'redirect_option' => 'index',
|
||||
'table' => 'Components',
|
||||
'route' => route('components.index'),
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($test_data as $scenario => $data ) {
|
||||
|
@ -78,7 +167,7 @@ class HelperTest extends TestCase
|
|||
Session::put('redirect_option', $data['redirect_option']);
|
||||
Session::put('checkout_to_type', $data['checkout_to_type']);
|
||||
|
||||
$redirect = Helper::getRedirectOption($data['request'],$data['id'], $data['table']);
|
||||
$redirect = redirect()->to(Helper::getRedirectOption($data['request'],$data['id'], $data['table']));
|
||||
|
||||
$this->assertInstanceOf(RedirectResponse::class, $redirect);
|
||||
$this->assertEquals($data['route'], $redirect->getTargetUrl(), $scenario.'failed.');
|
||||
|
|
111
webpack.mix.js
111
webpack.mix.js
|
@ -1,4 +1,5 @@
|
|||
const mix = require("laravel-mix");
|
||||
const fs = require("node:fs");
|
||||
|
||||
// This generates a file called app.css, which we use
|
||||
// later on to build all.css
|
||||
|
@ -68,67 +69,30 @@ mix
|
|||
"./public/js/build/app.js" //because of compiling - this does not work very well :(
|
||||
)
|
||||
|
||||
var skins = fs.readdirSync("resources/assets/less/skins");
|
||||
|
||||
// Convert the skins to CSS
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-blue.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-red.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-contrast.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-green.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-green-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-black.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-black-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-red-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-purple.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-purple-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-yellow.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-yellow-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-blue-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-orange-dark.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
mix.less(
|
||||
"./resources/assets/less/skins/skin-orange.less",
|
||||
"css/dist/skins",
|
||||
);
|
||||
for (var i in skins) {
|
||||
mix.less(
|
||||
"resources/assets/less/skins/" + skins[i],
|
||||
"css/dist/skins"
|
||||
)
|
||||
}
|
||||
|
||||
var css_skins = fs.readdirSync("public/css/dist/skins");
|
||||
for (var i in css_skins) {
|
||||
if (css_skins[i].endsWith(".min.css")) {
|
||||
//don't minify already minified skinns
|
||||
continue;
|
||||
}
|
||||
if (css_skins[i].endsWith(".css")) {
|
||||
// only minify files ending with '.css'
|
||||
mix.minify("public/css/dist/skins/" + css_skins[i]).version();
|
||||
}
|
||||
//TODO - if we only ever use the minified versions, this could be simplified down to one line (above)
|
||||
// but it stays like this so we have the minified and non-minified versions of the skins
|
||||
// right now the code seems to use the un-minified skins
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine bootstrap table css
|
||||
|
@ -163,7 +127,7 @@ mix.combine(
|
|||
"./node_modules/ekko-lightbox/dist/ekko-lightbox.js",
|
||||
"./resources/assets/js/extensions/pGenerator.jquery.js",
|
||||
"./node_modules/chart.js/dist/Chart.js",
|
||||
"./resources/assets/js/signature_pad.js",
|
||||
"./resources/assets/js/signature_pad.js", //dupe?
|
||||
"./node_modules/jquery-validation/dist/jquery.validate.js",
|
||||
"./node_modules/list.js/dist/list.js",
|
||||
"./node_modules/clipboard/dist/clipboard.js",
|
||||
|
@ -200,27 +164,4 @@ mix
|
|||
["./public/js/build/vendor.js", "./public/js/build/app.js"],
|
||||
"./public/js/dist/all.js"
|
||||
)
|
||||
.version();
|
||||
|
||||
/**
|
||||
* Copy, minify and version skins
|
||||
*/
|
||||
mix
|
||||
.minify([
|
||||
"./public/css/dist/skins/skin-green.css",
|
||||
"./public/css/dist/skins/skin-green-dark.css",
|
||||
"./public/css/dist/skins/skin-black.css",
|
||||
"./public/css/dist/skins/skin-black-dark.css",
|
||||
"./public/css/dist/skins/skin-blue.css",
|
||||
"./public/css/dist/skins/skin-blue-dark.css",
|
||||
"./public/css/dist/skins/skin-yellow.css",
|
||||
"./public/css/dist/skins/skin-yellow-dark.css",
|
||||
"./public/css/dist/skins/skin-red.css",
|
||||
"./public/css/dist/skins/skin-red-dark.css",
|
||||
"./public/css/dist/skins/skin-purple.css",
|
||||
"./public/css/dist/skins/skin-purple-dark.css",
|
||||
"./public/css/dist/skins/skin-orange.css",
|
||||
"./public/css/dist/skins/skin-orange-dark.css",
|
||||
"./public/css/dist/skins/skin-contrast.css",
|
||||
])
|
||||
.version();
|
||||
.version();
|
Loading…
Reference in a new issue