add comments for client in redmine module

parent 3b91dbde
...@@ -72,6 +72,7 @@ class SupportController extends Controller ...@@ -72,6 +72,7 @@ class SupportController extends Controller
$this->view->registerJsFile('/js/support.js', ['position' => yii\web\View::POS_END ]); $this->view->registerJsFile('/js/support.js', ['position' => yii\web\View::POS_END ]);
$model = new Issue(); $model = new Issue();
$model->setScenario(Issue::SCENARIO_CREATE);
$client = $this->getClient(); $client = $this->getClient();
...@@ -118,6 +119,44 @@ class SupportController extends Controller ...@@ -118,6 +119,44 @@ class SupportController extends Controller
]); ]);
} }
public function actionView($id)
{
$client = $this->getClient();
$user = $client->user->getCurrentUser();
$model = $client->issue->show($id, [
'include' => [
'attachments',
'journals'
]
]);
if(empty($model['issue']) || $model['issue']['author']['id'] != $user['user']['id'])
{
throw new NotFoundHttpException('Доступ запрещен!');
}
$issue = new Issue();
$issue->setScenario(Issue::SCENARIO_UPDATE);
if ($issue->load(Yii::$app->request->post()) && $issue->validate())
{
$params = [
'notes' => $issue->notes,
];
$client->issue->update($id, $params);
return $this->refresh();
}
return $this->render('view', [
'model' => $model['issue'],
'issue' => $issue
]);
}
public function actionFile() public function actionFile()
{ {
if(Yii::$app->request->isAjax) if(Yii::$app->request->isAjax)
...@@ -169,29 +208,6 @@ class SupportController extends Controller ...@@ -169,29 +208,6 @@ class SupportController extends Controller
} }
} }
public function actionView($id)
{
$client = $this->getClient();
$user = $client->user->getCurrentUser();
$model = $client->issue->show($id, [
'include' => [
'attachments',
'journals'
]
]);
if(empty($model['issue']) || $model['issue']['author']['id'] != $user['user']['id'])
{
throw new NotFoundHttpException('Доступ запрещен!');
}
return $this->render('view', [
'model' => $model['issue'],
]);
}
protected function getClient() protected function getClient()
{ {
return $client = new \Redmine\Client(Settings::getValue('redmine-url'), Yii::$app->support->identity->redmine_key); return $client = new \Redmine\Client(Settings::getValue('redmine-url'), Yii::$app->support->identity->redmine_key);
......
...@@ -13,6 +13,7 @@ class Issue extends yii\base\Model ...@@ -13,6 +13,7 @@ class Issue extends yii\base\Model
public $author_id; public $author_id;
public $tracker_id = self::TRACKER_NONE; public $tracker_id = self::TRACKER_NONE;
public $status_id = self::STATUS_NEW; public $status_id = self::STATUS_NEW;
public $notes;
public $files = null; public $files = null;
...@@ -23,22 +24,26 @@ class Issue extends yii\base\Model ...@@ -23,22 +24,26 @@ class Issue extends yii\base\Model
const STATUS_NEW = 7; const STATUS_NEW = 7;
const SCENARIO_CREATE = 'create';
const SCENARIO_UPDATE = 'update';
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() public function rules()
{ {
return [ return [
[['tracker_id', 'status_id', 'priority_id'], 'required'], [['notes'], 'required', 'on' => self::SCENARIO_UPDATE],
[['project_id'], 'required', 'message' => 'Выберите проект, к которому относится новая задача'], [['tracker_id', 'status_id', 'priority_id'], 'required', 'on' => self::SCENARIO_CREATE],
[['subject'], 'required', 'message' => 'Введите наименование задачи'], [['project_id'], 'required', 'message' => 'Выберите проект, к которому относится новая задача', 'on' => self::SCENARIO_CREATE],
[['description'], 'required', 'message' => 'Укажите описание задачи'], [['subject'], 'required', 'message' => 'Введите наименование задачи', 'on' => self::SCENARIO_CREATE],
[['description'], 'required', 'message' => 'Укажите описание задачи', 'on' => self::SCENARIO_CREATE],
[['tracker_id', 'project_id', 'status_id', 'priority_id'], 'integer', 'on' => self::SCENARIO_CREATE],
[['description'], 'string', 'on' => self::SCENARIO_CREATE],
[['subject'], 'string', 'max' => 255, 'on' => self::SCENARIO_CREATE],
[['tracker_id', 'project_id', 'status_id', 'priority_id'], 'integer'], [['files', 'notes'], 'safe'],
[['description'], 'string'],
[['files'], 'safe'],
[['subject'], 'string', 'max' => 255],
]; ];
} }
...@@ -55,6 +60,7 @@ class Issue extends yii\base\Model ...@@ -55,6 +60,7 @@ class Issue extends yii\base\Model
'description' => 'Текст задачи', 'description' => 'Текст задачи',
'priority_id' => 'Важность', 'priority_id' => 'Важность',
'status_id' => 'Статус', 'status_id' => 'Статус',
'notes' => 'Комментарий',
]; ];
} }
......
...@@ -8,6 +8,83 @@ class RedmineHelper ...@@ -8,6 +8,83 @@ class RedmineHelper
{ {
const MAX_FILE_SIZE = 5242880; //5mb const MAX_FILE_SIZE = 5242880; //5mb
public static $markupSet = [
[
'name' => 'Жирный',
'className' => 'fa fa-bold',
'openWith' => '*',
'closeWith' => '*'
],
[
'name' => 'Курсив',
'className' => 'fa fa-italic',
'openWith' => '_',
'closeWith' => '_'
],
[
'name' => 'Подчеркнутый',
'className' => 'fa fa-underline',
'openWith' => '+',
'closeWith' => '+'
],
[
'name' => 'Зачеркнутый',
'className' => 'fa fa-strikethrough',
'openWith' => '-',
'closeWith' => '-'
],
['separator' => '---------------'],
[
'name' => 'Заголовок 1',
'className' => 'fa fa-header header-1',
'openWith' => 'h1. ',
'closeWith' => ''
],
[
'name' => 'Заголовок 2',
'className' => 'fa fa-header header-2',
'openWith' => 'h2. ',
'closeWith' => ''
],
[
'name' => 'Заголовок 3',
'className' => 'fa fa-header header-3',
'openWith' => 'h3. ',
'closeWith' => ''
],
['separator' => '---------------'],
[
'name' => 'Маркированный список',
'className' => 'fa fa-list-ul',
'openWith' => '* ',
'multiline' => true,
'openBlockWith' => "",
'closeBlockWith' => ""
],
[
'name' => 'Нумерованный список',
'className' => 'fa fa-list-ol',
'openWith' => '# ',
'multiline' => true,
'openBlockWith' => "",
'closeBlockWith' => ""
],
['separator' => '---------------'],
[
'name' => 'Заранее форматированный тест',
'className' => 'fa fa-newspaper-o',
'openWith' => '<pre>',
'closeWith' => '</pre>'
],
['separator' => '---------------'],
[
'name' => 'Вставка изображения',
'className' => 'fa fa-picture-o',
'openWith' => '!',
'closeWith' => '!'
],
];
public static function sortIsuues($issues = null) public static function sortIsuues($issues = null)
{ {
if($issues) if($issues)
......
...@@ -8,7 +8,7 @@ use common\modules\support\models\redmine\RedmineHelper; ...@@ -8,7 +8,7 @@ use common\modules\support\models\redmine\RedmineHelper;
?> ?>
<div class="container_white"> <div class="container_white support-block">
<div class="container"> <div class="container">
<div class="right_box_top row"> <div class="right_box_top row">
...@@ -53,82 +53,7 @@ use common\modules\support\models\redmine\RedmineHelper; ...@@ -53,82 +53,7 @@ use common\modules\support\models\redmine\RedmineHelper;
<?=$form->field($model, 'description', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}<br>{hint}{error}"])->widget(\coderlex\markitup\MarkItUp::className(), [ <?=$form->field($model, 'description', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}<br>{hint}{error}"])->widget(\coderlex\markitup\MarkItUp::className(), [
'options' => ['class' => 'form-control', 'style' => 'overflow:auto;resize:none;width:100%;min-height:200px;'], 'options' => ['class' => 'form-control', 'style' => 'overflow:auto;resize:none;width:100%;min-height:200px;'],
'clientOptions' => [ 'clientOptions' => [
'markupSet' => [ 'markupSet' => RedmineHelper::$markupSet
[
'name' => 'Жирный',
'className' => 'fa fa-bold',
'openWith' => '*',
'closeWith' => '*'
],
[
'name' => 'Курсив',
'className' => 'fa fa-italic',
'openWith' => '_',
'closeWith' => '_'
],
[
'name' => 'Подчеркнутый',
'className' => 'fa fa-underline',
'openWith' => '+',
'closeWith' => '+'
],
[
'name' => 'Зачеркнутый',
'className' => 'fa fa-strikethrough',
'openWith' => '-',
'closeWith' => '-'
],
['separator' => '---------------'],
[
'name' => 'Заголовок 1',
'className' => 'fa fa-header header-1',
'openWith' => 'h1. ',
'closeWith' => ''
],
[
'name' => 'Заголовок 2',
'className' => 'fa fa-header header-2',
'openWith' => 'h2. ',
'closeWith' => ''
],
[
'name' => 'Заголовок 3',
'className' => 'fa fa-header header-3',
'openWith' => 'h3. ',
'closeWith' => ''
],
['separator' => '---------------'],
[
'name' => 'Маркированный список',
'className' => 'fa fa-list-ul',
'openWith' => '* ',
'multiline' => true,
'openBlockWith' => "",
'closeBlockWith' => ""
],
[
'name' => 'Нумерованный список',
'className' => 'fa fa-list-ol',
'openWith' => '# ',
'multiline' => true,
'openBlockWith' => "",
'closeBlockWith' => ""
],
['separator' => '---------------'],
[
'name' => 'Заранее форматированный тест',
'className' => 'fa fa-newspaper-o',
'openWith' => '<pre>',
'closeWith' => '</pre>'
],
['separator' => '---------------'],
[
'name' => 'Вставка изображения',
'className' => 'fa fa-picture-o',
'openWith' => '!',
'closeWith' => '!'
],
]
], ],
])?> ])?>
...@@ -163,41 +88,4 @@ use common\modules\support\models\redmine\RedmineHelper; ...@@ -163,41 +88,4 @@ use common\modules\support\models\redmine\RedmineHelper;
</div> </div>
</div> </div>
<style type="text/css">
.markItUpButton {
position: relative;
width: 23px;
height: 23px;
padding: 3px;
font-size: 13px;
text-align: center;
}
.markItUpButton a {
position: absolute;
top: 0;
left: 0;
z-index: 5;
}
.markItUp {
width: 100%;
margin: 5px 0 5px 0;
}
.header-2 {
font-size: 11px;
line-height: 16px;
}
.header-3 {
font-size: 9px;
line-height: 16px;
}
.help-block {
font-size: 12px;
line-height: 10px;
margin: -10px 0 25px;
}
.container_white .form-control {
float: none;
}
</style>
<?=$this->render('@app/views/layouts/footer');?> <?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
<?php <?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\modules\support\models\redmine\Issue; use common\modules\support\models\redmine\Issue;
use common\modules\support\models\redmine\RedmineHelper;
$parser = new \Netcarver\Textile\Parser();
?> ?>
<div class="container_white"> <div class="container_white support-block">
<div class="container"> <div class="container">
<div class="right_box_top row"> <div class="right_box_top row">
...@@ -60,8 +66,7 @@ use common\modules\support\models\redmine\Issue; ...@@ -60,8 +66,7 @@ use common\modules\support\models\redmine\Issue;
<p><strong>Описание задачи</strong></p> <p><strong>Описание задачи</strong></p>
<p> <p>
<?php $parser = new \Netcarver\Textile\Parser(); <?=$parser->textileThis($model['description']); ?>
echo $parser->textileThis($model['description']); ?>
</p> </p>
</div> </div>
...@@ -70,89 +75,87 @@ use common\modules\support\models\redmine\Issue; ...@@ -70,89 +75,87 @@ use common\modules\support\models\redmine\Issue;
<br> <br>
<!-- <div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<p class="label_p"><strong>Добавить комментарий к задаче</strong></p> <p class="label_p"><strong>Добавить комментарий к задаче</strong></p>
<div class="text_box_form text_box_form_bg"> <div class="text_box_form text_box_form_bg">
<div class="text_box_form_top"><img src="/images/text_box_img.jpg" width="100%" alt=""></div>
<textarea>Высылаю нужный файл</textarea>
<?php $form = ActiveForm::begin(); ?>
<div class="file_box_wr"> <div class="row">
<span class="glyphicon glyphicon-file"></span> <div class="col-sm-12">
<a href="">Error_window.jpg &nbsp;</a>
<span class="color_gray">&nbsp;50,6 кБ&nbsp;&nbsp;</span>
<a href=""><span class="glyphicon glyphicon-remove color_gray"></span></a>
</div>
<div class="file_box_wr">
<span class="glyphicon glyphicon-file"></span>
<a href="">Error_window.jpg &nbsp;</a>
<span class="color_gray">&nbsp;50,6 кБ&nbsp;&nbsp;</span>
<a href=""><span class="glyphicon glyphicon-remove color_gray"></span></a>
</div>
<div class="file_box_wr">
<span class="glyphicon glyphicon-file"></span>
<a href="">Error_window.jpg &nbsp;</a>
<span class="color_gray">&nbsp;50,6 кБ&nbsp;&nbsp;</span>
<a href=""><span class="glyphicon glyphicon-remove color_gray"></span></a>
</div>
<?=$form->field($issue, 'notes', ['template' => "{input}<br>{hint}{error}"])->widget(\coderlex\markitup\MarkItUp::className(), [
'options' => ['class' => 'form-control', 'style' => 'overflow:auto;resize:none;width:100%;min-height:100px;'],
'clientOptions' => [
'markupSet' => RedmineHelper::$markupSet
],
])->label(false)?>
<button class="btn btn-success-2 gray_button_poz">Отправить</button> </div>
</div>
<button class="gray_button">Прикрепить файл<i class="glyphicon glyphicon-paperclip"></i></button>
</div>
</div>
</div> -->
<!-- <div class="row"> <!-- <div class="file_box_wr">
<div class="col-md-12"> <span class="glyphicon glyphicon-file"></span>
<div class="commentary_col"> <a href="">Error_window.jpg &nbsp;</a>
<strong>Комментарии (14) </strong>&nbsp;<span class="label label-success" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="4 задачи требуют проверки">4</span> <span class="color_gray">&nbsp;50,6 кБ&nbsp;&nbsp;</span>
</div> <a href=""><span class="glyphicon glyphicon-remove color_gray"></span></a>
</div>
<div class="commentary_box"> <div class="file_box_wr">
<p><strong>Иван Иванов</strong> <span class="color_gray">16 января 2014, 12:13</span></p> <span class="glyphicon glyphicon-file"></span>
<p>Прошу направить файлы заказчику и составить для него письмо.</p> <a href="">Error_window.jpg &nbsp;</a>
<a href=""><span class="glyphicon glyphicon-file"></span>скан_паспорта.jpg</a>&nbsp;&nbsp; <span class="color_gray">&nbsp;50,6 кБ&nbsp;&nbsp;</span>
<a href=""><span class="glyphicon glyphicon-file"></span>данные.xml</a> <a href=""><span class="glyphicon glyphicon-remove color_gray"></span></a>
<br> </div>
<img src="/images/commentary_box_img_1.jpg" width="96" height="56" alt="commentary_box_img_1"> <div class="file_box_wr">
<img src="/images/commentary_box_img_2.jpg" width="96" height="56" alt="commentary_box_img_2"> <span class="glyphicon glyphicon-file"></span>
<br> <a href="">Error_window.jpg &nbsp;</a>
<a href="" class="commentary_box_ok">Ответить</a> &nbsp;&nbsp;&nbsp; <a href="" class="commentary_box_dell">Удалить</a> <span class="color_gray">&nbsp;50,6 кБ&nbsp;&nbsp;</span>
<div class="line_3"></div> <a href=""><span class="glyphicon glyphicon-remove color_gray"></span></a>
</div> -->
<?= Html::submitButton('Отправить', ['class' => 'btn btn-success-2 gray_button_poz']) ?>
</div> <!-- <button class="gray_button">Прикрепить файл<i class="glyphicon glyphicon-paperclip"></i></button> -->
<div class="commentary_box marg_l_20">
<p><strong>Сидоров Петр</strong> <span class="color_gray">16 января 2014, 13:06</span></p>
<p>Почтовый сервер при отправке письма выдает вот такую ошибку. Что делать?</p>
<a href=""><span class="glyphicon glyphicon-file"></span>Error_window.jpg </a>&nbsp;&nbsp; <span class="color_gray">50,6 кБ</span>
<br>
<a href="" class="commentary_box_ok">Ответить</a> &nbsp;&nbsp;&nbsp; <a href="" class="commentary_box_dell">Удалить</a>
<div class="line_3"></div>
</div> <?php ActiveForm::end(); ?>
<div class="commentary_box marg_l_40">
<p><strong>Сидоров Петр</strong> <span class="color_gray">16 января 2014, 13:06</span></p>
<p>Почтовый сервер при отправке письма выдает вот такую ошибку. Что делать?</p>
<a href=""><span class="glyphicon glyphicon-file"></span>Error_window.jpg </a>&nbsp;&nbsp; <span class="color_gray">50,6 кБ</span>
<br>
<a href="" class="commentary_box_ok">Ответить</a> &nbsp;&nbsp;&nbsp; <a href="" class="commentary_box_dell">Удалить</a>
</div> </div>
</div>
</div>
<?php if(isset($model['journals'])) : ?>
<div class="row">
<div class="col-md-12">
<div class="commentary_col">
<strong>Комментарии (<?=count($model['journals'])?>) </strong><!-- &nbsp;<span class="label label-success" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="4 задачи требуют проверки">4</span> -->
</div>
<?php foreach ($model['journals'] as $i => $journal) : ?>
<div class="commentary_box">
<p><strong><?=$journal['user']['name']?></strong> <span class="color_gray"><?=Yii::$app->formatter->asDate($journal['created_on'], 'php:d F Y, H:i');?></span></p>
<p>
<?=$parser->textileThis($journal['notes']);?>
</p>
<br>
<!-- <a href="" class="commentary_box_ok">Ответить</a> &nbsp;&nbsp;&nbsp; <a href="" class="commentary_box_dell">Удалить</a> -->
<?php if($i != count($model['journals']) - 1) : ?>
<div class="line_3"></div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div> </div>
</div> -->
<br>
<br> <br>
<br> <?php endif; ?>
</div> </div>
</div> </div>
......
...@@ -1804,4 +1804,40 @@ a.keys_test_btn { ...@@ -1804,4 +1804,40 @@ a.keys_test_btn {
.attachment-button { .attachment-button {
display: inline-block; display: inline-block;
cursor: pointer; cursor: pointer;
}
.support-block .markItUpButton {
position: relative;
width: 23px;
height: 23px;
padding: 3px;
font-size: 13px;
text-align: center;
}
.support-block .markItUpButton a {
position: absolute;
top: 0;
left: 0;
z-index: 5;
}
.support-block .markItUp {
width: 100%;
margin: 5px 0 5px 0;
}
.support-block .header-2 {
font-size: 11px;
line-height: 16px;
}
.support-block .header-3 {
font-size: 9px;
line-height: 16px;
}
.support-block .help-block {
font-size: 12px;
line-height: 10px;
margin: -10px 0 25px;
}
.support-block .form-control {
float: none !important;
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment