diff --git a/package.json b/package.json index 8cfab5c6..e921f236 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "dotenv": "^6.0.0", "glamor": "^2.20.40", "react": "^15.6.1", "react-animated-number": "^0.4.3", diff --git a/src/components/Content/Calendar/Calendar.js b/src/components/Content/Calendar/Calendar.js index 7be2329d..86e8a7f3 100644 --- a/src/components/Content/Calendar/Calendar.js +++ b/src/components/Content/Calendar/Calendar.js @@ -1,11 +1,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import moment from 'moment'; -import { - getTasks, - getPursuances, - showTaskDetails, -} from '../../../actions'; +import { getTasks, getPursuances, showTaskDetails } from '../../../actions'; import BigCalendar from 'react-big-calendar'; import 'react-big-calendar/lib/css/react-big-calendar.css'; import './Calendar.css'; @@ -14,7 +10,6 @@ import '../Content.css'; BigCalendar.momentLocalizer(moment); class Calendar extends Component { - componentDidMount() { const { getPursuances, @@ -25,9 +20,11 @@ class Calendar extends Component { } = this.props; // Fetch this pursuance's tasks if we haven't already - if (Object.keys(tasks.taskMap) - .filter(gid => gid.startsWith(currentPursuanceId + '_')) - .length === 0) { + if ( + Object.keys(tasks.taskMap).filter(gid => + gid.startsWith(currentPursuanceId + '_') + ).length === 0 + ) { getTasks(currentPursuanceId); } if (Object.keys(pursuances).length === 0) { @@ -36,18 +33,24 @@ class Calendar extends Component { } getEvents = () => { - const { currentPursuanceId, user, tasks: { taskMap } } = this.props; + const { + currentPursuanceId, + user, + tasks: { taskMap } + } = this.props; return Object.keys(taskMap) - .filter((gid) => { + .filter(gid => { const t = taskMap[gid]; - return t && + return ( + t && t.due_date && t.status !== 'Done' && t.assigned_to === user.username && (t.pursuance_id === currentPursuanceId || - t.assigned_to_pursuance_id === currentPursuanceId) + t.assigned_to_pursuance_id === currentPursuanceId) + ); }) - .map((gid) => { + .map(gid => { const t = taskMap[gid]; return { id: t.gid, @@ -55,14 +58,14 @@ class Calendar extends Component { start: new Date(t.due_date), end: new Date(t.due_date), desc: t.deliverables, - allDay: true, - } - }) - } + allDay: true + }; + }); + }; - onSelectEvent = (event) => { - this.props.showTaskDetails({taskGid: event.id}); - } + onSelectEvent = event => { + this.props.showTaskDetails({ taskGid: event.id }); + }; render() { const { pursuances, currentPursuanceId } = this.props; @@ -74,9 +77,8 @@ class Calendar extends Component {

Calendar: 

- { - pursuances[currentPursuanceId] && pursuances[currentPursuanceId].name - } + {pursuances[currentPursuanceId] && + pursuances[currentPursuanceId].name}

@@ -95,9 +97,17 @@ class Calendar extends Component { } } -export default connect(({ pursuances, currentPursuanceId, tasks, rightPanel, user }) => - ({ pursuances, currentPursuanceId, tasks, rightPanel, user }), { +export default connect( + ({ pursuances, currentPursuanceId, tasks, rightPanel, user }) => ({ + pursuances, + currentPursuanceId, + tasks, + rightPanel, + user + }), + { getTasks, getPursuances, - showTaskDetails, -})(Calendar); + showTaskDetails + } +)(Calendar); diff --git a/src/components/Content/RightPanel/TaskDetails/TaskDetails.css b/src/components/Content/RightPanel/TaskDetails/TaskDetails.css index d4413c8a..7f56bce1 100644 --- a/src/components/Content/RightPanel/TaskDetails/TaskDetails.css +++ b/src/components/Content/RightPanel/TaskDetails/TaskDetails.css @@ -75,6 +75,12 @@ min-height: 64px; } +.task-deliverables-header { + display: flex; + flex-direction: row; + justify-content: space-between; +} + .task-deliverables-ctn a { color: #50b3fe; } @@ -86,7 +92,7 @@ .subtasks-list { list-style: none; - padding-left: 0 + padding-left: 0; } .subtask-item { @@ -106,3 +112,23 @@ width: 100%; font-size: 36px; } + +.input { + color: black; +} + +.editSubmit { + border-radius: 1px; + font-size: 17px; + font-weight: 400; + margin: 15px auto; + border-radius: 10px; + color: #fff; + background-color: #288bd6; + padding-top: 0; + margin: 0; +} + +button { + margin: 0; +} diff --git a/src/components/Content/RightPanel/TaskDetails/TaskDetails.js b/src/components/Content/RightPanel/TaskDetails/TaskDetails.js index 0a5d117d..463478da 100644 --- a/src/components/Content/RightPanel/TaskDetails/TaskDetails.js +++ b/src/components/Content/RightPanel/TaskDetails/TaskDetails.js @@ -1,32 +1,86 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; -import { getPursuancesByIds, getTasks, patchTask } from '../../../../actions'; +import { getPursuancesByIds, getTasks } from '../../../../actions'; import ReactMarkdown from 'react-markdown'; import FaEllipsisV from 'react-icons/lib/fa/ellipsis-v'; import FaCircleO from 'react-icons/lib/fa/circle-o'; import TaskStatus from '../../TaskStatus/TaskStatus'; import TaskAssigner from '../../TaskHierarchy/Task/TaskAssigner/TaskAssigner'; import TaskDueDate from '../../TaskDueDate/TaskDueDate'; +import { updateFormField, patchTask } from '../../../../actions'; import './TaskDetails.css'; class TaskDetails extends Component { + constructor(props) { + super(props); + + this.state = { + editMode: false, + taskDescription: '', + refresh: false + }; + this.taskDescription = ''; + } + + editTaskDescription = e => { + this.taskDescription = e.target.value; + }; + + editModeToggle = () => { + this.setState({ + editMode: !this.state.editMode + }); + console.log(this.state.editMode); + }; + + closeOnEsc = e => { + if (this.state.editMode === true && e.keyCode === 27) { + this.editModeToggle(); + } + }; + + onSubmit = () => { + if (this.state.editMode) { + const patchedTaskDescription = { + gid: this.props.rightPanel.taskGid, + deliverables: this.taskDescription + }; + patchTask(patchedTaskDescription); + this.setState({ + editMode: false + }); + window.location.reload(); + } + }; + + refresh = () => { + this.setState({ + refresh: !this.state.refresh + }); + }; + + componentDidMount() { + document.addEventListener('keydown', this.closeOnEsc, false); + document.addEventListener('keydown', this.refresh, false); + } componentWillMount() { - const { - currentPursuanceId, - tasks, - getTasks, - rightPanel - } = this.props; + console.log(this.props); + + const { currentPursuanceId, tasks, getTasks, rightPanel } = this.props; + + if (tasks.taskMap[rightPanel.taskGid]) { + this.setState({ + taskDescription: tasks.taskMap[rightPanel.taskGid].deliverables + }); + } if (rightPanel.taskGid && !tasks.taskMap[rightPanel.taskGid]) { const thisTasksPursuanceId = rightPanel.taskGid.split(/_/)[0]; getTasks(thisTasksPursuanceId); - // If this task was assigned to this pursuance from another - // pursuance, grab the current pursuance's tasks, too if (thisTasksPursuanceId !== currentPursuanceId.toString()) { getTasks(currentPursuanceId); } @@ -43,9 +97,7 @@ class TaskDetails extends Component { const task = tasks.taskMap[taskGid]; if (!task) { - return ( - - ) + return ; } const assignedPursuanceId = task.assigned_to_pursuance_id; @@ -64,19 +116,25 @@ class TaskDetails extends Component { } return ( - (assignedPursuanceId && pursuances[assignedPursuanceId] && pursuances[assignedPursuanceId].suggestionName) - || - (task.assigned_to && '@' + task.assigned_to) - ) - } + (assignedPursuanceId && + pursuances[assignedPursuanceId] && + pursuances[assignedPursuanceId].suggestionName) || + (task.assigned_to && '@' + task.assigned_to) + ); + }; render() { - const { pursuances, tasks, rightPanel: { taskGid } } = this.props; + const { + pursuances, + tasks, + rightPanel: { taskGid } + } = this.props; const task = tasks.taskMap[taskGid]; if (!task) { - return
Ain't nobody got task fo' that.
+ return
Ain't nobody got task fo that.
; } const subtaskGids = task.subtask_gids; + const { editMode } = this.state; return (
@@ -115,31 +173,82 @@ class TaskDetails extends Component {
- Created in {pursuances[task.pursuance_id] && {pursuances[task.pursuance_id].name}} + Created in{' '} + {pursuances[task.pursuance_id] && ( + {pursuances[task.pursuance_id].name} + )}
+
-

Description / Deliverables

- - { - if (props.href.startsWith('/')) { - return {props.children}; - } - // If link to external site, open in new tab - return {props.children}; - }}} /> - +
+

+ Descriptions / Deliverables +

+ + +
+ + {editMode && ( +
+
+