diff --git a/app/Domain/Canvas/Controllers/EditCanvasComment.php b/app/Domain/Canvas/Controllers/EditCanvasComment.php index fe6c339a83..6e088e2dbf 100644 --- a/app/Domain/Canvas/Controllers/EditCanvasComment.php +++ b/app/Domain/Canvas/Controllers/EditCanvasComment.php @@ -258,6 +258,7 @@ public function post($params) return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . $_GET['id']); } + $this->tpl->assign('id', $_GET['id']); $this->tpl->assign('canvasTypes', $this->canvasRepo->getCanvasTypes()); $this->tpl->assign('canvasItem', $this->canvasRepo->getSingleCanvasItem($_GET['id'])); return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.canvasComment'); diff --git a/app/Domain/Canvas/Controllers/ShowCanvas.php b/app/Domain/Canvas/Controllers/ShowCanvas.php index d1d8caeffc..cdb55325bc 100644 --- a/app/Domain/Canvas/Controllers/ShowCanvas.php +++ b/app/Domain/Canvas/Controllers/ShowCanvas.php @@ -255,6 +255,12 @@ public function run() } } + $filter['status'] = $_GET['filter_status'] ?? (session('filter_status') ?? 'all'); + session(['filter_status' => $filter['status']]); + $filter['relates'] = $_GET['filter_relates'] ?? (session('filter_relates') ?? 'all'); + session(['filter_relates' => $filter['relates']]); + + $this->tpl->assign('filter', $filter); $this->tpl->assign('currentCanvas', $currentCanvasId); $this->tpl->assign('canvasIcon', $this->canvasRepo->getIcon()); $this->tpl->assign('canvasTypes', $this->canvasRepo->getCanvasTypes()); diff --git a/app/Domain/Goalcanvas/Controllers/Dashboard.php b/app/Domain/Goalcanvas/Controllers/Dashboard.php index b2f70629a9..d1ba321dee 100644 --- a/app/Domain/Goalcanvas/Controllers/Dashboard.php +++ b/app/Domain/Goalcanvas/Controllers/Dashboard.php @@ -39,8 +39,7 @@ public function init( ) { $this->projectService = $projectService; $this->goalService = $goalService; - $canvasName = Str::studly(static::CANVAS_NAME) . 'canvas'; - $repoName = app()->getNamespace() . "Domain\\$canvasName\\Repositories\\$canvasName"; + $repoName = app()->getNamespace() . "Domain\\goalcanvas\\Repositories\\goalcanvas"; $this->canvasRepo = app()->make($repoName); } @@ -305,6 +304,12 @@ public function run() } } + $filter['status'] = $_GET['filter_status'] ?? (session("filter_status") ?? 'all'); + session(["filter_status" => $filter['status']]); + $filter['relates'] = $_GET['filter_relates'] ?? (session("filter_relates") ?? 'all'); + session(["filter_relates" => $filter['relates']]); + + $this->tpl->assign('filter', $filter); $this->tpl->assign('currentCanvas', $currentCanvasId); $this->tpl->assign('goalStats', $goalAnalytics); $this->tpl->assign('canvasIcon', $this->canvasRepo->getIcon()); diff --git a/app/Domain/Goalcanvas/Controllers/DelCanvas.php b/app/Domain/Goalcanvas/Controllers/DelCanvas.php index 151d33af9c..c5aac1087c 100644 --- a/app/Domain/Goalcanvas/Controllers/DelCanvas.php +++ b/app/Domain/Goalcanvas/Controllers/DelCanvas.php @@ -1,16 +1,68 @@ getNamespace() . "Domain\\goalcanvas\\Repositories\\goalcanvas"; + $this->canvasRepo = app()->make($repoName); + } + + /** + * run - display template and edit data + * + * @access public + */ + public function run() + { + + Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]); + + if (isset($_POST['del']) && isset($_GET['id'])) { + $id = (int)($_GET['id']); + $this->canvasRepo->deleteCanvas($id); + + $allCanvas = $this->canvasRepo->getAllCanvas(session("currentProject")); + session(["current' . strtoupper(static::CANVAS_NAME) . 'Canvas" => $allCanvas[0]['id'] ?? -1]); + + $this->tpl->setNotification($this->language->__('notification.board_deleted'), 'success', strtoupper(static::CANVAS_NAME) . 'canvas_deleted'); + + $allCanvas = $this->canvasRepo->getAllCanvas(session("currentProject")); + + //Create default canvas. + if (!$allCanvas || count($allCanvas) == 0) { + return Frontcontroller::redirect(BASE_URL . '/strategy/showBoards'); + } else { + return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas/showCanvas'); + } + } + + return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.delCanvas'); + } } } diff --git a/app/Domain/Goalcanvas/Controllers/DelCanvasItem.php b/app/Domain/Goalcanvas/Controllers/DelCanvasItem.php index 81e5e8b9c0..b1a56ca705 100644 --- a/app/Domain/Goalcanvas/Controllers/DelCanvasItem.php +++ b/app/Domain/Goalcanvas/Controllers/DelCanvasItem.php @@ -1,17 +1,56 @@ getNamespace() . "Domain\\goalcanvas\\Repositories\\goalcanvas"; + $this->canvasRepo = app()->make($repoName); + } + + /** + * run - display template and edit data + * + * @access public + */ + public function run() + { + Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager, Roles::$editor]); + + if (isset($_POST['del']) && isset($_GET['id'])) { + $id = (int)($_GET['id']); + $this->canvasRepo->delCanvasItem($id); + + $this->tpl->setNotification($this->language->__('notification.element_deleted'), 'success', strtoupper(static::CANVAS_NAME) . 'canvasitem_deleted'); + return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas/showCanvas'); + } + + return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.delCanvasItem'); + } + } } diff --git a/app/Domain/Goalcanvas/Controllers/EditCanvasComment.php b/app/Domain/Goalcanvas/Controllers/EditCanvasComment.php index 54e4f61917..18826e22e0 100644 --- a/app/Domain/Goalcanvas/Controllers/EditCanvasComment.php +++ b/app/Domain/Goalcanvas/Controllers/EditCanvasComment.php @@ -1,17 +1,285 @@ ticketRepo = $ticketRepo; + $this->commentsRepo = $commentsRepo; + $this->sprintService = $sprintService; + $this->ticketService = $ticketService; + $this->projectService = $projectService; + + $repoName = app()->getNamespace() . "Domain\\goalcanvas\\Repositories\\goalcanvas"; + $this->canvasRepo = app()->make($repoName); + } + + /** + * get - handle get requests + * + * @access public + * + */ + public function get($params) + { + + $canvasTypes = $this->canvasRepo->getCanvasTypes(); + if (isset($params['id'])) { + // Delete comment + if (isset($params['delComment']) === true) { + $commentId = (int)($params['delComment']); + $this->commentsRepo->deleteComment($commentId); + $this->tpl->setNotification($this->language->__('notifications.comment_deleted'), 'success', strtoupper(static::CANVAS_NAME) . 'canvascomment_deleted'); + } + + $canvasItem = $this->canvasRepo->getSingleCanvasItem($params['id']); + + $comments = $this->commentsRepo->getComments(static::CANVAS_NAME . 'canvasitem', $canvasItem['id']); + $this->tpl->assign('numComments', $this->commentsRepo->countComments(static::CANVAS_NAME . 'canvasitem', $canvasItem['id'])); + } else { + if (isset($params['type'])) { + $type = strip_tags($params['type']); + } else { + $type = array_key_first($canvasTypes); + } + + $canvasItem = array( + 'id' => '', + 'box' => $type, + 'description' => '', + 'status' => array_key_first($this->canvasRepo->getStatusList()), + 'relates' => array_key_first($this->canvasRepo->GetRelatesList()), + 'assumptions' => '', + 'data' => '', + 'conclusion' => '', + 'milestoneHeadline' => '', + 'milestoneId' => '', + ); + + $comments = []; + } + + $this->tpl->assign('comments', $comments); + + $this->tpl->assign('canvasTypes', $canvasTypes); + $this->tpl->assign('canvasItem', $canvasItem); + return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.canvasComment'); + } + + /** + * post - handle post requests + * + * @access public + * + */ + public function post($params) + { + + if (isset($params['changeItem'])) { + if (isset($params['itemId']) && $params['itemId'] != '') { + if (isset($params['description']) && !empty($params['description'])) { + $currentCanvasId = (int)session("current" . strtoupper(static::CANVAS_NAME) . "Canvas"); + + $canvasItem = array( + 'box' => $params['box'], + 'author' => session("userdata.id"), + 'description' => $params['description'], + 'status' => $params['status'], + 'relates' => $params['relates'], + 'assumptions' => $params['assumptions'], + 'data' => $params['data'], + 'conclusion' => $params['conclusion'], + 'itemId' => $params['itemId'], + 'id' => $params['itemId'], + 'canvasId' => $currentCanvasId, + 'milestoneId' => $params['milestoneId'], + 'dependentMilstone' => '', + ); + + $this->canvasRepo->editCanvasComment($canvasItem); + + $comments = $this->commentsRepo->getComments(static::CANVAS_NAME . 'canvasitem', $params['itemId']); + $this->tpl->assign('numComments', $this->commentsRepo->countComments( + static::CANVAS_NAME . 'canvasitem', + $params['itemId'] + )); + $this->tpl->assign('comments', $comments); + + $this->tpl->setNotification($this->language->__('notifications.canvas_item_updates'), 'success', strtoupper(static::CANVAS_NAME) . 'canvasitem_updated'); + + + $notification = app()->make(NotificationModel::class); + $notification->url = array( + "url" => BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . (int)$params['itemId'], + "text" => $this->language->__('email_notifications.canvas_item_update_cta'), + ); + $notification->entity = $canvasItem; + $notification->module = static::CANVAS_NAME . 'canvas'; + $notification->projectId = session("currentProject"); + $notification->subject = $this->language->__('email_notifications.canvas_board_edited'); + $notification->authorId = session("userdata.id"); + $notification->message = sprintf( + $this->language->__('email_notifications.canvas_item_update_message'), + session("userdata.name"), + $canvasItem['description'] + ); + + $this->projectService->notifyProjectUsers($notification); + + return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . $params['itemId']); + } else { + $this->tpl->setNotification($this->language->__('notification.please_enter_element_title'), 'error'); + } + } else { + if (isset($_POST['description']) && !empty($_POST['description'])) { + $currentCanvasId = (int)session("current" . strtoupper(static::CANVAS_NAME) . "Canvas"); + + $canvasItem = array( + 'box' => $params['box'], + 'author' => session("userdata.id"), + 'description' => $params['description'], + 'status' => $params['status'], + 'relates' => $params['relates'], + 'assumptions' => $params['assumptions'], + 'data' => $params['data'], + 'conclusion' => $params['conclusion'], + 'canvasId' => $currentCanvasId, + ); + + $id = $this->canvasRepo->addCanvasItem($canvasItem); + + $canvasItem['id'] = $id; + + $canvasTypes = $this->canvasRepo->getCanvasTypes(); + + $this->tpl->setNotification($canvasTypes[$params['box']] . ' successfully created', 'success', strtoupper(static::CANVAS_NAME) . 'canvasitem_created'); + + + $notification = app()->make(NotificationModel::class); + $notification->url = array( + "url" => BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . (int)$params['itemId'], + "text" => $this->language->__('email_notifications.canvas_item_update_cta'), + ); + $notification->entity = $canvasItem; + $notification->module = static::CANVAS_NAME . 'canvas'; + $notification->projectId = session("currentProject"); + $notification->subject = $this->language->__('email_notifications.canvas_board_item_created'); + $notification->authorId = session("userdata.id"); + $notification->message = sprintf( + $this->language->__('email_notifications.canvas_item_created_message'), + session("userdata.name"), + $canvasItem['description'] + ); + + $this->projectService->notifyProjectUsers($notification); + + $this->tpl->setNotification($this->language->__('notification.element_created'), 'success', strtoupper(static::CANVAS_NAME) . 'canvasitem_created'); + + return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . $id); + } else { + $this->tpl->setNotification($this->language->__('notification.please_enter_element_title'), 'error'); + } + } + } + + if (isset($params['comment']) === true) { + $values = array( + 'text' => $params['text'], + 'date' => date('Y-m-d H:i:s'), + 'userId' => (session("userdata.id")), + 'moduleId' => $_GET['id'], + 'commentParent' => ($params['father']), + ); + + $message = $this->commentsRepo->addComment($values, static::CANVAS_NAME . 'canvasitem'); + $this->tpl->setNotification($this->language->__('notifications.comment_create_success'), 'success', strtoupper(static::CANVAS_NAME) . 'canvasitemcomment_created'); + + $notification = app()->make(NotificationModel::class); + $notification->url = array( + "url" => BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . (int)$_GET['id'], + "text" => $this->language->__('email_notifications.canvas_item_update_cta'), + ); + $notification->entity = $values; + $notification->module = static::CANVAS_NAME . 'canvas'; + $notification->projectId = session("currentProject"); + $notification->subject = $this->language->__('email_notifications.canvas_board_comment_created'); + $notification->authorId = session("userdata.id"); + $notification->message = sprintf( + $this->language->__('email_notifications.canvas_item__comment_created_message'), + session("userdata.name") + ); + + $this->projectService->notifyProjectUsers($notification); + + + return Frontcontroller::redirect(BASE_URL . '/' . static::CANVAS_NAME . 'canvas' . '/editCanvasComment/' . $_GET['id']); + } + + $this->tpl->assign('canvasTypes', $this->canvasRepo->getCanvasTypes()); + $this->tpl->assign('canvasItem', $this->canvasRepo->getSingleCanvasItem($_GET['id'])); + return $this->tpl->displayPartial(static::CANVAS_NAME . 'canvas.canvasComment'); + } + + /** + * put - handle put requests + * + * @access public + * + */ + public function put($params) + { + } + + /** + * delete - handle delete requests + * + * @access public + * + */ + public function delete($params) + { + } + } } diff --git a/app/Domain/Goalcanvas/Controllers/EditCanvasItem.php b/app/Domain/Goalcanvas/Controllers/EditCanvasItem.php index bff0b2bc8c..5c59614114 100644 --- a/app/Domain/Goalcanvas/Controllers/EditCanvasItem.php +++ b/app/Domain/Goalcanvas/Controllers/EditCanvasItem.php @@ -116,6 +116,8 @@ public function get($params): Response $comments = []; } + $this->tpl->assign('id', $canvasItem['id']??""); + $this->tpl->assign('canvasId', $canvasItem['canvasId']); $this->tpl->assign('comments', $comments); @@ -123,6 +125,7 @@ public function get($params): Response $allProjectMilestones = $this->ticketService->getAllMilestones(["sprint" => '', "type" => "milestone", "currentProject" => session("currentProject")]); $this->tpl->assign('milestones', $allProjectMilestones); + $this->tpl->assign('currentCanvas', $canvasItem['canvasId']); $this->tpl->assign('canvasItem', $canvasItem); $this->tpl->assign('canvasIcon', $this->canvasRepo->getIcon()); @@ -283,8 +286,7 @@ public function post($params): Response 'metricType' => $params['metricType'], 'assignedTo' => $params['assignedTo'] ?? '', ); - - $id = $this->canvasRepo->addCanvasItem($canvasItem); + $id = $this->canvasRepo->addCanvasItem($canvasItem); $canvasTypes = $this->canvasRepo->getCanvasTypes(); $this->tpl->setNotification($canvasTypes[$params['box']]['title'] . ' successfully created', 'success', "goal_item_created"); diff --git a/app/Domain/Goalcanvas/Controllers/ShowCanvas.php b/app/Domain/Goalcanvas/Controllers/ShowCanvas.php index 5fda1347a2..8ab9fa51df 100644 --- a/app/Domain/Goalcanvas/Controllers/ShowCanvas.php +++ b/app/Domain/Goalcanvas/Controllers/ShowCanvas.php @@ -36,8 +36,7 @@ public function init(Projects $projectService, Goalcanvas $goalService) { $this->projectService = $projectService; $this->goalService = $goalService; - $canvasName = Str::studly(static::CANVAS_NAME) . 'canvas'; - $repoName = app()->getNamespace() . "Domain\\$canvasName\\Repositories\\$canvasName"; + $repoName = app()->getNamespace() . "Domain\\goalcanvas\\Repositories\\goalcanvas"; $this->canvasRepo = app()->make($repoName); } diff --git a/app/Domain/Goalcanvas/Templates/bigRockDialog.blade.php b/app/Domain/Goalcanvas/Templates/bigRockDialog.blade.php index 8dd5e8618e..1388cf0b08 100644 --- a/app/Domain/Goalcanvas/Templates/bigRockDialog.blade.php +++ b/app/Domain/Goalcanvas/Templates/bigRockDialog.blade.php @@ -1,19 +1,19 @@