1 | <?php |
||
31 | class IssueController extends Controller |
||
32 | { |
||
33 | /** |
||
34 | * Project issue index page (List project issues). |
||
35 | * |
||
36 | * @param Project $project |
||
37 | * @param Issue $issue |
||
38 | * @param CommentForm $form |
||
39 | * |
||
40 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
41 | */ |
||
42 | public function getIndex(Project $project, Issue $issue, CommentForm $form) |
||
43 | { |
||
44 | $canEdit = $this->allows('update', $issue); |
||
45 | $usersCanFixIssues = $canEdit && $issue->status == Issue::STATUS_OPEN ? $project->getUsersCanFixIssue() : []; |
||
46 | |||
47 | // Projects should be limited to issue-modify |
||
48 | $projects = null; |
||
49 | if ($canEdit) { |
||
50 | $projects = $this->getLoggedUser()->getProjects(); |
||
51 | } |
||
52 | |||
53 | return view('project.issue.index', [ |
||
54 | 'issue' => $issue, |
||
55 | 'usersCanFixIssues' => $usersCanFixIssues, |
||
56 | 'project' => $project, |
||
57 | 'closed_issues_count' => $project->countClosedIssues($this->getLoggedUser()), |
||
58 | 'open_issues_count' => $project->countOpenIssues($this->getLoggedUser()), |
||
59 | 'commentForm' => $form, |
||
60 | 'sidebar' => 'project', |
||
61 | 'projects' => $projects, |
||
62 | ]); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Ajax: Assign new user to an issue. |
||
67 | * |
||
68 | * @param Issue $issue |
||
69 | * @param Request $request |
||
70 | * |
||
71 | * @return \Symfony\Component\HttpFoundation\Response |
||
72 | */ |
||
73 | public function postAssign(Issue $issue, Request $request) |
||
74 | { |
||
75 | $response = [ |
||
76 | 'status' => $issue->updater($this->getLoggedUser())->reassign((int) $request->input('user_id'), $this->getLoggedUser()), |
||
77 | ]; |
||
78 | |||
79 | return response()->json($response); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Ajax: save comment. |
||
84 | * |
||
85 | * @param Comment $comment |
||
86 | * @param Request $request |
||
87 | * |
||
88 | * @return \Symfony\Component\HttpFoundation\Response |
||
89 | */ |
||
90 | public function postEditComment(Comment $comment, Request $request) |
||
91 | { |
||
92 | $body = ''; |
||
93 | if ($request->has('body')) { |
||
94 | $comment |
||
95 | ->updater($this->getLoggedUser()) |
||
96 | ->updateBody((string) $request->input('body')); |
||
97 | $body = \Html::format($comment->comment); |
||
98 | } |
||
99 | |||
100 | return response()->json(['text' => $body]); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * To add new comment to an issue. |
||
105 | * |
||
106 | * @param Project $project |
||
107 | * @param Issue $issue |
||
108 | * @param Comment $comment |
||
109 | * @param FormRequest\Comment $request |
||
110 | * |
||
111 | * @return \Illuminate\Http\RedirectResponse |
||
112 | */ |
||
113 | public function postAddComment(Project $project, Issue $issue, Comment $comment, FormRequest\Comment $request) |
||
124 | |||
125 | /** |
||
126 | * Ajax: to delete a comment. |
||
127 | * |
||
128 | * @param Comment $comment |
||
129 | * |
||
130 | * @return \Symfony\Component\HttpFoundation\Response |
||
131 | */ |
||
132 | public function getDeleteComment(Comment $comment) |
||
138 | |||
139 | /** |
||
140 | * New issue form. |
||
141 | * |
||
142 | * @param Project $project |
||
143 | * @param IssueForm $form |
||
144 | * |
||
145 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
146 | */ |
||
147 | public function getNew(Project $project, IssueForm $form) |
||
155 | |||
156 | /** |
||
157 | * To create a new issue. |
||
158 | * |
||
159 | * @param Project $project |
||
160 | * @param Issue $issue |
||
161 | * @param FormRequest\Issue $request |
||
162 | * |
||
163 | * @return \Illuminate\Http\RedirectResponse |
||
164 | */ |
||
165 | public function postNew(Project $project, Issue $issue, FormRequest\Issue $request) |
||
175 | |||
176 | /** |
||
177 | * Edit an existing issue form. |
||
178 | * |
||
179 | * @param Project $project |
||
180 | * @param Issue $issue |
||
181 | * @param IssueForm $form |
||
182 | * |
||
183 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
184 | */ |
||
185 | public function getEdit(Project $project, Issue $issue, IssueForm $form) |
||
200 | |||
201 | /** |
||
202 | * To update an existing issue details. |
||
203 | * |
||
204 | * @param Project $project |
||
205 | * @param Issue $issue |
||
206 | * @param FormRequest\Issue $request |
||
207 | * |
||
208 | * @return \Illuminate\Http\RedirectResponse |
||
209 | */ |
||
210 | public function postEdit(Project $project, Issue $issue, FormRequest\Issue $request) |
||
228 | |||
229 | /** |
||
230 | * To close or reopen an issue. |
||
231 | * |
||
232 | * @param Project $project |
||
233 | * @param Issue $issue |
||
234 | * @param int $status |
||
235 | * |
||
236 | * @return \Illuminate\Http\RedirectResponse |
||
237 | */ |
||
238 | public function getClose(Project $project, Issue $issue, $status = 0) |
||
252 | |||
253 | /** |
||
254 | * To upload an attachment file. |
||
255 | * |
||
256 | * @param Project $project |
||
257 | * @param Attachment $attachment |
||
258 | * @param Request $request |
||
259 | * |
||
260 | * @return \Symfony\Component\HttpFoundation\Response |
||
261 | */ |
||
262 | public function postUploadAttachment(Project $project, Attachment $attachment, Request $request) |
||
289 | |||
290 | /** |
||
291 | * Delete attachment. |
||
292 | * |
||
293 | * @param Project $project |
||
294 | * @param Issue $issue |
||
295 | * @param Attachment $attachment |
||
296 | * |
||
297 | * @return \Illuminate\Http\RedirectResponse |
||
298 | */ |
||
299 | public function getDeleteAttachment(Project $project, Issue $issue, Attachment $attachment) |
||
307 | |||
308 | /** |
||
309 | * Display an attachment file such as image. |
||
310 | * |
||
311 | * @param Project $project |
||
312 | * @param Issue $issue |
||
313 | * @param Attachment $attachment |
||
314 | * @param Request $request |
||
315 | * |
||
316 | * @return Response |
||
317 | */ |
||
318 | public function getDisplayAttachment(Project $project, Issue $issue, Attachment $attachment, Request $request) |
||
325 | |||
326 | /** |
||
327 | * Download an attachment file. |
||
328 | * |
||
329 | * @param Project $project |
||
330 | * @param Issue $issue |
||
331 | * @param Attachment $attachment |
||
332 | * |
||
333 | * @return \Symfony\Component\HttpFoundation\BinaryFileResponse |
||
334 | */ |
||
335 | public function getDownloadAttachment(Project $project, Issue $issue, Attachment $attachment) |
||
344 | |||
345 | /** |
||
346 | * Ajax: move an issue to another project. |
||
347 | * |
||
348 | * @param Issue $issue |
||
349 | * @param Request $request |
||
350 | * |
||
351 | * @return \Symfony\Component\HttpFoundation\Response |
||
352 | */ |
||
353 | public function postChangeProject(Issue $issue, Request $request) |
||
359 | |||
360 | /** |
||
361 | * Ajax: change status of an issue. |
||
362 | * |
||
363 | * @param Issue $issue |
||
364 | * @param Request $request |
||
365 | * |
||
366 | * @return \Symfony\Component\HttpFoundation\Response |
||
367 | */ |
||
368 | public function postChangeKanbanTag(Issue $issue, Request $request) |
||
377 | |||
378 | /** |
||
379 | * Ajax: returns comments for an issue. |
||
380 | * |
||
381 | * @param Project $project |
||
382 | * @param Issue $issue |
||
383 | * |
||
384 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\Vie |
||
385 | */ |
||
386 | public function getIssueComments(Project $project, Issue $issue) |
||
398 | |||
399 | /** |
||
400 | * Ajax: returns activities for an issue excluding comments. |
||
401 | * |
||
402 | * @param Project $project |
||
403 | * @param Issue $issue |
||
404 | * |
||
405 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\Vie |
||
406 | */ |
||
407 | public function getIssueActivity(Project $project, Issue $issue) |
||
419 | } |
||
420 |