From afe3a885b37e0f5b6bcd3442eca4baabf954104e Mon Sep 17 00:00:00 2001 From: Albert Date: Sun, 7 May 2017 01:12:40 +0300 Subject: [PATCH] Add Pjax to ProductController. Remove Bootstrap from ProductAsset. --- backend/assets/ProductAsset.php | 1 - backend/controllers/ProductController.php | 4 ++++ backend/views/product/index.php | 11 ++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/assets/ProductAsset.php b/backend/assets/ProductAsset.php index a7a8b04..86a93f1 100644 --- a/backend/assets/ProductAsset.php +++ b/backend/assets/ProductAsset.php @@ -16,6 +16,5 @@ class ProductAsset extends AssetBundle public $depends = [ 'yii\web\YiiAsset', - 'yii\bootstrap\BootstrapAsset', ]; } \ No newline at end of file diff --git a/backend/controllers/ProductController.php b/backend/controllers/ProductController.php index efb4e38..ae5a90f 100644 --- a/backend/controllers/ProductController.php +++ b/backend/controllers/ProductController.php @@ -694,6 +694,7 @@ public function actionUp($id) $product->movePrev(); $this->trigger(self::EVENT_AFTER_EDIT_PRODUCT, new ProductEvent(['id' => $id])); } + if (\Yii::$app->request->isPjax) return $this->actionIndex(); return $this->redirect(\Yii::$app->request->referrer); } else throw new ForbiddenHttpException(\Yii::t('shop', 'You have not permission to do this action.')); } @@ -720,6 +721,7 @@ public function actionDown($id) $product->moveNext(); $this->trigger(self::EVENT_AFTER_EDIT_PRODUCT, new ProductEvent(['id' => $id])); } + if (\Yii::$app->request->isPjax) return $this->actionIndex(); return $this->redirect(\Yii::$app->request->referrer); } else throw new ForbiddenHttpException(\Yii::t('shop', 'You have not permission to do this action.')); } @@ -751,6 +753,8 @@ public function actionDelete($id) $product->delete(); $this->trigger(self::EVENT_AFTER_DELETE_PRODUCT, new ProductEvent(['id' => $id])); + + if (\Yii::$app->request->isPjax) return $this->actionIndex(); return $this->redirect('index'); } else throw new ForbiddenHttpException(\Yii::t('shop', 'You have not permission to delete this product.')); } diff --git a/backend/views/product/index.php b/backend/views/product/index.php index 2bc0a4d..d493684 100644 --- a/backend/views/product/index.php +++ b/backend/views/product/index.php @@ -34,7 +34,11 @@ Yii::t('shop', 'Products') ]; ?> - + 'p-products', + 'linkSelector' => '.pjax', + 'enablePushState' => false +]); ?>
@@ -79,14 +83,14 @@ class="btn btn-primary btn-xs"> '', Url::toRoute(['up', 'id' => $model->id]), [ - 'class' => 'fa fa-chevron-up' + 'class' => 'fa fa-chevron-up pjax' ] ); $buttonDown = Html::a( '', Url::toRoute(['down', 'id' => $model->id]), [ - 'class' => 'fa fa-chevron-down' + 'class' => 'fa fa-chevron-down pjax' ] ); return $buttonUp . '
' . $model->position . '
' . $buttonDown; @@ -229,3 +233,4 @@ class="btn btn-primary btn-xs pull-right">
+ \ No newline at end of file