Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak(adminPanel): RN-1419: Don't delete survey screens and components on import unless they have changed #5885

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

alexd-bes
Copy link
Contributor

Issue RN-1419: Don't delete survey screens and components on import unless they have changed

Changes:

  • Updated importSurveyQuestions to only update relevant fields in the survey screen component
  • It will delete the screens and recreate if the question or has changed or questions are added/removed

@@ -23,10 +23,16 @@ import {
SURVEY_METADATA,
} from './processSurveyMetadata';
import { caseAndSpaceInsensitiveEquals, convertCellToJson } from './utilities';
import { RECORDS } from '@tupaia/database';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { RECORDS } from '@tupaia/database';

const objectsAreEqual = (a, b) => {
if (!!a === !!b) return true;
return JSON.stringify(a) === JSON.stringify(b);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function is always going to be correct. I would probably just outsource this to lodash isEqual here since we need to do a deep equality check?! Or if you update the function it would probably be good to add a unit test for it

Screenshot 2024-09-12 at 3 23 58 PM

Copy link
Contributor

@tcaiger tcaiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything it looking good apart from the object equality check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants