Example #1
0
 public function init()
 {
     switch (1) {
         case !$this->model instanceof IssuesModel && ($this->parentType == null || $this->parentId == null):
             $this->model = null;
             break;
         default:
             $this->model = $this->model instanceof IssuesModel ? $this->model : IssuesModel::findModel([$this->parentId, $this->parentType]);
             break;
     }
     parent::init();
 }
    /**
     * Displays a single Issues model.
     * @param integer $id
     * @return mixed
     */
    public function actionIssues($type, $id, $key = null)
    {
        switch ($type) {
            case 'all':
                $this->model = new Issues();
                break;
            default:
                $this->model = Issues::findModel([$id, $type]);
                break;
        }
        $searchModel = new IssuesSearch(['queryOptions' => ['with' => ['closedBy', 'resolvedBy']]]);
        $get = \Yii::$app->request->getQueryParams();
        $params = array_merge($get, $this->model->constraints);
        unset($params['type'], $params['id'], $params['key']);
        $options = ['enableComments' => $this->enableComments];
        switch ($key) {
            case 'duplicate':
                $params = array_merge($params, ['duplicate' => true]);
                $orderBy = ['id' => SORT_DESC];
                break;
            case 'closed':
                $params = array_merge($params, ['closed' => true]);
                $orderBy = ['closed_at' => SORT_DESC];
                break;
            case 'open':
                $params = array_merge($params, ['closed' => false]);
                $orderBy = ['id' => SORT_DESC];
                break;
            case 'resolved':
                $params = array_merge($params, ['resolved' => true]);
                $orderBy = ['resolved_at' => SORT_DESC];
                break;
            case 'unresolved':
                $params = array_merge($params, ['resolved' => false]);
                $orderBy = ['id' => SORT_DESC];
                break;
            default:
                $orderBy = [];
                break;
        }
        $dataProvider = $searchModel->search($params);
        $dataProvider->query->orderBy($orderBy);
        Response::viewOptions(null, ['args' => ["content" => $this->renderAjax('issues', ['enableComments' => $this->enableComments, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'options' => $options, 'parentId' => $id, 'parentType' => $type, 'filterType' => $key])], 'modalOptions' => ['contentOnly' => true], 'js' => \Yii::$app->request->isAjax ? new \yii\web\JsExpression('$nitm.onModuleLoad("issue-tracker", function (module) {
				module.initDefaults("#issues-' . $key . '-list' . $id . '", "issue-tracker");
			});') : ''], true);
        //$this->setResponseFormat(\Yii::$app->request->isAjax ? 'modal' : 'html');
        return $this->renderResponse(null, null, \Yii::$app->request->isAjax);
    }
Example #3
0
 public function rating()
 {
     $options = array_merge(['orderBy' => ['id' => SORT_DESC]], $options);
     return $this->getWidgetRelationModelQuery(\nitm\widgets\models\Issues::className(), ['remote_id' => $this->getId(), 'remote_type' => $this->isWhat()], $options, true);
 }