From 4629c7d90f2be96fad290949f7a0d1e982be9500 Mon Sep 17 00:00:00 2001 From: Andres Felipe Ordonez Date: Tue, 3 Dec 2019 15:21:13 -0500 Subject: [PATCH] Added a custom card set to vote from 1 -5 and calculate the average when using it. --- .gitignore | 1 + src/components/cards/card.tsx | 3 +- src/model/cards.ts | 31 ++++++++++++++++++- src/pages/session/components/workItemView.tsx | 24 ++++++++++++-- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index bbdb064..64ca7c4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ yarn-debug.log* yarn-error.log* *.vsix +/.vs diff --git a/src/components/cards/card.tsx b/src/components/cards/card.tsx index 304d11a..9b13834 100644 --- a/src/components/cards/card.tsx +++ b/src/components/cards/card.tsx @@ -56,7 +56,7 @@ export interface ICardComponentProps { disabled?: boolean; selected?: boolean; - + confidence?: boolean; onClick?: () => void; } @@ -68,6 +68,7 @@ export class Card extends React.Component { back, disabled = false, flipped = false, + confidence = false, onClick, size = CardSize.medium, selected diff --git a/src/model/cards.ts b/src/model/cards.ts index 7f58942..50e1a74 100644 --- a/src/model/cards.ts +++ b/src/model/cards.ts @@ -5,7 +5,8 @@ export interface ICard { export enum CardSetType { Numeric, - Ordinal + Ordinal, + NumericWithAverage } export interface ICardSet { @@ -160,4 +161,32 @@ export const defaultCardSets: ICardSet[] = [ } ] }, + { + id: "confidence", + type: CardSetType.NumericWithAverage, + name: "Confidence", + cards: [ + { + identifier: "1", + value: 1 + }, + { + identifier: "2", + value: 2 + }, + { + identifier: "3", + value: 3 + }, + { + identifier: "4", + value: 4 + }, + { + identifier: "5", + value: 5 + } + + ] + } ]; diff --git a/src/pages/session/components/workItemView.tsx b/src/pages/session/components/workItemView.tsx index 6e2c18e..2d68b8e 100644 --- a/src/pages/session/components/workItemView.tsx +++ b/src/pages/session/components/workItemView.tsx @@ -10,7 +10,7 @@ import { Votes } from "../../../components/votes"; import { WorkItemDescription } from "../../../components/workitems/workItemDescription"; import { WorkItemEstimate } from "../../../components/workitems/workItemEstimate"; import { WorkItemHeader } from "../../../components/workitems/workItemHeader"; -import { ICard, ICardSet } from "../../../model/cards"; +import { ICard, ICardSet, CardSetType } from "../../../model/cards"; import { IEstimate } from "../../../model/estimate"; import { IIdentity } from "../../../model/identity"; import { IWorkItem } from "../../../model/workitem"; @@ -31,7 +31,7 @@ interface IWorkItemProps { revealed: boolean; canReveal: boolean; - + confidence: boolean; canPerformAdminActions: boolean; } @@ -50,7 +50,8 @@ class WorkItemView extends React.Component { selectedCardId, estimates, canReveal, - revealed + revealed, + confidence } = this.props; return ( @@ -142,6 +143,22 @@ class WorkItemView extends React.Component { ); })} + {confidence && ( + <> + Average +
+ {Math.round((estimates || []).reduce((sum, e) => { + const card = cardSet.cards.find( + x => + x.identifier === + e.cardIdentifier + )!; + sum += parseInt((card!.value!.toString() || "0")); + return sum; + }, 0) / (estimates!.length || 1))} +
+ + )}
Or enter a custom value:
0, selectedCardId: