/** * 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); }
/** * Displays a single model. * @param integer $id * @return mixed */ public function actionView($id, $modelClass = null, $with = []) { Response::$forceAjax = true; return parent::actionView($id); }
/** * Lists all new Replies models according to user activity. * @param string $type The parent type of the issue * @param int $id The id of the parent * @param string $key The key of the parent * @return mixed */ public function actionGetNewNotifications() { $this->model = new \nitm\widgets\models\Notification(['constrain' => ['user_id' => \Yii::$app->user->getId(), 'read' => false]]); $ret_val = false; $new = $this->model->hasNew(); switch ($new >= 1) { case true: $ret_val = ['data' => '', 'count' => $new, 'success' => true]; $ret_val['message'] = $ret_val['count'] . " new notifications"; $searchModel = new \nitm\widgets\models\search\Notification(['queryOptions' => ['andWhere' => new \yii\db\Expression('UNIX_TIMESTAMP(created_at)>=' . \Yii::$app->user->getIdentity()->lastActive())]]); $dataProvider = $searchModel->search($this->model->constraints); $dataProvider->setSort(['defaultOrder' => ['id' => SORT_DESC]]); $newReplies = $dataProvider->getModels(); foreach ($newReplies as $newReply) { $ret_val['data'] .= $this->renderAjax('@nitm/views/alerts/view-notification', ['model' => $newReply, 'isNew' => true]); } Response::viewOptions(null, ['args' => ["content" => $ret_val['data']], 'modalOptions' => ['contentOnly' => true]]); break; default: Response::viewOptions(null, ['args' => ["content" => $ret_val]]); break; } $this->setResponseFormat(\Yii::$app->request->isAjax ? 'json' : 'html'); return $this->renderResponse($ret_val, null, \Yii::$app->request->isAjax); }
/** * Lists all Revisions models. * @return mixed */ public function actionIndex($type = null, $id = null) { Response::viewOptions(null, ['args' => ["content" => RevisionsWidget::widget(["parentId" => $id, "parentType" => $type])], 'modalOptions' => ['contentOnly' => true]], true); return $this->renderResponse(null, null, \Yii::$app->request->isAjax); }