From 27b00572be3474c5296f404e887e8f8ab6541964 Mon Sep 17 00:00:00 2001 From: Niedermann IT-Dienstleistungen Date: Tue, 16 Jan 2024 14:22:08 +0100 Subject: [PATCH] feat(done): Support done state of Deck 1.12.0 Signed-off-by: Stefan Niedermann --- cypress/e2e/spec.cy.ts | 3 + src/app/analyzer/analyzer.component.html | 5 +- src/app/analyzer/analyzer.component.scss | 5 +- src/app/analyzer/analyzer.component.ts | 5 + src/app/analyzer/analyzer.service.ts | 22 ++- src/app/analyzer/cases.ts | 176 +++++++++++++++++++++++ 6 files changed, 211 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/spec.cy.ts b/cypress/e2e/spec.cy.ts index 1261e2dd..9ffdf3cf 100755 --- a/cypress/e2e/spec.cy.ts +++ b/cypress/e2e/spec.cy.ts @@ -53,6 +53,9 @@ describe('Analyzer main screen', () => { cases.forEach(([description, expected]) => { cy.visit('/'); + if (description.isDone) { + cy.get('[formControlName="isDone"]').click() + } if (description.isSharedBoard) { cy.get('[formControlName="isSharedBoard"]').click() } diff --git a/src/app/analyzer/analyzer.component.html b/src/app/analyzer/analyzer.component.html index d89c3366..c5ad5f7d 100755 --- a/src/app/analyzer/analyzer.component.html +++ b/src/app/analyzer/analyzer.component.html @@ -12,6 +12,9 @@
+ + Is your card marked as completed? +
Is your card on a shared board?
@@ -47,7 +50,7 @@ Learn in which cases a card appears in the upcoming view -

Starting with Deck 1.5 cards will appear in the upcoming view if one of the following two cases matches:

+

Starting with Deck 1.5 cards will appear in the upcoming view if they are not marked as completed and additionally one of the following two cases matches:

  • Card has a due date and card is in a not shared board
  • Card is in a board which is also shared with others and one of the following two cases diff --git a/src/app/analyzer/analyzer.component.scss b/src/app/analyzer/analyzer.component.scss index f38d46f6..31701b34 100755 --- a/src/app/analyzer/analyzer.component.scss +++ b/src/app/analyzer/analyzer.component.scss @@ -10,6 +10,7 @@ margin: auto; grid-template-columns: repeat(2, 50%); + mat-card:first-child { grid-column: 1 / span 2 } @@ -25,7 +26,8 @@ mat-card-actions { } mat-slide-toggle { - display: block; + display: inline-block; + padding: .5rem 0; } mat-icon { @@ -36,6 +38,7 @@ mat-icon { mat-card.result { border-bottom: .3rem solid #E9322D; + &.visible { border-color: #46BA61; } diff --git a/src/app/analyzer/analyzer.component.ts b/src/app/analyzer/analyzer.component.ts index 3ff9dfd9..6f87ae09 100755 --- a/src/app/analyzer/analyzer.component.ts +++ b/src/app/analyzer/analyzer.component.ts @@ -12,6 +12,7 @@ import { AnalyzerService, CardDescription, Hint } from './analyzer.service'; export class AnalyzerComponent implements OnDestroy { form: UntypedFormGroup = new UntypedFormGroup({ + isDone: new UntypedFormControl(), isSharedBoard: new UntypedFormControl(), hasDueDate: new UntypedFormControl(), youAssigned: new UntypedFormControl(), @@ -19,6 +20,7 @@ export class AnalyzerComponent implements OnDestroy { }); private readonly unsubscribe$ = new Subject(); + private readonly isDoneCheckbox = this.form.get('isDone'); private readonly isSharedBoardCheckbox = this.form.get('isSharedBoard'); private readonly hasDueDateCheckbox = this.form.get('hasDueDate'); private readonly youAssignedCheckbox = this.form.get('youAssigned'); @@ -47,6 +49,7 @@ export class AnalyzerComponent implements OnDestroy { */ private getInitialCardDescription(): CardDescription { return { + isDone: !!this.isDoneCheckbox?.value, isSharedBoard: !!this.isSharedBoardCheckbox?.value, hasDueDate: !!this.hasDueDateCheckbox?.value, youAssigned: !!this.youAssignedCheckbox?.value, @@ -59,12 +62,14 @@ export class AnalyzerComponent implements OnDestroy { */ private getCardDescription(): Observable { return merge( + this.isDoneCheckbox?.valueChanges || EMPTY, this.isSharedBoardCheckbox?.valueChanges || EMPTY, this.hasDueDateCheckbox?.valueChanges || EMPTY, this.youAssignedCheckbox?.valueChanges || EMPTY, this.someoneElseAssignedCheckbox?.valueChanges || EMPTY, ).pipe(map(() => { return { + isDone: this.isDoneCheckbox?.value, isSharedBoard: this.isSharedBoardCheckbox?.value, hasDueDate: this.hasDueDateCheckbox?.value, youAssigned: this.youAssignedCheckbox?.value, diff --git a/src/app/analyzer/analyzer.service.ts b/src/app/analyzer/analyzer.service.ts index 92f38028..82dc8b3e 100755 --- a/src/app/analyzer/analyzer.service.ts +++ b/src/app/analyzer/analyzer.service.ts @@ -9,8 +9,20 @@ export class AnalyzerService { constructor() { } public isVisible(cardDescription: CardDescription): boolean { - return (cardDescription.hasDueDate && !cardDescription.isSharedBoard) || - (cardDescription.isSharedBoard && (cardDescription.youAssigned || (cardDescription.hasDueDate && !cardDescription.someoneElseAssigned))) + return !cardDescription.isDone && ( + ( + cardDescription.hasDueDate && + !cardDescription.isSharedBoard + ) || + ( + cardDescription.isSharedBoard && ( + cardDescription.youAssigned || ( + cardDescription.hasDueDate && + !cardDescription.someoneElseAssigned + ) + ) + ) + ) } /** @@ -18,7 +30,9 @@ export class AnalyzerService { * Card is in a board which is also shared with others AND (card is assigned to you OR (card has a due date AND nobody is assigned to the card)) */ public mapCardDescriptionToHint(cardDescription: CardDescription): Hint { - if (cardDescription.isSharedBoard && cardDescription.hasDueDate && cardDescription.youAssigned && cardDescription.someoneElseAssigned) { + if (cardDescription.isDone) { + return Hint.CARD_MUST_NOT_BE_DONE; + } else if (cardDescription.isSharedBoard && cardDescription.hasDueDate && cardDescription.youAssigned && cardDescription.someoneElseAssigned) { return Hint.CARD_SHOULD_BE_SHOWN; } else if (!cardDescription.isSharedBoard && cardDescription.hasDueDate && cardDescription.youAssigned && cardDescription.someoneElseAssigned) { return Hint.CARD_SHOULD_BE_SHOWN; @@ -56,6 +70,7 @@ export class AnalyzerService { } export interface CardDescription { + isDone: boolean; isSharedBoard: boolean; hasDueDate: boolean; youAssigned: boolean; @@ -63,6 +78,7 @@ export interface CardDescription { } export enum Hint { + CARD_MUST_NOT_BE_DONE = 'Mark your card as "not completed".', CARD_SHOULD_BE_SHOWN = 'Your card should be visible.', SET_DUE_DATE = 'Set a due date to the card.', ASSIGN_CARD_OR_SET_DUE_DATE = 'Assign the card to you or set a due date.', diff --git a/src/app/analyzer/cases.ts b/src/app/analyzer/cases.ts index bd9e6825..4ae97104 100755 --- a/src/app/analyzer/cases.ts +++ b/src/app/analyzer/cases.ts @@ -3,6 +3,7 @@ import { CardDescription, Hint } from "./analyzer.service"; export const cases: Array<[CardDescription, Hint]> = [ [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": false, "youAssigned": false, @@ -12,6 +13,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": false, "youAssigned": false, @@ -21,6 +23,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": false, "youAssigned": true, @@ -30,6 +33,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": false, "youAssigned": true, @@ -39,6 +43,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": true, "youAssigned": false, @@ -48,6 +53,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": true, "youAssigned": false, @@ -57,6 +63,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": true, "youAssigned": true, @@ -66,6 +73,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": false, "hasDueDate": true, "youAssigned": true, @@ -75,6 +83,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": false, "youAssigned": false, @@ -84,6 +93,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": false, "youAssigned": false, @@ -93,6 +103,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": false, "youAssigned": true, @@ -102,6 +113,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": false, "youAssigned": true, @@ -111,6 +123,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": true, "youAssigned": false, @@ -120,6 +133,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": true, "youAssigned": false, @@ -129,6 +143,7 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": true, "youAssigned": true, @@ -138,11 +153,172 @@ export const cases: Array<[CardDescription, Hint]> = [ ], [ { + "isDone": false, "isSharedBoard": true, "hasDueDate": true, "youAssigned": true, "someoneElseAssigned": true }, Hint.CARD_SHOULD_BE_SHOWN + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": false, + "youAssigned": false, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": false, + "youAssigned": false, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": false, + "youAssigned": true, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": false, + "youAssigned": true, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": true, + "youAssigned": false, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": true, + "youAssigned": false, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": true, + "youAssigned": true, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": false, + "hasDueDate": true, + "youAssigned": true, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": false, + "youAssigned": false, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": false, + "youAssigned": false, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": false, + "youAssigned": true, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": false, + "youAssigned": true, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": true, + "youAssigned": false, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": true, + "youAssigned": false, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": true, + "youAssigned": true, + "someoneElseAssigned": false + }, + Hint.CARD_MUST_NOT_BE_DONE + ], + [ + { + "isDone": true, + "isSharedBoard": true, + "hasDueDate": true, + "youAssigned": true, + "someoneElseAssigned": true + }, + Hint.CARD_MUST_NOT_BE_DONE ] ]; \ No newline at end of file