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

Refactoring modals with partials and fixing misalignments #15498

Merged
merged 10 commits into from
Sep 26, 2024
13 changes: 2 additions & 11 deletions resources/views/modals/category.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,10 @@
{{ csrf_field() }}
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<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 required">
<input type='text' name='name' id='modal-name' class="form-control">
</div>
</div>
@include('modals.partials.name')
<input type="hidden" name='category_type' id="modal-category_type" value="{{ request('category_type') }}" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
</div>
@include('modals.partials.footer')
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
12 changes: 2 additions & 10 deletions resources/views/modals/location.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
<form action="{{ route('api.locations.store') }}" onsubmit="return false">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<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 required"><input type='text' name="name" id='modal-name' class="form-control"></div>
</div>
@include('modals.partials.name', ['item' => new \App\Models\Location(), 'required' => 'true'])

<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-city">{{ trans('general.city') }}:</label></div>
Expand All @@ -26,10 +22,6 @@
</div>
</form>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
</div>
@include('modals.partials.footer')
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
13 changes: 3 additions & 10 deletions resources/views/modals/manufacturer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@
</div>
<div class="modal-body">
<form action="{{ route('api.manufacturers.store') }}" onsubmit="return false">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<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 required">
<input type='text' name="name" id='modal-name' class="form-control">
</div>
@include('partials.forms.edit.name', ['item' => new \App\Models\Manufacturer(), 'translated_name' => trans('admin/manufacturers/table.name')])
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
<div class="dynamic-form-row">
@include('modals.partials.footer')
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
41 changes: 7 additions & 34 deletions resources/views/modals/model.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,13 @@
<form action="{{ route('api.models.store') }}" onsubmit="return false">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<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 required"><input type='text' name="name" id='modal-name' class="form-control"></div>
</div>

<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-8 col-xs-12 required">
<select class="js-data-ajax" data-endpoint="categories/asset" name="category_id" style="width: 100%" id="modal-category_id"></select>
</div>
</div>

<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-8 col-xs-12">
<select class="js-data-ajax" data-endpoint="manufacturers" name="manufacturer_id" style="width: 100%" id="modal-manufacturer_id"></select>
</div>
</div>

<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-8 col-xs-12"><input type='text' name="model_number" id='modal-model_number' class="form-control"></div>
</div>

<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-8 col-xs-12">{{ Form::select('fieldset_id', Helper::customFieldsetList(),old('fieldset_id'), array('class'=>'select2', 'id'=>'modal-fieldset_id', 'style'=>'width:350px')) }}</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
@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 -->
</div><!-- /.modal-dialog -->
11 changes: 11 additions & 0 deletions resources/views/modals/partials/categories-select.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- modals/partials/categories-select.blade.php -->
@php
$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-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>
</div>
<!-- modals/partials/categories-select.blade.php -->
6 changes: 6 additions & 0 deletions resources/views/modals/partials/fieldset-select.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +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-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 -->
6 changes: 6 additions & 0 deletions resources/views/modals/partials/footer.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- partials/modals/partials/footer.blade.php -->
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary pull-right" id="modal-save">{{ trans('general.save') }}</button>
</div>
<!-- partials/modals/partials/footer.blade.php -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- 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-8 col-xs-12">
<select class="js-data-ajax" data-endpoint="manufacturers" name="manufacturer_id" style="width: 100%" id="modal-manufacturer_id"></select>
</div>
</div>
<!-- partials/modals/partials/model-number.blade.php -->
6 changes: 6 additions & 0 deletions resources/views/modals/partials/model-number.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +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-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 -->
10 changes: 10 additions & 0 deletions resources/views/modals/partials/name.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- modals/partials/name.blade.php -->
@php
$required = $required ?? '';
@endphp
<div class="dynamic-form-row">
<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>
<!-- modals/partials/name.blade.php -->
13 changes: 5 additions & 8 deletions resources/views/modals/statuslabel.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<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 required"><input type='text' name="name" id='modal-name' class="form-control"></div>
@include('partials.forms.edit.name', ['required' => 'true', 'item' => new \App\Models\Statuslabel(),'translated_name' => trans('admin/statuslabels/table.name') ])
</div>

