mirror of
https://github.com/IT4Change/ohmyform-ui.git
synced 2025-12-13 09:45:50 +00:00
reload list after adding new form
fixes https://github.com/ohmyform/ohmyform/issues/139
This commit is contained in:
parent
92bc295580
commit
831e0d7779
@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- fixes for hide contrib setting
|
||||
- fix problem with node-prune on production build
|
||||
- translation for prev / continue during form submission
|
||||
- reload form list after adding new one (https://github.com/ohmyform/ohmyform/issues/139)
|
||||
|
||||
### Security
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ export interface FormPagerFragment {
|
||||
}
|
||||
|
||||
export const FORM_PAGER_FRAGMENT = gql`
|
||||
fragment Form on Form {
|
||||
fragment PagerForm on Form {
|
||||
id
|
||||
created
|
||||
lastModified
|
||||
|
||||
@ -80,7 +80,7 @@ export interface FormPublicFragment {
|
||||
}
|
||||
|
||||
export const FORM_PUBLIC_FRAGMENT = gql`
|
||||
fragment Form on Form {
|
||||
fragment PublicForm on Form {
|
||||
id
|
||||
title
|
||||
language
|
||||
|
||||
@ -26,5 +26,20 @@ const MUTATION = gql`
|
||||
`
|
||||
|
||||
export const useFormCreateMutation = (
|
||||
data?: MutationHookOptions<Data, Variables>
|
||||
): MutationTuple<Data, Variables> => useMutation<Data, Variables>(MUTATION, data)
|
||||
options: MutationHookOptions<Data, Variables> = {}
|
||||
): MutationTuple<Data, Variables> => {
|
||||
const oldUpdate = options.update
|
||||
|
||||
options.update = (cache, result, options) => {
|
||||
cache.evict({
|
||||
fieldName: 'listForms',
|
||||
})
|
||||
cache.gc()
|
||||
|
||||
if (oldUpdate) {
|
||||
oldUpdate(cache, result, options)
|
||||
}
|
||||
}
|
||||
|
||||
return useMutation<Data, Variables>(MUTATION, options)
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ const QUERY = gql`
|
||||
query listForms($start: Int, $limit: Int) {
|
||||
pager: listForms(start: $start, limit: $limit) {
|
||||
entries {
|
||||
...Form
|
||||
...PagerForm
|
||||
}
|
||||
total
|
||||
limit
|
||||
|
||||
@ -13,7 +13,7 @@ interface Variables {
|
||||
const QUERY = gql`
|
||||
query getFormById($id: ID!) {
|
||||
form: getFormById(id: $id) {
|
||||
...Form
|
||||
...PublicForm
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ interface Variables {
|
||||
const QUERY = gql`
|
||||
query listSubmissions($form: ID!, $start: Int, $limit: Int) {
|
||||
form: getFormById(id: $form) {
|
||||
...Form
|
||||
...PagerForm
|
||||
}
|
||||
|
||||
pager: listSubmissions(form: $form, start: $start, limit: $limit) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user