Skip to content

Commit 9d71d2e

Browse files
committed
add configuration to let user have a custom behavior for form
1 parent 7902d06 commit 9d71d2e

File tree

4 files changed

+109
-100
lines changed

4 files changed

+109
-100
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Configurations object allow you to personnalize the behavior of vue-datatable-ur
115115
| debounceTime | 0 | Allow you to specify a debounce time before sending request to your server. This is usefull when you have only text field but can bring lag feeling when using checkbox or select. You can also use debounce directly in your component to personalize this behavior |
116116
| serveurDefaultPageSize | 10 | The default value for you backend pagination to be sure to send it if the default value in front is different that the one in your back |
117117
| extraQueryParams | {} | Put variable in the url and send them to your back even if not in your form |
118+
| updateFormFunction | null | Use a custom function to update form instead of direct assignation. Usefull when form is a props and you want to emit an event because form is not mutable. |
118119

119120
# FormSchema
120121

package-lock.json

Lines changed: 99 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/useDatatableUrlSync.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export default function useDatatableUrlSync(route: any, router: any, form: Ref<G
3131
serveurDefaultPageSize: 10,
3232
// This mean to be overrided to add query params that are fixed and should not appear in url
3333
extraQueryParams: {},
34+
// this is used when you have special behavior to update your form like emit event instead of direct assignation
35+
updateFormFunction: null,
3436
...configurations || {}
3537
}
3638
options.value = {
@@ -233,7 +235,12 @@ export default function useDatatableUrlSync(route: any, router: any, form: Ref<G
233235
if (isEqual(form.value, newForm)) {
234236
return false;
235237
}
236-
form.value = newForm;
238+
// Let user update his form as he want to.
239+
if (configurations?.updateFormFunction) {
240+
configurations?.updateFormFunction(newForm)
241+
} else {
242+
form.value = newForm;
243+
}
237244
return true;
238245
}
239246

src/utils/VDUSTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type VDUSConfiguration = {
2323
debounceTime?: number;
2424
serveurDefaultPageSize?: number;
2525
extraQueryParams?: GenericDictionnary;
26+
updateFormFunction?: Function | null;
2627
}
2728

2829
type VuetifySortArraysObject = {

0 commit comments

Comments
 (0)