Skip to content

Commit

Permalink
increment toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
AravindRam-Ranium committed Feb 16, 2024
1 parent a443fcf commit 3ac99d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
42 changes: 17 additions & 25 deletions src/Resources/ConsentOptionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public static function form(Form $form): Form
return $form
->schema([
Section::make('')->schema([

Group::make()->schema([
Forms\Components\TextInput::make('title')
->live()
Expand All @@ -47,26 +46,30 @@ public static function form(Form $form): Form
)
->required(),
Forms\Components\TextInput::make('key')
->unique(ignorable: fn ($record) => $record)
// ->unique(ignorable: fn ($record) => $record)
->required(),
Forms\Components\TextInput::make('label')
->hint('(For checkbox)')
->required(),
Forms\Components\TextInput::make('sort_order')
->numeric()
->required(),
])->columns(2)->columnSpanFull(),

Forms\Components\Toggle::make('enabled')
->label('Enable this contract')
->required(),
Forms\Components\Toggle::make('is_mandatory')
->required(),
Forms\Components\Toggle::make('force_user_update')
->label('Require all users to re-confirm after this update')
->required(),

Group::make()->schema([
Forms\Components\Toggle::make('enabled')
->label('Enable this contract')
->required(),
Forms\Components\Toggle::make('is_mandatory')
->required(),

Forms\Components\Toggle::make('force_user_update')
->label('Require all users to re-confirm after this update')
->required(),

Forms\Components\Toggle::make('increment_version')
->label('Do you want to upgrade to next version?')
->required(),

Forms\Components\DateTimePicker::make('published_at')
->hint('(Will not be active until this date)')
->native(false)
Expand Down Expand Up @@ -118,21 +121,10 @@ public static function table(Table $table): Table
])
->defaultSort('created_at', 'desc')
->actions([
Tables\Actions\Action::make('Accept')
->requiresConfirmation()
->modalDescription(fn (ConsentOption $record) => $record->label)
->button()
->color('success')
->icon('heroicon-m-hand-thumb-up')
->action(fn (ConsentOption $record) => Notification::make()
->title('Accepted successfully')
->success()
->send()),

])
->bulkActions([
Tables\Actions\BulkActionGroup::make([

]),
Tables\Actions\BulkActionGroup::make([]),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getTitle(): string

protected function handleRecordUpdate(Model $record, array $data): Model
{
if ($requiresNewVersion = $record->usersViewedThisVersion) {
if ((bool)$data['increment_version']) { //$record->usersViewedThisVersion
//create a new version
$data['version'] = $record->nextVersionNumber;
$data['key'] = $record->key;
Expand Down

0 comments on commit 3ac99d8

Please sign in to comment.