Skip to content

Commit

Permalink
change category sort dir
Browse files Browse the repository at this point in the history
  • Loading branch information
noumo committed Apr 26, 2016
1 parent 7a50515 commit 3d3c232
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/ActiveQueryNS.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function behaviors()

public function sort()
{
$this->orderBy('order_num DESC, lft ASC');
$this->orderBy('order_num ASC, lft ASC');
return $this;
}
}
4 changes: 2 additions & 2 deletions components/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ private function move($id, $direction)
$modelClass = $this->categoryClass;

$up = $direction == 'up';
$orderDir = $up ? SORT_ASC : SORT_DESC;
$orderDir = $up ? SORT_DESC : SORT_ASC;

if ($model->depth == 0) {

$swapCat = $modelClass::find()->where([$up ? '>' : '<', 'order_num', $model->order_num])->orderBy(['order_num' => $orderDir])->one();
$swapCat = $modelClass::find()->where([$up ? '<' : '>', 'order_num', $model->order_num])->orderBy(['order_num' => $orderDir])->one();
if ($swapCat) {
$modelClass::updateAll(['order_num' => '-1'], ['order_num' => $swapCat->order_num]);
$modelClass::updateAll(['order_num' => $swapCat->order_num], ['order_num' => $model->order_num]);
Expand Down

0 comments on commit 3d3c232

Please sign in to comment.