From e5a77cb23c4a8f190b65632cccbad4e9667d8aa1 Mon Sep 17 00:00:00 2001 From: Matt Almenshad Date: Mon, 5 Jun 2017 11:51:30 -0700 Subject: [PATCH] Prepping to merge with backend again --- server/models/Participant.js | 12 +-- .../Activity/components/ActivityView.js | 3 +- .../components/GroupCard/GroupCard.js | 32 +++++--- .../ParticipantListSidebar.js | 3 + .../updateParticipantGroupNumberActions.js | 10 +-- ...teParticipantGroupNumberActionsHandlers.js | 6 +- src/store/createStore.js | 11 +-- src/store/createStore.js.orig | 74 +++++++++++++++++++ 8 files changed, 117 insertions(+), 34 deletions(-) create mode 100644 src/store/createStore.js.orig diff --git a/server/models/Participant.js b/server/models/Participant.js index ad1edb7..e74dc10 100644 --- a/server/models/Participant.js +++ b/server/models/Participant.js @@ -19,11 +19,11 @@ const ParticipantSchema = new Schema({ required: true, }, - // _creator: { - // type: Schema.ObjectId, - // ref: 'User', - // required: true, - // }, + _creator: { + type: Schema.ObjectId, + ref: 'User', + required: true, + }, _activity :{ type: Schema.ObjectId, @@ -77,7 +77,9 @@ ParticipantSchema.pre('save', function(next){ ParticipantSchema.methods.getPublicFields = function () { return { + _id: this._id, name: this.name, + email: this.email, image: this.image, groupNumber: this.groupNumber, surveyResponses: this.surveyResponses, diff --git a/src/routes/Activity/components/ActivityView.js b/src/routes/Activity/components/ActivityView.js index 926dd89..59467dd 100644 --- a/src/routes/Activity/components/ActivityView.js +++ b/src/routes/Activity/components/ActivityView.js @@ -57,7 +57,6 @@ export class ActivityView extends React.Component { }) } this.props.participants.forEach((participant) => { - console.log(participant); let participantGroupNumber = participant.get('groupNumber'); if (participantGroupNumber >= 0 && participantGroupNumber < numOfGroups) { groups[participantGroupNumber].participants.push(participant); @@ -68,7 +67,6 @@ export class ActivityView extends React.Component { }; let getGroupCards = (groups) => { - console.log(this.props.activityId) return ( groups.map( (group, i) => ( @@ -94,6 +92,7 @@ export class ActivityView extends React.Component { {console.log(v)}} updateParticipantGroupNumber={ this.props.updateParticipantGroupNumber } activityId={ this.props.activityId } /> diff --git a/src/routes/Activity/components/GroupCard/GroupCard.js b/src/routes/Activity/components/GroupCard/GroupCard.js index 7fd0bbe..dea4187 100644 --- a/src/routes/Activity/components/GroupCard/GroupCard.js +++ b/src/routes/Activity/components/GroupCard/GroupCard.js @@ -15,10 +15,11 @@ const transparentImage = 'https://upload.wikimedia.org/wikipedia/commons/thumb/0 const participantCardItemSource = { beginDrag(props) { + console.log(props); props.setCurrentlySelected(props.participant.participantId) // set current selected card return { - participantId: props.participant.participantId, - oldGroupNumber: props.participant.groupNumber + participantId: props.participant.get('participantId'), + oldGroupNumber: props.participant.get('groupNumber') } } } @@ -37,14 +38,14 @@ class DraggableCard extends React.Component { let participantCard =
} + trigger={ } position="top right" offset={ 0 } - name={ participant.name } - image={ participant.image } - surveyResponses={ this.props.surveyResponses } - groupNumber={participant.groupNumber } - participantId={ participant.participantId }/> + name={ participant.get('name') } + image={ participant.get('image') } + surveyResponses={ participant.get('surveyResponses') } + groupNumber={participant.get('groupNumber') } + participantId={ participant.get('participantId') }/>
if (this.props.unlocked) { return ( participantCard ) @@ -94,7 +95,7 @@ class GroupCard extends React.Component { const {connectDropTarget, isOver} = this.props let generateEmptySpots = () => { - let emptyNum = this.props.capacity - this.props.participants.size + let emptyNum = this.props.capacity - this.props.participants.length let result = [] for (let i = 0; i < emptyNum; i++) { result.push( @@ -161,12 +162,21 @@ class GroupCard extends React.Component { Group { this.props.groupNumber }   + + { this.props.participants.map((participant) => + console.log(v) } + unlocked= { this.props.unlocked } + /> + )} { generateEmptySpots() } - { diff --git a/src/routes/Activity/components/ParticipantListSidebar/ParticipantListSidebar.js b/src/routes/Activity/components/ParticipantListSidebar/ParticipantListSidebar.js index 47995e4..22cb368 100644 --- a/src/routes/Activity/components/ParticipantListSidebar/ParticipantListSidebar.js +++ b/src/routes/Activity/components/ParticipantListSidebar/ParticipantListSidebar.js @@ -68,6 +68,7 @@ class Participant extends React.Component { name={ this.props.name } image={ this.props.image } surveyResponses={ this.props.surveyResponses } + setCurrentlySelected={(v) => {console.log(v)}} participantId={ this.props.participantId } setCurrentlySelected={(v) => {console.log(v)}}/> ) @@ -77,6 +78,7 @@ class Participant extends React.Component { name={ this.props.name } image={ this.props.image } surveyResponses={ this.props.surveyResponses } + setCurrentlySelected={(v) => {console.log(v)}} groupNumber={ this.props.groupNumber } position="right center" offset={ 20 } @@ -147,6 +149,7 @@ class ParticipantListSidebar extends React.Component { participantId={ participantObj.get('participantId') } surveyResponses={ participantObj.get('surveyResponses') } name={ participantObj.get('name') } + setCurrentlySelected={(v) => {console.log(v)}} image={ participantObj.get('image') } groupNumber={ participantObj.get('groupNumber') } /> diff --git a/src/routes/Activity/modules/actions/updateParticipantGroupNumberActions.js b/src/routes/Activity/modules/actions/updateParticipantGroupNumberActions.js index c01e37a..c32230b 100644 --- a/src/routes/Activity/modules/actions/updateParticipantGroupNumberActions.js +++ b/src/routes/Activity/modules/actions/updateParticipantGroupNumberActions.js @@ -15,17 +15,15 @@ let updateParticipantGroupNumber = (dispatch) => { oldGroupNumber: oldGroupNumber, newGroupNumber: newGroupNumber }; - + console.log('-------------------------------'); + console.log({groupNumber:payload.newGroupNumber}); dispatch({ type: UPDATE_PARTICIPANT_GROUP_NUMBER, payload: payload }); - let url = SERVER_URL + "/api/activities/" + activityId + "/participants/" + participantId; - axios.put(url, { - oldGroupsNumber: oldGroupNumber, - newGroupNumber: newGroupNumber - }) + let url = SERVER_URL + "/api/activities/" + activityId + "/participants/" + participantId + '/groupNumber'; + axios.put(url, {groupNumber:payload.newGroupNumber}) .then((response) => { dispatch(updateParticipantGroupNumberSuccess(response)); }) diff --git a/src/routes/Activity/modules/reducer/actionsHandlers/updateParticipantGroupNumberActionsHandlers.js b/src/routes/Activity/modules/reducer/actionsHandlers/updateParticipantGroupNumberActionsHandlers.js index ccc4a14..52c0419 100644 --- a/src/routes/Activity/modules/reducer/actionsHandlers/updateParticipantGroupNumberActionsHandlers.js +++ b/src/routes/Activity/modules/reducer/actionsHandlers/updateParticipantGroupNumberActionsHandlers.js @@ -18,10 +18,12 @@ let handleUpdateParticipantGroupsNumber = (state, payload) => { console.log(state) let index = state.get('participants') .findIndex((participant) => (participant.get('participantId') === payload.participantId)) + console.log(payload.participantId) + console.log(index) let newState = ((index == -1) ? - state.setIn(['participants', index], payload.newGroupNumber) + state : - state) + state.setIn(['participants', index, 'groupNumber'], payload.newGroupNumber)) return newState; }; diff --git a/src/store/createStore.js b/src/store/createStore.js index 5955edb..4b87862 100644 --- a/src/store/createStore.js +++ b/src/store/createStore.js @@ -1,10 +1,11 @@ -import {applyMiddleware, compose, createStore} from 'redux' +import { applyMiddleware, compose, createStore } from 'redux' import thunk from 'redux-thunk' import baseHistory from './baseHistory' import makeRootReducer from './reducers' import { updateLocation } from './location' import { routerMiddleware } from 'react-router-redux' import { browserHistory } from 'react-router' +import Immutable from 'immutable'; export default (initialState = {}) => { // ====================================================== @@ -34,13 +35,6 @@ export default (initialState = {}) => { } } - // ====================================================== - // Store Instantiation and HMR Setup - if (typeof composeWithDevToolsExtension === 'function') { - composeEnhancers = composeWithDevToolsExtension - } - } - // ====================================================== // Store Instantiation and HMR Setup // ====================================================== @@ -68,3 +62,4 @@ export default (initialState = {}) => { return store } + diff --git a/src/store/createStore.js.orig b/src/store/createStore.js.orig new file mode 100644 index 0000000..30c4fb5 --- /dev/null +++ b/src/store/createStore.js.orig @@ -0,0 +1,74 @@ +import { applyMiddleware, compose, createStore } from 'redux' +import thunk from 'redux-thunk' +import baseHistory from './baseHistory' +import makeRootReducer from './reducers' +<<<<<<< HEAD +import {updateLocation} from './location' +import Immutable from 'immutable'; + +import generateUsers from "../routes/Activity/modules/UserGenerator" +======= +import { updateLocation } from './location' +import { routerMiddleware } from 'react-router-redux' +import { browserHistory } from 'react-router' +>>>>>>> fix-login + +export default (initialState = {}) => { + // ====================================================== + // Middleware Configuration + // ====================================================== + + // ====================================================== + // Store Enhancers + // ====================================================== + + /* create routing middleware */ + const routingMiddleware = routerMiddleware(baseHistory) + + const middleware = [thunk] + const enhancers = [] + + let composeEnhancers = compose + + if (__DEV__) { +<<<<<<< HEAD + const composeWithDevToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ + serialize: { + immutable: Immutable + } + }); +======= + const composeWithDevToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ +>>>>>>> fix-login + if (typeof composeWithDevToolsExtension === 'function') { + composeEnhancers = composeWithDevToolsExtension + } + } + + // ====================================================== + // Store Instantiation and HMR Setup + // ====================================================== + const store = createStore( + makeRootReducer(), + initialState, + composeEnhancers( + applyMiddleware(routingMiddleware), + applyMiddleware(...middleware), + ...enhancers + ) + ) + + store.asyncReducers = {} + + // To unsubscribe, invoke `store.unsubscribeHistory()` anytime + // store.unsubscribeHistory = browserHistory.listen(updateLocation(store)) + + if (module.hot) { + module.hot.accept('./reducers', () => { + const reducers = require('./reducers').default + store.replaceReducer(reducers(store.asyncReducers)) + }) + } + + return store +}