mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-09 11:16:39 -05:00
Consider the reorder column if present when adding and deleting new rows
This commit is contained in:
parent
734268c1dd
commit
3a3ddd09d3
1 changed files with 12 additions and 0 deletions
|
@ -167,6 +167,10 @@ class DashboardController extends Controller {
|
|||
if ($model_class != null) {
|
||||
if ($request['id'] == 'new') {
|
||||
$item = new $model_class;
|
||||
|
||||
if ($model_class::$dashboard_reorder) {
|
||||
$item->{$model_class::$dashboard_sort_column} = $model_class::count();
|
||||
}
|
||||
} else {
|
||||
$item = $model_class::find($request['id']);
|
||||
|
||||
|
@ -297,6 +301,14 @@ class DashboardController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
// update the order of the remaining rows if $dashboard_reorder is true
|
||||
if ($model_class::$dashboard_reorder) {
|
||||
foreach ($model_class::getDashboardData() as $index => $item) {
|
||||
$item->{$model_class::$dashboard_sort_column} = $index;
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Return a success
|
||||
return 'success';
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue