@@ -4,6 +4,8 @@ import {connect} from 'react-redux'
4
4
import { withRouter } from 'react-router-dom'
5
5
import Task from '../Task/Task'
6
6
7
+ import axios from 'axios'
8
+
7
9
8
10
///////////////////////////////////////////
9
11
import { DropTarget } from 'react-dnd'
@@ -26,6 +28,8 @@ import {
26
28
27
29
import '../../ProjectView.css'
28
30
31
+ import ColorPicker from './../../../tools/ColorPicker/ColorPicker'
32
+
29
33
30
34
const cardTarget = {
31
35
drop ( props ) {
@@ -46,12 +50,17 @@ class Card extends Component {
46
50
super ( props )
47
51
this . state = {
48
52
editOpen : false ,
49
- options : false
53
+ options : false ,
54
+ colorsOpen : false ,
55
+ cardID : 0
56
+
50
57
}
51
58
this . openHeaderEdit = this . openHeaderEdit . bind ( this )
52
59
this . openEditOptions = this . openEditOptions . bind ( this )
53
60
this . deleteCard = this . deleteCard . bind ( this )
54
61
this . closeEditOptions = this . closeEditOptions . bind ( this )
62
+ this . showColors = this . showColors . bind ( this )
63
+ this . pickColor = this . pickColor . bind ( this )
55
64
}
56
65
57
66
openHeaderEdit ( cardID , title ) {
@@ -106,6 +115,18 @@ class Card extends Component {
106
115
107
116
} //done
108
117
118
+ showColors ( cardID ) {
119
+ this . setState ( { colorsOpen : ! this . state . colorsOpen , cardID} )
120
+ console . log ( "Hit!" ) ;
121
+ }
122
+
123
+ pickColor ( color , cardID ) {
124
+ console . log ( color , cardID ) ;
125
+ axios . post ( '/api/changeCardColor' , { color, cardID} ) . then ( response => {
126
+ this . props . getNewCards ( this . props . match . params . id ) ;
127
+ this . setState ( { colorsOpen : ! this . state . colorsOpen , cardID} )
128
+ } )
129
+ }
109
130
110
131
111
132
@@ -121,7 +142,6 @@ class Card extends Component {
121
142
}
122
143
123
144
const style = { 'backgroundColor' : backgroundColor }
124
-
125
145
126
146
return connectDropTarget (
127
147
< div id = 'taskHolder' style = { style } >
@@ -167,14 +187,22 @@ class Card extends Component {
167
187
}
168
188
169
189
{
170
- < div id = 'cardTest' >
190
+ // Currently The background color is being changed on this div
191
+ < div id = 'cardTest' style = { { 'backgroundColor' : this . props . card . color } } >
171
192
< form onSubmit = { e => this . handleAddTask ( e , this . props . card . id , this . props . match . params . id ) } >
172
193
< input type = 'text'
173
194
className = 'newCard'
174
195
onClick = { ( ) => this . selectCard ( this . props . card . id ) }
175
196
onChange = { this . props . taskInput }
176
197
value = { this . props . taskInputID === this . props . card . id ? this . props . newTask : '' } />
177
198
</ form >
199
+
200
+ { /* These two divs are allowing us to position the box absoloutely. Do inline style to override component styling */ }
201
+ < div style = { { "position" : "relative" } } >
202
+ < div style = { { 'position' : "absolute" , 'top' : '-60px' , 'right' : '20px' } } >
203
+ < ColorPicker currentID = { this . props . card . id } colorsOpen = { this . state . colorsOpen } showColors = { this . showColors } currentItem = { this . props . card } pickColor = { this . pickColor } />
204
+ </ div >
205
+ </ div >
178
206
</ div >
179
207
}
180
208
{ /* <div id={this.props.inputOpen && this.state.taskCardID === card.cardID ? 'openEditer' : 'cardTest'} onClick={this.addText}>
@@ -188,6 +216,7 @@ class Card extends Component {
188
216
type="text"/>
189
217
</form>
190
218
</div> */ }
219
+
191
220
</ div >
192
221
) ;
193
222
}
0 commit comments