mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Finalize user-defined-fields (closes #176)
This commit is contained in:
@@ -6,6 +6,13 @@
|
||||
@php if(!isset($initialValue)) { $initialValue = ''; } @endphp
|
||||
@php if(empty($earlierThanInfoLimit)) { $earlierThanInfoLimit = ''; } @endphp
|
||||
@php if(empty($earlierThanInfoText)) { $earlierThanInfoText = ''; } @endphp
|
||||
@php if(empty($additionalCssClasses)) { $additionalCssClasses = ''; } @endphp
|
||||
@php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp
|
||||
@php if(empty($invalidFeedback)) { $invalidFeedback = ''; } @endphp
|
||||
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
||||
@php if(!isset($noNameAttribute)) { $noNameAttribute = false; } @endphp
|
||||
@php if(!isset($nextInputSelector)) { $nextInputSelector = false; } @endphp
|
||||
@php if(empty($additionalAttributes)) { $additionalAttributes = ''; } @endphp
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ $id }}">{{ $L($label) }}
|
||||
@@ -15,8 +22,8 @@
|
||||
</span>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group date datetimepicker @if(!empty($additionalCssClasses)){{ $additionalCssClasses }}@endif" id="{{ $id }}" data-target-input="nearest">
|
||||
<input type="text" @if($isRequired) required @endif class="form-control datetimepicker-input"
|
||||
<div class="input-group date datetimepicker @if(!empty($additionalGroupCssClasses)){{ $additionalGroupCssClasses }}@endif" id="{{ $id }}" @if(!$noNameAttribute) name="{{ $id }}" @endif data-target-input="nearest">
|
||||
<input {!! $additionalAttributes !!} type="text" @if($isRequired) @if($isRequired) required @endif @endif class="form-control datetimepicker-input @if(!empty($additionalCssClasses)){{ $additionalCssClasses }}@endif"
|
||||
data-target="#{{ $id }}" data-format="{{ $format }}"
|
||||
data-init-with-now="{{ BoolToString($initWithNow) }}"
|
||||
data-init-value="{{ $initialValue }}"
|
||||
|
@@ -14,11 +14,12 @@
|
||||
@php if(empty($additionalHtmlElements)) { $additionalHtmlElements = ''; } @endphp
|
||||
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
||||
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
||||
@php if(!isset($noNameAttribute)) { $noNameAttribute = false; } @endphp
|
||||
|
||||
<div class="form-group {{ $additionalGroupCssClasses }}">
|
||||
<label for="{{ $id }}">{{ $L($label) }} <span id="{{ $hintId }}" class="small text-muted">{{ $hint }}</span>{!! $additionalHtmlContextHelp !!}</label>
|
||||
<div class="input-group">
|
||||
<input {!! $additionalAttributes !!} type="number" class="form-control numberpicker {{ $additionalCssClasses }}" id="{{ $id }}" name="{{ $id }}" value="{{ $value }}" min="{{ $min }}" max="{{ $max }}" step="{{ $step }}" @if($isRequired) required @endif>
|
||||
<input {!! $additionalAttributes !!} type="number" class="form-control numberpicker {{ $additionalCssClasses }}" id="{{ $id }}" @if(!$noNameAttribute) name="{{ $id }}" @endif value="{{ $value }}" min="{{ $min }}" max="{{ $max }}" step="{{ $step }}" @if($isRequired) required @endif>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text numberpicker-up-button"><i class="fas fa-arrow-up"></i></div>
|
||||
</div>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
@foreach($userfields as $userfield)
|
||||
|
||||
@if($userfield->show_as_column_in_tables == 1)
|
||||
<th>{{ $userfield->name }}</th>
|
||||
<th>{{ $userfield->caption }}</th>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
@@ -12,14 +12,65 @@
|
||||
@if($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_SINGLE_LINE_TEXT)
|
||||
<div class="form-group">
|
||||
<label for="name">{{ $userfield->caption }}</label>
|
||||
<input type="text" class="form-control userfield-input" id="{{ $userfield->name }}" value="">
|
||||
<input type="text" class="form-control userfield-input" data-userfield-name="{{ $userfield->name }}">
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_SINGLE_MULTILINE_TEXT)
|
||||
<div class="form-group">
|
||||
<label for="description">{{ $userfield->caption }}</label>
|
||||
<textarea class="form-control userfield-input" rows="4" data-userfield-name="{{ $userfield->name }}"></textarea>
|
||||
</div>
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_INTEGRAL_NUMBER)
|
||||
@include('components.numberpicker', array(
|
||||
'id' => $userfield->name,
|
||||
'label' => $userfield->caption,
|
||||
'noNameAttribute' => true,
|
||||
'min' => 0,
|
||||
'isRequired' => false,
|
||||
'additionalCssClasses' => 'userfield-input',
|
||||
'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"'
|
||||
))
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DECIMAL_NUMBER)
|
||||
@include('components.numberpicker', array(
|
||||
'id' => '',
|
||||
'label' => $userfield->caption,
|
||||
'noNameAttribute' => true,
|
||||
'min' => 0,
|
||||
'step' => 0.01,
|
||||
'isRequired' => false,
|
||||
'additionalCssClasses' => 'userfield-input',
|
||||
'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"'
|
||||
))
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DATE)
|
||||
@include('components.datetimepicker', array(
|
||||
'id' => $userfield->name,
|
||||
'label' => $userfield->caption,
|
||||
'noNameAttribute' => true,
|
||||
'format' => 'YYYY-MM-DD',
|
||||
'initWithNow' => false,
|
||||
'limitEndToNow' => false,
|
||||
'limitStartToNow' => false,
|
||||
'additionalGroupCssClasses' => 'date-only-datetimepicker',
|
||||
'isRequired' => false,
|
||||
'additionalCssClasses' => 'userfield-input',
|
||||
'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"'
|
||||
))
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DATETIME)
|
||||
@include('components.datetimepicker', array(
|
||||
'id' => $userfield->name,
|
||||
'label' => $userfield->caption,
|
||||
'noNameAttribute' => true,
|
||||
'format' => 'YYYY-MM-DD HH:mm:ss',
|
||||
'initWithNow' => false,
|
||||
'limitEndToNow' => false,
|
||||
'limitStartToNow' => false,
|
||||
'isRequired' => false,
|
||||
'additionalCssClasses' => 'userfield-input',
|
||||
'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"'
|
||||
))
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
|
||||
<div class="form-group">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input userfield-input" type="checkbox" id="{{ $userfield->name }}" value="1">
|
||||
<input class="form-check-input userfield-input" type="checkbox" data-userfield-name="{{ $userfield->name }}" value="1">
|
||||
<label class="form-check-label" for="{{ $userfield->name }}">{{ $userfield->caption }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -22,6 +22,11 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $L('Name') }}</th>
|
||||
|
||||
@include('components.userfields_thead', array(
|
||||
'userfields' => $userfields
|
||||
))
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@@ -30,6 +35,12 @@
|
||||
<td>
|
||||
{{ $equipmentItem->name }}
|
||||
</td>
|
||||
|
||||
@include('components.userfields_tbody', array(
|
||||
'userfields' => $userfields,
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $equipmentItem->id)
|
||||
))
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@@ -56,6 +56,11 @@
|
||||
<textarea class="form-control" id="description" name="description">@if($mode == 'edit'){{ $equipment->description }}@endif</textarea>
|
||||
</div>
|
||||
|
||||
@include('components.userfieldsform', array(
|
||||
'userfields' => $userfields,
|
||||
'entity' => 'equipment'
|
||||
))
|
||||
|
||||
<button id="save-equipment-button" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
|
||||
</form>
|
||||
|
@@ -38,7 +38,7 @@
|
||||
'limitStartToNow' => false,
|
||||
'invalidFeedback' => $L('A best before date is required'),
|
||||
'nextInputSelector' => '#best_before_date',
|
||||
'additionalCssClasses' => 'date-only-datetimepicker',
|
||||
'additionalGroupCssClasses' => 'date-only-datetimepicker',
|
||||
'shortcutValue' => '2999-12-31',
|
||||
'shortcutLabel' => 'Never expires',
|
||||
'earlierThanInfoLimit' => date('Y-m-d'),
|
||||
|
@@ -226,6 +226,12 @@
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
<li data-nav-for-page="userfields" data-sub-menu-of="#top-nav-manager-master-data">
|
||||
<a class="nav-link discrete-link" href="{{ $U('/userfields') }}">
|
||||
<i class="fas fa-bookmark "></i>
|
||||
<span class="nav-link-text">{{ $L('Userfields') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@@ -82,6 +82,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('components.userfieldsform', array(
|
||||
'userfields' => $userfields,
|
||||
'entity' => 'recipes'
|
||||
))
|
||||
|
||||
<button id="save-recipe-button" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
|
||||
</form>
|
||||
|
@@ -37,6 +37,11 @@
|
||||
<th>{{ $L('Servings') }}</th>
|
||||
<th>{{ $L('Requirements fulfilled') }}</th>
|
||||
<th class="d-none">Hidden status for sorting of "Requirements fulfilled" column</th>
|
||||
|
||||
@include('components.userfields_thead', array(
|
||||
'userfields' => $userfields
|
||||
))
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@@ -55,6 +60,12 @@
|
||||
<td class="d-none">
|
||||
{{ FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->missing_products_count }}
|
||||
</td>
|
||||
|
||||
@include('components.userfields_tbody', array(
|
||||
'userfields' => $userfields,
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $recipe->id)
|
||||
))
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@@ -49,7 +49,7 @@
|
||||
'limitStartToNow' => false,
|
||||
'invalidFeedback' => $L('A due date is required'),
|
||||
'nextInputSelector' => 'category_id',
|
||||
'additionalCssClasses' => 'date-only-datetimepicker',
|
||||
'additionalGroupCssClasses' => 'date-only-datetimepicker',
|
||||
'isRequired' => false
|
||||
))
|
||||
|
||||
@@ -76,6 +76,11 @@
|
||||
'prefillByUserId' => $initUserId
|
||||
))
|
||||
|
||||
@include('components.userfieldsform', array(
|
||||
'userfields' => $userfields,
|
||||
'entity' => 'tasks'
|
||||
))
|
||||
|
||||
<button id="save-task-button" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
|
||||
</form>
|
||||
|
@@ -62,6 +62,11 @@
|
||||
<th class="d-none">Hidden category</th>
|
||||
<th>{{ $L('Assigned to') }}</th>
|
||||
<th class="d-none">Hidden status</th>
|
||||
|
||||
@include('components.userfields_thead', array(
|
||||
'userfields' => $userfields
|
||||
))
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@@ -98,6 +103,12 @@
|
||||
<td class="d-none">
|
||||
@if($task->done == 1) text-muted @endif @if(!empty($task->due_date) && $task->due_date < date('Y-m-d')) overdue @elseif(!empty($task->due_date) && $task->due_date < date('Y-m-d', strtotime("+$nextXDays days"))) duesoon @endif
|
||||
</td>
|
||||
|
||||
@include('components.userfields_tbody', array(
|
||||
'userfields' => $userfields,
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $task->id)
|
||||
))
|
||||
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@@ -34,8 +34,8 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">{{ $L('Name') }}</label>
|
||||
<input type="text" class="form-control" required id="name" name="name" value="@if($mode == 'edit'){{ $userfield->name }}@endif">
|
||||
<div class="invalid-feedback">{{ $L('A name is required') }}</div>
|
||||
<input type="text" class="form-control" required pattern="^[a-zA-Z0-9]*$" id="name" name="name" value="@if($mode == 'edit'){{ $userfield->name }}@endif">
|
||||
<div class="invalid-feedback">{{ $L('This is required and can only contain letters and numbers') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<div class="col">
|
||||
<h1>
|
||||
@yield('title')
|
||||
<a class="btn btn-outline-dark" href="{{ $U('/userfield/new') }}">
|
||||
<a id="new-userfield-button" class="btn btn-outline-dark" href="{{ $U('/userfield/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add') }}
|
||||
</a>
|
||||
</h1>
|
||||
|
Reference in New Issue
Block a user