Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field type #242

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"flowframe/laravel-trend": "^0.1.5",
"guava/filament-icon-picker": "^2.0",
"lara-zeus/accordion": "^1.0",
"lara-zeus/core": "^3.0"
"lara-zeus/core": "^3.0",
"ryangjchandler/blade-tabler-icons": "^2.2"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down
122 changes: 92 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions resources/views/filament/fields/types.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="py-2 cursor-pointer !w-full flex items-start justify-start gap-2">
@svg($field['icon'],'text-primary-500 w-5 h-5')
<span class="w-full flex items-center justify-between gap-2">
<span class="flex flex-col items-start justify-between gap-2">
<span class="font-semibold">{{ $field['title'] }}</span>
{{--<span class="text-sm field-desc">{{ $field['description'] }}</span>--}}
</span>
<span class="tip" x-tooltip="{
content: @js($field['description']),
theme: $store.theme,
}">
@svg('heroicon-o-information-circle','mx-2 w-4 h-4 text-gray-400')
</span>
</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ class="rounded-full"
<div class="mb-4">
<span>{{ __('status') }}</span>
@php $getStatues = $getRecord->statusDetails() @endphp
<span class="{{ $getStatues['class']}}" x-tooltip.raw="{{ __('status') }}">
<span class="{{ $getStatues['class']}}"
x-tooltip="{
content: @js(__('status')),
theme: $store.theme,
}">
@svg($getStatues['icon'],'w-4 h-4 inline')
{{ $getStatues['label'] }}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ class="rounded-full"
<div class="mb-4">
<span>{{ __('status') }}</span>
@php $getStatues = $response->statusDetails() @endphp
<span class="{{ $getStatues['class']}}" x-tooltip.raw="{{ __('status') }}">
<span class="{{ $getStatues['class']}}"
x-tooltip="{
content: @js(__('status')),
theme: $store.theme,
}">
@svg($getStatues['icon'],'w-4 h-4 inline')
{{ $getStatues['label'] }}
</span>
Expand All @@ -69,4 +73,4 @@ class="rounded-full"
</div>
</div>
</div>
</x-filament::page>
</x-filament::page>
6 changes: 5 additions & 1 deletion resources/views/themes/zeus/bolt/show-entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@
<div>
<span>{{ __('status') }}</span>
@php $getStatues = $response->statusDetails() @endphp
<span class="{{ $getStatues['class']}}" x-tooltip.raw="{{ __('status') }}">
<span class="{{ $getStatues['class']}}"
x-tooltip="{
content: @js(__('status')),
theme: $store.theme,
}">
@svg($getStatues['icon'],'w-4 h-4 inline')
{{ $getStatues['label'] }}
</span>
Expand Down
33 changes: 30 additions & 3 deletions src/Concerns/Schemata.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static function getMainFormSchema(): array
->addActionLabel(__('Add Section'))
->cloneable()
->collapsible()
->collapsed(fn (string $operation) => $operation === 'edit')
//->collapsed(fn (string $operation) => $operation === 'edit')
->minItems(1)
->extraItemActions([
Action::make('options')
Expand Down Expand Up @@ -352,7 +352,7 @@ public static function getSectionsSchema(): array
->cloneable()
->minItems(1)
->collapsible()
->collapsed(fn (string $operation) => $operation === 'edit')
//->collapsed(fn (string $operation) => $operation === 'edit')
->grid([
'default' => 1,
'md' => 2,
Expand Down Expand Up @@ -411,6 +411,14 @@ public static function getSectionsSchema(): array
];
}

public static function getCleanOptionString(array $field): string
{
return
view('zeus::filament.fields.types')
->with('field', $field)
->render();
}

public static function getFieldsSchema(): array
{
return [
Expand All @@ -423,7 +431,26 @@ public static function getFieldsSchema(): array
->label(__('Field Name')),
Select::make('type')
->required()
->options(Bolt::availableFields()->pluck('title', 'class'))
->searchable()
->preload()
//->options(Bolt::availableFields()->pluck('title', 'class'))

/*->getSearchResultsUsing(function (string $search) {
$users = Bolt::availableFields()->where('title', 'like', "%{$search}%");

return $users->mapWithKeys(function ($user) {
return [$user->getKey() => static::getCleanOptionString($user)];
})->toArray();
})*/
->allowHtml()
->extraAttributes(['class' => 'field-type'])
->options(function (): array {
return Bolt::availableFields()
->mapWithKeys(function ($user) {
return [$user['class'] => static::getCleanOptionString($user)];
})
->toArray();
})
->live()
->default('\LaraZeus\Bolt\Fields\Classes\TextInput')
->label(__('Field Type')),
Expand Down
10 changes: 10 additions & 0 deletions src/Fields/Classes/CheckboxList.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public function title(): string
return __('Checkbox List');
}

public function icon(): string
{
return 'tabler-list-check';
}

public function description(): string
{
return __('checkbox items from data source');
}

public static function getOptions(?array $sections = null): array
{
return [
Expand Down
Loading