field-details.blade.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <b><code>{{ $name }}</code></b>&nbsp;&nbsp;@if($type)<small>{{ $type }}</small>@endif @if(!$required)
  2. <i>optional</i>@endif &nbsp;
  3. @if(($isInput ?? true) && empty($hasChildren))
  4. @php
  5. $isList = Str::endsWith($type, '[]');
  6. $fullName =str_replace('[]', '.0', $name);
  7. $baseType = $isList ? substr($type, 0, -2) : $type;
  8. // Ignore the first '[]': the frontend will take care of it
  9. while (\Str::endsWith($baseType, '[]')) {
  10. $fullName .= '.0';
  11. $baseType = substr($baseType, 0, -2);
  12. }
  13. // When the body is an array, the item names will be ".0.thing"
  14. $fullName = ltrim($fullName, '.');
  15. switch($baseType) {
  16. case 'number':
  17. case 'integer':
  18. $inputType = 'number';
  19. break;
  20. case 'file':
  21. $inputType = 'file';
  22. break;
  23. default:
  24. $inputType = 'text';
  25. }
  26. @endphp
  27. @if($type === 'boolean')
  28. <label data-endpoint="{{ $endpointId }}" hidden>
  29. <input type="radio" name="{{ $fullName }}"
  30. value="{{$component === 'body' ? 'true' : 1}}"
  31. data-endpoint="{{ $endpointId }}"
  32. data-component="{{ $component }}" @if($required)required @endif
  33. >
  34. <code>true</code>
  35. </label>
  36. <label data-endpoint="{{ $endpointId }}" hidden>
  37. <input type="radio" name="{{ $fullName }}"
  38. value="{{$component === 'body' ? 'false' : 0}}"
  39. data-endpoint="{{ $endpointId }}"
  40. data-component="{{ $component }}" @if($required)required @endif
  41. >
  42. <code>false</code>
  43. </label>
  44. @elseif($isList)
  45. <input type="{{ $inputType }}"
  46. name="{{ $fullName.".0" }}"
  47. data-endpoint="{{ $endpointId }}"
  48. data-component="{{ $component }}" @if($required)required @endif hidden>
  49. <input type="{{ $inputType }}"
  50. name="{{ $fullName.".1" }}"
  51. data-endpoint="{{ $endpointId }}"
  52. data-component="{{ $component }}" hidden>
  53. @else
  54. <input type="{{ $inputType }}"
  55. name="{{ $fullName }}"
  56. data-endpoint="{{ $endpointId }}"
  57. value="{{ $example }}"
  58. data-component="{{ $component }}" @if($required)required @endif hidden>
  59. @endif
  60. @endif
  61. <br>
  62. {!! Parsedown::instance()->text($description) !!}