redmine visual redactor update

parent d601c3cf
......@@ -7,7 +7,6 @@ use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use League\HTMLToMarkdown\HtmlConverter;
use common\models\Settings;
use common\modules\support\models\redmine\Issue;
......@@ -74,8 +73,6 @@ class SupportController extends Controller
public function actionCreate()
{
$this->view->registerJsFile('/plugins/ckeditor/ckeditor.js', ['position' => yii\web\View::POS_END ]);
$model = new Issue();
$client = $this->getClient();
......@@ -84,11 +81,9 @@ class SupportController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->validate())
{
$converter = new HtmlConverter();
$client->issue->create([
'subject' => $model->subject,
'description' => $converter->convert($model->description),
'description' => $model->description,
'project_id' => $model->project_id,
'priority_id' => $model->priority_id,
'status_id' => $model->status_id,
......@@ -116,7 +111,7 @@ class SupportController extends Controller
$model = $client->issue->show($id, [
'include' => [
'attachments',
'changesets'
'journals'
]
]);
......
......@@ -50,21 +50,103 @@ use common\modules\support\models\redmine\RedmineHelper;
<div class="row">
<div class="col-sm-12">
<?=$form->field($model, 'description', ['template' => "<p class='label_p'><strong>{label}</strong></p>\n{input}\n{hint}\n{error}"])->textArea(['id' => 'ckeditor'])?>
<?=$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;'],
'clientOptions' => [
'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' => '!'
],
]
],
])?>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<button class="gray_button">Прикрепить файл<i class="glyphicon glyphicon-paperclip"></i></button>
<br>
<?= Html::submitButton('Создать задачу', ['class' => 'btn btn-success-2']) ?>
</div>
</div>
<script type="text/javascript">
$(function() {
CKEDITOR.replace( 'ckeditor' );
});
</script>
</div>
<?php ActiveForm::end(); ?>
......@@ -75,4 +157,33 @@ use common\modules\support\models\redmine\RedmineHelper;
</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;
}
</style>
<?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
......@@ -59,7 +59,10 @@ use common\modules\support\models\redmine\Issue;
<div class="col-md-12">
<p><strong>Описание задачи</strong></p>
<?=$model['description']?>
<p>
<?php $parser = new \Netcarver\Textile\Parser();
echo $parser->textileThis($model['description']); ?>
</p>
</div>
......
......@@ -31,8 +31,8 @@
"bower-asset/jquery-cookie": "*",
"2amigos/yii2-transliterator-helper": "*",
"kbsali/redmine-api" : "~1.0",
"league/html-to-markdown" : "*",
"netcarver/textile" : "3.5.*"
"netcarver/textile" : "3.5.*",
"coderlex/yii2-markitup" : "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
......
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