Commit 36744c04d190583ebc62e06d5868a442d576cdbf
1 parent
a2ea9d10
- fast order in admin
Showing
2 changed files
with
43 additions
and
0 deletions
Show diff stats
| 1 | +<?php | ||
| 2 | + namespace artbox\order\columns; | ||
| 3 | + | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + | ||
| 6 | + /** | ||
| 7 | + * Created by PhpStorm. | ||
| 8 | + * User: stes | ||
| 9 | + * Date: 23.04.18 | ||
| 10 | + * Time: 17:02 | ||
| 11 | + */ | ||
| 12 | + class ActionColumn extends \artbox\core\admin\grid\columns\ActionColumn | ||
| 13 | + { | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + public $columnTemplate = '{item}'; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + protected function renderLink($model) | ||
| 21 | + { | ||
| 22 | + $fieldName = $this->field; | ||
| 23 | + if ($this->columnTemplate instanceof \Closure){ | ||
| 24 | + $options = call_user_func($this->columnTemplate, $model); | ||
| 25 | + return $options; | ||
| 26 | + }else{ | ||
| 27 | + return str_replace('{item}', Html::a($model->$fieldName, '#', $this->linkOptions), $this->columnTemplate); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + } | ||
| 0 | \ No newline at end of file | 35 | \ No newline at end of file |
controllers/OrderController.php
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | 4 | ||
| 5 | use artbox\catalog\models\Variant; | 5 | use artbox\catalog\models\Variant; |
| 6 | use artbox\core\admin\actions\Index; | 6 | use artbox\core\admin\actions\Index; |
| 7 | + use artbox\order\columns\ActionColumn; | ||
| 7 | use artbox\order\labels\models\Delivery; | 8 | use artbox\order\labels\models\Delivery; |
| 8 | use artbox\order\labels\models\Label; | 9 | use artbox\order\labels\models\Label; |
| 9 | use artbox\order\models\OrderProduct; | 10 | use artbox\order\models\OrderProduct; |
| @@ -70,7 +71,15 @@ | @@ -70,7 +71,15 @@ | ||
| 70 | 'name' => [ | 71 | 'name' => [ |
| 71 | 'type' => Index::ACTION_COL, | 72 | 'type' => Index::ACTION_COL, |
| 72 | 'columnConfig' => [ | 73 | 'columnConfig' => [ |
| 74 | + 'class' => ActionColumn::class, | ||
| 73 | 'buttonsTemplate' => '{edit}{delete}', | 75 | 'buttonsTemplate' => '{edit}{delete}', |
| 76 | + 'columnTemplate' => function (Order $model){ | ||
| 77 | + if (empty($model->name)){ | ||
| 78 | + return "<span>(не указано)<b class='mouse-lmc'></b></span>"; | ||
| 79 | + }else{ | ||
| 80 | + return $model->name; | ||
| 81 | + } | ||
| 82 | + } | ||
| 74 | ], | 83 | ], |
| 75 | ], | 84 | ], |
| 76 | 'phone' => [ | 85 | 'phone' => [ |