Skip to content

Commit

Permalink
Merge pull request #15 from lara-zeus/trans
Browse files Browse the repository at this point in the history
imporvments
  • Loading branch information
atmonshi authored Sep 1, 2022
2 parents f9f350b + 889b13e commit d74b322
Show file tree
Hide file tree
Showing 27 changed files with 673 additions and 492 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"php": "^8.0",
"codeat3/blade-clarity-icons": "^1.7",
"filament/notifications": "^2.0",
"filament/spatie-laravel-translatable-plugin": "^2.0",
"lara-zeus/core": "^2.2"
},
"require-dev": {
Expand Down
425 changes: 280 additions & 145 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions config/zeus-bolt.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@
'disk' => 'public',
'directory' => 'logos',
],

/**
* available locales, this currently used only in tags manager.
*/
'translatable_Locales' => ['en', 'ar'],
];
4 changes: 2 additions & 2 deletions database/migrations/create_forms_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class CreateFormsTable extends Migration
Schema::create('forms', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users');
$table->foreignId('category_id')->constrained('categories');
$table->foreignId('category_id')->nullable()->constrained('categories');
$table->text('name');
$table->string('slug');
$table->string('layout');
$table->integer('ordering');
$table->integer('ordering')->default(1);
$table->boolean('is_active');
$table->text('desc')->nullable();
$table->longText('details')->nullable();
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"User must be logged in or create an account before can submit a new entry": "اجبار المستخدمين على تسجيل الدخول قبل تعبئة النموذج",
"One Entry Per User": "ادخال واحد فقط لكل مستخدم",
"to check if the user already submitted an entry in this form": "يتم منع المستخدمين من اكمال النموذج عدة مرات",
"Sections To Pages": "عرض الاقسام كصفحات",
"Show As Wizard": "عرض كخظوات",
"instead of showing all section in one page, separate them in multiple pages with next and previous buttons": "عوضا عن عرض كافة الاقسام في صفحة واحدة هذا الخيار يعرض النموذج في صفحات منفضلة مع عرض التالي والسابق",
"Form Name": "عنوان النموذج",
"Form Slug": "الرابط المختصر",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<x-forms::field-wrapper
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
>
<div class="space-y-4" x-data="{ state: $wire.entangle('{{ $getStatePath() }}') }">

<div class="flex justify-between gap-4">
<x-filament::card class="w-full">
<x-filament::card.heading>User Details</x-filament::card.heading>
<p>
<span class="text-base font-light">{{ __('By') }}</span>:
{{ ($getRecord()->user->name) ?? '' }}
</p>
<p>
<span class="text-base font-light">{{ __('created at') }}</span>:
<span class="font-semibold">{{ $getRecord()->created_at->format('Y.m/d') }}-{{ $getRecord()->created_at->format('h:i a') }}</span>
</p>
</x-filament::card>
<x-filament::card class="w-full">
<x-filament::card.heading>Form Details</x-filament::card.heading>
<p>{{ ($getRecord()->form->name) ?? '' }}</p>
<p>{{ ($getRecord()->form->desc) ?? '' }}</p>
</x-filament::card>
</div>

<x-filament::card>
<x-filament::card.heading>Respons Details</x-filament::card.heading>
@foreach($getRecord()->fieldsResponses as $resp)
<div class="py-2">
<p>{{ $resp->field->name }}</p>
<p class="font-semibold mb-2">{{ $resp->response ?? ''}}</p>
<x-filament::hr />
</div>
@endforeach
</x-filament::card>
</div>
</x-forms::field-wrapper>
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
<x-filament::page>
<x-filament::card>
@forelse ($rows as $row)
<x-slot name="header">
<div>
<p>
<span class="text-base font-light">{{ __('From') }}</span>:
{{ ($row->user->name) ?? '' }}
</p>
<p>
<span class="text-base font-light">{{ __('created at') }}</span>:
<span class="font-semibold">{{ $row->created_at->format('Y.m/d') }}-{{ $row->created_at->format('h:i a') }}</span>
</p>
</div>
</x-slot>
@forelse ($rows as $row)
<div class="flex justify-between gap-4">
<x-filament::card class="w-full">
<x-filament::card.heading>User Details</x-filament::card.heading>
<p>
<span class="text-base font-light">{{ __('By') }}</span>:
{{ ($row->user->name) ?? '' }}
</p>
<p>
<span class="text-base font-light">{{ __('created at') }}</span>:
<span class="font-semibold">{{ $row->created_at->format('Y.m/d') }}-{{ $row->created_at->format('h:i a') }}</span>
</p>
</x-filament::card>
<x-filament::card class="w-full">
<x-filament::card.heading>Form Details</x-filament::card.heading>
<p>{{ ($row->form->name) ?? '' }}</p>
<p>{{ ($row->form->desc) ?? '' }}</p>
</x-filament::card>
</div>
<x-filament::card.heading>Respons Details</x-filament::card.heading>
<div class="grid grid-cols-1 grid-cols-2 gap-4">
@foreach($row->fieldsResponses as $resp)
<x-filament::card>
<p>{{ $resp->field->name }}</p>
<p class="font-semibold mb-2">{{ $resp->response ?? ''}}</p>
</x-filament::card>
@endforeach
</div>
@empty
<div class="flex justify-center items-center space-x-2">
<x-clarity-data-cluster-line class="h-8 w-8 text-gray-400"/>
<span class="font-medium py-8 text-gray-400 text-xl">No responses found...</span>
</div>
@endforelse

<div wire:key="row-{{ $row->id }}">
<div class="divide-y divide-gray-200 flex flex-col">
@foreach($fields->where('inShow',true) as $field)
<div class="py-2">
{{ $field['label'] }}:
@if(\Illuminate\Support\Str::contains($field['id'],'.'))
{{ ($flattenedRows[$loop->parent->index.'.'.$field['id']]) ?? '' }}
@elseif(isset($field['listAtt']))
{!! $row->{$field['listAtt']} !!}
@elseif(isset($row->{$field['id']}))
{{ $row->{$field['id']} }}
@else
{{ $field['id'] ?? '' }}
@endif
</div>
@endforeach
@foreach($row->fieldsResponses as $resp)
<div class="py-2">
{{ $resp->field->name }}:<span class="font-semibold">{{ $resp->response ?? ''}}</span>
</div>
@endforeach
</div>
</div>
@empty
<div class="flex justify-center items-center space-x-2">
<x-clarity-data-cluster-line class="h-8 w-8 text-gray-400"/>
<span class="font-medium py-8 text-gray-400 text-xl">No responses found...</span>
</div>
@endforelse

@if ($rows->hasPages())
<x-slot name="footer">
{{ $rows->links() }}
</x-slot>
@endif
</x-filament::card>
@if ($rows->hasPages())
{{ $rows->links() }}
@endif
</x-filament::page>
16 changes: 16 additions & 0 deletions src/Filament/Resources/BoltResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace LaraZeus\Bolt\Filament\Resources;

use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Resource;

class BoltResource extends Resource
{
use Translatable;

public static function getTranslatableLocales(): array
{
return config('zeus-bolt.translatable_Locales');
}
}
3 changes: 1 addition & 2 deletions src/Filament/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\DeleteBulkAction;
Expand All @@ -20,7 +19,7 @@
use LaraZeus\Bolt\Filament\Resources\CategoryResource\Pages\ListCategories;
use LaraZeus\Bolt\Models\Category;

class CategoryResource extends Resource
class CategoryResource extends BoltResource
{
protected static ?string $model = Category::class;

Expand Down
3 changes: 1 addition & 2 deletions src/Filament/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables\Columns\TextColumn;
use LaraZeus\Bolt\Filament\Resources\CollectionResource\Pages;
use LaraZeus\Bolt\Models\Collection;

class CollectionResource extends Resource
class CollectionResource extends BoltResource
{
protected static ?string $model = Collection::class;

Expand Down
Loading

0 comments on commit d74b322

Please sign in to comment.