diff --git a/app/Domain/Goalcanvas/Controllers/DelCanvas.php b/app/Domain/Goalcanvas/Controllers/DelCanvas.php index 02e5f0aba..49cdd7bcc 100644 --- a/app/Domain/Goalcanvas/Controllers/DelCanvas.php +++ b/app/Domain/Goalcanvas/Controllers/DelCanvas.php @@ -1,30 +1,69 @@ getNamespace() . "Domain\\$canvasName\\Repositories\\$canvasName"; + $this->canvasRepo = app()->make($repoName); + } + + /** + * run - display template and edit data + * + * @access public + */ + public function run() { - $id = filter_var($params['id'] ?? '', FILTER_SANITIZE_NUMBER_INT); - $this->tpl->assign('id', $id); - return $this->tpl->displayPartial('goalcanvas.delCanvas'); + 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 c70253209..4604267f4 100644 --- a/app/Domain/Goalcanvas/Controllers/DelCanvasItem.php +++ b/app/Domain/Goalcanvas/Controllers/DelCanvasItem.php @@ -1,27 +1,57 @@ tpl->assign('id', $id); - return $this->tpl->displayPartial('goalcanvas.delCanvasItem'); + private mixed $canvasRepo; + /** + * init - initialize private variables + */ + public function init() + { + $canvasName ='goalcanvas'; + $repoName = app()->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 54e4f6191..b61e0a2de 100644 --- a/app/Domain/Goalcanvas/Controllers/EditCanvasComment.php +++ b/app/Domain/Goalcanvas/Controllers/EditCanvasComment.php @@ -1,17 +1,286 @@ ticketRepo = $ticketRepo; + $this->commentsRepo = $commentsRepo; + $this->sprintService = $sprintService; + $this->ticketService = $ticketService; + $this->projectService = $projectService; + + $canvasName = Str::studly(static::CANVAS_NAME) . 'canvas'; + $repoName = app()->getNamespace() . "Domain\\$canvasName\\Repositories\\$canvasName"; + $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 3a284339b..5c5961411 100644 --- a/app/Domain/Goalcanvas/Controllers/EditCanvasItem.php +++ b/app/Domain/Goalcanvas/Controllers/EditCanvasItem.php @@ -286,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/Templates/canvasDialog.blade.php b/app/Domain/Goalcanvas/Templates/canvasDialog.blade.php index 0785ab8c4..022c77dd2 100644 --- a/app/Domain/Goalcanvas/Templates/canvasDialog.blade.php +++ b/app/Domain/Goalcanvas/Templates/canvasDialog.blade.php @@ -15,7 +15,7 @@ {{ $canvasTypes[$canvasItem['box']]['title'] }} -
+ @@ -85,21 +85,19 @@ @endif @if ($id !== '') -


- +


+

{{ __('subtitles.discussion') }}

+ class="fa fa-comments">{{ $tpl->__('subtitles.discussion') }} @php - $formUrl = '/strategyPro/editCanvasItem/' . $id; + $tpl->assign('formUrl', '/strategyPro/editCanvasItem/' . $id . ''); + $tpl->displaySubmodule('comments-generalComment'); @endphp - @include('comments.generalComment', [ - 'formUrl' => '/goalcanvas/editCanvasComment/' . $id, - ]) @endif @if ($id != '') - + {{ __('links.delete') }} @endif diff --git a/app/Domain/Goalcanvas/Templates/dashboard.blade.php b/app/Domain/Goalcanvas/Templates/dashboard.blade.php index 08b731fe0..be615a805 100644 --- a/app/Domain/Goalcanvas/Templates/dashboard.blade.php +++ b/app/Domain/Goalcanvas/Templates/dashboard.blade.php @@ -311,10 +311,73 @@ @endif -viewFactory->make( - $tpl->getTemplatePath('canvas', 'showCanvasBottom'), - array_merge($__data, ['canvasName' => 'goal']) -)->render(); ?> + + +{{-- + * showCanvasBottom.blade.php template - Bottom part of the main canvas page + * + * Required variables: + * - $canvasName Name of current canvas +--}} + +@if (count($allCanvas) > 0) + {{-- --}} +@else +

+
+
+ {!! file_get_contents(ROOT . "/dist/images/svg/undraw_design_data_khdb.svg") !!} +
+

{{ __("headlines.$canvasName.analysis") }}

+
{!! __("text.$canvasName.helper_content") !!} + + @if ($login::userIsAtLeast($roles::$editor)) +

+ + {{ __("links.icon.create_new_board") }} + + @endif +
+@endif + +@if (!empty($disclaimer) && count($allCanvas) > 0) + {{ $disclaimer }} +@endif + +{!! $tpl->viewFactory->make($tpl->getTemplatePath('canvas', 'modals'), $__data)->render() !!} + + + + + @endsection \ No newline at end of file diff --git a/app/Domain/Goalcanvas/Templates/delCanvas.blade.php b/app/Domain/Goalcanvas/Templates/delCanvas.blade.php index cb24385b3..4ad458839 100644 --- a/app/Domain/Goalcanvas/Templates/delCanvas.blade.php +++ b/app/Domain/Goalcanvas/Templates/delCanvas.blade.php @@ -3,13 +3,13 @@

{!!__("subtitles.delete") !!}

- + @if(isset($csrf_token)) @endif

{{ __('text.confirm_board_deletion') }}


- {{ __('buttons.back') }} + {{ __('buttons.back') }}
@endsection \ No newline at end of file