-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
WIP - Form row component evolved #18130
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
Draft
snipe
wants to merge
23
commits into
develop
Choose a base branch
from
form-row-component-evolved
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
359e019
Start building out the box+form stuff
snipe fb1a894
Removed p-static class
snipe 96cc2c9
Move form into its own component
snipe be344c4
Different approach - rely on nested slots
snipe 08609d4
Moar refactorings
snipe d968444
This doesn’t actually work yet
snipe 6d5f515
Make select2 ajax a little more flexible
snipe affee0a
Handle unfilled data
snipe 8ce3fe0
Pass name to input
snipe 53716cb
Still not working (pre-selecting the ID of the asset)
snipe d2edc77
Debugging - remove later
snipe 3d675d3
Re-add the form static so it’s less noisy for this PR
snipe 9232ee7
Updated validation JS for select2
snipe 6f3ee19
Updated maintenances screen
snipe e6c49da
Use new blade for textarea
snipe 4812e25
Added name awareness in child elements
snipe 03130f0
Try to undo the asset stuff for the PR
snipe 1e85c7b
Put the form-control-static back since it didn’t cut down the number …
snipe 7161d56
Prod assets for some reason
snipe 80e4e4a
Updated more form fields
snipe 7c58fb9
Fixed test
snipe 448f4b9
Remove classes
snipe 6f233bc
Get more of the select2 ajax lists working
snipe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| @props([ | ||
| 'item' => null, | ||
| 'border_class' => 'default', | ||
| 'header_icon' => null, | ||
| 'form_route' => null, | ||
| ]) | ||
|
|
||
|
|
||
|
|
||
| <div {{ $attributes->merge(['class' => 'col-lg-6 col-lg-offset-3 col-md-10 col-md-offset-1 col-sm-12 col-sm-offset-0']) }}> | ||
|
|
||
|
|
||
| <!-- CSRF Token --> | ||
| {{ csrf_field() }} | ||
|
|
||
| <div class="box box-{{ $border_class }}"> | ||
|
|
||
| <!-- .box-header --> | ||
| <div class="box-header with-border"> | ||
| <h2 class="box-title"> | ||
| @if ($header_icon) | ||
| <x-icon type="{{ $header_icon }}" class="box-header-icon" /> | ||
| @endif | ||
| {{ ($item->id) ? $item->display_name : trans('general.create') }} | ||
| </h2> | ||
| </div> | ||
| <!-- /.box-header --> | ||
|
|
||
| <!-- box-body --> | ||
| <div class="box-body"> | ||
|
|
||
| {{ $slot }} | ||
|
|
||
| </div> | ||
| <!-- /.box-body --> | ||
|
|
||
| <div class="box-footer text-right"> | ||
| <button type="submit" class="btn btn-success"> | ||
| <x-icon type="checkmark" /> | ||
| {{ trans('general.save') }} | ||
| </button> | ||
| </div> | ||
| <!-- /.box-footer --> | ||
|
|
||
| </div> <!-- /.box-default --> | ||
|
|
||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <!-- Help Text --> | ||
| <div {{ $attributes->merge(['class' => 'col-md-8 col-md-offset-3']) }}> | ||
| <p class="help-block"> | ||
| {{ $slot }} | ||
| </p> | ||
| </div> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
|
|
||
| <!-- Info Tooltip --> | ||
| <div class="col-md-1 text-left" style="padding-left:0; margin-top: 5px;"> | ||
| <x-form-tooltip> | ||
| {{ $slot }} | ||
| </x-form-tooltip> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| @aware(['name']) | ||
|
|
||
| @props([ | ||
| 'class' => null, | ||
| 'new_model' => false, | ||
| 'category_type' => null, | ||
| 'modal_type' => false, | ||
| 'modal_id' => false, | ||
| ]) | ||
|
|
||
| <?php | ||
|
|
||
| // Let's set some sane defaults here for smaller fields | ||
| // This uses the form name to determine the appropriate class | ||
| switch ($name) { | ||
| case 'qty': | ||
| case 'min_amt': | ||
| case 'seats': | ||
| $class_override = $new_model ? 'col-md-3' : 'col-md-4'; | ||
| break; | ||
| case 'purchase_cost': | ||
| case 'purchase_date': | ||
| case 'termination_date': | ||
| case 'expiration_date': | ||
| case 'start_date': | ||
| case 'end_date': | ||
| $class_override = $new_model ? 'col-md-4' : 'col-md-5'; | ||
| break; | ||
| case 'model_number': | ||
| case 'item_no': | ||
| case 'order_number': | ||
| case 'purchase_order': | ||
| $class_override = $new_model ? 'col-md-5' : 'col-md-6'; | ||
| break; | ||
| default: | ||
| $class_override = $new_model ? 'col-md-7' : 'col-md-8'; | ||
| break; | ||
| } | ||
|
|
||
| // Use the explicit override if one is set | ||
| if ($class) { | ||
| $class_override = $class; | ||
| } | ||
| ?> | ||
| <!-- form-input blade component --> | ||
| <div {{ $attributes->merge(['class' => $class_override]) }}> | ||
| {{ $slot }} | ||
| </div> | ||
|
|
||
| @if ($new_model) | ||
| <div class="col-md-1 col-sm-1"> | ||
| @can('create', $new_model) | ||
| <a href='{{ route('modal.show',[ | ||
| 'type' => $modal_type ?? null, | ||
| 'category_type' => $category_type ?? null | ||
| ]) }}' data-toggle="modal" data-target="#createModal" data-select="{{ $modal_id }}" class="btn btn-sm btn-primary text-left">{{ trans('button.new') }}</a> | ||
| @endcan | ||
| </div> | ||
| @endif | ||
|
|
||
|
|
||
| @error($name) | ||
| <div class="col-md-8 col-md-offset-3"> | ||
| <span class="alert-msg" aria-hidden="true"> | ||
| <x-icon type="x" /> | ||
| {{ $message }} | ||
| </span> | ||
| </div> | ||
|
|
||
|
|
||
| @enderror |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| @aware(['name']) | ||
|
|
||
| <!-- form-label blade component --> | ||
| <label {{ $attributes->merge(['class' => 'control-label']) }}> | ||
| <label {{ $attributes->merge(['class' => 'control-label col-md-3']) }} for="{{ $name }}"> | ||
| {{ $slot }} | ||
| </label> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,9 @@ | ||
| <!-- form-row blade component --> | ||
| @props([ | ||
| 'name' => null, | ||
| 'type' => 'text', | ||
| 'item' => null, | ||
| 'info_tooltip_text' => null, | ||
| 'help_text' => null, | ||
| 'label' => null, | ||
| 'input_div_class' => 'col-md-8', | ||
| 'errors_class' => $errors->has('support_url') ? ' has-error' : '', | ||
| 'input_icon' => null, | ||
| 'input_group_addon' => null, | ||
| 'rows' => null, | ||
| 'placeholder' => null, | ||
| ]) | ||
|
|
||
| <div {{ $attributes->merge(['class' => 'form-group'. $errors_class]) }}> | ||
|
|
||
| <!-- form label --> | ||
| @if (isset($label)) | ||
| <x-form-label :for="$name" class="{{ $label_class ?? 'col-md-3' }}">{{ $label }}</x-form-label> | ||
| @endif | ||
|
|
||
|
|
||
| @php | ||
| $blade_type = in_array($type, ['text', 'email', 'url', 'tel', 'number', 'password']) ? 'text' : $type; | ||
| @endphp | ||
|
|
||
| <div class="{{ $input_div_class }}"> | ||
| <x-dynamic-component | ||
| :$name | ||
| :$type | ||
| :aria-label="$name" | ||
| :component="'input.'.$blade_type" | ||
| :id="$name" | ||
| :required="Helper::checkIfRequired($item, $name)" | ||
| :value="old($name, $item->{$name})" | ||
| :input_icon="$input_icon" | ||
| :input_group_addon="$input_group_addon" | ||
| :rows="$rows" | ||
| :placeholder="$placeholder" | ||
|
|
||
| /> | ||
| </div> | ||
|
|
||
| @if ($info_tooltip_text) | ||
| <!-- Info Tooltip --> | ||
| <div class="col-md-1 text-left" style="padding-left:0; margin-top: 5px;"> | ||
| <x-form-tooltip> | ||
| {{ $info_tooltip_text }} | ||
| </x-form-tooltip> | ||
| </div> | ||
| @endif | ||
|
|
||
|
|
||
| @error($name) | ||
| <div class="col-md-8 col-md-offset-3"> | ||
| <span class="alert-msg" aria-hidden="true"> | ||
| <x-icon type="x" /> | ||
| {{ $message }} | ||
| </span> | ||
| </div> | ||
| @enderror | ||
|
|
||
| @if ($help_text) | ||
| <!-- Help Text --> | ||
| <div class="col-md-8 col-md-offset-3"> | ||
| <p class="help-block"> | ||
| {!! $help_text !!} | ||
| </p> | ||
| </div> | ||
| @endif | ||
|
|
||
|
|
||
| <!-- form-row blade component --> | ||
| <div {{ $attributes->merge(['name' => $name]) }} class="form-group @error($name) has-error @enderror"> | ||
| {{ $slot }} | ||
| </div> | ||
|
|
||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @props([ | ||
| 'item' => null, | ||
| 'update_route' => null, | ||
| 'create_route' => null, | ||
| ]) | ||
|
|
||
| <form class="form-horizontal" id="create-form" method="post" action="{{ ($item->id) ? route($update_route, $item->id) : route($create_route) }}" autocomplete="off" enctype="multipart/form-data"> | ||
|
|
||
| @if ($item->id) | ||
| {{ method_field('PUT') }} | ||
| @endif | ||
|
|
||
| {{ $slot }} | ||
|
|
||
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,31 @@ | ||
| @aware(['name']) | ||
|
|
||
| @props([ | ||
| 'value' => '', | ||
| 'required' => '', | ||
| 'value' => null, | ||
| 'required' => false, | ||
| 'end_date' => null, | ||
| 'col_size_class' => null, | ||
| 'name' => null, | ||
| ]) | ||
|
|
||
| <!-- Datepicker --> | ||
| <div class="input-group date {{ $col_size_class }}" data-provide="datepicker" data-date-today-highlight="true" data-date-language="{{ auth()->user()->locale }}" data-date-locale="{{ auth()->user()->locale }}" data-date-format="yyyy-mm-dd" data-date-autoclose="true" data-date-clear-btn="true"{{ $end_date ? ' data-date-end-date=' . $end_date : '' }}> | ||
| <input type="text" placeholder="{{ trans('general.select_date') }}" value="{{ $value }}" maxlength="10" {{ $attributes->merge(['class' => 'form-control']) }} {{ $required=='1' ? 'required' : '' }}> | ||
| <div | ||
| {{ $attributes->merge(['class' => 'input-group date']) }} | ||
| data-provide="datepicker" | ||
| data-date-today-highlight="true" | ||
| data-date-language="{{ auth()->user()->locale }}" | ||
| data-date-locale="{{ auth()->user()->locale }}" | ||
| data-date-format="yyyy-mm-dd" | ||
| data-date-autoclose="true" | ||
| data-date-clear-btn="true"{{ $end_date ? ' data-date-end-date=' . $end_date : '' }}> | ||
|
|
||
| <input | ||
| type="text" | ||
| name="{{ $name }}" | ||
| placeholder="{{ trans('general.select_date') }}" | ||
| value="{{ $value }}" maxlength="10" | ||
| {{ $attributes->merge(['class' => 'form-control']) }} | ||
| {{ $required ? ' required' : '' }} | ||
| > | ||
| <span class="input-group-addon"><x-icon type="calendar" /></span> | ||
|
|
||
| </div> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely need to check this and make sure it won't introduce XSS issues, etc.