From e932b943a334ed120b0ba7a10a342c30be02a29b Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Fri, 11 Jun 2021 09:42:41 -0700 Subject: [PATCH] Fixed checkChanges --- ui/src/app/metadata/editor/MetadataEditor.js | 10 +--------- ui/src/app/metadata/hooks/utility.js | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/ui/src/app/metadata/editor/MetadataEditor.js b/ui/src/app/metadata/editor/MetadataEditor.js index ffe6f01b6..e76b4e267 100644 --- a/ui/src/app/metadata/editor/MetadataEditor.js +++ b/ui/src/app/metadata/editor/MetadataEditor.js @@ -17,9 +17,7 @@ import { useTranslator } from '../../i18n/hooks'; import API_BASE_PATH from '../../App.constant'; import { MetadataObjectContext } from '../hoc/MetadataSelector'; import { FilterableProviders } from '../domain/provider'; - -import { detailedDiff } from 'deep-object-diff'; -import { removeNull } from '../../core/utility/remove_null'; +import { checkChanges } from '../hooks/utility'; export function MetadataEditor ({ current }) { @@ -38,12 +36,6 @@ export function MetadataEditor ({ current }) { const { state, dispatch } = React.useContext(MetadataFormContext); const { metadata, errors } = state; - const checkChanges = (original, updates) => { - const diff = detailedDiff(original, removeNull(updates, true)); - const hasChanges = Object.keys(diff).some(d => Object.keys(diff[d]).length > 0); - return hasChanges; - }; - const onChange = (changes) => { dispatch(setFormDataAction(changes.formData)); dispatch(setFormErrorAction(changes.errors)); diff --git a/ui/src/app/metadata/hooks/utility.js b/ui/src/app/metadata/hooks/utility.js index c197911a8..653448c25 100644 --- a/ui/src/app/metadata/hooks/utility.js +++ b/ui/src/app/metadata/hooks/utility.js @@ -2,7 +2,7 @@ import { detailedDiff } from "deep-object-diff"; import { removeNull } from "../../core/utility/remove_null"; export const checkChanges = (original, updates) => { - const diff = detailedDiff(original, removeNull(updates, true)); + const diff = detailedDiff(removeNull(original, true), removeNull(updates, true)); const hasChanges = Object.keys(diff).some(d => Object.keys(diff[d]).length > 0); return hasChanges; }