Skip to content

Commit

Permalink
htmx setup for goal card
Browse files Browse the repository at this point in the history
  • Loading branch information
muhtasimhafiz committed Oct 11, 2024
1 parent acf4a9f commit 942af41
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace Leantime\Domain\Goalcanvas\Hxcontrollers;

use Leantime\Core\Controller\HtmxController;
use Leantime\Domain\Goalcanvas\Services\Goalcanvas;
use Leantime\Domain\Goalcanvas\Services\Goalcanvas as GoalcanvasService;
use Leantime\Domain\Projects\Services\Projects;


class GoalcanvasCard extends HtmxController
class Canvas extends HtmxController
{
protected static string $view = 'goalcanvas::partials.goalCanvasCard';
protected static string $view = 'goalcanvas::components.canvas';

private Goalcanvas $goalService;
private GoalcanvasService $goalService;
private Projects $projectService;

/**
* Controller constructor
*
*/
public function init(Goalcanvas $goalService, Projects $projectService): void
public function init(GoalcanvasService $goalService, Projects $projectService): void
{
$this->goalService = $goalService;
$this->projectService = $projectService;
Expand All @@ -34,9 +34,12 @@ public function get($params): void
$statusLabels = $this->goalService->getGoalStatusLabels();
$relatesLabels = $this->goalService->getGoalRelatesLabels();
$users = $this->projectService->getUsersAssignedToProject(session('currentProject'));
$canvasItems = $this->goalService->getCanvasItemsById($id);

$this->tpl->assign('canvas', $canvas);
$this->tpl->assign('statusLabels', $statusLabels);
$this->tpl->assign('relatesLabels', $relatesLabels);
$this->tpl->assign('users', $users);
$this->tpl->assign('goalItems', $canvasItems);
}
}
56 changes: 56 additions & 0 deletions app/Domain/Goalcanvas/Templates/components/canvas.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

@props([
'canvasId' => '',
'canvasTitle' => '',
'goalItems' => [],
'statusLabels' => [],
'relatesLabels' => [],
'users' => [],
'id' => '',
])

@if (empty($id) == false)
<div hx-get="{{ BASE_URL }}/hx/goalcanvas/canvas/get?id={{ $id }}" hx-trigger="load"
hx-swap="innerHtml">

loading...

</div>
@else
<div class="row">
<div class="col-md-12">
<a href="#/goalcanvas/editCanvasItem?type=goal&canvasId={{ $canvasId }}"
class="btn btn-primary pull-right">
<i class="fa fa-plus"></i> Create New Goal
</a>
<h5 class='subtitle'>
<a href='{{ BASE_URL }}/goalcanvas/showCanvas/{{ $canvasId }}'>
{{ $canvasTitle }}
</a>
</h5>
</div>
</div>

<div class="row" style="border-bottom:1px solid var(--main-border-color); margin-bottom:20px">
<div id="sortableCanvasKanban-{{ $canvasId }}" class="sortableTicketList disabled col-md-12"
style="padding-top:15px;">
<div class="row">
<div class="col-md-12">
<div class="row">
@if (count($goalItems) == 0)
<div class='col-md-12'>No goals on this board yet. Open the <a
href='{{ BASE_URL }}/goalcanvas/showCanvas/{{ $canvasId }}'>board</a> to
start adding goals</div>
@endif

@foreach ($goalItems as $goal)
<x-goalcanvas::goal-item-card :row="$goal" elementName="goal" :filter="$filter ?? []"
:statusLabels="$statusLabels" :relatesLabels="$relatesLabels" :users="$users" />
@endforeach
</div>
<br />
</div>
</div>
</div>
</div>
@endif
68 changes: 0 additions & 68 deletions app/Domain/Goalcanvas/Templates/components/goal-card.blade.php

This file was deleted.

10 changes: 5 additions & 5 deletions app/Domain/Goalcanvas/Templates/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ class="sr-only">{{ sprintf(__('text.percent_complete'), round($goalStats['avgPer
</div>
@if (count($allCanvas) > 0)
@foreach ($allCanvas as $canvasRow)
@php
{{-- @php
$canvasItems = $canvasSvc->getCanvasItemsById($canvasRow['id']);
@endphp
@endphp --}}

<x-goalcanvas::goal-card
canvasId="{{ $canvasRow['id'] }}"
<x-goalcanvas::canvas
id="{{ $canvasRow['id'] }}"
canvasTitle="{{ $canvasRow['title'] }}"
:goalItems="$canvasItems"
{{-- :goalItems="$canvasItems" --}}
:statusLabels="$statusLabels"
:relatesLabels="$relatesLabels"
:users="$users"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<x-goalcanvas::goal-card
canvasTitle="{{ $canvas->title }}"
canvasId = "{{ $canvas->id }}"
:goalItems="$canvasItems"
:statusLabels="$statusLabels"
:relatesLabels="$relatesLabels"
:users="$users"
Expand Down
6 changes: 3 additions & 3 deletions app/Domain/Projects/Services/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ public function notifyProjectUsers(Notification $notification): void
{

//Filter notifications
$eventCore = new EventCore();
$notification = $eventCore->dispatchFilter('notificationFilter', $notification);

$notification = self::dispatchFilter('notificationFilter', $notification);

//Email
$users = $this->getUsersToNotify($notification->projectId);
Expand Down Expand Up @@ -330,7 +330,7 @@ public function notifyProjectUsers(Notification $notification): void
);
}

$eventCore->dispatchEvent('notifyProjectUsers', ['type' => 'projectUpdate', 'module' => $notification->module, 'moduleId' => $entityId, 'message' => $notification->message, 'subject' => $notification->subject, 'users' => $this->getAllUserInfoToNotify($notification->projectId), 'url' => $notification->url['url']], 'domain.services.projects');
self::dispatchEvent('notifyProjectUsers', ['type' => 'projectUpdate', 'module' => $notification->module, 'moduleId' => $entityId, 'message' => $notification->message, 'subject' => $notification->subject, 'users' => $this->getAllUserInfoToNotify($notification->projectId), 'url' => $notification->url['url']], 'domain.services.projects');
}

/**
Expand Down

0 comments on commit 942af41

Please sign in to comment.