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

[ADVAPP-11]: Campaign Action Blocks execute_at minDate doesn't work #385

Merged
merged 6 commits into from
Dec 21, 2023
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
4 changes: 3 additions & 1 deletion app-modules/campaign/config/permissions/web/custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
</COPYRIGHT>
*/

return [];
return [
'view_campaign_settings',
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
<COPYRIGHT>

Copyright © 2022-2023, Canyon GBS LLC. All rights reserved.

Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.

Notice:

- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.

For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

return [
'custom' => [
'campaign.view_campaign_settings',
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
<COPYRIGHT>

Copyright © 2022-2023, Canyon GBS LLC. All rights reserved.

Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.

Notice:

- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.

For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

use Spatie\LaravelSettings\Migrations\SettingsMigration;

return new class () extends SettingsMigration {
public function up(): void
{
$this->migrator->add('campaign.action_execution_timezone');
}
};
13 changes: 9 additions & 4 deletions app-modules/campaign/src/CampaignPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ public function getId(): string

public function register(Panel $panel): void
{
$panel->discoverResources(
in: __DIR__ . '/Filament/Resources',
for: 'AdvisingApp\\Campaign\\Filament\\Resources'
);
$panel
->discoverResources(
in: __DIR__ . '/Filament/Resources',
for: 'AdvisingApp\\Campaign\\Filament\\Resources'
)
->discoverPages(
in: __DIR__ . '/Filament/Pages',
for: 'AdvisingApp\\Campaign\\Filament\\Pages'
);
}

public function boot(Panel $panel): void {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@

namespace AdvisingApp\Campaign\Filament\Blocks;

use Carbon\CarbonInterface;
use Filament\Forms\Components\Builder\Block;
use AdvisingApp\Campaign\Settings\CampaignSettings;

abstract class CampaignActionBlock extends Block
{
Expand All @@ -63,4 +65,11 @@ public function editFields(): array
abstract public function generateFields(string $fieldPrefix = ''): array;

abstract public static function type(): string;

public function generateUserTimezoneHint(CarbonInterface $dateTime): string
{
return $dateTime
->shiftTimezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->setTimezone(auth()->user()->timezone)->format('M j, Y H:i:s') . ' in your timezone';
}
}
10 changes: 8 additions & 2 deletions app-modules/campaign/src/Filament/Blocks/CareTeamBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
namespace AdvisingApp\Campaign\Filament\Blocks;

use App\Models\User;
use Carbon\CarbonImmutable;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Campaign\Settings\CampaignSettings;

class CareTeamBlock extends CampaignActionBlock
{
Expand Down Expand Up @@ -69,9 +71,13 @@ public function generateFields(string $fieldPrefix = ''): array
->hintIconTooltip('If checked, all prior care team assignments will be removed.'),
DateTimePicker::make($fieldPrefix . 'execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now(auth()->user()->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@

namespace AdvisingApp\Campaign\Filament\Blocks;

use Carbon\CarbonImmutable;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Campaign\Settings\CampaignSettings;
use AdvisingApp\Engagement\Enums\EngagementDeliveryMethod;

class EngagementBatchBlock extends CampaignActionBlock
Expand Down Expand Up @@ -88,9 +90,13 @@ public function generateFields(string $fieldPrefix = ''): array
}),
DateTimePicker::make('execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now(auth()->user()->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
10 changes: 8 additions & 2 deletions app-modules/campaign/src/Filament/Blocks/InteractionBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
namespace AdvisingApp\Campaign\Filament\Blocks;

use Closure;
use Carbon\CarbonImmutable;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Textarea;
Expand All @@ -45,6 +46,7 @@
use AdvisingApp\Division\Models\Division;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Interaction\Models\Interaction;
use AdvisingApp\Campaign\Settings\CampaignSettings;
use AdvisingApp\Interaction\Models\InteractionType;
use AdvisingApp\Interaction\Models\InteractionDriver;
use AdvisingApp\Interaction\Models\InteractionStatus;
Expand Down Expand Up @@ -128,9 +130,13 @@ public function generateFields(string $fieldPrefix = ''): array
]),
DateTimePicker::make($fieldPrefix . 'execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now(auth()->user()->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
10 changes: 8 additions & 2 deletions app-modules/campaign/src/Filament/Blocks/ProactiveAlertBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

namespace AdvisingApp\Campaign\Filament\Blocks;

use Carbon\CarbonImmutable;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use AdvisingApp\Alert\Enums\AlertStatus;
use AdvisingApp\Alert\Enums\AlertSeverity;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Campaign\Settings\CampaignSettings;

class ProactiveAlertBlock extends CampaignActionBlock
{
Expand Down Expand Up @@ -76,9 +78,13 @@ public function generateFields(string $fieldPrefix = ''): array
->enum(AlertStatus::class),
DateTimePicker::make($fieldPrefix . 'execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now(auth()->user()->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
10 changes: 8 additions & 2 deletions app-modules/campaign/src/Filament/Blocks/ServiceRequestBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@

use Closure;
use App\Models\User;
use Carbon\CarbonImmutable;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Illuminate\Database\Eloquent\Model;
use AdvisingApp\Division\Models\Division;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Campaign\Settings\CampaignSettings;
use Illuminate\Contracts\Database\Eloquent\Builder;
use AdvisingApp\ServiceManagement\Models\ServiceRequest;
use AdvisingApp\ServiceManagement\Models\ServiceRequestType;
Expand Down Expand Up @@ -107,9 +109,13 @@ public function generateFields(string $fieldPrefix = ''): array
->string(),
DateTimePicker::make('execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now(auth()->user()->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
15 changes: 9 additions & 6 deletions app-modules/campaign/src/Filament/Blocks/SubscriptionBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
namespace AdvisingApp\Campaign\Filament\Blocks;

use App\Models\User;
use Carbon\CarbonImmutable;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Campaign\Settings\CampaignSettings;

class SubscriptionBlock extends CampaignActionBlock
{
Expand All @@ -52,16 +54,13 @@ protected function setUp(): void

public function generateFields(string $fieldPrefix = ''): array
{
/** @var User $user */
$user = auth()->user();

return [
Select::make($fieldPrefix . 'user_ids')
->label('Who should be subscribed?')
->options(User::all()->pluck('name', 'id'))
->multiple()
->searchable()
->default([$user->id])
->default([auth()->id()])
->required()
->exists('users', 'id'),
Toggle::make($fieldPrefix . 'remove_prior')
Expand All @@ -70,9 +69,13 @@ public function generateFields(string $fieldPrefix = ''): array
->hintIconTooltip('If checked, all prior care subscriptions will be removed.'),
DateTimePicker::make($fieldPrefix . 'execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now($user->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
14 changes: 8 additions & 6 deletions app-modules/campaign/src/Filament/Blocks/TaskBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@

namespace AdvisingApp\Campaign\Filament\Blocks;

use App\Models\User;
use Carbon\CarbonImmutable;
use AdvisingApp\Task\Models\Task;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\DateTimePicker;
use AdvisingApp\Campaign\Settings\CampaignSettings;

class TaskBlock extends CampaignActionBlock
{
Expand All @@ -57,9 +58,6 @@ protected function setUp(): void

public function generateFields(string $fieldPrefix = ''): array
{
/** @var User $user */
$user = auth()->user();

return [
Fieldset::make('Details')
->schema([
Expand All @@ -81,9 +79,13 @@ public function generateFields(string $fieldPrefix = ''): array
]),
DateTimePicker::make($fieldPrefix . 'execute_at')
->label('When should the journey step be executed?')
->columnSpanFull()
->timezone(app(CampaignSettings::class)->getActionExecutionTimezone())
->helperText(app(CampaignSettings::class)->getActionExecutionTimezoneLabel())
->lazy()
->hint(fn ($state): ?string => filled($state) ? $this->generateUserTimezoneHint(CarbonImmutable::parse($state)) : null)
->required()
->minDate(now($user->timezone))
->closeOnDateSelection(),
->minDate(now()),
];
}

Expand Down
Loading