From d0f3b99fc4107be9e08df36ae701f7492e3ed8f1 Mon Sep 17 00:00:00 2001 From: Yarik Date: Wed, 27 Apr 2016 13:34:52 +0300 Subject: [PATCH] test --- common/models/Feedback.php | 2 +- common/modules/comment/models/CommentProject.php | 1 + common/modules/comment/models/CommentProjectAnswer.php | 17 +++++++++++++++++ common/modules/comment/resources/comment.js | 3 +++ common/modules/comment/widgets/views/_question_comment_view.php | 51 +++++++++++++++++++++++++++++---------------------- common/modules/comment/widgets/views/form-comment-answer.php | 34 +++++++++++++++++++++++----------- common/modules/comment/widgets/views/form-project-comment.php | 2 +- frontend/views/tender/view.php | 352 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------- 8 files changed, 269 insertions(+), 193 deletions(-) diff --git a/common/models/Feedback.php b/common/models/Feedback.php index 80844ea..50b30ad 100644 --- a/common/models/Feedback.php +++ b/common/models/Feedback.php @@ -54,7 +54,7 @@ class Feedback extends \yii\db\ActiveRecord return [ [['name', 'answer', 'email'], 'required'], [['email'], 'email'], - [['phone'], 'match', 'pattern' => '^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$'], + [['phone'], 'match', 'pattern' => '/^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$/'], [['name', 'phone', 'answer'], 'string', 'max' => 255], ]; } diff --git a/common/modules/comment/models/CommentProject.php b/common/modules/comment/models/CommentProject.php index f1cd1ec..d35290c 100644 --- a/common/modules/comment/models/CommentProject.php +++ b/common/modules/comment/models/CommentProject.php @@ -342,6 +342,7 @@ return \Yii::$app->user->can(\common\modules\comment\Permissions::CREATE, [ 'model' => $this->model, 'model_id' => $this->model_id, + 'comment_model' => $this->className(), ]); } } diff --git a/common/modules/comment/models/CommentProjectAnswer.php b/common/modules/comment/models/CommentProjectAnswer.php index 2b4c5c5..2d0b4d1 100644 --- a/common/modules/comment/models/CommentProjectAnswer.php +++ b/common/modules/comment/models/CommentProjectAnswer.php @@ -75,6 +75,23 @@ 'model_id' => $this->model_id, ], ], + [ + ['comment_pid'], + 'required', + 'when' => function($model, $attribute) { + /** + * @var CommentProjectAnswer $model + * @var string $attribute + */ + if(!empty(\Yii::$app->user->id) && $model->isNewRecord && !empty($model->model) && !empty($model->model_id)) { + $project = Project::findOne($model->model_id); + if(!empty($project) && $project->user_id == \Yii::$app->user->id) { + return true; + } + } + return false; + } + ], ]; } diff --git a/common/modules/comment/resources/comment.js b/common/modules/comment/resources/comment.js index b689e2f..48ea487 100644 --- a/common/modules/comment/resources/comment.js +++ b/common/modules/comment/resources/comment.js @@ -187,11 +187,14 @@ $(function() { $(document).on('click', '.artbox_comment_reply_answer', function(e) { e.preventDefault(); var widget = $(this).parents('.artbox_comment_widget'); + var form = $(widget).find('.artbox_comment_form'); + $(form).removeClass('hidden'); $(widget).find('.artbox_comment_answer_label').text('Ответ'); }); $(document).on('click', '.artbox_comment_reply_answer_block', function(e) { var form = $(this).parents('.artbox_comment_form'); + $(form).addClass('hidden'); $(form).find('.artbox_comment_answer_label').text('Вопрос'); }); diff --git a/common/modules/comment/widgets/views/_question_comment_view.php b/common/modules/comment/widgets/views/_question_comment_view.php index 84fe00f..c733a62 100644 --- a/common/modules/comment/widgets/views/_question_comment_view.php +++ b/common/modules/comment/widgets/views/_question_comment_view.php @@ -21,8 +21,8 @@ ]); } ?> -
-
user ) && !empty($model->user->userInfo->image) ) ? $model->user->minImg($model->user->userInfo->image, 48, 48) : '/images/ico-profile.png') ?>
+
+
user ) && !empty( $model->user->userInfo->image ) ) ? $model->user->minImg($model->user->userInfo->image, 48, 48) : '/images/ico-profile.png') ?>
getAuthor(' (Гость)') ?> @@ -30,16 +30,17 @@
-
Pro
- +
Pro
+ -formatter->asDate($model->date_add, 'php:d.m.Y') ?> + formatter->asDate($model->date_add, 'php:d.m.Y') ?>
Вопрос
@@ -61,19 +62,25 @@ ]); } ?> -
- buttons[ 'delete' ] )) { - echo Html::a(( $model->user_id != NULL && $model->user_id == \Yii::$app->user->id ) ? 'Удалить' : 'Пожаловаться ', $model->buttons[ 'delete' ], [ 'class' => 'artbox_comment_delete_answer' ]); - } - if(!empty( $model->buttons[ 'update' ] )) { - echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => 'artbox_comment_update_answer' ]); - } - if(!empty( $model->buttons[ 'reply' ] )) { - echo Html::a('Ответить', $model->buttons[ 'reply' ], [ 'class' => CommentWidget::$baseClass[ 'comment_reply' ] . ' artbox_comment_reply_answer' ]); - } - ?> -
+ buttons)) { + ?> +
+ buttons[ 'delete' ] )) { + echo Html::a(( $model->user_id != NULL && $model->user_id == \Yii::$app->user->id ) ? 'Удалить' : 'Пожаловаться ', $model->buttons[ 'delete' ], [ 'class' => 'artbox_comment_delete_answer' ]); + } + if(!empty( $model->buttons[ 'update' ] )) { + echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => 'artbox_comment_update_answer' ]); + } + if(!empty( $model->buttons[ 'reply' ] )) { + echo Html::a('Ответить', $model->buttons[ 'reply' ], [ 'class' => CommentWidget::$baseClass[ 'comment_reply' ] . ' artbox_comment_reply_answer' ]); + } + ?> +
+
-
Задать вопрос
+model_id )) { + $project = Project::findOne($model->model_id); + } + if(!empty( $project ) && $project->user_id != \Yii::$app->user->id) { + ?> +
Задать вопрос
+
user->id)) {?> -
-
-
user->identity->name; ?>
-
+ if(!empty( \Yii::$app->user->id )) { ?> +
+
+ +
+
user->identity->name; ?>
+
- ['data' => ['pjax' => true]]]); if(!$model->isNewRecord) { echo $form->field($model, 'comment_id') ->hiddenInput() ->label(false) ->error(false); } - if(!empty($model->comment_pid)) { + if(!empty( $model->comment_pid )) { echo $form->field($model, 'comment_pid') ->hiddenInput() ->label(false) @@ -68,7 +80,7 @@ 'class' => 'custom-area-4', ], ]) - ->label($model->isNewRecord?'Вопрос':'Ответ', ['class' => 'artbox_comment_answer_label']) + ->label($model->isNewRecord ? 'Вопрос' : 'Ответ', [ 'class' => 'artbox_comment_answer_label' ]) ->textarea(); ?>
diff --git a/common/modules/comment/widgets/views/form-project-comment.php b/common/modules/comment/widgets/views/form-project-comment.php index d9c5020..7437ade 100644 --- a/common/modules/comment/widgets/views/form-project-comment.php +++ b/common/modules/comment/widgets/views/form-project-comment.php @@ -17,7 +17,7 @@
[ 'class' => 'resformsfile MultiFile-intercepted', 'enctype' => 'multipart/form-data' ] ]); + $form = ActiveForm::begin([ 'options' => [ 'class' => 'resformsfile MultiFile-intercepted', 'enctype' => 'multipart/form-data', 'data' => ['pjax' => true] ] ]); ?>
diff --git a/frontend/views/tender/view.php b/frontend/views/tender/view.php index f10af5e..91dded7 100755 --- a/frontend/views/tender/view.php +++ b/frontend/views/tender/view.php @@ -1,18 +1,19 @@ title = 'My Yii Application'; + $this->title = 'My Yii Application'; ?>
@@ -22,21 +23,24 @@ $this->title = 'My Yii Application';
- parent->name)):?> -
ПОДРЯД
-
- Из заказа: parent->name, Url::toRoute(['tender/view', 'tender_id' =>$model->parent->project_id ])) ?> -
+ parent->name )): ?> +
ПОДРЯД
+
+ Из заказа: parent->name, Url::toRoute([ + 'tender/view', + 'tender_id' => $model->parent->project_id, + ])) ?> +
- Бюджет: budget?> budgetCurrency->label?> + Бюджет: budget ?> budgetCurrency->label ?>
- formatter->asDatetime($model->date_end, 'dd.MM.Y')?> + formatter->asDatetime($model->date_end, 'dd.MM.Y') ?>
@@ -49,25 +53,30 @@ $this->title = 'My Yii Application';
-
+
+ +
user->owner->name ?>
'rating_company', - 'value' => $model->user->userInfo->rating, - 'pluginOptions' => ['displayOnly' => true, 'size' => 'xxs'] + 'name' => 'rating_company', + 'value' => $model->user->userInfo->rating, + 'pluginOptions' => [ + 'displayOnly' => true, + 'size' => 'xxs', + ], ]); ?>
-
user->comments)?> отзывов
+
user->comments) ?> отзывов
- user->userInfo->social_fb}",['target'=>'_blank'])?> - user->userInfo->social_t}", ['target'=>'_blank'])?> - user->userInfo->social_in}",['target'=>'_blank'])?> - user->userInfo->social_vk}",['target'=>'_blank'])?> + user->userInfo->social_fb}", [ 'target' => '_blank' ]) ?> + user->userInfo->social_t}", [ 'target' => '_blank' ]) ?> + user->userInfo->social_in}", [ 'target' => '_blank' ]) ?> + user->userInfo->social_vk}", [ 'target' => '_blank' ]) ?>
title = 'My Yii Application';
- На сайте: user->liveTime?> + На сайте: user->liveTime ?>
- - - - - - - - - - + + + + + + + + + +
- Последний визит:

