From 6e12ed6524cfb217c9e2beb61dd9abfcbab20efa Mon Sep 17 00:00:00 2001 From: catarak Date: Wed, 6 Jul 2016 17:29:07 -0400 Subject: [PATCH] fix default file on server, change file to files in lots of places --- client/modules/IDE/actions/project.js | 12 +++--------- client/modules/IDE/reducers/files.js | 4 ++-- server/controllers/project.controller.js | 15 +++------------ server/models/project.js | 4 ++-- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index 1759c74b..3f5339d2 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -12,7 +12,7 @@ export function getProject(id) { dispatch({ type: ActionTypes.SET_PROJECT, project: response.data, - file: response.data.file + files: response.data.files }); }) .catch(response => dispatch({ @@ -54,10 +54,7 @@ export function saveProject() { type: ActionTypes.NEW_PROJECT, name: response.data.name, id: response.data.id, - file: { - name: response.data.file.name, - content: response.data.file.content - } + files: response.data.files }); }) .catch(response => dispatch({ @@ -78,10 +75,7 @@ export function createProject() { type: ActionTypes.NEW_PROJECT, name: response.data.name, id: response.data.id, - file: { - name: response.data.file.name, - content: response.data.file.content - } + files: response.data.files }); }) .catch(response => dispatch({ diff --git a/client/modules/IDE/reducers/files.js b/client/modules/IDE/reducers/files.js index dc82f77b..eca66fb1 100644 --- a/client/modules/IDE/reducers/files.js +++ b/client/modules/IDE/reducers/files.js @@ -45,9 +45,9 @@ const files = (state = initialState, action) => { }; }); case ActionTypes.NEW_PROJECT: - return { ...action.files }; + return [...action.files]; case ActionTypes.SET_PROJECT: - return { ...action.files }; + return [...action.files]; default: return state; } diff --git a/server/controllers/project.controller.js b/server/controllers/project.controller.js index bc621ed1..c4a4887a 100644 --- a/server/controllers/project.controller.js +++ b/server/controllers/project.controller.js @@ -13,10 +13,7 @@ export function createProject(req, res) { return res.json({ id: newProject._id, // eslint-disable-line no-underscore-dangle name: newProject.name, - file: { - name: newProject.file.name, - content: newProject.file.content - } + files: newProject.files }); }); } @@ -30,10 +27,7 @@ export function updateProject(req, res) { return res.json({ id: updatedProject._id, // eslint-disable-line no-underscore-dangle name: updatedProject.name, - file: { - name: updatedProject.file.name, - content: updatedProject.file.content - } + file: updatedProject.files }); }); } @@ -47,10 +41,7 @@ export function getProject(req, res) { return res.json({ id: project._id, // eslint-disable-line no-underscore-dangle name: project.name, - file: { - name: project.file.name, - content: project.file.content - } + files: project.files }); }); } diff --git a/server/models/project.js b/server/models/project.js index b5e5785f..a1306dc7 100644 --- a/server/models/project.js +++ b/server/models/project.js @@ -2,10 +2,10 @@ import mongoose from 'mongoose'; const Schema = mongoose.Schema; import shortid from 'shortid'; -const defaultSketch = `setup() { +const defaultSketch = `function setup() { createCanvas(400, 400); } -draw() { +function draw() { background(220); }`