-
Notifications
You must be signed in to change notification settings - Fork 49
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
Interview import dataset #1188
Draft
jochenklar
wants to merge
29
commits into
interview-copy-dataset
Choose a base branch
from
interview-import-dataset
base: interview-copy-dataset
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Interview import dataset #1188
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a96d85c
Add import function to create set modal on pages
jochenklar 271d1d9
Add separate search endpoint for values and use AsyncSelect in PageHe…
jochenklar 9eda9d9
Fix errors after rebase
jochenklar 30194d2
Add error handling to copy-set action and fix/add tests
jochenklar 80e5ef9
Improve PageHeadFormModal
jochenklar e88a844
Add import function into existing set
jochenklar 4dff50f
Update/fix tests
jochenklar 8f9f3a6
Rename import/copy answers to reuse answers
jochenklar b9a547a
Fix copy_set action and update tests
jochenklar ef84164
Add reuse value modal for questions
jochenklar 6ed31f2
Add reuse value model to checkboxes
jochenklar c8de022
Add project filter to reuse value modal
jochenklar 30e3742
Add useLsState hook and use it to store reuse modal information
jochenklar 40208cd
Fix page component
jochenklar 6c5e2f3
Fix react select error state
jochenklar e4d35a3
Fix reuse modal
jochenklar 9d25784
Add tests for value search endpoint
jochenklar 0a6abff
Fix QuestionSetCopySet component
jochenklar 29dbaa5
Fix Page component
jochenklar 8055cb6
Refactor interview modals
jochenklar 71d4b84
Fix Value model
jochenklar 7984080
Fix typo
jochenklar d88ad3e
Update .gitignore
jochenklar 24f6831
Fix radio input
jochenklar 3966d34
Fix search component
jochenklar 87aa8c5
Add set label to search component
jochenklar fbbe3dc
Add project_interview_sidebar template
jochenklar c0eecfa
Fix SelectWidget
jochenklar 4ca340d
Add append to reuse value functionality
jochenklar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState } from 'react' | ||
import { isEmpty, isPlainObject, omit as lodashOmit } from 'lodash' | ||
|
||
import { checkStoreId } from '../utils/store' | ||
|
||
const useLsState = (path, initialValue, omit = []) => { | ||
checkStoreId() | ||
|
||
const getLs = (path) => { | ||
const data = JSON.parse(localStorage.getItem(path)) | ||
return isPlainObject(data) ? lodashOmit(data, omit) : data | ||
} | ||
|
||
const setLs = (path, value) => { | ||
const data = isPlainObject(value) ? lodashOmit(value, omit) : value | ||
localStorage.setItem(path, JSON.stringify(data)) | ||
} | ||
|
||
// get the value from the local storage | ||
const lsValue = getLs(path) | ||
|
||
// setup the state with the value from the local storage or the provided initialValue | ||
const [value, setValue] = useState(isEmpty(lsValue) ? initialValue : lsValue) | ||
|
||
return [ | ||
value, | ||
(value) => { | ||
setLs(path, value) | ||
setValue(value) | ||
}, | ||
() => { | ||
if (isPlainObject(initialValue)) { | ||
setValue({ ...initialValue, ...getLs(path) }) | ||
} else { | ||
setValue(initialValue) | ||
} | ||
} | ||
] | ||
} | ||
|
||
export default useLsState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this
localStorage
useLsState
hook just a re-implementation of what was already stored in localStorage before or is it a new state altogether??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we had
configActions
which are synced with the local storage. Here I bypass the redux store and just use auseState
hook which is synced to the local storage.