user->userInfo->lastVisit?>

+ Последний визит:
+

user->userInfo->lastVisit ?>

- user->type == 2):?> -
-
-
-
- - Сотрудники: user->companyInfo->staff?> + user->type == 2): ?> +
+
+
+
+ + Сотрудники: user->companyInfo->staff ?> +
-
- user->phones as $phone ):?> -
-
-
- - + user->phones as $phone): ?> +
+
+
+ + +
-
- +
- user->site as $site ):?> -
-
-
- - Сайт + user->site as $site): ?> +
+
+
+ + Сайт +
-
- +
- parent->name)):?> - Подряд$model->parent->project_id ])) ?> + parent->name )): ?> + Подряд + $model->parent->project_id, + ])) ?>
@@ -177,7 +191,7 @@ $this->title = 'My Yii Application';
Специализации
- specializations as $specialization):?> + specializations as $specialization): ?> specialization_name ?>,
@@ -191,35 +205,30 @@ $this->title = 'My Yii Application';
-
- -
-
-
-
- + +
+
+
+
+ $this, 'model' => $model::className(), @@ -257,7 +267,7 @@ $this->title = 'My Yii Application'; 'status' => \common\modules\comment\models\CommentProject::STATUS_ACTIVE, ], 'list_options' => [ - 'view' => 'list-project-comment', + 'view' => 'list-project-comment', 'class' => 'section box tender-offer-proj-wr', ], 'form_options' => [ @@ -269,20 +279,22 @@ $this->title = 'My Yii Application'; 'tag' => false, ], ]); - ?> -
+ Pjax::end(); + ?>
-
-
-
- +
+
+
+ $this, - 'model' => $model->className(), - 'model_id' => $model->project_id, - 'comment_class' => \common\modules\comment\models\CommentProjectAnswer::className(), - 'class_options' => [ + 'context' => $this, + 'model' => $model->className(), + 'model_id' => $model->project_id, + 'comment_class' => \common\modules\comment\models\CommentProjectAnswer::className(), + 'class_options' => [ 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, 'user_id' => \Yii::$app->user->getId(), 'guestComment' => false, @@ -293,24 +305,25 @@ $this->title = 'My Yii Application'; 'pageSize' => 2, ], ], - 'success_options' => [ + 'success_options' => [ 'tag' => 'div', 'content' => 'Вопрос успешно создан и появится как только будет получен ответ', 'class' => 'test-class-success', ], - 'list_options' => [ + 'list_options' => [ 'view' => 'list-comment-question', ], - 'form_options' => [ - 'view' => 'form-comment-answer', - 'tag' => 'span', + 'form_options' => [ + 'view' => 'form-comment-answer', + 'tag' => 'span', + 'class' => ( ( $model->user_id == \Yii::$app->user->id ) ? 'hidden' : '' ), ], - 'options' => [ + 'options' => [ 'class' => 'proektant-comments-wr fix_te style', ], ]); - ?> -
+ Pjax::end(); + ?>
@@ -320,64 +333,87 @@ $this->title = 'My Yii Application';
\ No newline at end of file -- libgit2 0.21.4