mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 15:05:39 +00:00
fix(GridFieldOrderableRows): Added additional SQL that updates the "LastEdited" column if working with a non-ManyManyList
This commit is contained in:
parent
11ee7b0647
commit
51b5e657d6
@ -349,13 +349,15 @@ class GridFieldOrderableRows extends RequestHandler implements
|
||||
// Loop through each item, and update the sort values which do not
|
||||
// match to order the objects.
|
||||
if (!$isVersioned) {
|
||||
$additionalSQL = (!$list instanceof ManyManyList) ? ', "LastEdited" = NOW()' : '';
|
||||
foreach(array_values($order) as $pos => $id) {
|
||||
if($values[$id] != $pool[$pos]) {
|
||||
DB::query(sprintf(
|
||||
'UPDATE "%s" SET "%s" = %d WHERE %s',
|
||||
'UPDATE "%s" SET "%s" = %d%s WHERE %s',
|
||||
$this->getSortTable($list),
|
||||
$this->getSortField(),
|
||||
$pool[$pos],
|
||||
$additionalSQL,
|
||||
$this->getSortTableClauseForIds($list, $id)
|
||||
));
|
||||
}
|
||||
@ -383,16 +385,18 @@ class GridFieldOrderableRows extends RequestHandler implements
|
||||
$field = $this->getSortField();
|
||||
$table = $this->getSortTable($list);
|
||||
$clause = sprintf('"%s"."%s" = 0', $table, $this->getSortField());
|
||||
$additionalSQL = (!$list instanceof ManyManyList) ? ', "LastEdited" = NOW()' : '';
|
||||
|
||||
foreach($list->where($clause)->column('ID') as $id) {
|
||||
$max = DB::query(sprintf('SELECT MAX("%s") + 1 FROM "%s"', $field, $table));
|
||||
$max = $max->value();
|
||||
|
||||
DB::query(sprintf(
|
||||
'UPDATE "%s" SET "%s" = %d WHERE %s',
|
||||
'UPDATE "%s" SET "%s" = %d%s WHERE %s',
|
||||
$table,
|
||||
$field,
|
||||
$max,
|
||||
$additionalSQL,
|
||||
$this->getSortTableClauseForIds($list, $id)
|
||||
));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user