From 285656bda2f0059e91a27825099e44eb055be786 Mon Sep 17 00:00:00 2001 From: EL OUFIR Hatim Date: Fri, 16 Dec 2022 14:46:03 +0100 Subject: [PATCH 1/2] Add epic parent link --- .../Controllers/RoadMap/DataController.php | 2 +- app/Http/Livewire/RoadMap/EpicForm.php | 24 +++++++++++--- app/Models/Epic.php | 9 ++++-- .../2022_12_16_133836_add_parent_to_epics.php | 32 +++++++++++++++++++ 4 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 database/migrations/2022_12_16_133836_add_parent_to_epics.php diff --git a/app/Http/Controllers/RoadMap/DataController.php b/app/Http/Controllers/RoadMap/DataController.php index 0373b8c01..4c1fe0fc2 100644 --- a/app/Http/Controllers/RoadMap/DataController.php +++ b/app/Http/Controllers/RoadMap/DataController.php @@ -76,7 +76,7 @@ private function epicObj(Epic $epic) "pGroup" => 1, "pParent" => 0, "pOpen" => 1, - "pDepend" => "", + "pDepend" => $epic->parent_id ?? "", "pCaption" => "", "pNotes" => "", "pBarText" => "", diff --git a/app/Http/Livewire/RoadMap/EpicForm.php b/app/Http/Livewire/RoadMap/EpicForm.php index 1158d28a0..9a6a0d5cb 100644 --- a/app/Http/Livewire/RoadMap/EpicForm.php +++ b/app/Http/Livewire/RoadMap/EpicForm.php @@ -18,9 +18,16 @@ class EpicForm extends Component implements HasForms use InteractsWithForms; public Epic $epic; + public array $epics = []; public function mount() { + $query = Epic::query(); + $query->where('project_id', $this->epic->project_id); + if ($this->epic->id) { + $query->where('id', '<>', $this->epic->id); + } + $this->epics = $query->get()->pluck('name', 'id')->toArray(); $this->form->fill($this->epic->toArray()); } @@ -32,10 +39,18 @@ public function render() protected function getFormSchema(): array { return [ - Select::make('project_id') - ->label(__('Project')) - ->disabled() - ->options(Project::all()->pluck('name', 'id')), + Grid::make() + ->schema([ + Select::make('project_id') + ->label(__('Project')) + ->disabled() + ->options(Project::all()->pluck('name', 'id')), + + Select::make('parent_id') + ->label(__('Parent epic')) + ->searchable() + ->options($this->epics), + ]), TextInput::make('name') ->label(__('Epic name')) @@ -59,6 +74,7 @@ public function submit(): void { $data = $this->form->getState(); $this->epic->project_id = $data['project_id']; + $this->epic->parent_id = $data['parent_id']; $this->epic->name = $data['name']; $this->epic->starts_at = $data['starts_at']; $this->epic->ends_at = $data['ends_at']; diff --git a/app/Models/Epic.php b/app/Models/Epic.php index 804ed191d..4ba253b27 100644 --- a/app/Models/Epic.php +++ b/app/Models/Epic.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -14,7 +13,8 @@ class Epic extends Model use HasFactory, SoftDeletes; protected $fillable = [ - 'name', 'project_id', 'starts_at', 'ends_at' + 'name', 'project_id', 'starts_at', 'ends_at', + 'parent_id' ]; protected $casts = [ @@ -31,4 +31,9 @@ public function tickets(): HasMany { return $this->hasMany(Ticket::class, 'epic_id', 'id'); } + + public function parent(): BelongsTo + { + return $this->belongsTo(Epic::class, 'parent_id', 'id'); + } } diff --git a/database/migrations/2022_12_16_133836_add_parent_to_epics.php b/database/migrations/2022_12_16_133836_add_parent_to_epics.php new file mode 100644 index 000000000..904b8b33b --- /dev/null +++ b/database/migrations/2022_12_16_133836_add_parent_to_epics.php @@ -0,0 +1,32 @@ +foreignId('parent_id')->nullable()->constrained('epics'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('epics', function (Blueprint $table) { + $table->dropForeign(['parent_id']); + $table->dropColumn('parent_id'); + }); + } +}; From 9479eab099702b8c1e1224bb51c836b6bb8c29b1 Mon Sep 17 00:00:00 2001 From: EL OUFIR Hatim Date: Fri, 16 Dec 2022 14:46:34 +0100 Subject: [PATCH 2/2] Update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bd4d3af43..bac4962ef 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio - Manage _Epics_ by projects - **Release 1.1.1** - Add issue creation (dialog) into kanban view +- **Release 1.1.2** + - Add Epic parent link (dependencies) ## Support us