diff --git a/controllers/BrandController.php b/controllers/BrandController.php
index 2952bbf..fefa714 100755
--- a/controllers/BrandController.php
+++ b/controllers/BrandController.php
@@ -40,6 +40,7 @@
'update',
'view',
'delete',
+ 'delete-image',
],
'allow' => true,
'roles' => [ '@' ],
@@ -49,7 +50,8 @@
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
- 'logout' => [ 'post' ],
+ 'logout' => [ 'post' ],
+ 'delete-image' => [ 'post' ],
],
],
];
@@ -57,6 +59,7 @@
/**
* Lists all Brand models.
+ *
* @return mixed
*/
public function actionIndex()
@@ -64,10 +67,13 @@
$searchModel = new BrandSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
+ return $this->render(
+ 'index',
+ [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]
+ );
}
/**
@@ -79,33 +85,42 @@
*/
public function actionView($id)
{
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
+ return $this->render(
+ 'view',
+ [
+ 'model' => $this->findModel($id),
+ ]
+ );
}
/**
* Creates a new Brand model.
* If creation is successful, the browser will be redirected to the 'view' page.
+ *
* @return mixed
*/
public function actionCreate()
{
$model = new Brand();
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([
- 'view',
- 'id' => $model->id,
- ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams));
+ if ($model->save() && $model->transactionStatus) {
+ return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ ) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams));
}
}
- return $this->render('create', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'create',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -121,19 +136,24 @@
$model = $this->findModel($id);
$model->generateLangs();
- if($model->load(Yii::$app->request->post())) {
+ if ($model->load(Yii::$app->request->post())) {
$model->loadLangs(\Yii::$app->request);
- if($model->save() && $model->transactionStatus) {
- return $this->redirect([
- 'view',
- 'id' => $model->id,
- ]);
+ if ($model->save() && $model->transactionStatus) {
+ return $this->redirect(
+ [
+ 'view',
+ 'id' => $model->id,
+ ]
+ );
}
}
- return $this->render('update', [
- 'model' => $model,
- 'modelLangs' => $model->modelLangs,
- ]);
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ 'modelLangs' => $model->modelLangs,
+ ]
+ );
}
/**
@@ -152,6 +172,14 @@
return $this->redirect([ 'index' ]);
}
+ public function actionDeleteImage($id)
+ {
+ $model = $this->findModel($id);
+ $model->image = null;
+ $model->updateAttributes(['image']);
+ return true;
+ }
+
/**
* Finds the Brand model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
@@ -163,7 +191,11 @@
*/
protected function findModel($id)
{
- if(( $model = Brand::find()->with('lang')->where(['id' => $id])->one() ) !== NULL) {
+ if (( $model = Brand::find()
+ ->with('lang')
+ ->where([ 'id' => $id ])
+ ->one() ) !== null
+ ) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
diff --git a/controllers/CategoryController.php b/controllers/CategoryController.php
index 34b97eb..97bc144 100755
--- a/controllers/CategoryController.php
+++ b/controllers/CategoryController.php
@@ -210,6 +210,22 @@
return $this->redirect([ 'index' ]);
}
+
+ public function actionDeleteImage($id)
+ {
+ $model = $this->findModel($id);
+ $model->image = null;
+ $model->updateAttributes(['image']);
+ return true;
+ }
+
+ public function actionDeleteIcon($id)
+ {
+ $model = $this->findModel($id);
+ $model->icon = null;
+ $model->updateAttributes(['icon']);
+ return true;
+ }
/**
* Finds the Category model based on its primary key value.
diff --git a/controllers/ManageController.php b/controllers/ManageController.php
index d8facaa..cfe7b6c 100755
--- a/controllers/ManageController.php
+++ b/controllers/ManageController.php
@@ -123,6 +123,7 @@
[
'model' => $model,
'modelLangs' => $model->modelLangs,
+ 'videos' => !empty( $model->videos ) ? $model->videos : [ new ProductVideo() ],
]
);
}
@@ -409,6 +410,14 @@
]
);
}
+
+ public function actionDeleteSize($id)
+ {
+ $model = $this->findModel($id);
+ $model->size_image = null;
+ $model->updateAttributes(['size_image']);
+ return true;
+ }
/**
* Finds the Product model based on its primary key value.
diff --git a/controllers/TaxOptionController.php b/controllers/TaxOptionController.php
index 6f78463..5103ea7 100755
--- a/controllers/TaxOptionController.php
+++ b/controllers/TaxOptionController.php
@@ -156,6 +156,14 @@
]
);
}
+
+ public function actionDeleteImage($id)
+ {
+ $model = $this->findModel($id);
+ $model->image = null;
+ $model->updateAttributes(['image']);
+ return true;
+ }
/**
* Finds the TaxOption model based on its primary key value.
diff --git a/views/brand/_form.php b/views/brand/_form.php
index 77fbda4..fd8baa7 100755
--- a/views/brand/_form.php
+++ b/views/brand/_form.php
@@ -5,6 +5,7 @@
use artweb\artbox\ecommerce\models\Brand;
use artweb\artbox\ecommerce\models\BrandLang;
use yii\helpers\Html;
+ use yii\helpers\Url;
use yii\web\View;
use yii\widgets\ActiveForm;
@@ -18,47 +19,77 @@
- false,
- 'options' => [ 'enctype' => 'multipart/form-data' ],
- ]); ?>
+ false,
+ 'options' => [ 'enctype' => 'multipart/form-data' ],
+ ]
+ ); ?>
= $form->field($model, 'image')
- ->widget(\kartik\file\FileInput::className(), [
- 'language' => 'ru',
- 'options' => [
- 'accept' => 'image/*',
- 'multiple' => false,
- ],
- 'pluginOptions' => [
- 'allowedFileExtensions' => [
- 'jpg',
- 'gif',
- 'png',
+ ->widget(
+ \kartik\file\FileInput::className(),
+ [
+ 'language' => 'ru',
+ 'options' => [
+ 'accept' => 'image/*',
+ 'multiple' => false,
+ 'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/brand/delete-image', 'id' => $model->id]),
+ 'class' => $model->isNewRecord?'':'artbox-delete-file',
],
- 'initialPreview' => !empty( $model->imageUrl ) ? ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
- 'overwriteInitial' => true,
- 'showRemove' => false,
- 'showUpload' => false,
- 'previewFileType' => 'image',
- ],
- ]); ?>
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => [
+ 'jpg',
+ 'gif',
+ 'png',
+ ],
+ 'initialPreview' => !empty( $model->getImageUrl(
+ 0,
+ false
+ ) ) ? ArtboxImageHelper::getImage(
+ $model->imageUrl,
+ 'list',
+ []
+ ) : '',
+ 'initialPreviewShowDelete' => false,
+ 'overwriteInitial' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'showClose' => false,
+ 'previewFileType' => 'image',
+ ],
+ ]
+ ); ?>
- = $form->field($model, 'in_menu')->dropDownList([\Yii::t('product', 'No'), \Yii::t('product', 'Yes')]); ?>
+ = $form->field($model, 'in_menu')
+ ->dropDownList(
+ [
+ \Yii::t('product', 'No'),
+ \Yii::t('product', 'Yes'),
+ ]
+ ); ?>
- = LanguageForm::widget([
- 'modelLangs' => $modelLangs,
- 'formView' => '@artweb/artbox/ecommerce/views/brand/_form_language',
- 'form' => $form,
- ]) ?>
+ = LanguageForm::widget(
+ [
+ 'modelLangs' => $modelLangs,
+ 'formView' => '@artweb/artbox/ecommerce/views/brand/_form_language',
+ 'form' => $form,
+ ]
+ ) ?>
- = Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?>
- isNewRecord) : ?>
- = Html::submitButton(Yii::t('product', 'Create and continue'), [
- 'name' => 'create_and_new',
- 'class' => 'btn btn-primary',
- ]) ?>
+ = Html::submitButton(
+ $model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'),
+ [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
+ ) ?>
+ isNewRecord) : ?>
+ = Html::submitButton(
+ Yii::t('product', 'Create and continue'),
+ [
+ 'name' => 'create_and_new',
+ 'class' => 'btn btn-primary',
+ ]
+ ) ?>
diff --git a/views/category/_form.php b/views/category/_form.php
index 61cd4b6..f33009b 100755
--- a/views/category/_form.php
+++ b/views/category/_form.php
@@ -5,6 +5,7 @@
use artweb\artbox\ecommerce\models\Category;
use artweb\artbox\ecommerce\models\CategoryLang;
use yii\helpers\Html;
+ use yii\helpers\Url;
use yii\web\View;
use yii\widgets\ActiveForm;
@@ -55,6 +56,8 @@
'options' => [
'accept' => 'image/*',
'multiple' => false,
+ 'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/category/delete-image', 'id' => $model->id]),
+ 'class' => $model->isNewRecord?'':'artbox-delete-file',
],
'pluginOptions' => [
'allowedFileExtensions' => [
@@ -62,14 +65,16 @@
'gif',
'png',
],
- 'initialPreview' => !empty( $model->imageUrl ) ? ArtboxImageHelper::getImage(
+ 'initialPreview' => !empty( $model->getImageUrl(0, false) ) ? ArtboxImageHelper::getImage(
$model->imageUrl,
'list'
) : '',
- 'overwriteInitial' => true,
- 'showRemove' => false,
- 'showUpload' => false,
- 'previewFileType' => 'image',
+ 'initialPreviewShowDelete' => false,
+ 'overwriteInitial' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'showClose' => false,
+ 'previewFileType' => 'image',
],
]
); ?>
@@ -82,6 +87,8 @@
'options' => [
'accept' => 'image/*',
'multiple' => false,
+ 'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/category/delete-icon', 'id' => $model->id]),
+ 'class' => $model->isNewRecord?'':'artbox-delete-file',
],
'pluginOptions' => [
'allowedFileExtensions' => [
@@ -96,10 +103,12 @@
$model->getImageUrl(1, false),
'list'
) : '',
- 'overwriteInitial' => true,
- 'showRemove' => false,
- 'showUpload' => false,
- 'previewFileType' => 'image',
+ 'initialPreviewShowDelete' => false,
+ 'overwriteInitial' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'showClose' => false,
+ 'previewFileType' => 'image',
],
]
); ?>
diff --git a/views/manage/_form.php b/views/manage/_form.php
index 94a356c..7d1dc60 100755
--- a/views/manage/_form.php
+++ b/views/manage/_form.php
@@ -9,6 +9,7 @@
use wbraganca\dynamicform\DynamicFormWidget;
use yii\db\ActiveQuery;
use yii\helpers\Html;
+ use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use artweb\artbox\components\artboxtree\ArtboxTreeHelper;
@@ -190,6 +191,8 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) {
'options' => [
'accept' => 'image/*',
'multiple' => false,
+ 'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/manage/delete-size', 'id' => $model->id]),
+ 'class' => $model->isNewRecord?'':'artbox-delete-file',
],
'pluginOptions' => [
'allowedFileExtensions' => [
@@ -197,14 +200,16 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) {
'gif',
'png',
],
- 'initialPreview' => !empty( $model->getBehavior('size_image')->imageUrl ) ? ArtboxImageHelper::getImage(
+ 'initialPreview' => !empty( $model->getBehavior('size_image')->getImageUrl(0, false)) ? ArtboxImageHelper::getImage(
$model->getBehavior('size_image')->imageUrl,
'list'
) : '',
- 'overwriteInitial' => true,
- 'showRemove' => false,
- 'showUpload' => false,
- 'previewFileType' => 'image',
+ 'initialPreviewShowDelete' => false,
+ 'overwriteInitial' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'showClose' => false,
+ 'previewFileType' => 'image',
],
]
); ?>
diff --git a/views/manage/create.php b/views/manage/create.php
index adb632d..91404fd 100755
--- a/views/manage/create.php
+++ b/views/manage/create.php
@@ -2,13 +2,15 @@
use artweb\artbox\ecommerce\models\Product;
use artweb\artbox\ecommerce\models\ProductLang;
+ use artweb\artbox\ecommerce\models\ProductVideo;
use yii\helpers\Html;
use yii\web\View;
/**
- * @var View $this
- * @var Product $model
- * @var ProductLang[] $modelLangs
+ * @var View $this
+ * @var Product $model
+ * @var ProductLang[] $modelLangs
+ * @var ProductVideo[] $videos
*/
$this->title = Yii::t('product', 'Create Product');
@@ -22,9 +24,13 @@
= Html::encode($this->title) ?>
- = $this->render('_form', [
- 'model' => $model,
- 'modelLangs' => $modelLangs,
- ]) ?>
+ = $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ 'modelLangs' => $modelLangs,
+ 'videos' => $videos,
+ ]
+ ) ?>
diff --git a/views/tax-option/_form.php b/views/tax-option/_form.php
index 3cd71c1..fff572c 100755
--- a/views/tax-option/_form.php
+++ b/views/tax-option/_form.php
@@ -6,6 +6,7 @@
use artweb\artbox\ecommerce\models\TaxOptionLang;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
+ use yii\helpers\Url;
use yii\widgets\ActiveForm;
use artweb\artbox\ecommerce\models\TaxOption;
@@ -48,6 +49,8 @@
'options' => [
'accept' => 'image/*',
'multiple' => false,
+ 'deleteurl' => $model->isNewRecord?false:Url::to(['/ecommerce/tax-option/delete-image', 'id' => $model->id]),
+ 'class' => $model->isNewRecord?'':'artbox-delete-file',
],
'pluginOptions' => [
'allowedFileExtensions' => [
@@ -55,14 +58,16 @@
'gif',
'png',
],
- 'initialPreview' => !empty( $model->imageUrl ) ? ArtboxImageHelper::getImage(
+ 'initialPreview' => !empty( $model->getImageUrl(0, false) ) ? ArtboxImageHelper::getImage(
$model->imageUrl,
'list'
) : '',
- 'overwriteInitial' => true,
- 'showRemove' => false,
- 'showUpload' => false,
- 'previewFileType' => 'image',
+ 'initialPreviewShowDelete' => false,
+ 'overwriteInitial' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'showClose' => false,
+ 'previewFileType' => 'image',
],
]
)
--
libgit2 0.21.4