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

[ASSIST-289] Add ability to log interactions #76

Merged
merged 29 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b8fb5c0
Create interaction module, initial models and schema.
dgoetzit Sep 7, 2023
4c133ba
Create base relations, update migrations.
dgoetzit Sep 7, 2023
f01c098
Merge branch 'develop' into feature/ASSIST-289-interactions
dgoetzit Sep 7, 2023
1539970
Create initial resources, policies.
dgoetzit Sep 7, 2023
c100d95
Add content to factories, seeders.
dgoetzit Sep 7, 2023
c5150aa
Add content to resources.
dgoetzit Sep 7, 2023
be4b8e1
Simplify resources, add duration.
dgoetzit Sep 7, 2023
d666ab1
Change method name.
dgoetzit Sep 8, 2023
d511867
Merge branch 'develop' into feature/ASSIST-289-interactions
dgoetzit Sep 11, 2023
abc848b
Add interaction institution and relation models, migration, factories.
dgoetzit Sep 11, 2023
41f434e
Add remaining interaction meta resources, form and table fields.
dgoetzit Sep 11, 2023
a27e367
Add tests for interaction meta resources.
dgoetzit Sep 11, 2023
2cbab42
php cs fixes.
dgoetzit Sep 11, 2023
2635e68
Remove unused tables, ide helper.
dgoetzit Sep 11, 2023
1f17bbe
Make integration meta searchable.
dgoetzit Sep 12, 2023
e64bad4
Rename method.
dgoetzit Sep 12, 2023
ee59c17
Update a todo.
dgoetzit Sep 12, 2023
c7ec8df
Use helper to get identifier for model.
dgoetzit Sep 12, 2023
8008ec3
Remove completed todo.
dgoetzit Sep 12, 2023
46e9a2f
Clean up final relationships, tables, fields for institutions and rel…
dgoetzit Sep 12, 2023
06b0c61
Update interactions list table view, add ability to edit on relation …
dgoetzit Sep 12, 2023
96d0ee0
php cs
dgoetzit Sep 12, 2023
c37807a
Fix namespace.
dgoetzit Sep 12, 2023
2938388
Remove gitkeep files.
dgoetzit Sep 13, 2023
3c8b1ce
Merge branch 'develop' into feature/ASSIST-289-interactions
dgoetzit Sep 13, 2023
e2eb727
Extend new base relation manager.
dgoetzit Sep 13, 2023
9421351
Update relationship names.
dgoetzit Sep 13, 2023
7a5eece
Update doc blocks.
dgoetzit Sep 13, 2023
66299ea
Other regen changes.
dgoetzit Sep 13, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Assist\AssistDataModel\Models\Student;
use Filament\Resources\RelationManagers\RelationGroup;
use Assist\Alert\Filament\RelationManagers\AlertsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\Pages;
use Assist\Task\Filament\Resources\TaskResource\RelationManagers\TasksRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\EngagementsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\InteractionsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\SubscriptionsRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\EngagementFilesRelationManager;
use Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers\EngagementResponsesRelationManager;
Expand All @@ -33,11 +35,14 @@ public static function form(Form $form): Form
public static function getRelations(): array
{
return [
RelationGroup::make('Engagement', [
EngagementsRelationManager::class,
EngagementResponsesRelationManager::class,
EngagementFilesRelationManager::class,
]),
SubscriptionsRelationManager::class,
EngagementsRelationManager::class,
EngagementResponsesRelationManager::class,
EngagementFilesRelationManager::class,
TasksRelationManager::class,
InteractionsRelationManager::class,
AlertsRelationManager::class,
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Assist\AssistDataModel\Filament\Resources\StudentResource\RelationManagers;

use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Infolists\Infolist;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Component;
use Assist\AssistDataModel\Models\Student;
use Filament\Forms\Components\MorphToSelect;
use Filament\Resources\RelationManagers\RelationManager;
use Assist\Interaction\Filament\Resources\InteractionResource\Pages\CreateInteraction;
use Assist\Interaction\Filament\Resources\InteractionResource\RelationManagers\HasManyMorphedInteractionsRelationManager;

class InteractionsRelationManager extends RelationManager
Orrison marked this conversation as resolved.
Show resolved Hide resolved
{
protected static string $relationship = 'interactions';

public function form(Form $form): Form
{
$createInteractionForm = (resolve(CreateInteraction::class))->form($form);

$formComponents = collect($createInteractionForm->getComponents())->filter(function (Component $component) {
if (! $component instanceof MorphToSelect) {
return true;
}
})->toArray();

return parent::form($createInteractionForm)
->schema([
Hidden::make('interactable_id')
->default($this->ownerRecord->identifier()),
Hidden::make('interactable_type')
->default(resolve(Student::class)->getMorphClass()),
...$formComponents,
]);
}

public function infolist(Infolist $infolist): Infolist
{
return (resolve(HasManyMorphedInteractionsRelationManager::class))->infolist($infolist);
}

public function table(Table $table): Table
{
return (resolve(HasManyMorphedInteractionsRelationManager::class))->table($table);
}
}
4 changes: 4 additions & 0 deletions app-modules/assist-data-model/src/Models/Student.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Illuminate\Notifications\DatabaseNotificationCollection;
use Assist\Audit\Models\Concerns\Auditable as AuditableTrait;
use Assist\Engagement\Models\Concerns\HasManyMorphedEngagements;
use Assist\Interaction\Models\Concerns\HasManyMorphedInteractions;
use Assist\Engagement\Models\Concerns\HasManyMorphedEngagementResponses;

/**
Expand All @@ -42,6 +43,8 @@
* @property-read int|null $engagement_responses_count
* @property-read Collection<int, Engagement> $engagements
* @property-read int|null $engagements_count
* @property-read Collection<int, \Assist\Interaction\Models\Interaction> $interactions
* @property-read int|null $interactions_count
* @property-read DatabaseNotificationCollection<int, DatabaseNotification> $notifications
* @property-read int|null $notifications_count
* @property-read Collection<int, ServiceRequest> $serviceRequests
Expand All @@ -66,6 +69,7 @@ class Student extends Model implements Auditable, Subscribable, Identifiable
use Notifiable;
use HasManyMorphedEngagements;
use HasManyMorphedEngagementResponses;
use HasManyMorphedInteractions;

protected $primaryKey = 'sisid';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function boot()
$schedule->job(DeliverEngagements::class)->everyMinute();
});

$this->observers();
$this->registerObservers();
}

public function observers(): void
public function registerObservers(): void
{
EngagementFileEntities::observe(EngagementFileEntitiesObserver::class);
Engagement::observe(EngagementObserver::class);
Expand Down
26 changes: 26 additions & 0 deletions app-modules/interaction/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "canyon-gbs/interaction",
"description": "",
"type": "library",
"version": "1.0",
"license": "proprietary",
"require": {
"filament/filament": "^3.0.0"
},
"autoload": {
"psr-4": {
"Assist\\Interaction\\": "src/",
"Assist\\Interaction\\Tests\\": "tests/",
"Assist\\Interaction\\Database\\Factories\\": "database/factories/",
"Assist\\Interaction\\Database\\Seeders\\": "database/seeders/"
}
},
"minimum-stability": "dev",
"extra": {
"laravel": {
"providers": [
"Assist\\Interaction\\Providers\\InteractionServiceProvider"
]
}
}
}
3 changes: 3 additions & 0 deletions app-modules/interaction/config/permissions/api/custom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return [];
3 changes: 3 additions & 0 deletions app-modules/interaction/config/permissions/web/custom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

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

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

return [];
Orrison marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionCampaign>
*/
class InteractionCampaignFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionDriver>
*/
class InteractionDriverFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
50 changes: 50 additions & 0 deletions app-modules/interaction/database/factories/InteractionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Assist\Interaction\Database\Factories;

use App\Models\User;
use Assist\Prospect\Models\Prospect;
use Assist\AssistDataModel\Models\Student;
use Assist\Interaction\Models\InteractionType;
use Assist\Interaction\Models\InteractionDriver;
use Assist\Interaction\Models\InteractionStatus;
use Assist\Interaction\Models\InteractionOutcome;
use Assist\Interaction\Models\InteractionCampaign;
use Assist\Interaction\Models\InteractionRelation;
use Assist\ServiceManagement\Models\ServiceRequest;
use Illuminate\Database\Eloquent\Factories\Factory;
use Assist\Interaction\Models\InteractionInstitution;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\Interaction>
*/
class InteractionFactory extends Factory
{
public function definition(): array
{
$interactable = fake()->randomElement([
Student::class,
Prospect::class,
ServiceRequest::class,
Orrison marked this conversation as resolved.
Show resolved Hide resolved
]);

$interactable = $interactable::factory()->create();

return [
'user_id' => User::factory(),
'interactable_id' => $interactable->identifier(),
'interactable_type' => $interactable->getMorphClass(),
'interaction_type_id' => InteractionType::factory(),
'interaction_relation_id' => InteractionRelation::factory(),
'interaction_campaign_id' => InteractionCampaign::factory(),
'interaction_driver_id' => InteractionDriver::factory(),
'interaction_status_id' => InteractionStatus::factory(),
'interaction_outcome_id' => InteractionOutcome::factory(),
'interaction_institution_id' => InteractionInstitution::factory(),
'start_datetime' => now(),
'end_datetime' => now()->addMinutes(5),
'subject' => fake()->sentence(),
'description' => fake()->paragraph(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionInstitution>
*/
class InteractionInstitutionFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionOutcome>
*/
class InteractionOutcomeFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionRelation>
*/
class InteractionRelationFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Assist\ServiceManagement\Enums\ColumnColorOptions;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionStatus>
*/
class InteractionStatusFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
'color' => $this->faker->randomElement(ColumnColorOptions::cases())->value,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Assist\Interaction\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Assist\Interaction\Models\InteractionType>
*/
class InteractionTypeFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->word(),
];
}
}
Orrison marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class () extends Migration {
public function up(): void
{
Schema::create('interaction_types', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class () extends Migration {
public function up(): void
{
Schema::create('interaction_statuses', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name');
$table->string('color');
$table->timestamps();
$table->softDeletes();
});
}
};
Loading