OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
48
app/Domain/Projects/Hxcontrollers/Checklist.php
Normal file
48
app/Domain/Projects/Hxcontrollers/Checklist.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Projects\Hxcontrollers;
|
||||
|
||||
use Error;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Leantime\Core\Controller\HtmxController;
|
||||
use Leantime\Domain\Projects\Services\Projects;
|
||||
|
||||
class Checklist extends HtmxController
|
||||
{
|
||||
protected static string $view = 'projects::partials.checklist';
|
||||
|
||||
private Projects $projectService;
|
||||
|
||||
/**
|
||||
* Controller constructor
|
||||
*
|
||||
* @param Projects $projectService The projects domain service.
|
||||
*/
|
||||
public function init(Projects $projectService): void
|
||||
{
|
||||
$this->projectService = $projectService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates subtask status
|
||||
*
|
||||
* @throws BindingResolutionException
|
||||
*/
|
||||
public function updateSubtask(): void
|
||||
{
|
||||
if (! $this->incomingRequest->getMethod() == 'PATCH') {
|
||||
throw new Error('This endpoint only supports PATCH requests');
|
||||
}
|
||||
|
||||
// update project progress
|
||||
$projectProgress = $this->incomingRequest->request->all();
|
||||
|
||||
$this->projectService->updateProjectProgress($projectProgress, session('currentProject'));
|
||||
|
||||
// return view with new data
|
||||
[$progressSteps, $percentDone] = $this->projectService->getProjectSetupChecklist(session('currentProject'));
|
||||
$this->tpl->assign('progressSteps', $progressSteps);
|
||||
$this->tpl->assign('percentDone', $percentDone);
|
||||
$this->tpl->assign('includeTitle', false);
|
||||
}
|
||||
}
|
||||
87
app/Domain/Projects/Hxcontrollers/ProjectCard.php
Normal file
87
app/Domain/Projects/Hxcontrollers/ProjectCard.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Projects\Hxcontrollers;
|
||||
|
||||
use Leantime\Core\Controller\Frontcontroller;
|
||||
use Leantime\Core\Controller\HtmxController;
|
||||
use Leantime\Domain\Menu\Services\Menu;
|
||||
use Leantime\Domain\Projects\Services\Projects as ProjectService;
|
||||
use Leantime\Domain\Reactions\Services\Reactions;
|
||||
|
||||
class ProjectCard extends HtmxController
|
||||
{
|
||||
protected static string $view = 'projects::partials.projectCard';
|
||||
|
||||
private ProjectService $projectsService;
|
||||
|
||||
private Menu $menuService;
|
||||
|
||||
private Reactions $reactionService;
|
||||
|
||||
/**
|
||||
* Controller constructor
|
||||
*
|
||||
* @param \Leantime\Domain\Projects\Services\Projects $projectsService The projects domain service.
|
||||
* @param \Leantime\Domain\Menu\Services\Menu $menuService The menu domain service.
|
||||
* @param \Leantime\Domain\Reactions\Services\Reactions $reactionService The reactions domain service.
|
||||
*/
|
||||
public function init(
|
||||
ProjectService $projectsService,
|
||||
Menu $menuService,
|
||||
Reactions $reactionService
|
||||
): void {
|
||||
$this->projectsService = $projectsService;
|
||||
$this->menuService = $menuService;
|
||||
$this->reactionService = $reactionService;
|
||||
}
|
||||
|
||||
public function get() {}
|
||||
|
||||
/**
|
||||
* Toggles the current user's favorite reaction for a project and re-renders the card.
|
||||
*/
|
||||
public function toggleFavorite(): void
|
||||
{
|
||||
$projectData = $this->incomingRequest->request->all();
|
||||
|
||||
$projectId = $projectData['projectId'];
|
||||
$isFavorite = $projectData['isFavorite'];
|
||||
|
||||
if ($isFavorite) {
|
||||
$this->reactionService->removeReaction(
|
||||
userId: session('userdata.id'),
|
||||
module: 'project',
|
||||
moduleId: $projectId,
|
||||
reaction: 'favorite'
|
||||
);
|
||||
} else {
|
||||
$this->reactionService->addReaction(
|
||||
userId: session('userdata.id'),
|
||||
module: 'project',
|
||||
moduleId: $projectId,
|
||||
reaction: 'favorite'
|
||||
);
|
||||
}
|
||||
|
||||
$this->tpl->setHTMXEvent('HTMX.updateProjectList');
|
||||
|
||||
$this->tpl->assign('project', $this->projectsService->getProject($projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the project card for a project.
|
||||
*/
|
||||
public function getProgress(): void
|
||||
{
|
||||
$projectId = $_GET['projectId'];
|
||||
|
||||
$projectTypeAvatars = $this->menuService->getProjectTypeAvatars();
|
||||
|
||||
$currentUrlPath = BASE_URL.'/'.str_replace('.', '/', Frontcontroller::getCurrentRoute());
|
||||
|
||||
$this->tpl->assign('projectTypeAvatars', $projectTypeAvatars);
|
||||
$this->tpl->assign('currentUrlPath', $currentUrlPath);
|
||||
$this->tpl->assign('project', $this->projectsService->getProject($projectId));
|
||||
$this->tpl->assign('type', 'full');
|
||||
}
|
||||
}
|
||||
50
app/Domain/Projects/Hxcontrollers/ProjectCardProgress.php
Normal file
50
app/Domain/Projects/Hxcontrollers/ProjectCardProgress.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Projects\Hxcontrollers;
|
||||
|
||||
use Leantime\Core\Controller\Frontcontroller;
|
||||
use Leantime\Core\Controller\HtmxController;
|
||||
use Leantime\Domain\Menu\Services\Menu;
|
||||
use Leantime\Domain\Projects\Services\Projects as ProjectService;
|
||||
|
||||
class ProjectCardProgress extends HtmxController
|
||||
{
|
||||
protected static string $view = 'projects::partials.projectCardProgressBar';
|
||||
|
||||
private ProjectService $projectsService;
|
||||
|
||||
private Menu $menuService;
|
||||
|
||||
/**
|
||||
* Controller constructor
|
||||
*
|
||||
* @param \Leantime\Domain\Projects\Services\Projects $projectsService The projects domain service.
|
||||
* @param \Leantime\Domain\Menu\Services\Menu $menuService The menu domain service.
|
||||
*/
|
||||
public function init(
|
||||
ProjectService $projectsService,
|
||||
Menu $menuService
|
||||
): void {
|
||||
$this->projectsService = $projectsService;
|
||||
$this->menuService = $menuService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the project card progress bar partial.
|
||||
*/
|
||||
public function getProgress(): void
|
||||
{
|
||||
$projectId = $_GET['pId'];
|
||||
|
||||
$project = $this->projectsService->getProjectCardData($projectId);
|
||||
|
||||
$projectTypeAvatars = $this->menuService->getProjectTypeAvatars();
|
||||
|
||||
$currentUrlPath = BASE_URL.'/'.str_replace('.', '/', Frontcontroller::getCurrentRoute());
|
||||
|
||||
$this->tpl->assign('projectTypeAvatars', $projectTypeAvatars);
|
||||
$this->tpl->assign('currentUrlPath', $currentUrlPath);
|
||||
$this->tpl->assign('project', $project);
|
||||
$this->tpl->assign('type', 'full');
|
||||
}
|
||||
}
|
||||
50
app/Domain/Projects/Hxcontrollers/ProjectHubProjects.php
Normal file
50
app/Domain/Projects/Hxcontrollers/ProjectHubProjects.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Projects\Hxcontrollers;
|
||||
|
||||
use Leantime\Core\Controller\Frontcontroller;
|
||||
use Leantime\Core\Controller\HtmxController;
|
||||
use Leantime\Domain\Menu\Services\Menu;
|
||||
use Leantime\Domain\Projects\Services\Projects as ProjectService;
|
||||
|
||||
class ProjectHubProjects extends HtmxController
|
||||
{
|
||||
protected static string $view = 'projects::partials.projectHubProjects';
|
||||
|
||||
private ProjectService $projectsService;
|
||||
|
||||
private Menu $menuService;
|
||||
|
||||
/**
|
||||
* Controller constructor
|
||||
*
|
||||
* @param \Leantime\Domain\Projects\Services\Projects $projectsService The projects domain service.
|
||||
* @param \Leantime\Domain\Menu\Services\Menu $menuService The menu domain service.
|
||||
*/
|
||||
public function init(
|
||||
ProjectService $projectsService,
|
||||
Menu $menuService
|
||||
): void {
|
||||
$this->projectsService = $projectsService;
|
||||
$this->menuService = $menuService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the project hub project list partial.
|
||||
*/
|
||||
public function get(): void
|
||||
{
|
||||
$clientId = (isset($_GET['client']) === true && $_GET['client'] != '') ? (int) $_GET['client'] : null;
|
||||
|
||||
$hubData = $this->projectsService->getProjectHubData(session('userdata.id'), $clientId);
|
||||
|
||||
$currentUrlPath = BASE_URL.'/'.str_replace('.', '/', Frontcontroller::getCurrentRoute());
|
||||
|
||||
$this->tpl->assign('projectTypeAvatars', $this->menuService->getProjectTypeAvatars());
|
||||
$this->tpl->assign('currentUrlPath', $currentUrlPath);
|
||||
$this->tpl->assign('currentClientName', $hubData['currentClientName']);
|
||||
$this->tpl->assign('currentClient', $hubData['currentClient']);
|
||||
$this->tpl->assign('clients', $hubData['clients']);
|
||||
$this->tpl->assign('allProjects', $hubData['allProjects']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user