-
-
Notifications
You must be signed in to change notification settings - Fork 328
/
Copy pathfield-details.blade.php
69 lines (69 loc) · 2.93 KB
/
field-details.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@php
$html ??= []; $class = $html['class'] ?? null;
@endphp
<b style="line-height: 2;"><code>{{ $name }}</code></b>
@if($type)<small>{{ $type }}</small>@endif
@if($isInput && !$required)<i>optional</i>@endif
@if($isInput && empty($hasChildren))
@php
$isList = Str::endsWith($type, '[]');
$fullName = str_replace('[]', '.0', $fullName ?? $name);
$baseType = $isList ? substr($type, 0, -2) : $type;
// Ignore the first '[]': the frontend will take care of it
while (\Str::endsWith($baseType, '[]')) {
$fullName .= '.0';
$baseType = substr($baseType, 0, -2);
}
// When the body is an array, the item names will be ".0.thing"
$fullName = ltrim($fullName, '.');
$inputType = match($baseType) {
'number', 'integer' => 'number',
'file' => 'file',
default => 'text',
};
@endphp
@if($type === 'boolean')
<label data-endpoint="{{ $endpointId }}" style="display: none">
<input type="radio" name="{{ $fullName }}"
value="{{$component === 'body' ? 'true' : 1}}"
data-endpoint="{{ $endpointId }}"
data-component="{{ $component }}" @if($class)class="{{ $class }}"@endif
>
<code>true</code>
</label>
<label data-endpoint="{{ $endpointId }}" style="display: none">
<input type="radio" name="{{ $fullName }}"
value="{{$component === 'body' ? 'false' : 0}}"
data-endpoint="{{ $endpointId }}"
data-component="{{ $component }}" @if($class)class="{{ $class }}"@endif
>
<code>false</code>
</label>
@elseif($isList)
<input type="{{ $inputType }}" style="display: none"
name="{{ $fullName."[0]" }}" @if($class)class="{{ $class }}"@endif
data-endpoint="{{ $endpointId }}"
data-component="{{ $component }}">
<input type="{{ $inputType }}" style="display: none"
name="{{ $fullName."[1]" }}" @if($class)class="{{ $class }}"@endif
data-endpoint="{{ $endpointId }}"
data-component="{{ $component }}">
@else
<input type="{{ $inputType }}" style="display: none"
name="{{ $fullName }}" @if($class)class="{{ $class }}"@endif
data-endpoint="{{ $endpointId }}"
value="{!! (isset($example) && (is_string($example) || is_numeric($example))) ? $example : '' !!}"
data-component="{{ $component }}">
@endif
@endif
<br>
@php
if($example !== null && $example !== '' && !is_array($example)) {
$exampleAsString = $example;
if (is_bool($example)) {
$exampleAsString = $example ? "true" : "false";
}
$description .= " Example: `$exampleAsString`";
}
@endphp
{!! Parsedown::instance()->text(trim($description)) !!}