Skip to content

Commit ac036f9

Browse files
Merge pull request #3360 from Leantime/fix/move-ticket-kpi-backlog-tiptap-lists
fix: moveTicket, KPI linking, backlog filter on Postgres, tiptap list rendering
2 parents 20bb2f7 + 513af3b commit ac036f9

4 files changed

Lines changed: 74 additions & 16 deletions

File tree

app/Domain/Canvas/Repositories/Canvas.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ public function getAllAvailableKPIs($projectId): false|array
546546
$parentProject = $this->connection->table('zp_projects')
547547
->select('parent')
548548
->where('id', $projectId)
549-
->whereIn('type', ['strategy', 'program'])
550549
->first();
551550

552551
if ($parentProject && $parentProject->parent) {

app/Domain/Tickets/Repositories/Tickets.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,18 @@ public function getAllBySearchCriteria(array $searchCriteria, string $sort = 'st
561561
});
562562
}
563563

564-
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] > 0 && $searchCriteria['sprint'] != 'all') {
565-
$sprintIds = explode(',', $searchCriteria['sprint']);
566-
$query->whereIn('zp_tickets.sprint', $sprintIds);
564+
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] !== '' && $searchCriteria['sprint'] !== 'backlog') {
565+
$sprintIds = array_values(array_filter(
566+
array_map('trim', explode(',', (string) $searchCriteria['sprint'])),
567+
static fn ($token) => ctype_digit($token) && (int) $token > 0
568+
));
569+
570+
if ($sprintIds !== []) {
571+
$query->whereIn('zp_tickets.sprint', array_map('intval', $sprintIds));
572+
}
567573
}
568574

569-
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] == 'backlog') {
575+
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] === 'backlog') {
570576
$query->where(function ($q) {
571577
$q->whereNull('zp_tickets.sprint')
572578
->orWhere('zp_tickets.sprint', 0)
@@ -1224,15 +1230,22 @@ public function getAllMilestones(array $searchCriteria, string $sort = 'standard
12241230
});
12251231
}
12261232

1227-
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] > 0 && $searchCriteria['sprint'] != 'all') {
1228-
$sprintIds = explode(',', $searchCriteria['sprint']);
1229-
$query->where(function ($q) use ($sprintIds) {
1230-
$q->whereIn('zp_tickets.sprint', $sprintIds)
1231-
->orWhere('zp_tickets.type', 'milestone');
1232-
});
1233+
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] !== '' && $searchCriteria['sprint'] !== 'backlog') {
1234+
$sprintIds = array_values(array_filter(
1235+
array_map('trim', explode(',', (string) $searchCriteria['sprint'])),
1236+
static fn ($token) => ctype_digit($token) && (int) $token > 0
1237+
));
1238+
1239+
if ($sprintIds !== []) {
1240+
$intSprintIds = array_map('intval', $sprintIds);
1241+
$query->where(function ($q) use ($intSprintIds) {
1242+
$q->whereIn('zp_tickets.sprint', $intSprintIds)
1243+
->orWhere('zp_tickets.type', 'milestone');
1244+
});
1245+
}
12331246
}
12341247

1235-
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] == 'backlog') {
1248+
if (isset($searchCriteria['sprint']) && $searchCriteria['sprint'] === 'backlog') {
12361249
$query->where(function ($q) {
12371250
$q->whereNull('zp_tickets.sprint')
12381251
->orWhere('zp_tickets.sprint', 0)

app/Domain/Tickets/Services/Tickets.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,43 @@ public function patch($id, $params): bool
22172217
return (bool) $return;
22182218
}
22192219

2220+
/**
2221+
* moveTicket - Moves a ticket from one project to another. Milestone children will be moved as well.
2222+
*
2223+
* @throws BindingResolutionException
2224+
*
2225+
* @api
2226+
*/
2227+
public function moveTicket(int $id, int $projectId): bool
2228+
{
2229+
$ticket = $this->getTicket($id);
2230+
2231+
if (! $ticket) {
2232+
return false;
2233+
}
2234+
2235+
if ($ticket->type == 'milestone') {
2236+
$milestoneTickets = $this->getAll(['milestone' => $ticket->id]);
2237+
foreach ($milestoneTickets as $childTicket) {
2238+
$childMoved = $this->patch($childTicket['id'], [
2239+
'projectId' => $projectId,
2240+
'sprint' => null,
2241+
]);
2242+
2243+
if (! $childMoved) {
2244+
return false;
2245+
}
2246+
}
2247+
}
2248+
2249+
return $this->patch($ticket->id, [
2250+
'projectId' => $projectId,
2251+
'sprint' => null,
2252+
'dependingTicketId' => null,
2253+
'milestoneid' => null,
2254+
]);
2255+
}
2256+
22202257
/**
22212258
* @return bool|string[]
22222259
*

public/assets/css/components/tiptap-editor.css

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,33 @@
195195
========================================================================== */
196196

197197
.tiptap-editor .ProseMirror ul,
198-
.tiptap-editor .ProseMirror ol {
198+
.tiptap-editor .ProseMirror ol,
199+
.tiptap-content ul,
200+
.tiptap-content ol {
199201
padding-left: 1.5em;
200202
margin: 0 0 1em 0;
201203
}
202204

203-
.tiptap-editor .ProseMirror li {
205+
.tiptap-editor .ProseMirror li,
206+
.tiptap-content li {
204207
margin-bottom: 0.25em;
205208
}
206209

207-
.tiptap-editor .ProseMirror li p {
210+
.tiptap-editor .ProseMirror li > p,
211+
.tiptap-content li > p {
212+
display: inline;
208213
margin: 0;
209214
}
210215

211216
/* Nested lists */
212217
.tiptap-editor .ProseMirror ul ul,
213218
.tiptap-editor .ProseMirror ol ol,
214219
.tiptap-editor .ProseMirror ul ol,
215-
.tiptap-editor .ProseMirror ol ul {
220+
.tiptap-editor .ProseMirror ol ul,
221+
.tiptap-content ul ul,
222+
.tiptap-content ol ol,
223+
.tiptap-content ul ol,
224+
.tiptap-content ol ul {
216225
margin-top: 0.25em;
217226
margin-bottom: 0;
218227
}

0 commit comments

Comments
 (0)