Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gammamatrix committed Dec 23, 2024
1 parent 3985f7b commit 7294650
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 229 deletions.
52 changes: 52 additions & 0 deletions resources/views/layouts/resource/detail-actions.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@if ($withDelete || $withEdit)
<div class="btn-group float-end" role="group"
aria-label="{{ $meta['info']['model_label'] }} Controls and Actions">
<button id="detail-actions" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"
aria-expanded="false">
<span class="fas fa-gear"></span> {{ __('Actions') }}
</button>
<ul class="dropdown-menu" aria-labelledby="detail-actions">
@if($data->trashed())
<form method="POST" action="{{ $routeRestore }}" novalidate>
@csrf
@method('put')
<button class="dropdown-item text-success" role="button">
{{ __('Restore') }} <span class="fa-solid fa-recycle float-end"></span>
</button>
</form>
@else
@if(!$data->locked)
<a class="dropdown-item text-success" href="{{ $routeEdit }}" role="button">
{{ __('Edit') }} <span class="fas fa-edit float-end"></span>
</a>
@endif
@endif
@if($data->locked)
<form method="POST" action="{{ $routeUnlock }}" novalidate>
@csrf
@method('delete')
<button class="dropdown-item text-warning" role="button">
{{ __('Unlock') }} <span class="fa-solid fa-lock-open float-end"></span>
</button>
</form>
@else
@if(!$data->trashed())
<form method="POST" action="{{ $routeLock }}" novalidate>
@csrf
@method('put')
<button class="dropdown-item text-warning" role="button">
{{ __('Lock') }} <i class="fa-solid fa-lock float-end"></i>
</button>
</form>
<form method="POST" action="{{ $routeDelete }}" novalidate>
@csrf
@method('delete')
<button class="dropdown-item text-danger" role="button">
{{ __('Trash') }} <span class="fas fa-trash float-end"></span>
</button>
</form>
@endif
@endif
</ul>
</div>
@endif
34 changes: 34 additions & 0 deletions resources/views/layouts/resource/detail-card.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="card my-1">
@if($withCardHeader)
<div class="card-header">
@include('playground::layouts.resource.detail-actions')
<h1>{{ $data->getAttributeValue($meta['info']['model_attribute']) }}</h1>
</div>
@endif
@if ($withImage && $data && $data->image)
<div class="card-header">
<img class="card-img-top" src="{{ $data->image }}" alt="{{ $meta['info']['model_label'] }} Image">
</div>
@endif
@if($withCardBody)
<div class="card-body">
@yield('detail-card-body-header')
@yield('detail-card-body')
@includeWhen($withInfo, 'playground::layouts.resource.detail-info')
@yield('detail-card-body-footer')
</div>
@endif

@if($withCardFlags)
<div class="card-footer">
@yield('detail-information-flags')
</div>
@endif

@if($withCardTimestamps)
<div class="card-footer">
@include('playground::layouts.resource.detail-timestamps')
</div>
@endif

</div>
17 changes: 17 additions & 0 deletions resources/views/layouts/resource/detail-flags.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@if(!empty($data) && $data->deleted_at)
<span class="badge text-bg-danger">
<i class="fas fa-trash"></i>
{{ __('Trashed') }}
</span>
@endif

@if(!empty($flags) && is_array($flags))
@foreach ($flags as $flagKey => $flagMeta)
@if ($data->getAttribute($flagKey))
<span class="badge {{$flagMeta['badge'] ?? 'text-bg-secondary'}}">
<i class="{{$flagMeta['icon'] ?? ''}}"></i>
{{ __($flagMeta['label']) }}
</span>
@endif
@endforeach
@endif
48 changes: 48 additions & 0 deletions resources/views/layouts/resource/detail-info.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<table class="table">
<tbody>
@yield('detail-info-table-header')
<tbody>
<tr>
<th scope="row">{{ __('Slug') }}</th>
<td>{{ $data->slug }}</td>
</tr>
@yield('detail-info-table-body')
@if ($parent)
<tr>
<th scope="row">{{ __('Parent ' . $meta['info']['model_label']) }}</th>
<td>
<a
href="{{ route(sprintf('%1$s.show', $meta['info']['model_route']), [$meta['info']['model_slug'] => $parent->id]) }}">
{{ $parent->label }}
</a>
</td>
</tr>
@endif
</tbody>
@yield('detail-info-table-header')
</tbody>
</table>

@if ($data->description)
<h4>{{ __('Description') }}</h4>

<div class="description">{{ $data->description }}</div>
@endif

@if ($data->introduction)
<h4>{{ __('Introduction') }}</h4>

<div class="introduction">{{ $data->introduction }}</div>
@endif

@if ($data->content)
<h4>{{ __('Content') }}</h4>

<div class="content">{!! $data->content !!}</div>
@endif

@if ($data->summary)
<h4>{{ __('Summary') }}</h4>

<div class="summary">{!! $data->summary !!}</div>
@endif
130 changes: 0 additions & 130 deletions resources/views/layouts/resource/detail-information.blade.php

This file was deleted.

45 changes: 45 additions & 0 deletions resources/views/layouts/resource/detail-tables.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@if ($hasTables)
@foreach ($dataDetail['tables'] as $table)
<div class="row" id="{{ sprintf('section-%1$s-%2$s', $meta['info']['model_slug'], $table) }}">
@php
$hasTable = is_string($table) && !empty($dataDetail[$table]) && !empty($dataDetail[$table]['label']) && !empty($$table) && is_object($$table);
@endphp
@continue(!$hasTable)
@php
if (!empty($dataDetail[$table]['table']) && is_array($dataDetail[$table]['table'])) {
$components_table = $dataDetail[$table]['table'];
$components_table['paginator'] = $$table;
} else {
$components_table = [
'columns' => [
$meta['info']['model_attribute'] => [
'label' => ucfirst($meta['info']['model_attribute']),
],
'slug' => [
// 'linkType' => 'slug',
// 'linkRoute' => 'slug',
'label' => 'Slug',
],
],
'modelActions' => true,
'routeEdit' => sprintf('%1$s.edit', $meta['info']['model_route']),
'paginator' => $$table,
'styling' => [
'header' => [
'class' => 'mt-3',
],
],
];
}
@endphp
<div class="row">
<div class="col-md-12">
@component(sprintf('%1$scomponents/table', $package_config['view']), $components_table)
{{ $dataDetail[$table]['label'] }}
@endcomponent
</div>
</div>

</div>
@endforeach
@endif
20 changes: 20 additions & 0 deletions resources/views/layouts/resource/detail-timestamps.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<ul class="list-group list-group-flush">
@if ($data->created_at)
<li class="list-group-item">
{{ __('Created') }}:
<time datetime="{{ $data['created_at']->toW3cString() }}">{{ $data['created_at']->toDayDateTimeString() }}</time>
</li>
@endif
@if ($data->updated_at)
<li class="list-group-item">
{{ __('Updated') }}:
<time datetime="{{ $data['updated_at']->toW3cString() }}">{{ $data['updated_at']->toDayDateTimeString() }}</time>
</li>
@endif
@if ($data->deleted_at)
<li class="list-group-item">
{{ __('Deleted') }}:
<time datetime="{{ $data['deleted_at']->toW3cString() }}">{{ $data['deleted_at']->toDayDateTimeString() }}</time>
</li>
@endif
</ul>
Loading

0 comments on commit 7294650

Please sign in to comment.