From c80643f97dc4d6a68b1b758e3978b42bdaa6c40a Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sun, 15 Dec 2024 18:50:24 +0100 Subject: [PATCH] feat(xLevelSubTasks): add very basic sub sub task mode --- .../is-markdown-checklist.spec.ts | 3 +++ .../is-markdown-checklist.ts | 12 +++++++--- .../task-detail-panel.component.html | 7 ++++++ .../task-detail-panel.component.ts | 3 +++ .../inline-markdown.component.html | 12 ++++++++++ .../inline-markdown.component.ts | 22 +++++++++++++++++++ 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/app/features/markdown-checklist/is-markdown-checklist.spec.ts b/src/app/features/markdown-checklist/is-markdown-checklist.spec.ts index b3fac59367b..36e6b30b1de 100644 --- a/src/app/features/markdown-checklist/is-markdown-checklist.spec.ts +++ b/src/app/features/markdown-checklist/is-markdown-checklist.spec.ts @@ -18,6 +18,7 @@ describe('isMarkdownChecklist()', () => { [ // -- '- [ ] task', + ' - [ ] task', '- [x] task another yeah', '\n- [ ] task\n\n', ].forEach((text, i) => { @@ -30,6 +31,8 @@ describe('isMarkdownChecklist()', () => { // -- 'some what - [ ] task', '- [x] task another yeah\nSomewhat', + '', + '\n\n', 'Some what yeah\n- [ ] task\n\n', ].forEach((text, i) => { it(`should return false for a non valid checklist #${i}`, () => { diff --git a/src/app/features/markdown-checklist/is-markdown-checklist.ts b/src/app/features/markdown-checklist/is-markdown-checklist.ts index 3cdd2d771f2..4560edbb07a 100644 --- a/src/app/features/markdown-checklist/is-markdown-checklist.ts +++ b/src/app/features/markdown-checklist/is-markdown-checklist.ts @@ -14,10 +14,16 @@ Some text yeah export const isMarkdownChecklist = (text: string): boolean => { try { - const lines = text.split('\n'); - return lines.every( - (it) => it.trim() === '' || it.startsWith('- [x] ') || it.startsWith('- [ ] '), + const lines = text.split('\n').filter((it) => it.trim() !== ''); + + if (lines.length === 0) { + return false; + } + + const items = lines.filter( + (it) => it.trim().startsWith('- [x] ') || it.trim().startsWith('- [ ] '), ); + return items.length === lines.length || items.length >= 3; } catch (e) { console.error('Checklist parsing failed'); console.error(e); diff --git a/src/app/features/tasks/task-detail-panel/task-detail-panel.component.html b/src/app/features/tasks/task-detail-panel/task-detail-panel.component.html index ae4c3afea5a..f5bbfd50615 100644 --- a/src/app/features/tasks/task-detail-panel/task-detail-panel.component.html +++ b/src/app/features/tasks/task-detail-panel/task-detail-panel.component.html @@ -179,9 +179,15 @@ [type]="'panel'" > + @if(isMarkdownChecklist){ + checklist + Checklist + + } @else { chat chat_bubble_outline {{T.F.TASK.ADDITIONAL_INFO.NOTES|translate}} + } @@ -192,6 +198,7 @@ (keyboardUnToggle)="focusItem(noteWrapperElRef)" [isFocus]="isFocusNotes" [isShowControls]="true" + [isShowChecklistToggle]="true" [model]="task.notes|| defaultTaskNotes" > diff --git a/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts b/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts index 4e70bb5d1cc..853525c0f03 100644 --- a/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts +++ b/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts @@ -71,6 +71,7 @@ import { PlannerService } from '../../planner/planner.service'; import { DialogScheduleTaskComponent } from '../../planner/dialog-schedule-task/dialog-schedule-task.component'; import { Store } from '@ngrx/store'; import { selectIssueProviderById } from '../../issue/store/issue-provider.selectors'; +import { isMarkdownChecklist } from '../../markdown-checklist/is-markdown-checklist'; interface IssueAndType { id: string | number | null; @@ -105,6 +106,7 @@ export class TaskDetailPanelComponent implements AfterViewInit, OnDestroy { selectedItemIndex: number = 0; isFocusNotes: boolean = false; isDragOver: boolean = false; + isMarkdownChecklist: boolean = false; T: typeof T = T; issueAttachments: TaskAttachment[] = []; @@ -333,6 +335,7 @@ export class TaskDetailPanelComponent implements AfterViewInit, OnDestroy { this.isExpandedIssuePanel = !IS_MOBILE && !!this.issueData; this.isExpandedNotesPanel = !IS_MOBILE && (!!newVal.notes || (!newVal.issueId && !newVal.attachments?.length)); + this.isMarkdownChecklist = isMarkdownChecklist(newVal.notes || ''); } get progress(): number { diff --git a/src/app/ui/inline-markdown/inline-markdown.component.html b/src/app/ui/inline-markdown/inline-markdown.component.html index 4398163adc0..b069d8e6159 100644 --- a/src/app/ui/inline-markdown/inline-markdown.component.html +++ b/src/app/ui/inline-markdown/inline-markdown.component.html @@ -34,7 +34,19 @@ *ngIf="isShowControls" class="controls" > + @if(isShowChecklistToggle){ + + } + +