Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
v73.0.0
  • Loading branch information
gammamatrix authored Dec 28, 2024
1 parent 3985f7b commit 08c7a18
Show file tree
Hide file tree
Showing 25 changed files with 705 additions and 268 deletions.
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
],
"require": {
"php": "^8.2",
"gammamatrix/playground": "dev-develop|dev-master|dev-feature/*|^73.0@dev|^73.0"
"gammamatrix/playground": "*"
},
"require-dev": {
"gammamatrix/playground-auth": "dev-develop|dev-master|dev-feature/*|^73.0@dev|^73.0",
"gammamatrix/playground-test": "dev-develop|dev-master|dev-feature/*|^73.0@dev|^73.0"
"gammamatrix/playground-auth": "*",
"gammamatrix/playground-test": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -47,8 +47,7 @@
},
"extra": {
"branch-alias": {
"dev-develop": "73.x-dev",
"dev-master": "73.x-dev"
"dev-develop": "73.x-dev"
},
"laravel": {
"providers": [
Expand Down
2 changes: 2 additions & 0 deletions config/playground-blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

return [
'about' => (bool) env('PLAYGROUND_BLADE_ABOUT', true),
'app' => [
'name' => env('PLAYGROUND_BLADE_APP_NAME', 'Demo'),
'url' => env('PLAYGROUND_BLADE_APP_URL', '/'),
Expand All @@ -11,6 +12,7 @@
'view' => env('PLAYGROUND_BLADE_VIEW', 'playground::'),
'load' => [
'views' => (bool) env('PLAYGROUND_BLADE_LOAD_VIEWS', true),
'translations' => (bool) env('PLAYGROUND_BLADE_LOAD_TRANSLATIONS', true),
],
'session' => [
'enable' => (bool) env('PLAYGROUND_BLADE_SESSION_ENABLE', true),
Expand Down
26 changes: 26 additions & 0 deletions lang/en/pagination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| Used for submitting the form on the table index.
|
| @see \Playground\Blade\View\Components\Table\Data
*/

'previous' => '&laquo; Previous',
'next' => 'Next &raquo;',

'go' => 'Go',

'form.label' => 'Pagination Options',

'show' => 'Showing page :currentPage of :lastPage with :perPage per page.',

'row.actions.label' => 'Record Controls and Actions',

];
35 changes: 30 additions & 5 deletions resources/views/components/forms/column-select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
// '__METHOD__' => __METHOD__,
// '__FILE__' => __FILE__,
// '__LINE__' => __LINE__,
// '$flags' => $flags,
// '$key' => $key,
// '$column' => $column,
// '$records' => $records,
Expand All @@ -66,10 +67,14 @@
<div class="{{ trim(sprintf('%s %s %s', $withoutMargin, $advanced, $class)) }}">
<div class="input-group my-3">
@if (empty($column))
<div class="alert alert-danger">Expecting a column for the form select.</div>
<div class="alert alert-danger">
Expecting a column for the form select.
</div>
@endif
@if ($label)
<label class="input-group-text" for="form-input-{{ $column }}">{{ $label }}</label>
<label class="input-group-text" for="form-input-{{ $column }}">
{{ $label }}
</label>
@endif
<select class="form-select @error($column) is-invalid @enderror" value="{{ $oldValue }}"
{!! $required !!}{!! $attributes !!}>
Expand All @@ -78,7 +83,23 @@
@endif
@foreach ($records as $record)
<option value="{{ $record[$id] }}" @if ($record[$id] === $oldValue) selected @endif>
{{ $record[$key] }}</option>
@if (!empty($flags) && is_array($flags))
@foreach ($flags as $flagKey => $flagMeta)
@if (array_key_exists($flagKey, $record) && is_bool($record[$flagKey]))
@if ($record[$flagKey])
@if (!empty($flagMeta['enabled']))
{{ $flagMeta['enabled'] }} -
@endif
@else
@if (!empty($flagMeta['disabled']))
{{ $flagMeta['disabled'] }} -
@endif
@endif
@endif
@endforeach
@endif
{{ $record[$key] }}
</option>
@endforeach
</select>
</div>
Expand All @@ -88,11 +109,15 @@
</div>
@else
@error($column)
<div class="invalid-feedback" id="form-input-error-{{ $column }}">{{ $message }}</div>
<div class="invalid-feedback" id="form-input-error-{{ $column }}">
{{ $message }}
</div>
@enderror
@endif
@if ($described)
<small id="form-input-help-{{ $column }}" class="form-text text-muted">{!! $described !!}</small>
<small id="form-input-help-{{ $column }}" class="form-text text-muted">
{!! $described !!}
</small>
@endif
{{ $slot }}
</div>
44 changes: 44 additions & 0 deletions resources/views/components/model/image.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@if(empty($fkModelData))
{{$value}}
@else
@php
$withInitials = !empty($columnMeta['with-initials']) && is_bool($columnMeta['with-initials']);
$withName = !empty($columnMeta['with-name']) && is_bool($columnMeta['with-name']);
$hasAvatar = !empty($fkModelData['avatar']) && is_string($fkModelData['avatar']);
$hasImage = !empty($fkModelData['image']) && is_string($fkModelData['image']);
$property = !empty($columnMeta['property']) && is_string($columnMeta['property']) ? $columnMeta['property'] : '';
$width = 36;
$image = '';
$initials = '';
$name = !empty($fkModelData[$property]) && is_string($fkModelData[$property]) ? $fkModelData[$property] : '';
if ($name) {
$initials = preg_filter('/[^A-Z]/', '', $name);
if (mb_strlen($initials) > 2) {
$initials = mb_substr($initials, 0, 1).mb_substr($initials, -1);
}
}
if ($hasAvatar) {
$image = $fkModelData['avatar'];
} elseif ($hasImage) {
$image = $fkModelData['image'];
}
@endphp
@if($image)
<img src="{{$image}}" class="rounded-circle" alt="Avatar" width="{{$width}}" height="{{$width}}">
@elseif($initials)
<span class="rounded-circle" width="{{$width}}">
{{$initials}}
</span>
@endif

@if($withName && $name)
<span data-model-id="{{$value}}">{{$name}}</span>
@endif

@endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
$columns = [
'all' => [
'label' => 'All',
],
'standard' => [
'label' => 'Standard',
],
'mobile' => [
'label' => 'Mobile',
],
];
$viewableColumns = 'standard';
if (!empty($validated)
&& !empty($validated['columns'])
&& is_string($validated['columns'])
&& in_array($validated['columns'], array_keys($columns))
) {
$viewableColumns = $validated['columns'];
}
// dd([
// '$viewableColumns' => $viewableColumns,
// '$validated' => $validated,
// '$columns' => $columns,
// '$meta' => $meta,
// ])
?>
<fieldset class="mb-3" id="{{ $id }}-fieldset-filter-columns">
<legend>
Filter Columns
</legend>

<div class="container collapse show">
<div class="row">

<div class="col">
<div class="input-group mb-3">

@foreach($columns as $column => $columnMeta)
<div class="form-check me-2">
<input class="form-check-input" type="radio" name="columns" id="filter_columns_{{$column}}"
{{ $column === $viewableColumns ? 'checked' : '' }} value="{{$column}}">
<label class="form-check-label" for="filter_columns_{{$column}}">
{{$columnMeta['label'] ?? 'view' }}
</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
}
?>
<fieldset class="mb-3" id="{{ $id }}-fieldset-filter-ids">
<fieldset class="mb-3" id="{{ $id }}-fieldset-filter-trash">
<legend>
Filter Trash
</legend>
Expand Down
2 changes: 2 additions & 0 deletions resources/views/components/table/data-form-filter.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
</button>
</div>

@include('playground::components/table/data-form-filter-columns')

@includeWhen($trashable, 'playground::components/table/data-form-filter-trash')

@includeWhen(!empty($meta['ids']), 'playground::components/table/data-form-filter-ids')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<fieldset class="mb-3">

<legend>{{ __('playground::pagination.form.label') }}</legend>
<legend>{{ __('playground-blade::pagination.form.label') }}</legend>

<div class="input-group mb-3">

<label class="input-group-text" for="form_per_page">
{{ __('playground::pagination.show', [
{{ __('playground-blade::pagination.show', [
'currentPage' => $paginator->currentPage(),
'lastPage' => $paginator->lastPage(),
'perPage' => $paginator->perPage(),
Expand All @@ -28,7 +28,7 @@
</span>

<button type="submit" class="btn btn-success">
{{ __('playground::pagination.go') }}
{{ __('playground-blade::pagination.go') }}
</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<th>
<div class="text-nowrap" role="group" aria-label="{{ __('playground::pagination.row.actions.label') }}">
<div class="text-nowrap" role="group" aria-label="{{ __('playground-blade::pagination.row.actions.label') }}">
@if ($withUnlock && !empty($record['locked']) && $routeUnlock)
@include('playground::components/table/data-row-actions-unlock')
@else
Expand Down
30 changes: 23 additions & 7 deletions resources/views/components/table/data-row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
$routeParameter = !empty($routeParameter) && is_string($routeParameter) ? $routeParameter : '';
$record = !empty($record) && is_array($record) ? $record : [];
$fkModelData = [];
$hasColumnError = false;
/**
Expand Down Expand Up @@ -63,7 +65,7 @@
/**
* @var string $isFk Is the column a foreign key?
*/
$isFk = 'fk' === $columnMeta['linkType'];
$isFk = in_array($columnMeta['linkType'], ['fk', 'filter-id']);
// The foreign key needs a property to access.
$isFk = $isFk && isset($columnMeta['property']) && !empty($columnMeta['property']);
if ($preferLinkSlug) {
Expand All @@ -85,7 +87,10 @@
// '$isUrlLink' => $isUrlLink,
// '$link' => $link,
// '$record' => $record,
// '$datum' => $datum,
// // '$datum' => $datum,
// '$routeParameter' => $routeParameter,
// '$routeParameterKey' => $routeParameterKey,
// '$record[$routeParameterKey]' => $record[$routeParameterKey] ?? 'nope',
// ]);
// Check for slug link first.
Expand All @@ -98,7 +103,11 @@
} elseif ($preferLinkGo) {
$link = empty($record[$routeParameterKey]) ? '' : route($columnMeta['linkRoute'], ['go' => $record[$routeParameterKey]]);
} elseif ($isFk) {
$link = empty($record[$column]) ? '' : route($columnMeta['linkRoute'], [$routeParameter => $record[$column]]);
if (!empty($record[$column]) && !empty($columnMeta['routeParameter']) && !empty($columnMeta['routeParameterKey'])) {
$link = route($columnMeta['linkRoute'], [
$columnMeta['routeParameter'] => $record[$columnMeta['routeParameterKey']],
]);
}
}
if ($isUrlLink) {
Expand All @@ -117,17 +126,21 @@
// '$isFk' => $isFk,
// '$isUrlLink' => $isUrlLink,
// '$link' => $link,
// '$record' => $record,
// '$datum' => $datum,
// // '$record' => $record,
// // '$datum' => $datum,
// ]);
if ($isFk && !empty($accessor)) {
try {
$fkModel = $datum && is_callable([$datum, $accessor]) ? $datum->{$accessor}()->first() : null;
if ($fkModel) {
$fkModelData = $fkModel->toArray();
if (!empty($property) && isset($fkModelData[$property])) {
$value = $fkModelData[$property];
if (!empty($property)) {
if ($property === 'label_or_title') {
$value = $fkModel->label_or_title;
} elseif (isset($fkModelData[$property])) {
$value = $fkModelData[$property];
}
}
}
} catch (\Throwable $th) {
Expand Down Expand Up @@ -170,6 +183,7 @@
}
$isFlag = isset($columnMeta['flag']) && is_bool($columnMeta['flag']) && $columnMeta['flag'];
$withImage = isset($columnMeta['with-image']) && is_bool($columnMeta['with-image']) && $columnMeta['with-image'];
// dump([
// '__METHOD__' => __METHOD__,
Expand All @@ -195,6 +209,8 @@ class="{{ !empty($hasColumnError) ? 'text-danger ' : '' }}{{ !empty($columnMeta[

@if ($isFlag)
<x-playground::model-flag :$columnMeta :$value />
@elseif ($withImage)
<x-playground::model-image :$columnMeta :$fkModelData :$value />
@elseif ($columnMeta['html'])
{!! $value !!}
@elseif ($isDate)
Expand Down
Loading

0 comments on commit 08c7a18

Please sign in to comment.