Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/RoadMap/DataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function epicObj(Epic $epic)
"pGroup" => 1,
"pParent" => 0,
"pOpen" => 1,
"pDepend" => "",
"pDepend" => $epic->parent_id ?? "",
"pCaption" => "",
"pNotes" => "",
"pBarText" => "",
Expand Down
24 changes: 20 additions & 4 deletions app/Http/Livewire/RoadMap/EpicForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -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'))
Expand All @@ -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'];
Expand Down
9 changes: 7 additions & 2 deletions app/Models/Epic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = [
Expand All @@ -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');
}
}
32 changes: 32 additions & 0 deletions database/migrations/2022_12_16_133836_add_parent_to_epics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

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

return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('epics', function (Blueprint $table) {
$table->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');
});
}
};