Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional model fields to model modal screen #15941

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/Http/Controllers/ModalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Helpers\Helper;
use App\Models\AssetModel;

class ModalController extends Controller
{
Expand Down Expand Up @@ -41,7 +42,11 @@ public function show ($type, $itemId = null) {

if ($type == "statuslabel") {
$view->with('statuslabel_types', Helper::statusTypeList());
}
}
if ($type == "model") {
$view->with('depreciation_list', Helper::depreciationList())
->with('item', new AssetModel);
}
if (in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
$view->with('kitId', $itemId);
}
Expand Down
35 changes: 22 additions & 13 deletions resources/views/modals/model.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<h2 class="modal-title">{{ trans('admin/models/table.create') }}</h2>
</div>
<div class="modal-body">
<form action="{{ route('api.models.store') }}" onsubmit="return false">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
@include('modals.partials.name', ['required' => 'true'])
@include('modals.partials.categories-select', ['required' => 'true'])
@include('modals.partials.manufacturer-select')
@include('modals.partials.model-number')
@include('modals.partials.fieldset-select')
</form>
</div>
@include('modals.partials.footer')
</div><!-- /.modal-content -->
<form action="{{ route('api.models.store') }}" onsubmit="return false">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
@include('modals.partials.name', ['required' => 'true'])
@include('modals.partials.categories-select', ['required' => 'true'])
@include('modals.partials.manufacturer-select')
@include('modals.partials.model-number')
@include ('modals.partials.depreciation')
@include ('modals.partials.minimum_quantity')
@include ('modals.partials.eol_months')
@include('modals.partials.fieldset-select')
@include ('modals.partials.notes')
@include ('modals.partials.requestable', ['requestable_text' => trans('admin/models/general.requestable')])

<!-- Hidden input for created_by -->
<input type="hidden" name="created_by" value="{{ auth()->user()->id }}">
</form>
</div>
@include('modals.partials.footer')
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$required = $required ?? '';
@endphp
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-category_id">{{ trans('general.category') }}:</label></div>
<div class="col-md-4 col-xs-12"><label for="modal-category_id">{{ trans('general.category') }}</label></div>
<div class="col-md-8 col-xs-12 required">
<select class="js-data-ajax" data-endpoint="categories/asset" name="category_id" style="width: 100%" id="modal-category_id" {{$required ? 'required' : ''}}></select>
</div>
Expand Down
11 changes: 11 additions & 0 deletions resources/views/modals/partials/depreciation.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- partials/modals/partials/depreciation.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12">
<label for="modal-depreciation_id">{{ trans('general.depreciation') }}</label>
</div>
<div class="col-md-8 col-xs-12">
{{ Form::select('depreciation_id', $depreciation_list , old('depreciation_id', $item->depreciation_id), array('class'=>'select2', 'style'=>'width:100%;', 'aria-label'=>'depreciation_id')) }}
{!! $errors->first('depreciation_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
<!-- partials/modals/partials/depreciation.blade.php -->
22 changes: 22 additions & 0 deletions resources/views/modals/partials/eol_months.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- partials/modals/partials/eol_months.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12">
<label for="eol">{{ trans('general.eol') }}</label>
</div>
<div class="col-md-5 col-xs-12">
<div class="input-group" style="width: 100%;">
<input
class="form-control"
type="text"
name="eol"
id="eol"
value="{{ old('eol', isset($item->eol) ? $item->eol : '') }}"
/>
<span class="input-group-addon">
{{ trans('general.months') }}
</span>
</div>
{!! $errors->first('eol', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times"></i> :message</span>') !!}
</div>
</div>
<!-- partials/modals/partials/eol_months.blade.php -->
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- partials/modals/partials/fieldset-select.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-fieldset_id">{{ trans('admin/models/general.fieldset') }}:</label></div>
<div class="col-md-4 col-xs-12"><label for="modal-fieldset_id">{{ trans('admin/models/general.fieldset') }}</label></div>
<div class="col-md-8 col-xs-12">{{ Form::select('fieldset_id', Helper::customFieldsetList(),old('fieldset_id'), array('class'=>'select2', 'id'=>'modal-fieldset_id', 'style'=>'width:100%;')) }}</div>
</div>
<!-- partials/modals/partials/fieldset-select.blade.php -->
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- partials/modals/partials/model-number.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-manufacturer_id">{{ trans('general.manufacturer') }}:</label></div>
<div class="col-md-4 col-xs-12"><label for="modal-manufacturer_id">{{ trans('general.manufacturer') }}</label></div>
<div class="col-md-8 col-xs-12">
<select class="js-data-ajax" data-endpoint="manufacturers" name="manufacturer_id" style="width: 100%" id="modal-manufacturer_id"></select>
</div>
Expand Down
27 changes: 27 additions & 0 deletions resources/views/modals/partials/minimum_quantity.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- partials/modals/partials/minimum-quantity.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12">
<label for="modal-min_amt">{{ trans('general.min_amt') }}</label>
</div>
<div class="col-md-3 col-xs-12">
<div class="dynamic-input-group" style="display: flex; align-items: center;">
<input
class="form-control"
maxlength="5"
type="text"
name="min_amt"
id="modal-min_amt"
aria-label="min_amt"
value="{{ old('min_amt', $item->min_amt) }}"
style="flex: 1; margin-right: 10px;"
{{ Helper::checkIfRequired($item, 'min_amt') ? 'required' : '' }}
/>
<a href="#" data-tooltip="true" title="{{ trans('general.min_amt_help') }}" class="info-icon">
<x-icon type="info-circle" />
<span class="sr-only">{{ trans('general.min_amt_help') }}</span>
</a>
</div>
{!! $errors->first('min_amt', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
<!-- partials/modals/partials/minimum-quantity.blade.php -->
2 changes: 1 addition & 1 deletion resources/views/modals/partials/model-number.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- partials/modals/partials/model-number.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-modelno">{{ trans('general.model_no') }}:</label></div>
<div class="col-md-4 col-xs-12"><label for="modal-modelno">{{ trans('general.model_no') }}</label></div>
<div class="col-md-8 col-xs-12"><input type='text' name="model_number" id='modal-model_number' class="form-control"></div>
</div>
<!-- partials/modals/partials/model-number.blade.php -->
2 changes: 1 addition & 1 deletion resources/views/modals/partials/name.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$required = $required ?? '';
@endphp
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-name">{{ trans('general.name') }}:
<div class="col-md-4 col-xs-12"><label for="modal-name">{{ trans('general.name') }}
</label></div>
<div class="col-md-8 col-xs-12"><input type='text' name="name" id='modal-name' class="form-control" {{$required ? 'required' : ''}}></div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions resources/views/modals/partials/notes.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- partials/modals/partials/notes.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12">
<label for="modal-notes">{{ trans('admin/hardware/form.notes') }}</label>
</div>
<div class="col-md-8 col-xs-12">
<textarea
class="form-control"
id="modal-notes"
aria-label="notes"
name="notes"
style="width: 100%; min-height: 100px;"
>{{ old('notes', $item->notes) }}</textarea>
{!! $errors->first('notes', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
<!-- partials/modals/partials/notes.blade.php -->
17 changes: 17 additions & 0 deletions resources/views/modals/partials/requestable.blade.php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An improvement would be wrapping the input in a label so clicking the text checks/unchecks the box.

Here's an example of what I mean from the regular "Create Asset Model" page:
CleanShot 2024-12-09 at 15 46 39

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- partials/modals/partials/requestable.blade.php -->
<div class="dynamic-form-row" >
<div class="col-md-offset-4 col-xs-12" style="margin-top:5px;">
<div style="display: flex; align-items: center;">
<input
type="checkbox"
value="1"
name="requestable"
id="requestable"
{{ old('requestable', $item->requestable) == '1' ? 'checked="checked"' : '' }}
style="margin-right: 10px;"
>
{{ $requestable_text }}
</div>
</div>
</div>
<!-- partials/modals/partials/requestable.blade.php -->
Loading