@iankibetsh/shframework 5.1.6 → 5.1.8

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/dist/library.js CHANGED
@@ -3383,7 +3383,7 @@ var script$q = {
3383
3383
  'action', 'successCallback', 'retainDataAfterSubmission',
3384
3384
  'successMessage', 'fields', 'customComponents', 'placeHolders',
3385
3385
  'formClasses',
3386
- 'helperTexts', 'labels', 'data',
3386
+ 'helperTexts', 'labels', 'data','preSubmitCallback',
3387
3387
  'fillSelects',
3388
3388
  'formClass',
3389
3389
  'actionLabel',
@@ -3482,9 +3482,11 @@ const fieldChanged = field => {
3482
3482
  formFields.value.map(field => {
3483
3483
  data[field.field] = field.value;
3484
3484
  });
3485
- emit('fieldChanged', field, formFields.value.filter(f => f.field === field)[0].value, data);
3485
+ setTimeout(() => {
3486
+ emit('fieldChanged', field, formFields.value.filter(f => f.field === field)[0].value, data);
3487
+ }, 300);
3486
3488
  };
3487
- const getComponentProps = field => {
3489
+ const getComponentProps = (field) => {
3488
3490
  const newField = {...field};
3489
3491
  delete newField.component;
3490
3492
  delete newField.value;
@@ -3495,7 +3497,7 @@ const loading = vue.ref(false);
3495
3497
  const submitBtn = vue.ref(false);
3496
3498
  const validationErrors = vue.ref({});
3497
3499
  const formError = vue.ref(null);
3498
- const submitForm = e => {
3500
+ const submitForm = async (e) => {
3499
3501
  submitBtnWidth.value = submitBtn.value.getBoundingClientRect().width + 'px !important';
3500
3502
  validationErrors.value = {};
3501
3503
  e.preventDefault();
@@ -3504,6 +3506,13 @@ const submitForm = e => {
3504
3506
  formFields.value.map(field => {
3505
3507
  data[field.field] = field.value;
3506
3508
  });
3509
+ if (props.preSubmitCallback) {
3510
+ const callbackkRes = await props.preSubmitCallback(data);
3511
+ if (callbackkRes !== true) {
3512
+ loading.value = false;
3513
+ return false
3514
+ }
3515
+ }
3507
3516
  if (props.gqlMutation) {
3508
3517
  let args = `(`;
3509
3518
  let selectFields = Object.keys(data);
@@ -3518,6 +3527,7 @@ const submitForm = e => {
3518
3527
  args = '';
3519
3528
  }
3520
3529
  emit('preSubmit', data);
3530
+
3521
3531
  const mutation = `{\n${props.gqlMutation} ${args} {\n${selectFields.join(`\n`)}\n}\n}`;
3522
3532
  shApis.graphQlMutate(mutation).then(res => handleSuccessRequest(res)).catch(reason => handlefailedRequest(reason));
3523
3533
  } else {
package/dist/library.mjs CHANGED
@@ -3371,7 +3371,7 @@ var script$q = {
3371
3371
  'action', 'successCallback', 'retainDataAfterSubmission',
3372
3372
  'successMessage', 'fields', 'customComponents', 'placeHolders',
3373
3373
  'formClasses',
3374
- 'helperTexts', 'labels', 'data',
3374
+ 'helperTexts', 'labels', 'data','preSubmitCallback',
3375
3375
  'fillSelects',
3376
3376
  'formClass',
3377
3377
  'actionLabel',
@@ -3470,9 +3470,11 @@ const fieldChanged = field => {
3470
3470
  formFields.value.map(field => {
3471
3471
  data[field.field] = field.value;
3472
3472
  });
3473
- emit('fieldChanged', field, formFields.value.filter(f => f.field === field)[0].value, data);
3473
+ setTimeout(() => {
3474
+ emit('fieldChanged', field, formFields.value.filter(f => f.field === field)[0].value, data);
3475
+ }, 300);
3474
3476
  };
3475
- const getComponentProps = field => {
3477
+ const getComponentProps = (field) => {
3476
3478
  const newField = {...field};
3477
3479
  delete newField.component;
3478
3480
  delete newField.value;
@@ -3483,7 +3485,7 @@ const loading = ref(false);
3483
3485
  const submitBtn = ref(false);
3484
3486
  const validationErrors = ref({});
3485
3487
  const formError = ref(null);
3486
- const submitForm = e => {
3488
+ const submitForm = async (e) => {
3487
3489
  submitBtnWidth.value = submitBtn.value.getBoundingClientRect().width + 'px !important';
3488
3490
  validationErrors.value = {};
3489
3491
  e.preventDefault();
@@ -3492,6 +3494,13 @@ const submitForm = e => {
3492
3494
  formFields.value.map(field => {
3493
3495
  data[field.field] = field.value;
3494
3496
  });
3497
+ if (props.preSubmitCallback) {
3498
+ const callbackkRes = await props.preSubmitCallback(data);
3499
+ if (callbackkRes !== true) {
3500
+ loading.value = false;
3501
+ return false
3502
+ }
3503
+ }
3495
3504
  if (props.gqlMutation) {
3496
3505
  let args = `(`;
3497
3506
  let selectFields = Object.keys(data);
@@ -3506,6 +3515,7 @@ const submitForm = e => {
3506
3515
  args = '';
3507
3516
  }
3508
3517
  emit('preSubmit', data);
3518
+
3509
3519
  const mutation = `{\n${props.gqlMutation} ${args} {\n${selectFields.join(`\n`)}\n}\n}`;
3510
3520
  shApis.graphQlMutate(mutation).then(res => handleSuccessRequest(res)).catch(reason => handlefailedRequest(reason));
3511
3521
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "5.1.6",
3
+ "version": "5.1.8",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",