-
Notifications
You must be signed in to change notification settings - Fork 0
FetchAPI and Comparer #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { ReactElement } from "react"; | ||
| import React from "react"; | ||
| import { Paper, Table, TableHead, TableRow, TableCell, TableBody } from "@material-ui/core"; | ||
| import StatusComponent from "../Status.component"; | ||
| import VoteComponent from "../Vote.component"; | ||
|
|
@@ -8,6 +8,8 @@ import FeaturesCategory from "../../dataModel/FeaturesCategory"; | |
|
|
||
| interface FeaturesTableProps { | ||
| featuresCategories: FeaturesCategory[]; | ||
| featuresCategoryCompareFn?: (a: FeaturesCategory, b: FeaturesCategory) => number; | ||
| featuresCompareFn?: (a: Feature, b: Feature) => number; | ||
| featuresVoted: Set<string>; | ||
| featureVoteHandle(featureId: string): void; | ||
| featureUnvoteHandle(featureId: string): void; | ||
|
|
@@ -22,7 +24,7 @@ export default class FeaturesTableComponent extends React.Component<FeaturesTabl | |
| {this.CreateTableHeaderRow()} | ||
| </TableHead> | ||
| <TableBody> | ||
| {this.props.featuresCategories.map(category => | ||
| {this.props.featuresCategories.sort(this.getFeaturesCategoryComparerFunc()).map(category => | ||
| [this.CreateCategoryRow(category), | ||
| this.CreateFeatureRow(category.features)])} | ||
| </TableBody> | ||
|
|
@@ -43,16 +45,16 @@ export default class FeaturesTableComponent extends React.Component<FeaturesTabl | |
| } | ||
|
|
||
| private CreateCategoryRow(category: FeaturesCategory): JSX.Element { | ||
| return <TableRow key={category.name}> | ||
| return <TableRow className="categoryRow" id={category.name} key={category.name}> | ||
| <TableCell colSpan={7} style={{ fontWeight: 'bold' }}> | ||
| {category.name} | ||
| </TableCell> | ||
| </TableRow>; | ||
| } | ||
|
|
||
| private CreateFeatureRow(features: Feature[]): JSX.Element[] { | ||
| return features.map(feature => | ||
| <TableRow key={feature.id} className="feature-row"> | ||
| return features.sort(this.getFeaturesComparerFunc()).map(feature=> | ||
| <TableRow className="featureRow" id={feature.id} key={feature.id} > | ||
| <TableCell style={{ paddingLeft: '2%' }}> | ||
| {this.getLinkableFeatureTitle(feature)} | ||
| </TableCell> | ||
|
|
@@ -62,7 +64,7 @@ export default class FeaturesTableComponent extends React.Component<FeaturesTabl | |
| {this.getTableCell(Status.ReadySoon, feature)} | ||
| {this.getTableCell(Status.Released, feature)} | ||
| {this.getVoteCell(feature)} | ||
| </TableRow >); | ||
| </TableRow >); | ||
| } | ||
|
|
||
| private getLinkableFeatureTitle(feature: Feature): JSX.Element { | ||
|
|
@@ -98,4 +100,12 @@ export default class FeaturesTableComponent extends React.Component<FeaturesTabl | |
| return <TableCell align="left"></TableCell> | ||
| } | ||
| } | ||
|
|
||
| private getFeaturesCategoryComparerFunc(): (a: FeaturesCategory, b: FeaturesCategory) => number { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a way to pass default values to properties. |
||
| return this.props.featuresCategoryCompareFn ? this.props.featuresCategoryCompareFn : FeaturesCategory.Compare; | ||
| } | ||
|
|
||
| private getFeaturesComparerFunc(): (a: Feature, b: Feature) => number { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a way to pass default values to properties. look here: https://stackoverflow.com/questions/37282159/default-property-value-in-react-component-using-typescript |
||
| return this.props.featuresCompareFn ? this.props.featuresCompareFn : Feature.Compare; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order shoul be the opposite, since you use the custome (reverse) comparer