@@ 295-317 (lines=23) @@ | ||
292 | * |
|
293 | * @return bool |
|
294 | */ |
|
295 | public function changePosition($project_id, $category_id, $position) |
|
296 | { |
|
297 | if ($position < 1 || $position > $this->db->table(self::TABLE)->eq('project_id', $project_id)->count()) { |
|
298 | return false; |
|
299 | } |
|
300 | ||
301 | $category_ids = $this->db->table(self::TABLE)->eq('project_id', $project_id)->neq('id', $category_id)->asc('position')->findAllByColumn('id'); |
|
302 | $offset = 1; |
|
303 | $results = []; |
|
304 | ||
305 | foreach ($category_ids as $current_category_id) { |
|
306 | if ($offset == $position) { |
|
307 | $offset++; |
|
308 | } |
|
309 | ||
310 | $results[] = $this->db->table(self::TABLE)->eq('id', $current_category_id)->update(['position' => $offset]); |
|
311 | $offset++; |
|
312 | } |
|
313 | ||
314 | $results[] = $this->db->table(self::TABLE)->eq('id', $category_id)->update(['position' => $position]); |
|
315 | ||
316 | return !in_array(false, $results, true); |
|
317 | } |
|
318 | } |
|
319 |
@@ 211-233 (lines=23) @@ | ||
208 | * |
|
209 | * @return bool |
|
210 | */ |
|
211 | public function changePosition($project_id, $column_id, $position) |
|
212 | { |
|
213 | if ($position < 1 || $position > $this->db->table(self::TABLE)->eq('project_id', $project_id)->count()) { |
|
214 | return false; |
|
215 | } |
|
216 | ||
217 | $column_ids = $this->db->table(self::TABLE)->eq('project_id', $project_id)->neq('id', $column_id)->asc('position')->findAllByColumn('id'); |
|
218 | $offset = 1; |
|
219 | $results = []; |
|
220 | ||
221 | foreach ($column_ids as $current_column_id) { |
|
222 | if ($offset == $position) { |
|
223 | $offset++; |
|
224 | } |
|
225 | ||
226 | $results[] = $this->db->table(self::TABLE)->eq('id', $current_column_id)->update(['position' => $offset]); |
|
227 | $offset++; |
|
228 | } |
|
229 | ||
230 | $results[] = $this->db->table(self::TABLE)->eq('id', $column_id)->update(['position' => $position]); |
|
231 | ||
232 | return !in_array(false, $results, true); |
|
233 | } |
|
234 | } |
|
235 |
@@ 30-52 (lines=23) @@ | ||
27 | * |
|
28 | * @return bool |
|
29 | */ |
|
30 | public function changePosition($task_id, $subtask_id, $position) |
|
31 | { |
|
32 | if ($position < 1 || $position > $this->db->table(SubtaskModel::TABLE)->eq('task_id', $task_id)->count()) { |
|
33 | return false; |
|
34 | } |
|
35 | ||
36 | $subtask_ids = $this->db->table(SubtaskModel::TABLE)->eq('task_id', $task_id)->neq('id', $subtask_id)->asc('position')->findAllByColumn('id'); |
|
37 | $offset = 1; |
|
38 | $results = []; |
|
39 | ||
40 | foreach ($subtask_ids as $current_subtask_id) { |
|
41 | if ($offset == $position) { |
|
42 | $offset++; |
|
43 | } |
|
44 | ||
45 | $results[] = $this->db->table(SubtaskModel::TABLE)->eq('id', $current_subtask_id)->update(['position' => $offset]); |
|
46 | $offset++; |
|
47 | } |
|
48 | ||
49 | $results[] = $this->db->table(SubtaskModel::TABLE)->eq('id', $subtask_id)->update(['position' => $position]); |
|
50 | ||
51 | return !in_array(false, $results, true); |
|
52 | } |
|
53 | } |
|
54 |
@@ 457-485 (lines=29) @@ | ||
454 | * |
|
455 | * @return bool |
|
456 | */ |
|
457 | public function changePosition($project_id, $swimlane_id, $position) |
|
458 | { |
|
459 | if ($position < 1 || $position > $this->db->table(self::TABLE)->eq('project_id', $project_id)->count()) { |
|
460 | return false; |
|
461 | } |
|
462 | ||
463 | $swimlane_ids = $this->db->table(self::TABLE) |
|
464 | ->eq('is_active', 1) |
|
465 | ->eq('project_id', $project_id) |
|
466 | ->neq('id', $swimlane_id) |
|
467 | ->asc('position') |
|
468 | ->findAllByColumn('id'); |
|
469 | ||
470 | $offset = 1; |
|
471 | $results = []; |
|
472 | ||
473 | foreach ($swimlane_ids as $current_swimlane_id) { |
|
474 | if ($offset == $position) { |
|
475 | $offset++; |
|
476 | } |
|
477 | ||
478 | $results[] = $this->db->table(self::TABLE)->eq('id', $current_swimlane_id)->update(['position' => $offset]); |
|
479 | $offset++; |
|
480 | } |
|
481 | ||
482 | $results[] = $this->db->table(self::TABLE)->eq('id', $swimlane_id)->update(['position' => $position]); |
|
483 | ||
484 | return !in_array(false, $results, true); |
|
485 | } |
|
486 | ||
487 | /** |
|
488 | * Duplicate Swimlane to project. |