<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-type">{{ trans('admin/statuslabels/table.status_type') }}:
<div class="col-md-3 col-xs-12"><label for="modal-type">{{ trans('admin/statuslabels/table.status_type') }}:
</label></div>
<div class="col-md-8 col-xs-12 required">{{ Form::select('type', $statuslabel_types, '', array('class'=>'select2', 'style'=>'width:90%','id' =>'modal-type')) }}</div>
<div class="col-md-8 col-xs-12">{{ Form::select('type', $statuslabel_types, '', array('class'=>'select2', 'style'=>'width:100%','id' =>'modal-type', 'required',)) }}</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
<div class="dynamic-form-row">
@include('modals.partials.footer')
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
9 changes: 3 additions & 6 deletions resources/views/modals/supplier.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>
<div class="dynamic-form-row">
<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 required"><input type='text' name="name" id='modal-name' class="form-control"></div>
@include('partials.forms.edit.name', [ 'item' => new \App\Models\Supplier(), 'translated_name' => trans('admin/suppliers/table.name')])
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
<div class="dynamic-form-row">
@include('modals.partials.footer')
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
76 changes: 36 additions & 40 deletions resources/views/modals/user.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h2 class="modal-title">{{ trans('admin/users/table.createuser') }}</h2>
</div>
<div class="modal-body">
<div class="modal-body" style="width:100%; display:block;">
<form action="{{ route('api.users.store') }}" onsubmit="return false">
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div>

<!-- Setup of default company, taken from asset creator -->
@if ($user->company)
<input type="hidden" name="company_id" id='modal-company' value='{{ $user->company->id }}' class="form-control">
Expand All @@ -42,63 +41,60 @@
<div class="dynamic-form-row">
@include ('partials.forms.edit.location-profile-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
</div>

<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-first_name">{{ trans('general.first_name') }}:</label></div>
<div class="col-md-8 col-xs-12 required"><input type='text' name="first_name" id='modal-first_name' class="form-control"></div>
@include('partials.forms.edit.name-first', [ 'required' => 'true', 'class' => 'col-md-8 col-xs-12-pull', 'style' => 'width:67%;'])
</div>

<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-last_name">{{ trans('general.last_name') }}:</label></div>
<div class="col-md-8 col-xs-12"><input type='text' name="last_name" id='modal-last_name' class="form-control"> </div>
@include('partials.forms.edit.name-last', ['required' => 'true', 'class' => 'col-md-8 col-xs-12-pull', 'style' => 'width:67%;'])
</div>

<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-username">{{ trans('admin/users/table.username') }}:</label></div>
<div class="col-md-8 col-xs-12 required"><input type='text' name="username" id='modal-username' class="form-control"></div>
@include('partials.forms.edit.email')
</div>

<!-- User email address -->
<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-email">{{ trans('admin/users/table.email') }}:</label></div>
<div class="col-md-8 col-xs-12">
<input class="form-control" type="text" name="email" id="modal-email" autocomplete="off">
{!! $errors->first('email', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
<div class="dynamic-form-row">
@include('partials.forms.edit.username', [ 'required' => 'true'])
</div>

<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-password">{{ trans('admin/users/table.password') }}:</label></div>
<div class="col-md-8 col-xs-12 required"><input type='password' name="password" id='modal-password' class="form-control">
<a href="#" class="left" id="modal-genPassword">Generate</a>
<div class="form-group">
<div class="col-md-3 col-xs-12">
<label class="control-label" for="modal-password">{{ trans('admin/users/table.password') }}:</label>
</div>
<div class="col-md-8 col-xs-12 " style="margin-bottom:5px;">
<input type='password' name="password" id='modal-password' class="form-control" required>
<a href="#" class="left" id="modal-genPassword">Generate</a>
<div id="modal-generated-password"></div>
</div>
</div>
</div>

<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-password_confirmation">{{ trans('admin/users/table.password_confirm') }}:</label></div>
<div class="col-md-8 col-xs-12 required"><input type='password' name="password_confirmation" id='modal-password_confirmation' class="form-control">
<div id="modal-generated-password"></div>
</div>
<div class="form-group">
<div class="col-md-3 col-xs-12 ">
<label class="control-label" for="modal-password_confirmation">{{ trans('admin/users/table.password_confirm') }}:</label>
</div>
<div class="col-md-8 col-xs-12">
<input class="form-control" type='password' name="password_confirmation" id='modal-password_confirmation' required>

</div>
</div>
</div>



<!-- Checkbox for activation new user, by default set for activated -->
<div class="dynamic-form-row">
<div class="col-md-offset-3 col-md-8 col-xs-12">
<label class="form-control">
<input type="checkbox" value="1" name="activated" id="modal-activated" {{ (old('activated', $user->activated)) == '1' ? ' checked="checked"' : '' }} aria-label="activated">
{{ trans('general.login_enabled') }}
</label>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-3 col-md-8 col-xs-12">
<label class="form-control">
<input type="checkbox" value="1" name="activated" id="modal-activated" {{ (old('activated', $user->activated)) == '1' ? ' checked="checked"' : '' }} aria-label="activated">
{{ trans('general.login_enabled') }}
</label>
</div>
</div>
</div>
<div class="dynamic-form-row">
@include('modals.partials.footer')
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('button.cancel') }}</button>
<button type="button" class="btn btn-primary" id="modal-save">{{ trans('general.save') }}</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

Expand Down
Loading
Loading