Skip to content

Commit ac631b7

Browse files
authored
Merge pull request #68 from dm9-project-manager/dnd-testing
Dnd testing
2 parents 6ee86a6 + 70be076 commit ac631b7

File tree

13 files changed

+98
-78
lines changed

13 files changed

+98
-78
lines changed

server/controllers/tasks_controller.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ module.exports = {
1212
},
1313
addNewTask: (req, res, next) => {
1414
const dbInstance = req.app.get('db')
15-
console.log(req.body)
16-
1715

1816
dbInstance.addNewTask([req.body.projectID, req.body.cardID, req.body.task])
1917
.then(response => {
@@ -130,10 +128,9 @@ module.exports = {
130128

131129
assignToTask: (req, res, next) => {
132130
const dbInstance = req.app.get('db')
133-
console.log(req.user.id, req.body.userID, "CHECK RIGHT HERE YOURS IS FIRST")
134131
dbInstance.assignToTask([req.body.taskID, req.body.userID, req.body.projectID])
135132
.then(response => {
136-
res.status(200).srsend(response)
133+
res.status(200).send(response)
137134
})
138135
.catch(console.log)
139136
},
@@ -150,7 +147,6 @@ module.exports = {
150147
removeFromTask: (req, res, next) => {
151148
const dbInstance = req.app.get('db')
152149

153-
console.log(req.params.assignID)
154150
dbInstance.removeFromTask([req.params.taskID, req.params.memberID])
155151
.then(response => {
156152
res.status(200).send(response)
@@ -177,7 +173,6 @@ module.exports = {
177173
},
178174
deleteProject: (req, res, next) => {
179175
const dbInstance = req.app.get('db')
180-
console.log("Hit the controller", req.params.projID);
181176
dbInstance.deleteProject([req.params.projID])
182177
.then(response => {
183178
res.status(200).send(response)

server/controllers/users_controller.js

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const axios = require('axios');
33

44
module.exports = {
55
createLocalUser: (req, res) => {
6-
// console.log('BODY: ', req.body);
76
const db = req.app.get('db');
87
const hashData = hashPassword.saltHashString(req.body.password);
98
req.session.user = {};
@@ -32,7 +31,6 @@ module.exports = {
3231
},
3332
getUserInfo: (req, res) => {
3433
const dbInstance = req.app.get('db');
35-
console.log("hit")
3634
dbInstance
3735
.getUserInfo([req.user.id])
3836
.then(response => res.status(200).send(response))
@@ -74,7 +72,6 @@ module.exports = {
7472

7573
sendNewDisplayName: (req, res, next) => {
7674
const dbInstance = req.app.get('db');
77-
console.log("hit")
7875
dbInstance
7976
.sendNewDisplayName([req.params.displayName, req.session.passport.user])
8077
.then(response => res.status(200).send(response))

src/components/Dashboard/Dashboard.js

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ componentWillUnmount(){
5858
}
5959

6060
pickColor(color, projectID){
61-
console.log(color, projectID);
6261
axios.post('/api/changeColor', {color, projectID}).then(response => {
6362
this.props.getAllProjects();
6463
this.setState({colorsOpen: !this.state.colorsOpen, projectID})

src/components/Header/Header.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const Header = (props) => {
1717
return (
1818
<div className="header-container">
1919
{ props.path == 'Board' ? <BackButton goBack={props.history.goBack} /> : null}
20-
{console.log(props)}
2120
<div>
2221
<span className="header-light">{props.path}</span> - <span className="header-bold">{props.currentPath}</span>
2322
</div>

src/components/ProjectView/PVComponents/Card/Card.css

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
margin-right: auto;
2323
margin-left: 12px;
2424
margin-top: 2px;
25-
height: 30px;
25+
/* height: 30px; */
2626
width: calc(100% - 12px);
2727
font-family: 'Open Sans Condensed';
2828
font-weight: 700;
@@ -84,9 +84,8 @@
8484
border-radius: 3px;
8585
}
8686
.editHeader{
87-
height: 50px;
88-
width: 210px;
89-
padding: 0 10px;
87+
height: 25px;
88+
width: 200px;
9089
position: relative;
9190
border-top-left-radius: 5px;
9291
border-top-right-radius: 5px;

src/components/ProjectView/PVComponents/Card/Card.js

+27-36
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ class Card extends Component {
5858
this.closeEditOptions = this.closeEditOptions.bind(this);
5959
this.showColors = this.showColors.bind(this);
6060
this.pickColor = this.pickColor.bind(this);
61+
this.cancelEdit = this.cancelEdit.bind(this)
6162
}
6263

64+
cancelEdit() {
65+
this.setState({options: false, editOpen: !this.state.editOpen})
66+
this.props.editCardHeader(0, '');
67+
}
6368
openHeaderEdit(cardID, title) {
6469
this.setState({ editOpen: !this.state.editOpen, options: false });
6570
}
@@ -76,13 +81,14 @@ class Card extends Component {
7681

7782
openEditOptions(cardID, title) {
7883
if (cardID === this.props.editHeaderID) {
79-
this.setState({ options: false });
84+
this.setState({ options: false, editOpen: !this.state.editOpen });
8085
this.props.editCardHeader(0, '');
8186
} else {
8287
this.setState({ options: true });
8388
this.props.editCardHeader(cardID, title);
8489
}
8590
}
91+
8692
closeEditOptions() {
8793
this.setState({ options: false });
8894
}
@@ -110,11 +116,9 @@ class Card extends Component {
110116

111117
showColors(cardID) {
112118
this.setState({ colorsOpen: !this.state.colorsOpen, cardID });
113-
console.log('Hit!');
114119
}
115120

116121
pickColor(color, cardID) {
117-
console.log(color, cardID);
118122
axios.post('/api/changeCardColor', { color, cardID }).then(response => {
119123
this.props.getNewCards(this.props.match.params.id);
120124
this.setState({ colorsOpen: !this.state.colorsOpen, cardID });
@@ -141,12 +145,24 @@ class Card extends Component {
141145
return connectDropTarget(
142146
<div className="task-card">
143147
<div className="task-card-header">
144-
145-
{this.props.card.title}
148+
{this.state.editOpen === false &&
149+
<div>{this.props.card.title}</div>
150+
}
151+
{this.state.editOpen === true && this.props.editHeaderID !== this.props.card.id &&
152+
<div>{this.props.card.title}</div>
153+
}
154+
{this.state.editOpen === true && this.props.editHeaderID === this.props.card.id &&
155+
<div>
156+
<form onSubmit={e => this.submitHeaderEdit(e, this.props.header, this.props.card.id)}>
157+
<input className="editHeader" value={this.props.header} onChange={e => this.handleHeaderEdit(e)} />
158+
<h3 onClick={this.cancelEdit}>Cancel</h3>
159+
</form>
160+
</div>
161+
}
146162
<div className="dot-menu-container" onClick={() => this.openEditOptions(this.props.card.id, this.props.card.title)}>
147-
<div class="menu-dot" />
148-
<div class="menu-dot" />
149-
<div class="menu-dot" />
163+
<div className="menu-dot" />
164+
<div className="menu-dot" />
165+
<div className="menu-dot" />
150166
</div>
151167

152168
</div>
@@ -163,39 +179,14 @@ class Card extends Component {
163179
{this.state.editOpen === false && <div className="card-header">
164180

165181
</div>}
166-
{this.state.options === true && this.props.card.id === this.props.editHeaderID && <div className="editOptionsBox">
182+
{this.state.options === true && this.props.card.id === this.props.editHeaderID &&
183+
<div className="editOptionsBox">
167184
<h3 onClick={this.openHeaderEdit}>Edit</h3>
168185
<h3 onClick={() => this.deleteCard(this.props.card.id)}>
169186
Delete
170187
</h3>
171188
</div>}
172-
{this.state.editOpen === true && this.props.editHeaderID !== this.props.card.id && <div className="card-header">
173-
{/* {this.props.card.title} */}
174-
{/* <img
175-
id="downArrow"
176-
src="http://freevector.co/wp-content/uploads/2010/10/61041-downwards-arrow-key.png"
177-
onClick={() =>
178-
this.openEditOptions(
179-
this.props.card.id,
180-
this.props.card.title
181-
)
182-
}
183-
/> */}
184-
185-
{this.state.options === true &&
186-
this.props.card.id === this.props.editHeaderID && (
187-
<div className="editOptionsBox">
188-
<h3 onClick={this.openHeaderEdit}>Edit</h3>
189-
<h3 onClick={() => this.deleteCard(this.props.card.id)}>
190-
Delete
191-
</h3>
192-
</div>
193-
)}
194-
</div>}
195-
{this.state.editOpen === true && this.props.editHeaderID === this.props.card.id && <form onSubmit={e => this.submitHeaderEdit(e, this.props.header, this.props.card.id)}>
196-
<input className="editHeader" value={this.props.header} onChange={e => this.handleHeaderEdit(e)} />
197-
<h3 onClick={this.openHeaderEdit}>Cancle</h3>
198-
</form>}
189+
199190

200191
{/* {this.props.cardTasks &&
201192
this.props.cardTasks.map((task, index) => (

src/components/ProjectView/PVComponents/Task/Task.css

+4
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@
3636
width: 100%;
3737
}
3838

39+
40+
.collaberators {
41+
padding-left: 5px
42+
}

src/components/ProjectView/PVComponents/Task/Task.js

+30-16
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import {
3232
assignToTask,
3333
getAssignedTasks,
3434
removeUserFromTask,
35-
dragTask
35+
dragTask,
36+
movedTask
3637
} from '../../../../ducks/reducers/projectViewReducer';
3738

3839
const cardSource = {
@@ -48,10 +49,23 @@ const cardSource = {
4849
const dropResult = monitor.getDropResult()
4950

5051
if (dropResult) {
51-
props.dragTask(item.id, dropResult.id).then(() => {
52+
53+
let selectedTask = props.tasks.filter(task => item.id === task.task_id)
54+
if(selectedTask[0].parent_card_id !== dropResult.id){
55+
56+
let updatedTask = Object.assign({}, selectedTask[0], {parent_card_id: dropResult.id})
5257

53-
props.getTasks(props.match.params.id)
54-
})
58+
let taskProps = props.tasks
59+
let updatedTaskIndex = taskProps.findIndex(task => task.task_id === selectedTask[0].task_id)
60+
taskProps.splice(updatedTaskIndex, 1, updatedTask)
61+
props.movedTask(taskProps)
62+
63+
props.dragTask(item.id, dropResult.id).then(() => {
64+
65+
// props.getTasks(props.match.params.id)
66+
})
67+
}
68+
5569
}
5670
}
5771
}
@@ -185,9 +199,9 @@ class Task extends Component {
185199

186200
const { isDragging, connectDragSource, name } = this.props
187201
const opacity = isDragging ? 0.4 : 1;
188-
const complete = this.props.task.completed ? 'green' : 'rgba(242, 242, 242, 0.906)'
202+
const complete = this.props.task.completed ? 'blue' : 'rgba(242, 242, 242, 0.906)'
189203
const userTasks = this.props.assignedTasks ? this.props.assignedTasks.filter( task => task.task_id === this.props.task.task_id) : []
190-
console.log("Here are the user tasks", userTasks, this.props.localUserID)
204+
191205
const style = { opacity: opacity, background: complete};
192206
const userFreeMembers = this.props.members ? this.props.members.filter(member => member.id !== this.props.userID) : []
193207

@@ -229,35 +243,35 @@ console.log("Here are the user tasks", userTasks, this.props.localUserID)
229243
{this.state.assignModel === true &&
230244
<div style={{width: '100%'}}>
231245
{this.props.assignedTasks.length === 0 &&
232-
<h4 style={ userTasks.find(me => me.user_id === this.props.localUserID) ? {background: 'white'} : {background: 'blue'}}
246+
<h4 className='collaberators' style={ userTasks.find(me => me.user_id === this.props.localUserID) ? {background: 'white'} : {background: '#5c5c8a', color: 'white'}}
233247
onClick={
234248
userTasks.find(me => me.user_id === this.props.localUserID ) ?
235249
() => this.removeFromTasks(this.props.localUserID, this.props.task.task_id):
236250
() => this.assigningOfTasks(this.props.task.task_id, this.props.localUserID, this.props.match.params.id)}
237-
>Assign Self</h4>}
251+
>{userTasks.find(me => me.user_id === this.props.localUserID) ? 'You Got This' : 'Assign Self'}</h4>}
238252

239253
{this.props.assignedTasks.length > 0 &&
240-
<h4 style={
241-
userTasks.find(currentID => currentID.user_id === this.props.localUserID ) ? {background: 'white'} : {background: 'blue'}
254+
<h4 className='collaberators' style={
255+
userTasks.find(currentID => currentID.user_id === this.props.localUserID ) ? {background: 'white'} : {background: '#5c5c8a', color: 'white'}
242256
}
243257
onClick={
244258
userTasks.find(me => me.user_id === this.props.localUserID) ?
245259
() => this.removeFromTasks(this.props.localUserID, this.props.task.task_id) :
246260
() => this.assigningOfTasks(this.props.task.task_id, this.props.localUserID, this.props.match.params.id)}>
247-
Assign Self</h4>
248-
}{console.log()}
261+
{userTasks.find(me => me.user_id === this.props.localUserID) ? 'You Got This' : 'Assign Self'}</h4>
262+
}
249263
{this.props.members && userFreeMembers.map((member, index) => {
250264
const assignedUser = this.props.assignedTasks.filter(task => task.task_id === this.props.task.task_id)
251265

252266
return (
253267

254-
<h4 key={index} className="teamMembers"
255-
style={assignedUser.find(currentID => currentID.user_id === member.id) ? {background: 'white'} : {background: 'blue'}}
268+
<h4 key={index} className="collaberators"
269+
style={assignedUser.find(currentID => currentID.user_id === member.id) ? {background: 'white'} : {background: '#5c5c8a', color: 'white'}}
256270
onClick={
257271
assignedUser.find(currentID => currentID.user_id === member.id) ?
258272
() => this.removeFromTasks(member.id, this.props.task.task_id):
259273
() => this.assigningOfTasks(this.props.task.task_id, member.id, this.props.match.params.id)}>
260-
{member.display_name}{console.log(member, "heres the member")}</h4>)
274+
{member.display_name}{assignedUser.find(currentID => currentID.user_id === member.id) ? ' is on it!' : ''}</h4>)
261275

262276
})}
263277
</div>
@@ -283,5 +297,5 @@ const mapStateToProps = state => {
283297
Task = DragSource(ItemTypes.CARD, cardSource, collect)(Task)
284298

285299
export default withRouter(
286-
connect(mapStateToProps, { addToList, removeFromList, addCard, cardInput, addTask, taskInput, openInput, getCards, openEditTask, changeEditTask, sendEditTask, deleteTask, getCards2, getTasks, assignToTask, getAssignedTasks, removeUserFromTask, dragTask})(Task)
300+
connect(mapStateToProps, { addToList, removeFromList, addCard, cardInput, addTask, taskInput, openInput, getCards, openEditTask, changeEditTask, sendEditTask, deleteTask, getCards2, getTasks, assignToTask, getAssignedTasks, removeUserFromTask, dragTask, movedTask })(Task)
287301
);

src/components/ProjectView/ProjectView.js

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class ProjectView extends Component {
100100
}
101101
editTitle(e){
102102
this.setState({title: e.target.value})
103-
console.log(e.target.value);
104103
}
105104
openEditTitle(){
106105
this.setState({titleEditor: !this.state.titleEditor})

src/components/Sidebar/Menu/SettingsMenu/Settings/KellySetting.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import {
1717
sendNewDisplayName,
1818
sendNewEmailName,
1919
sendNewBio,
20-
logOut
20+
logOut,
21+
updateDN,
22+
getUserInfo
2123
} from '../../../../../ducks/reducers/userReducer';
2224

2325
class KellySetting extends Component {
@@ -35,15 +37,17 @@ class KellySetting extends Component {
3537
this.sendNewBio = this.sendNewBio.bind(this);
3638
}
3739

40+
componentDidMount(){
41+
this.props.getUserInfo()
42+
}
43+
3844
handleImageChange(image) {
39-
console.log(image, 'image');
4045
this.setState({
4146
avatarImage: this.state.avatarImage.concat(image)
4247
});
4348
}
4449

4550
uploadImage(event) {
46-
console.log(event, 'event');
4751
// event.preventDefault();
4852
let file = event[0][0];
4953
const storageRef = firebase.storage().ref();
@@ -55,7 +59,6 @@ class KellySetting extends Component {
5559
snapshot => {},
5660
function(error) {},
5761
function() {
58-
console.log(uploadTask.snapshot.downloadURL);
5962
// that.setState({ downloadURL: uploadTask.snapshot.downloadURL });
6063
// console.log(this.state.downloadURL);
6164
}
@@ -66,6 +69,9 @@ class KellySetting extends Component {
6669
sendDisplayName(e){
6770
e.preventDefault()
6871
this.props.sendNewDisplayName(this.props.user.newDisplayName)
72+
.then(() => {
73+
this.props.updateDN()
74+
})
6975
}
7076

7177
sendNewEmailName(e){
@@ -79,7 +85,6 @@ class KellySetting extends Component {
7985
}
8086

8187
render() {
82-
console.log(this.props, 'kelly props')
8388
const {
8489
updateUserName,
8590
updatePasswordField,
@@ -187,5 +192,7 @@ export default withRouter(connect(mapStateToProps, {
187192
sendNewDisplayName,
188193
sendNewEmailName,
189194
sendNewBio,
190-
logOut
195+
logOut,
196+
updateDN,
197+
getUserInfo
191198
})(KellySetting));

0 commit comments

Comments
 (0)