Exemplo n.º 1
0
 public function actionView($id)
 {
     $model = $this->loadModel('app\\models\\Issue', $id);
     $this->view->params['appSettings'] = ['app_name' => $model->project->title];
     if (!\Yii::$app->user->can('viewProject', ['project' => $model->project]) || \Yii::$app->user->isGuest) {
         throw new ForbiddenHttpException('Access denied');
     }
     if (\Yii::$app->request->post('hasEditable') && !\Yii::$app->user->isGuest) {
         $post = \Yii::$app->request->post('Issue');
         if (isset($post['status_id'])) {
             $model->status_id = $post['status_id'];
             $output = StatusEnum::i()->getMap()[$post['status_id']];
             $this->sendMessage($model, ['subject' => \Yii::t('app', 'Issue Status Changed'), 'view' => 'changeStatus']);
         }
         if (isset($post['priority_id'])) {
             $model->priority_id = (int) $post['priority_id'];
             $output = PriorityEnum::i()->getMap()[$post['priority_id']];
         }
         if (isset($post['tracker_id'])) {
             $model->tracker_id = (int) $post['tracker_id'];
             $output = TrackerEnum::i()->getMap()[$post['tracker_id']];
         }
         if (isset($post['assignee_id'])) {
             if ($post['assignee_id']) {
                 $model->assignee_id = (int) $post['assignee_id'];
                 $output = \app\models\Project::getAssigneeOptions($model->project_id)[$post['assignee_id']];
                 $this->sendMessage($model);
             } else {
                 $model->assignee_id = null;
                 $output = '<i>(' . \Yii::t('app', 'not set') . ')</i>';
             }
         }
         if (isset($post['readiness_id'])) {
             $model->readiness_id = (int) $post['readiness_id'];
             $output = Issue::getReadinessOptions()[$post['readiness_id']];
         }
         if (isset($post['deadline'])) {
             $model->deadline = $post['deadline'];
             $output = $post['deadline'];
         }
         if ($model->save()) {
             $out = Json::encode(['output' => $output, 'message' => '']);
             echo $out;
             return;
         }
     }
     if ($post = \Yii::$app->request->post('IssueComment')) {
         $comment = new IssueComment();
         $comment->text = $post['text'];
         $comment->issue_id = $id;
         if ($comment->save()) {
             \Yii::$app->session->setFlash('success', \Yii::t('app', 'Comment successfully added.'));
         }
     }
     return $this->render('view', ['model' => $model]);
 }
Exemplo n.º 2
0
            <dt><?php 
echo \Yii::t('app', 'Assignee');
?>
</dt>
            <dd>
                <?php 
echo Editable::widget(['model' => $model, 'attribute' => 'assignee_id', 'header' => \Yii::t('app', 'Assignee'), 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => \app\models\Project::getAssigneeOptions($model->project_id), 'options' => ['class' => 'form-control', 'prompt' => ' - '], 'displayValue' => $model->assignee ? $model->assignee->getFullName() : '<i>(' . \Yii::t('app', 'not set') . ')</i>']);
?>
            </dd>
            <dt><?php 
echo \Yii::t('app', '% Done');
?>
</dt>
            <dd>
                <?php 
echo Editable::widget(['model' => $model, 'attribute' => 'readiness_id', 'header' => \Yii::t('app', '% Done'), 'inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => Issue::getReadinessOptions(), 'options' => ['class' => 'form-control'], 'displayValue' => Issue::getReadinessOptions()[$model->readiness_id]]);
?>
            </dd>
            <dt><?php 
echo \Yii::t('app', 'Deadline');
?>
</dt>
            <dd>
                <?php 
echo Editable::widget(['model' => $model, 'attribute' => 'deadline', 'size' => 'md', 'inputType' => Editable::INPUT_DATE, 'displayValue' => $model->deadline, 'options' => ['pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]]);
?>
            </dd>
        </dl>
    </div>
    <div class="col-sm-6">
Exemplo n.º 3
0
?>
</a>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-sm-6">
        <?php 
echo $form->field($model, 'status_id')->dropDownList(\app\components\enums\StatusEnum::i()->getMap());
echo $form->field($model, 'priority_id')->dropDownList(\app\components\enums\PriorityEnum::i()->getMap());
?>
    </div>
    <div class="col-sm-6">
        <?php 
echo $form->field($model, 'deadline')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control']]);
echo $form->field($model, 'readiness_id')->dropDownList(\app\models\Issue::getReadinessOptions());
echo $form->field($model, 'image_array[]')->fileInput(['multiple' => ''])->hint(\Yii::t('app', 'Chose one or few files'));
if (!empty($model->photos)) {
    echo $this->render('_imageGrid', ['model' => $model]);
}
?>
    </div>
</div>

<?php 
echo Html::submitButton($model->isNewRecord ? \Yii::t('app', 'Create') : \Yii::t('app', 'Save'), ['class' => 'btn btn-primary']);
?>

<?php 
ActiveForm::end();
?>