Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Nov 27, 2021
1 parent a7a4140 commit 6b7c11d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 44 deletions.
10 changes: 5 additions & 5 deletions resources/stubs/table.fillable.stub
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use PowerComponents\LivewirePowerGrid\Traits\ActionButton;
final class {{ componentName }} extends PowerGridComponent
{
use ActionButton;

//Messages informing success/error data is updated.
public bool $showUpdateMessages = true;

Expand Down Expand Up @@ -110,19 +110,19 @@ final class {{ componentName }} extends PowerGridComponent
*
* @return array<int, \PowerComponents\LivewirePowerGrid\Button>
*/

/*
public function actions(): array
{
return [
Button::add('edit')
->caption('Edit')
->class('bg-indigo-500 text-white')
->class('bg-indigo-500 cursor-pointer text-white px-3 py-2.5 m-1 rounded text-sm')
->route('{{ modelKebabCase }}.edit', ['{{ modelKebabCase }}' => 'id']),

Button::add('destroy')
->caption('Delete')
->class('bg-red-500 text-white')
->class('bg-red-500 cursor-pointer text-white px-3 py-2 m-1 rounded text-sm')
->route('{{ modelKebabCase }}.destroy', ['{{ modelKebabCase }}' => 'id'])
->method('delete')
];
Expand All @@ -143,7 +143,7 @@ final class {{ componentName }} extends PowerGridComponent
*
* @param array<string,string> $data
*/

/*
public function update(array $data ): bool
{
Expand Down
10 changes: 5 additions & 5 deletions resources/stubs/table.model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use PowerComponents\LivewirePowerGrid\Traits\ActionButton;
final class {{ componentName }} extends PowerGridComponent
{
use ActionButton;

//Messages informing success/error data is updated.
public bool $showUpdateMessages = true;

Expand Down Expand Up @@ -140,19 +140,19 @@ final class {{ componentName }} extends PowerGridComponent
*
* @return array<int, \PowerComponents\LivewirePowerGrid\Button>
*/

/*
public function actions(): array
{
return [
Button::add('edit')
->caption('Edit')
->class('bg-indigo-500 text-white')
->class('bg-indigo-500 cursor-pointer text-white px-3 py-2.5 m-1 rounded text-sm')
->route('{{ modelKebabCase }}.edit', ['{{ modelKebabCase }}' => 'id']),

Button::add('destroy')
->caption('Delete')
->class('bg-red-500 text-white')
->class('bg-red-500 cursor-pointer text-white px-3 py-2 m-1 rounded text-sm')
->route('{{ modelKebabCase }}.destroy', ['{{ modelKebabCase }}' => 'id'])
->method('delete')
];
Expand All @@ -173,7 +173,7 @@ final class {{ componentName }} extends PowerGridComponent
*
* @param array<string,string> $data
*/

/*
public function update(array $data ): bool
{
Expand Down
22 changes: 11 additions & 11 deletions resources/views/components/actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
'theme' => null,
'row' => null
])
<div class="w-full md:w-auto">
@if(isset($actions) && count($actions) && $row !== '')
@foreach($actions as $key => $action)
<td wire:key="action-{{ $key }}" class="pg-actions {{ $theme->table->tdBodyClass }}"
style="{{ $theme->table->tdBodyStyle }}">
@if(isset($actions) && count($actions) && $row !== '')
@foreach($actions as $key => $action)
<td wire:key="action-{{ $key }}" class="pg-actions {{ $theme->table->tdBodyClass }}"
style="{{ $theme->table->tdBodyStyle }}">
<div class="w-full md:w-auto">
@php
foreach ($action->param as $param => $value) {
if (!empty($row->{$value})) {
Expand Down Expand Up @@ -36,19 +36,19 @@ class="{{ filled($action->class) ? $action->class : $theme->actions->headerBtnCl
@method($action->method)
@csrf
<button type="submit"
class="{{ filled( $action->class) ? $action->class : $theme->actions->headerBtnClass }}">
class="{{ filled( $action->class) ? $action->class : $theme->actions->headerBtnClass }}">
{!! $action->caption ?? '' !!}
</button>
</form>
@else
<a href="{{ route($action->route, $parameters) }}"
target="{{ $action->target }}"
target="{{ $action->target }}"
class="{{ filled($action->class) ? $action->class : $theme->actions->headerBtnClass }}">
{!! $action->caption !!}
</a>
@endif
@endif
</td>
@endforeach
@endif
</div>
</div>
</td>
@endforeach
@endif
42 changes: 21 additions & 21 deletions resources/views/components/row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
'columns' => null,
'currentTable' => null,
])
<div>
@foreach($columns as $column)
@php
$content = $row->{$column->field};
$content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
@endphp
@if($column->hidden === false)
<td class="{{ $theme->table->tdBodyClass . ' '.$column->bodyClass ?? '' }}"
style=" {{ $theme->table->tdBodyStyle . ' '.$column->bodyStyle ?? '' }}"
>
@if($column->editable === true)
<span class="{{ $theme->editable->spanClass }}">

@foreach($columns as $column)
@php
$content = $row->{$column->field};
$content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
@endphp
@if($column->hidden === false)
<td class="{{ $theme->table->tdBodyClass . ' '.$column->bodyClass ?? '' }}"
style=" {{ $theme->table->tdBodyStyle . ' '.$column->bodyStyle ?? '' }}"
>
@if($column->editable === true)
<span class="{{ $theme->editable->spanClass }}">
<x-livewire-powergrid::editable
:primaryKey="$primaryKey"
:currentTable="$currentTable"
Expand All @@ -31,10 +31,10 @@
:enabled="$column->click_to_copy['enabled'] ?? false"/>
</span>

@elseif(count($column->toggleable) > 0)
@include($theme->toggleable->view)
@else
<span class="flex justify-between">
@elseif(count($column->toggleable) > 0)
@include($theme->toggleable->view)
@else
<span class="flex justify-between">
<div>
{!! $content !!}
</div>
Expand All @@ -44,8 +44,8 @@
:label="data_get($column->clickToCopy, 'label') ?? null"
:enabled="data_get($column->clickToCopy, 'enabled') ?? false"/>
</span>
@endif
</td>
@endif
@endforeach
</div>
@endif
</td>
@endif
@endforeach

2 changes: 1 addition & 1 deletion resources/views/components/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'theme' => null
])
<div class="relative">
<select >
<select>
<option value="">{{ $empty }}</option>
@foreach($data as $value => $label)
<option wire:key="{{ md5($field->key.$value) }}" value="{{ $value }}">{{ $label }}</option>
Expand Down
6 changes: 5 additions & 1 deletion src/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PowerComponents\LivewirePowerGrid\Commands;

use Exception;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\File;
Expand All @@ -12,13 +13,16 @@ class PublishCommand extends Command

protected $description = 'Publish table stub';

/**
* @throws Exception
*/
public function handle(): void
{
if ($this->option('type') === 'job') {
$exportJobFile = __DIR__ . '/../Jobs/ExportJob.php';

if (File::exists($exportJobFile) === false && File::isReadable($exportJobFile) === true) {
throw new \Exception('ExportJob.php not found.');
throw new Exception('ExportJob.php not found.');
}

$file = (string) file_get_contents($exportJobFile);
Expand Down

0 comments on commit 6b7c11d

Please sign in to comment.