From d4b18eae8181051f5230b796046cc7ff56e94862 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 19 Aug 2016 09:23:41 +0200 Subject: refactoring --- web/src/js/components/ContentView/UploadContentButton.jsx | 4 +--- web/src/js/components/common/Dropdown.jsx | 2 +- web/src/js/ducks/ui/flow.js | 3 +-- web/src/js/utils.js | 7 ++++--- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'web/src/js') diff --git a/web/src/js/components/ContentView/UploadContentButton.jsx b/web/src/js/components/ContentView/UploadContentButton.jsx index 6764e234..de349af4 100644 --- a/web/src/js/components/ContentView/UploadContentButton.jsx +++ b/web/src/js/components/ContentView/UploadContentButton.jsx @@ -6,9 +6,7 @@ UploadContentButton.propTypes = { } export default function UploadContentButton({ uploadContent }) { - - let fileInput; - + return ( } +export const Divider = () =>
export default class Dropdown extends Component { diff --git a/web/src/js/ducks/ui/flow.js b/web/src/js/ducks/ui/flow.js index 22a8c22d..e65c39a3 100644 --- a/web/src/js/ducks/ui/flow.js +++ b/web/src/js/ducks/ui/flow.js @@ -152,6 +152,5 @@ export function setContent(content){ } export function stopEdit(flow, modifiedFlow) { - let diff = getDiff(flow, modifiedFlow) - return flowsActions.update(flow, diff) + return flowsActions.update(flow, getDiff(flow, modifiedFlow)) } diff --git a/web/src/js/utils.js b/web/src/js/utils.js index e44182d0..e8470cec 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -107,14 +107,15 @@ fetchApi.put = (url, json, options) => fetchApi( ...options } ) - +// deep comparison of two json objects (dicts). arrays are handeled as a single value. +// return: json object including only the changed keys value pairs. export function getDiff(obj1, obj2) { let result = {...obj2}; for(let key in obj1) { if(_.isEqual(obj2[key], obj1[key])) result[key] = undefined - else if(!(Array.isArray(obj2[key]) && Array.isArray(obj1[key])) && - typeof obj2[key] == 'object' && typeof obj1[key] == 'object') + else if(Object.prototype.toString.call(obj2[key]) === '[object Object]' && + Object.prototype.toString.call(obj1[key]) === '[object Object]' ) result[key] = getDiff(obj1[key], obj2[key]) } return result -- cgit v1.2.3