PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.1.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.1.0
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
← All changes | app/Models/Stage.php +11 -12 1.112.1.0 View file →
@@ -51,9 +51,9 @@
51 51 ->first();
52 52
53 53 if ($firstItem) {
54 54 if ($firstItem->position < 0.02) {
55 - self::reIndexTasksPositions($this->toArray());
55 + self::reIndexStagesPositions($this->toArray());
56 56 return $this->moveToNewPosition($newIndex);
57 57 }
58 58 $index = round($firstItem->position / 2, 2);
59 59 } else {
@@ -86,27 +86,21 @@
86 86 $this->save();
87 87 return $this;
88 88 }
89 89
90 - $newPosition = ($prevTask->position + $nextItem->position) / 2;
91 -
92 - // check if new position is already taken
93 - $exist = $stageQuery
94 - ->where('position', $newPosition)
95 - ->where('id', '!=', $this->id)
96 - ->first();
97 -
98 - if ($exist) {
99 - self::reIndexTasksPositions($this->toArray());
90 + if ($nextItem->position - $prevTask->position < 0.02) {
91 + self::reIndexStagesPositions($this->toArray());
100 92 return $this->moveToNewPosition($newIndex);
101 93 }
102 94
95 + $newPosition = ($prevTask->position + $nextItem->position)/ 2;
96 +
103 97 $this->position = $newPosition;
104 98 $this->save();
105 99 return $this;
106 100 }
107 101
108 - public static function reIndexTasksPositions($stage)
102 + public static function reIndexStagesPositions($stage)
109 103 {
110 104 $allStages = self::where('board_id', $stage['board_id'])->where('type', 'stage')->orderBy('position', 'asc')->whereNull('archived_at')->get();
111 105
112 106 foreach ($allStages as $index => $stage) {
@@ -112,7 +106,12 @@
112 106 foreach ($allStages as $index => $stage) {
113 107 $stage->position = $index + 1;
114 108 $stage->save();
115 109 }
110 + }
111 +
112 + public function tasks()
113 + {
114 + return $this->hasMany(Task::class, 'stage_id');
116 115 }
117 116
118 117 }