Skip to content

A free open source IT asset/license management system

Updated depreciations to use new form row components

snipef227d3d37a7a
diff --git a/resources/views/blade/form/row.blade.php b/resources/views/blade/form/row.blade.php
index 14ca7f7622..257824ed96 100644
--- a/resources/views/blade/form/row.blade.php
+++ b/resources/views/blade/form/row.blade.php
@@ -11,6 +11,9 @@
'errors_class' => $errors->has('support_url') ? ' has-error' : '',
'input_icon' => null,
'input_group_addon' => null,
+ 'maxlength' => null,
+ 'min' => null,
+ 'max' => null,
'rows' => null,
'placeholder' => null,
])
@@ -25,10 +28,26 @@
@php
$blade_type = in_array($type, ['text', 'email', 'url', 'tel', 'number', 'password']) ? 'text' : $type;
+
+ // The vast majority of string columns in this schema are varchar(191),
+ // so default text-family inputs to that length when the caller didn't
+ // pass one explicitly. Textareas and numbers opt out — textareas often
+ // back TEXT columns with no length limit, and browsers ignore
+ // maxlength on type="number" anyway. Callers can still override with
+ // an explicit :maxlength="..."
+ $effective_maxlength = $maxlength ?? (in_array($type, ['text', 'email', 'url', 'tel', 'password']) ? 191 : null);
@endphp
<div class="{{ $input_div_class }}">
- <x-dynamic-component
+ {{-- You can pass an <x-slot:input>...</x-slot:input> when the
+ field needs custom markup (e.g. an input plus a select side
+ by side, or a widget the input.* components don't cover).
+ The wrapping label + error + help + aria still come from
+ <x-form.row>, so only the input area is hand-authored. --}}
+ @isset($input)
+ {{ $input }}
+ @else
+ <x-dynamic-component
:$name
:$type
:aria-label="$name"
@@ -39,10 +58,14 @@
:value="old($name, $item->{$name})"
:input_icon="$input_icon"
:input_group_addon="$input_group_addon"
+ :maxlength="$effective_maxlength"
+ :min="$min"
+ :max="$max"
:rows="$rows"
:placeholder="$placeholder"
- />
+ />
+ @endisset
</div>
@if ($info_tooltip_text)
@@ -55,17 +78,15 @@
@endif
+ {{-- Error + help live in a single col-md-8 col-md-offset-3 wrapper so
+ they always span the wide-column area regardless of how narrow the
+ input above is. --}}
<div class="col-md-8 col-md-offset-3">
<x-form.error :name="$name" />
- </div>
- @if ($help_text)
- <!-- Help Text -->
- <div class="col-md-8 col-md-offset-3">
+ @if ($help_text)
<x-form.help :name="$name" :icon="$help_icon">{!! $help_text !!}</x-form.help>
- </div>
- @endif
-
-
+ @endif
+ </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/resources/views/depreciations/edit.blade.php b/resources/views/depreciations/edit.blade.php
index daf9468fe4..d34c149008 100755
--- a/resources/views/depreciations/edit.blade.php
+++ b/resources/views/depreciations/edit.blade.php
@@ -1,39 +1,69 @@
-@extends('layouts/edit-form', [
- 'createText' => trans('admin/depreciations/general.create') ,
- 'updateText' => trans('admin/depreciations/general.update'),
- 'helpPosition' => 'right',
- 'helpText' => trans('help.depreciations'),
- 'formAction' => (isset($item->id)) ? route('depreciations.update', ['depreciation' => $item->id]) : route('depreciations.store'),
-])
+@extends('layouts/default')
+
+@php
+ $helpText = trans('help.depreciations');
+ $helpPosition = 'right';
+@endphp
+
+{{-- Page title --}}
+@section('title')
+ @if ($item->id)
+ {{ trans('admin/depreciations/general.update') }}
+ @else
+ {{ trans('admin/depreciations/general.create') }}
+ @endif
+ @parent
+@stop
{{-- Page content --}}
-@section('inputFields')
-
-@include ('partials.forms.edit.name', ['translated_name' => trans('admin/depreciations/general.depreciation_name')])
-<!-- Months -->
-<div class="form-group {{ $errors->has('months') ? ' has-error' : '' }}">
- <label for="months" class="col-md-3 control-label">
- {{ trans('admin/depreciations/general.number_of_months') }}
- </label>
- <div class="col-md-9 col-sm-12">
- <input class="form-control" type="number" min="0" max="3600" name="months" id="months" value="{{ old('months', $item->months) }}" style="width: 90px;"{!! (\App\Helpers\Helper::checkIfRequired($item, 'months')) ? ' required' : '' !!} />
- <x-form.error name="months" />
- </div>
-</div>
-
-<!-- Depreciation Minimum -->
-<div class="form-group {{ $errors->has('depreciation_min') ? ' has-error' : '' }}">
- <label for="depreciation_min" class="col-md-3 control-label">
- {{ trans('admin/depreciations/general.depreciation_min') }}
- </label>
- <div class="col-md-9" style="display: flex;">
- <input class="form-control" name="depreciation_min" id="depreciation_min" required type="number" value="{{ old('depreciation_min', $item->depreciation_min) }}" style="width: 90px; margin-right: 15px; display: inline-block;" />
- <select class="form-control select2" name="depreciation_type" id="depreciation_type" data-minimum-results-for-search="Infinity" style="width: 150px; display: inline-block;">
- <option value="amount" {{ old('depreciation_type', $item->depreciation_type) == 'amount' ? 'selected' : '' }}>{{ trans('general.depreciation_options.amount') }}</option>
- <option value="percent" {{ old('depreciation_type', $item->depreciation_type) == 'percent' ? 'selected' : '' }}>{{ trans('general.depreciation_options.percent') }}</option>
- </select>
- <div class="col-md-7 col-md-offset-3"><x-form.error name="depreciation_min" /></div>
- </div>
-
-</div>
+@section('content')
+
+ <x-container class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 col-sm-12 col-sm-offset-0">
+
+ <x-form :$item route="{{ (isset($item->id)) ? route('depreciations.update', ['depreciation' => $item->id]) : route('depreciations.store') }}">
+
+ <x-box>
+
+ <x-form.row
+ :label="trans('admin/depreciations/general.depreciation_name')"
+ :$item
+ name="name"
+ />
+
+ <x-form.row
+ :label="trans('admin/depreciations/general.number_of_months')"
+ :$item
+ name="months"
+ type="number"
+ :min="0"
+ :max="3600"
+ input_div_class="col-md-2"
+ />
+
+ {{-- Depreciation minimum: an input plus an "amount / percent" select
+ on the same row. Uses <x-form.row>'s <x-slot:input> so the
+ label, error placement, and grid still come from the row
+ wrapper; only the input area itself is hand-authored. --}}
+ <x-form.row
+ :label="trans('admin/depreciations/general.depreciation_min')"
+ name="depreciation_min"
+ input_div_class="col-md-9"
+ >
+ <x-slot:input>
+ <div style="display: flex;">
+ <input class="form-control" name="depreciation_min" id="depreciation_min" required type="number" value="{{ old('depreciation_min', $item->depreciation_min) }}" style="width: 90px; margin-right: 15px; display: inline-block;" />
+ <select class="form-control select2" name="depreciation_type" id="depreciation_type" data-minimum-results-for-search="Infinity" style="width: 150px; display: inline-block;">
+ <option value="amount" {{ old('depreciation_type', $item->depreciation_type) == 'amount' ? 'selected' : '' }}>{{ trans('general.depreciation_options.amount') }}</option>
+ <option value="percent" {{ old('depreciation_type', $item->depreciation_type) == 'percent' ? 'selected' : '' }}>{{ trans('general.depreciation_options.percent') }}</option>
+ </select>
+ </div>
+ </x-slot:input>
+ </x-form.row>
+
+ </x-box>
+
+ </x-form>
+
+ </x-container>
+
@stop