Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
102 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,77 @@ | ||
var React = require('react'); | ||
import {ListItem, FontIcon, IconButton, Checkbox} from 'material-ui'; | ||
import {ListItem, FontIcon, IconButton, | ||
IconMenu, MenuItem, Checkbox} from 'material-ui'; | ||
var util = require('utils/util'); | ||
var DateTime = require('components/common/DateTime'); | ||
var api = require('utils/api'); | ||
|
||
export default class TaskLI extends React.Component { | ||
static propTypes = { | ||
onUpdateStatus: React.PropTypes.func, | ||
onArchive: React.PropTypes.func, | ||
onUpdateWIP: React.PropTypes.func | ||
} | ||
|
||
static defaultProps = { | ||
task: null, | ||
onUpdateStatus: null, | ||
onArchive: null | ||
onArchive: null, | ||
onUpdateWIP: null | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
}; | ||
this.ICONS = ['check', 'check_circle', 'archive']; | ||
this.NOT_DONE = 1; | ||
this.DONE = 2; | ||
this.TASK_COLOR = "#DF00FF"; | ||
} | ||
|
||
set_wip(is_wip) { | ||
this.props.onUpdateWIP(this.props.task, is_wip); | ||
} | ||
|
||
render() { | ||
let t = this.props.task; | ||
let icon = this.ICONS[t.status-1]; | ||
let click = null; | ||
let archive = null; | ||
let menu = []; | ||
let done = t.status == this.DONE; | ||
let archived = t.archived; | ||
if (!archived) menu.push({icon: 'archive', click: this.props.onArchive.bind(this, t), label: 'Archive'}); | ||
if (!done) { | ||
if (t.wip) menu.push({icon: 'stop', click: this.set_wip.bind(this, false), label: 'Clear WIP'}); | ||
else menu.push({icon: 'play_for_work', click: this.set_wip.bind(this, true), label: 'On It (Set as WIP)'}); | ||
} | ||
if (t.status == this.NOT_DONE) click = this.props.onUpdateStatus.bind(this, t, this.DONE); | ||
if (done) click = this.props.onUpdateStatus.bind(this, t, this.NOT_DONE); | ||
if (!archived) archive = <IconButton onClick={this.props.onArchive.bind(this, t)} tooltip="Archive" iconClassName="material-icons">archive</IconButton> | ||
let st = { fill: this.TASK_COLOR }; | ||
let check = <Checkbox iconStyle={st} onCheck={click} checked={done} disabled={archived} /> | ||
let hours_until = util.hours_until(t.ts_due); | ||
let _icon, secondary; | ||
if (!done) { | ||
if (done) secondary = "Done"; | ||
else if (archived) secondary = "Archived"; | ||
else { | ||
_icon = <i className="glyphicon glyphicon-time" />; | ||
if (hours_until < 0) _icon = <i className="glyphicon glyphicon-alert" style={{color: "#FC4750"}} />; | ||
else if (hours_until <= 3) _icon = <i className="glyphicon glyphicon-hourglass" style={{color: "orange"}} />; | ||
secondary = <span>{ _icon } {util.from_now(t.ts_due)}</span> | ||
} else { | ||
secondary = "Done"; | ||
} | ||
|
||
let rightIcon = ( | ||
<IconMenu iconButtonElement={<IconButton iconClassName="material-icons">more_vert</IconButton>}> | ||
{ menu.map((mi, i) => { | ||
return <MenuItem key={i} leftIcon={<FontIcon className="material-icons">{mi.icon}</FontIcon>} onClick={mi.click}>{mi.label}</MenuItem> | ||
}) } | ||
</IconMenu> | ||
); | ||
let primaryText; | ||
if (t.wip) primaryText = <div className="wip">[ WIP ] {t.title}</div>; | ||
else primaryText = t.title; | ||
return ( | ||
<ListItem key={t.id} | ||
primaryText={ t.title } | ||
primaryText={ primaryText } | ||
secondaryText={secondary} | ||
leftCheckbox={check} | ||
style={{fontWeight: 'normal'}} | ||
rightIconButton={archive} /> | ||
rightIconButton={rightIcon} /> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters