@mythpe/quasar-ui-qui 0.2.75 → 0.2.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.2.75",
3
+ "version": "0.2.77",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -10,7 +10,7 @@
10
10
  lang="ts"
11
11
  setup
12
12
  >
13
- import type { GenericMDtBtn, MDatatableProps } from '../../types'
13
+ import type { ApiInterface, GenericMDtBtn, MDatatableProps } from '../../types'
14
14
  import type { InvalidSubmissionHandler, SubmissionHandler } from 'vee-validate'
15
15
  import { useForm } from 'vee-validate'
16
16
  import { computed, onMounted, ref, toValue, watch } from 'vue'
@@ -47,8 +47,10 @@ type Props = {
47
47
  hideShowBtn?: boolean;
48
48
  hideDestroyBtn?: boolean;
49
49
  storeRoute?: MDatatableProps['storeRoute'];
50
+ storeCallback?: MDatatableProps['storeCallback'];
50
51
  storeQueryParams?: boolean;
51
52
  updateRoute?: MDatatableProps['updateRoute'];
53
+ updateCallback?: MDatatableProps['updateCallback'];
52
54
  updateQueryParams?: boolean;
53
55
  showRoute?: MDatatableProps['showRoute'];
54
56
  showQueryParams?: boolean;
@@ -113,8 +115,10 @@ const props = withDefaults(defineProps<Props>(), {
113
115
  hideShowBtn: !1,
114
116
  hideDestroyBtn: !1,
115
117
  storeRoute: undefined,
118
+ storeCallback: undefined,
116
119
  storeQueryParams: !1,
117
120
  updateRoute: undefined,
121
+ updateCallback: undefined,
118
122
  updateQueryParams: !1,
119
123
  showRoute: undefined,
120
124
  showQueryParams: !1,
@@ -349,18 +353,25 @@ const onSuccess: SubmissionHandler = async (form) => {
349
353
  form,
350
354
  _conf) : await apiServices.store(form, _conf)
351
355
  try {
352
- const { _data, _message, _success }: any = await method()
356
+ const response: ApiInterface = await method()
357
+ const { _message, _success, _data } = response
353
358
  _message && alertSuccess(_message)
354
359
  if (_success) {
355
360
  if (isUpdateMode.value) {
356
361
  if (_data) {
357
- updateDatatableItem(_data, dialogItemIndex.value)
362
+ updateDatatableItem(_data as any, dialogItemIndex.value)
358
363
  }
359
364
  } else {
360
365
  setTimeout(() => refresh(), openDialogTimeout)
361
366
  }
362
- // nextTick()
363
- closeFormDialog()
367
+ if (isUpdateMode.value && props.updateCallback) {
368
+ props.updateCallback(response)
369
+ } else if (!isUpdateMode.value && props.storeCallback) {
370
+ props.storeCallback(response)
371
+ } else {
372
+ // nextTick()
373
+ closeFormDialog()
374
+ }
364
375
  }
365
376
  } catch (e: any) {
366
377
  const { _message, _errors } = e || {}
@@ -429,6 +440,9 @@ defineExpose({
429
440
  updateFilterOptions,
430
441
  openShowDialogNoIndex,
431
442
  openShowDialog,
443
+ dialogItem,
444
+ dialogItemIndex,
445
+ dialogErrors,
432
446
  closeShowDialog,
433
447
  openUpdateDialogNoIndex,
434
448
  openUpdateDialog,
@@ -11,7 +11,7 @@ import type { NamedColor, QAvatarProps, QAvatarSlots, QTableProps, QTableSlots }
11
11
  import type { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, UnwrapNestedRefs, UnwrapRef, VNode } from 'vue'
12
12
  import type { RouteLocationRaw } from 'vue-router'
13
13
  import type { StubSchema } from './api-helpers'
14
- import type { ApiMetaInterface, Generic } from './m-helpers'
14
+ import type { ApiInterface, ApiMetaInterface, Generic } from './m-helpers'
15
15
  import type { MFormSlots } from './api/MForm'
16
16
  import type { MBtnProps, MBtnSlots } from './api/MBtn'
17
17
  import type { GenericFormValues } from './api/MInput'
@@ -230,8 +230,10 @@ export type MDatatableProps<I extends GenericFormValues = GenericFormValues> = O
230
230
  hideShowBtn?: boolean;
231
231
  hideDestroyBtn?: boolean;
232
232
  storeRoute?: string | RouteLocationRaw;
233
+ storeCallback?: (response: ApiInterface) => void;
233
234
  storeQueryParams?: boolean;
234
235
  updateRoute?: string | RouteLocationRaw;
236
+ updateCallback?: (response: ApiInterface) => void;
235
237
  updateQueryParams?: boolean;
236
238
  showRoute?: string | RouteLocationRaw;
237
239
  showQueryParams?: boolean;