diff --git a/client/coral-framework/mocks.json b/client/coral-framework/mocks.json new file mode 100644 index 000000000..ce455e922 --- /dev/null +++ b/client/coral-framework/mocks.json @@ -0,0 +1,43 @@ +{ + "query": [ + { + "item_id": "assetTest", + "type": "asset", + "data": { + "url": "http://coralproject.net" + }, + "related": { + "comment": [ + "abc", + "def" + ] + } + }, + { + "item_id": "abc", + "type": "comment", + "data": { + "content": "Sample comment" + }, + "related":{ + "child": [ + "xyz" + ] + } + }, + { + "item_id": "xyz", + "type": "comment", + "data": { + "content": "Sample reply" + } + }, + { + "item_id": "def", + "type": "comment", + "data": { + "content": "Another reply" + } + } + ] +} diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index c797f0a8f..fe45feb0c 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -1,6 +1,7 @@ /* Item Actions */ import { fromJS } from 'immutable' +import mocks from '../../mocks.json' /** * Action name constants @@ -88,21 +89,26 @@ export const appendItemRelated = (item_id, property, value) => { * @dispatches * A set of items to the item store */ -export function getItemsQuery (query, rootId) { +export function getItemsQuery (rootId) { return (dispatch) => { - return fetch('/v1/exec/view/' + rootId) - .then( - response => { - return response.ok ? response.json() : Promise.reject(response.status + ' ' + response.statusText) - } - ) - .then((json) => { - let items = json.results[0].Docs - for (var i = 0; i < items.length; i++) { - dispatch(addItem(items[i])) - } - return (items) - }) + // return fetch('/v1/exec/view/' + rootId) + // .then( + // response => { + // return response.ok ? response.json() : Promise.reject(response.status + ' ' + response.statusText) + // } + // ) + // .then((json) => { + // let items = json.results[0].Docs + // for (var i = 0; i < items.length; i++) { + // dispatch(addItem(items[i])) + // } + // return (items) + // }) + console.log('Loading mock data', mocks); + let mockData = mocks.query + for (var i=0; i < mockData.length; i++ ) { + dispatch(addItem(mockData[i])) + } } } diff --git a/client/coral-plugin-replies/ReplyButton.js b/client/coral-plugin-replies/ReplyButton.js index 9a786e223..33c6d4c3f 100644 --- a/client/coral-plugin-replies/ReplyButton.js +++ b/client/coral-plugin-replies/ReplyButton.js @@ -7,8 +7,8 @@ const ReplyButton = (props) => export default ReplyButton diff --git a/package.json b/package.json index 289f5488d..632135005 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "lint": "eslint .", "start": "./bin/www", - "embed-start":"node client/coral-embed-stream/dev-server.js" + "embed-start": "node client/coral-embed-stream/dev-server.js" }, "repository": { "type": "git", @@ -45,6 +45,7 @@ "exports-loader": "^0.6.3", "immutable": "^3.8.1", "imports-loader": "^0.6.5", + "json-loader": "^0.5.4", "pym.js": "^1.1.1", "react": "15.3.2", "react-dom": "15.3.2",