New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contact force verification #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
use hipanel\modules\client\grid\ContactGridView; | ||
use hipanel\modules\client\menus\ContactDetailMenu; | ||
use hipanel\modules\client\widgets\Verification; | ||
use hipanel\modules\client\widgets\ForceVerificationBlock; | ||
use hipanel\modules\document\widgets\StackedDocumentsView; | ||
use hipanel\widgets\Box; | ||
use hipanel\widgets\ClientSellerLink; | ||
|
@@ -46,30 +46,9 @@ | |
<?= ContactDetailMenu::widget(['model' => $model]) ?> | ||
</div> | ||
<?php Box::end() ?> | ||
|
||
<?php if (Yii::$app->user->can('contact.force-verify')) : ?> | ||
<?php $box = Box::begin(['renderBody' => false]) ?> | ||
<?php $box->beginHeader() ?> | ||
<?= $box->renderTitle(Yii::t('hipanel:client', 'Verification status')) ?> | ||
<?php $box->endHeader() ?> | ||
<?php $box->beginBody() ?> | ||
<table class="table table-striped table-bordered"> | ||
<tbody> | ||
<?php foreach (['name', 'address', 'email', 'voice_phone', 'fax_phone'] as $attribute) : ?> | ||
<tr> | ||
<th><?= $model->getAttributeLabel($attribute) ?></th> | ||
<td> | ||
<?= Verification::widget([ | ||
'model' => $model->getVerification($attribute), | ||
]) ?> | ||
</td> | ||
</tr> | ||
<?php endforeach ?> | ||
</tbody> | ||
</table> | ||
<?php $box->endBody() ?> | ||
<?php $box->end() ?> | ||
<?php endif ?> | ||
<?= ForceVerificationBlock::widget([ | ||
'model' => $model, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. у тебя тут отступ 8 пробелов - а у нас везде 4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. правильно. виджет находится между дивами. таб = 4 пробела |
||
]) ?> | ||
</div> | ||
|
||
<div class="col-md-9"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/* | ||
* Client module for HiPanel | ||
* | ||
* @link https://github.com/hiqdev/hipanel-module-client | ||
* @package hipanel-module-client | ||
* @license BSD-3-Clause | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace hipanel\modules\client\widgets; | ||
|
||
use Yii; | ||
use yii\base\InvalidConfigException; | ||
use yii\base\Widget; | ||
use yii\helpers\Html; | ||
use hipanel\widgets\Box; | ||
|
||
class ForceVerificationBlock extends Widget | ||
{ | ||
/** | ||
* @var \hipanel\base\Model | ||
*/ | ||
public $model; | ||
/** | ||
* options | ||
* | ||
* @var array | ||
*/ | ||
public $options = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. кажется, это свойство не используется |
||
/** | ||
* @var string | ||
*/ | ||
public $scenario; | ||
/** | ||
* @var string | ||
*/ | ||
public $submitUrl; | ||
/** | ||
* @var array | ||
*/ | ||
public $attributes; | ||
/** | ||
* @var string | ||
*/ | ||
public $title; | ||
|
||
public function init() | ||
{ | ||
if ($this->model === null) { | ||
throw new InvalidConfigException('Please specify the "model" property.'); | ||
} | ||
|
||
if ($this->attributes === null) { | ||
$this->attributes = ['name', 'address', 'email', 'voice_phone', 'fax_phone']; | ||
} | ||
|
||
if ($this->title === null) { | ||
$this->title = Yii::t('hipanel:client', 'Verification status'); | ||
} | ||
} | ||
|
||
public function run() | ||
{ | ||
if (Yii::$app->user->can('contact.force-verify')) { | ||
return $this->render((new \ReflectionClass($this))->getShortName(), [ | ||
'attributes' => $this->attributes, | ||
'model' => $this->model, | ||
'title' => $this->title, | ||
'scenario' => $this->scenario, | ||
'submitUrl' => $this->submitUrl | ||
]); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Методы должны иметь явно описанные возвращаемые данные. Предпочтительно использование условий для прерывания выполнения, вместо описания полезного кода внутри if. Это упрощает чтение кода. if (!Yii::$app->user->can('contact.force-verify')) {
return;
}
return $this->render((new \ReflectionClass($this))->getShortName(), [
'attributes' => $this->attributes,
'model' => $this->model,
'title' => $this->title,
'scenario' => $this->scenario,
'submitUrl' => $this->submitUrl
]);
} |
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,14 @@ class Verification extends Widget | |
* @var string | ||
*/ | ||
public $type; | ||
/** | ||
* @var string | ||
*/ | ||
public $submitUrl; | ||
/** | ||
* @var string | ||
*/ | ||
public $title; | ||
|
||
public function init() | ||
{ | ||
|
@@ -44,6 +52,16 @@ public function init() | |
if ($this->type === null) { | ||
$this->type = $this->model->type; | ||
} | ||
|
||
if ($this->submitUrl === null) { | ||
$this->submitUrl = '@contact/set-confirmation'; | ||
} | ||
|
||
if ($this->title === null) { | ||
$this->title = Yii::t('hipanel:client', 'Verification level'); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лишняя строка |
||
} | ||
|
||
} | ||
|
||
public function run() | ||
|
@@ -64,7 +82,7 @@ public function run() | |
|
||
protected function renderXEditable() | ||
{ | ||
return\hipanel\widgets\XEditable::widget([ | ||
return \hipanel\widgets\XEditable::widget([ | ||
'model' => $this->model, | ||
'attribute' => 'level', | ||
'scenario' => $this->scenario, | ||
|
@@ -73,9 +91,10 @@ protected function renderXEditable() | |
'data-attribute' => $this->type | ||
], | ||
'pluginOptions' => [ | ||
'url' => $this->submitUrl, | ||
'selector' => '#' . $this->getId(), | ||
'type' => 'select', | ||
'title' => Yii::t('hipanel:client', 'Verification level'), | ||
'title' => $this->title, | ||
'source' => $this->model->getAvailableLevels(), | ||
'params' => new JsExpression("function (params) { | ||
params.type = $(this).attr('data-attribute'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
use hipanel\widgets\Box; | ||
use hipanel\modules\client\widgets\Verification; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В блоке PHPDoc мы описываем переменные, которые приходят извне. |
||
?> | ||
<?php $box = Box::begin(['renderBody' => false]) ?> | ||
<?php $box->beginHeader() ?> | ||
<?= $box->renderTitle($title) ?> | ||
<?php $box->endHeader() ?> | ||
<?php $box->beginBody() ?> | ||
<table class='table table-striped table-borderetable table-striped table-bordered'> | ||
<tbody> | ||
<?php foreach ($attributes as $attribute) : ?> | ||
<?php if (!empty($model->$attribute)) : ?> | ||
<tr> | ||
<th><?= $model->getAttributeLabel($attribute) ?></th> | ||
<td> | ||
<?= Verification::widget([ | ||
'model' => $model->getVerification($attribute), | ||
'scenario' => $scenario, | ||
'submitUrl' => $submitUrl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тут тоже не хватает запятой |
||
]) ?> | ||
</td> | ||
</tr> | ||
<?php endif ?> | ||
<?php endforeach ?> | ||
</tbody> | ||
</table> | ||
<?php $box->endBody() ?> | ||
<?php $box->end() ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
закидывай запятую в массивах, потом легче докидывать новые элементы