Skip to content

Commit

Permalink
Merge pull request #48 from lara-zeus/improve-view-create-forms
Browse files Browse the repository at this point in the history
rename some fields placeholders and add buttons on view form page
  • Loading branch information
atmonshi authored Jun 8, 2023
2 parents 3192273 + e984263 commit f03ea15
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
22 changes: 22 additions & 0 deletions src/Filament/Resources/FormResource/Pages/ViewForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace LaraZeus\Bolt\Filament\Resources\FormResource\Pages;

use Filament\Pages\Actions\Action;
use Filament\Pages\Actions\LocaleSwitcher;
use Filament\Resources\Pages\ViewRecord;
use LaraZeus\Bolt\Filament\Resources\FormResource;

Expand All @@ -16,6 +18,26 @@ protected function getFormSchema(): array
return FormResource::getMainFormSchemaForView();
}

protected function getActions(): array
{
return [
LocaleSwitcher::make(),
Action::make('entries')
->label(__('Entries'))
->icon('clarity-data-cluster-line')
->tooltip(__('view all entries'))
->url(fn () => url('admin/responses?form_id=' . $this->record->id)),

Action::make('view')
->label(__('View'))
->icon('heroicon-o-external-link')
->tooltip(__('view form'))
->color('warning')
->url(fn () => route('bolt.form.show', $this->record))
->openUrlInNewTab(),
];
}

protected function getHeaderWidgets(): array
{
return [
Expand Down
26 changes: 13 additions & 13 deletions src/Filament/Resources/FormResource/Schemata.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public static function getMainFormSchema(): array
Hidden::make('layout')->default(1),
Hidden::make('ordering')->default(1),

Tabs::make('Name')
Tabs::make('form-tabs')
->tabs(static::getTabsSchema())
->columnSpan(2),
Card::make()
->schema([
Placeholder::make('Sections-title')
Placeholder::make('section-title-placeholder')
->label(__('Sections'))
->helperText(__('sections are here to group the fields, and you can display it as pages from the Form options. if you have one section, it wont show in the form')),
]),
Expand All @@ -72,7 +72,7 @@ public static function getMainFormSchema(): array
public static function getTabsSchema(): array
{
return [
Tabs\Tab::make('title-slug')
Tabs\Tab::make('title-slug-tab')
->label(__('Title & Slug'))
->columns(2)
->schema([
Expand All @@ -96,7 +96,7 @@ public static function getTabsSchema(): array
->unique(ignoreRecord: true)
->label(__('Form Slug')),
]),
Tabs\Tab::make('text-details')
Tabs\Tab::make('text-details-tab')
->label(__('Text & Details'))
->schema([
Textarea::make('desc')
Expand All @@ -113,7 +113,7 @@ public static function getTabsSchema(): array
->label(__('Confirmation Message'))
->helperText(__('optional, show a massage whenever any one submit a new entry')),
]),
Tabs\Tab::make('display-access')
Tabs\Tab::make('display-access-tab')
->label(__('Display & Access'))
->columns(2)
->schema([
Expand Down Expand Up @@ -148,7 +148,7 @@ public static function getTabsSchema(): array
'tabs' => __('Show As Tabs'),
]),
]),
Tabs\Tab::make('advanced')
Tabs\Tab::make('advanced-tab')
->label(__('Advanced'))
->schema([
Select::make('category_id')
Expand Down Expand Up @@ -187,18 +187,18 @@ public static function getSectionsSchema(): array
Grid::make()
->columns(2)
->schema([
Tabs::make('Heading')
Tabs::make('section-tab')
->columnSpan(2)
->tabs([
Tabs\Tab::make('section-info')
Tabs\Tab::make('section-info-tab')
->label(__('Section Info'))
->schema([
TextInput::make('name')
->required()
->lazy()
->label(__('Section Name')),
]),
Tabs\Tab::make('section-details')
Tabs\Tab::make('section-details-tab')
->label(__('Section Details'))
->columns(2)
->schema([
Expand All @@ -225,7 +225,7 @@ public static function getSectionsSchema(): array
]),
]),
]),
Placeholder::make('Fields')
Placeholder::make('section-fields-placeholder')
->label(__('Section Fields')),
Repeater::make('fields')
->relationship()
Expand All @@ -249,9 +249,9 @@ public static function getSectionsSchema(): array
public static function getFieldsSchema(): array
{
return [
Tabs::make('fields')
Tabs::make('fields-tab')
->tabs([
Tabs\Tab::make('type-text')
Tabs\Tab::make('type-text-tab')
->icon('heroicon-o-menu-alt-2')
->label(__('Type & title'))
->schema([
Expand All @@ -268,7 +268,7 @@ public static function getFieldsSchema(): array
->default('\LaraZeus\Bolt\Fields\Classes\TextInput')
->label(__('Field Type')),
]),
Tabs\Tab::make('options')
Tabs\Tab::make('options-tab')
->label(__('Options'))
->icon('heroicon-o-cog')
->schema([
Expand Down

0 comments on commit f03ea15

Please sign in to comment.