Skip to content

Commit

Permalink
Added navigation Cluster, icon and and label to config
Browse files Browse the repository at this point in the history
Made default config more generic
  • Loading branch information
cannycookie committed Apr 7, 2024
1 parent eaf09e4 commit 93c1119
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 40 deletions.
60 changes: 33 additions & 27 deletions config/filament-user-consent.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<?php

//use Visualbuilder\FilamentUserConsent\Events\ConsentsUpdatedComplete;
//use Visualbuilder\FilamentUserConsent\Events\ConsentUpdated;
use Visualbuilder\FilamentUserConsent\Listeners\NotifyConsentsUpdated;

return [

//To which authenticatable models consents should be applied?
'models' => [
App\Models\Admin::class,
App\Models\Practitioner::class,
App\Models\EndUser::class,
App\Models\User::class,

Check failure on line 9 in config/filament-user-consent.php

View workflow job for this annotation

GitHub Actions / phpstan

Class App\Models\User not found.
],

'auth-guards' => 'web',

'options' => [
'App\Models\Admin' => 'Admin',
'App\Models\Practitioner' => 'Practitioner',
'App\Models\EndUser' => 'EndUser',
App\Models\User::class => 'User',

Check failure on line 15 in config/filament-user-consent.php

View workflow job for this annotation

GitHub Actions / phpstan

Class App\Models\User not found.
],

'notify' => ['mail'],

Check failure on line 18 in config/filament-user-consent.php

View workflow job for this annotation

GitHub Actions / phpstan

Array has 2 duplicate keys with value 'notify' ('notify', 'notify').
Expand All @@ -28,13 +22,25 @@
],

'navigation' => [
'sort' => 50,
'group' => 'Content',
'consent_options' => [
'sort' => 50,
'label' => 'Consent Options',
'icon' => 'heroicon-o-check-badge',
'group' => 'Content',
'cluster' => false,
],
'consent_responses' => [
'sort' => 60,
'label' => 'Consent Responses',
'icon' => 'heroicon-o-user-circle',
'group' => 'Content',
'cluster' => false,
],
],

'listeners' => [
//Event triggered after a consent updated
ConsentUpdated::class => [
ConsentUpdated::class => [

Check failure on line 43 in config/filament-user-consent.php

View workflow job for this annotation

GitHub Actions / phpstan

Class ConsentUpdated not found.
// Default listeners for this event
// You may want to update mailchump if consent withdrawn for marketing
],
Expand All @@ -45,32 +51,32 @@
],

//send user an email with a copy of the consent after saving.
'notify' => ['mail'],
'notify' => ['mail'],

'email-template' => 'vendor.user-consent.layouts.email',

//The mailable class to use for sending consent notification
'mailable' => \Visualbuilder\FilamentUserConsent\Mail\ConsentsUpdatedMail::class,
'mailable' => \Visualbuilder\FilamentUserConsent\Mail\ConsentsUpdatedMail::class,

'components' => [
'placeholder' => 'Placeholder',
'likert' => 'Likert Slider',
'text' => 'Free Text Input',
'email' => 'Email Input',
'number' => 'Number Input',
'textarea' => 'Text area',
'select' => 'Select dropdown',
'radio' => 'Radio options',
'check' => 'Checkbox',
'date' => 'Date Picker',
'datetime' => 'Date & Time Picker',
'likert' => 'Likert Slider',
'text' => 'Free Text Input',
'email' => 'Email Input',
'number' => 'Number Input',
'textarea' => 'Text area',
'select' => 'Select dropdown',
'radio' => 'Radio options',
'check' => 'Checkbox',
'date' => 'Date Picker',
'datetime' => 'Date & Time Picker',
],

'autofill_columns' => [
'salutation' => 'Title',
'full_name' => 'Full Name',
'email' => 'Email address',
'mobile' => 'Mobile number',
'salutation' => 'Title',
'full_name' => 'Full Name',
'email' => 'Email address',
'mobile' => 'Mobile number',
'phone_number' => 'Phone number',
'full_address' => "Full address"
]
Expand Down
27 changes: 21 additions & 6 deletions src/Resources/ConsentOptionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,31 @@ class ConsentOptionResource extends Resource
{
protected static ?string $model = ConsentOption::class;

protected static ?string $navigationIcon = 'heroicon-o-clipboard';
protected static ?string $navigationIcon = 'heroicon-o-check-badge';

public static function getNavigationLabel(): string
{
return config('filament-user-consent.navigation.consent_options.label');
}

public static function getNavigationIcon(): ?string
{
return config('filament-user-consent.navigation.consent_options.icon');
}

public static function getNavigationGroup(): ?string
{
return config('filament-user-consent.navigation.group');
return config('filament-user-consent.navigation.consent_options.group');
}

public static function getNavigationSort(): ?int
{
return config('filament-user-consent.navigation.sort');
return config('filament-user-consent.navigation.consent_options.sort');
}

public static function getCluster(): ?string
{
return config('filament-user-consent.navigation.consent_options.cluster');
}

public static function form(Form $form): Form
Expand Down Expand Up @@ -95,10 +110,10 @@ public static function form(Form $form): Form
->label('Contract text')
->required()
->columnSpanFull(),

])->columns(3),
Section::make('Additional Info')->schema([

Repeater::make('fields')->label('')
->schema([
Forms\Components\TextInput::make('name')
Expand Down Expand Up @@ -170,7 +185,7 @@ public static function table(Table $table): Table
])
->defaultSort('created_at', 'desc')
->actions([

])
->bulkActions([
Tables\Actions\BulkActionGroup::make([]),
Expand Down
26 changes: 19 additions & 7 deletions src/Resources/ConsentOptionResponseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,38 @@ class ConsentOptionResponseResource extends Resource
{
protected static ?string $model = ConsentOptionUser::class;

protected static ?string $navigationIcon = 'heroicon-o-clipboard';

public static ?string $label = 'Consent Response';
public static function getNavigationLabel(): string
{
return config('filament-user-consent.navigation.consent_responses.label');
}

public static function getNavigationIcon(): ?string
{
return config('filament-user-consent.navigation.consent_responses.icon');
}


public static function getNavigationGroup(): ?string
{
return config('filament-user-consent.navigation.group');
return config('filament-user-consent.navigation.consent_responses.group');
}

public static function getNavigationSort(): ?int
{
return config('filament-user-consent.navigation.sort');
return config('filament-user-consent.navigation.consent_responses.sort');
}

public static function getCluster(): ?string
{
return config('filament-user-consent.navigation.consent_responses.cluster');
}

public static function form(Form $form): Form
{
return $form
->schema([

]);
}

Expand All @@ -66,7 +78,7 @@ public static function table(Table $table): Table
Tables\Columns\TextColumn::make('created_at')
->label('Accepted at')
->sortable(),

])
->filters([
Tables\Filters\SelectFilter::make('consent_option_id')
Expand Down Expand Up @@ -110,7 +122,7 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('response'),
TextEntry::make('additional_info')
->visible(fn (Model $model) => $model->additional_info),
])->columns(3)
])->columns(3)
])
]),
]);
Expand Down

0 comments on commit 93c1119

Please sign in to comment.