Skip to content
Closed
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
14 changes: 7 additions & 7 deletions database/factories/TaskFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Relaticle\Flowforge\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Relaticle\Flowforge\Services\Rank;
use Relaticle\Flowforge\Services\DecimalPosition;
use Relaticle\Flowforge\Tests\Fixtures\Task;

class TaskFactory extends Factory
Expand Down Expand Up @@ -176,15 +176,15 @@ private function generateResearchTitle(): string

private function generatePosition(): string
{
// Generate positions in a realistic range
static $baseRank = null;
// Generate positions in a realistic range using decimal positions
static $position = null;

if ($baseRank === null) {
$baseRank = Rank::forEmptySequence();
if ($position === null) {
$position = DecimalPosition::forEmptyColumn();
} else {
$baseRank = Rank::after($baseRank);
$position = DecimalPosition::after($position);
}

return $baseRank->get();
return $position;
}
}
35 changes: 35 additions & 0 deletions database/migrations/add_unique_position_constraint.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*
* IMPORTANT: Before running this migration, ensure you have no duplicate
* positions in your table by running:
*
* php artisan flowforge:repair-positions YourModel --column=status
*/
public function up(): void
{
Schema::table('your_table_name', function (Blueprint $table) {
// Add unique constraint on (status_column, position_column) combination
// This prevents duplicate positions within the same column/status
$table->unique(['status_column', 'position_column'], 'unique_position_per_column');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('your_table_name', function (Blueprint $table) {
$table->dropUnique('unique_position_per_column');
});
}
};
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 5
paths:
- src
- config
Expand Down
2 changes: 1 addition & 1 deletion resources/dist/flowforge.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/js/flowforge.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function flowforge({state}) {
const afterCardId = cardIndex > 0 ? newOrder[cardIndex - 1] : null;
const beforeCardId = cardIndex < newOrder.length - 1 ? newOrder[cardIndex + 1] : null;

this.$wire.moveCard(cardId, targetColumn, beforeCardId, afterCardId)
this.$wire.moveCard(cardId, targetColumn, afterCardId, beforeCardId)
.then(() => this.setCardState(cardElement, false))
.catch(() => this.setCardState(cardElement, false));
},
Expand Down
Loading