@iankibetsh/shframework 1.8.9 → 1.9.1
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/dist/library.mjs.css +32 -32
- package/dist/library.js +64 -34
- package/dist/library.mjs +59 -34
- package/package.json +1 -1
|
@@ -1,36 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
.colored-toast.swal2-icon-success {
|
|
3
|
-
background-color: #a5dc86 !important;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.colored-toast.swal2-icon-error {
|
|
7
|
-
background-color: #f27474 !important;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.colored-toast.swal2-icon-warning {
|
|
11
|
-
background-color: #f8bb86 !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.colored-toast.swal2-icon-info {
|
|
15
|
-
background-color: #3fc3ee !important;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.colored-toast.swal2-icon-question {
|
|
19
|
-
background-color: #87adbd !important;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.colored-toast .swal2-title {
|
|
23
|
-
color: white;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.colored-toast .swal2-close {
|
|
27
|
-
color: white;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.colored-toast .swal2-html-container {
|
|
31
|
-
color: white;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
2
|
.sh-phone{
|
|
35
3
|
display: flex;
|
|
36
4
|
width: 100%;
|
|
@@ -63,6 +31,38 @@
|
|
|
63
31
|
opacity: 0.5;
|
|
64
32
|
}
|
|
65
33
|
|
|
34
|
+
.colored-toast.swal2-icon-success {
|
|
35
|
+
background-color: #a5dc86 !important;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.colored-toast.swal2-icon-error {
|
|
39
|
+
background-color: #f27474 !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.colored-toast.swal2-icon-warning {
|
|
43
|
+
background-color: #f8bb86 !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.colored-toast.swal2-icon-info {
|
|
47
|
+
background-color: #3fc3ee !important;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.colored-toast.swal2-icon-question {
|
|
51
|
+
background-color: #87adbd !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.colored-toast .swal2-title {
|
|
55
|
+
color: white;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.colored-toast .swal2-close {
|
|
59
|
+
color: white;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.colored-toast .swal2-html-container {
|
|
63
|
+
color: white;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
66
|
.permissions-main {
|
|
67
67
|
background: #edeff2;
|
|
68
68
|
}
|
package/dist/library.js
CHANGED
|
@@ -11,6 +11,7 @@ var _ = require('lodash');
|
|
|
11
11
|
var vueRouter = require('vue-router');
|
|
12
12
|
var pinia = require('pinia');
|
|
13
13
|
var bootstrap = require('bootstrap');
|
|
14
|
+
var shGql_js = require('@/lib/repo/graphql/shGql.js');
|
|
14
15
|
|
|
15
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
17
|
|
|
@@ -37,6 +38,7 @@ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
|
37
38
|
var Swal__default = /*#__PURE__*/_interopDefaultLegacy(Swal);
|
|
38
39
|
var NProgress__default = /*#__PURE__*/_interopDefaultLegacy(NProgress);
|
|
39
40
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
41
|
+
var shGql_js__default = /*#__PURE__*/_interopDefaultLegacy(shGql_js);
|
|
40
42
|
|
|
41
43
|
function setItem (key, value) {
|
|
42
44
|
let toStore = value;
|
|
@@ -377,6 +379,7 @@ const updateSession = () =>{
|
|
|
377
379
|
ShStorage.setItem('last_activity', timeNow);
|
|
378
380
|
};
|
|
379
381
|
|
|
382
|
+
const graphQlEndpoint = 'sh-ql';
|
|
380
383
|
let apiUrl = undefined.VITE_APP_API_URL;
|
|
381
384
|
// eslint-disable-next-line no-undef
|
|
382
385
|
if (process.env.NODE_ENV === 'production') {
|
|
@@ -413,24 +416,23 @@ function doPost (endPoint, data) {
|
|
|
413
416
|
)
|
|
414
417
|
}
|
|
415
418
|
function graphQlQuery(query) {
|
|
416
|
-
updateSession();
|
|
417
419
|
const data = {
|
|
418
|
-
query
|
|
420
|
+
query
|
|
419
421
|
};
|
|
420
|
-
return
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
})
|
|
422
|
+
return doGet(graphQlEndpoint,data)
|
|
423
|
+
}
|
|
424
|
+
function graphQlMutate(mutation) {
|
|
425
|
+
const data = {
|
|
426
|
+
query: `mutation ${mutation}`
|
|
427
|
+
};
|
|
428
|
+
return doPost(graphQlEndpoint,data)
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
var shApis = {
|
|
431
432
|
doGet,
|
|
432
433
|
doPost,
|
|
433
|
-
graphQlQuery
|
|
434
|
+
graphQlQuery,
|
|
435
|
+
graphQlMutate
|
|
434
436
|
};
|
|
435
437
|
|
|
436
438
|
const countries = [
|
|
@@ -3094,7 +3096,7 @@ var script$n = {
|
|
|
3094
3096
|
'textAreas',
|
|
3095
3097
|
'currentData',
|
|
3096
3098
|
'emails',
|
|
3097
|
-
'phones','numbers','selects','dates'
|
|
3099
|
+
'phones','numbers','selects','dates','gqlMutation'
|
|
3098
3100
|
],
|
|
3099
3101
|
emits: ['success'],
|
|
3100
3102
|
setup(__props, { emit }) {
|
|
@@ -3189,30 +3191,54 @@ const submitForm = e => {
|
|
|
3189
3191
|
e.preventDefault();
|
|
3190
3192
|
loading.value = true;
|
|
3191
3193
|
const data = {};
|
|
3192
|
-
formFields.value.map(field=>
|
|
3193
|
-
|
|
3194
|
-
loading.value = false;
|
|
3195
|
-
emit('formSubmitted',res.data);
|
|
3196
|
-
emit('success',res.data);
|
|
3197
|
-
props.successMessage && shRepo.showToast(props.successMessage);
|
|
3198
|
-
props.successCallback && props.successCallback(res.data);
|
|
3199
|
-
!props.retainDataAfterSubmission && formFields.value.map(field=>field.value = null);
|
|
3200
|
-
closeModal();
|
|
3201
|
-
}).catch(reason=>{
|
|
3202
|
-
console.log(reason);
|
|
3203
|
-
loading.value = false;
|
|
3204
|
-
const httpStatus = reason.response ? reason.response.status:0;
|
|
3205
|
-
formError.value = httpStatus === 422 ? formError.value = null:reason.message ?? null;
|
|
3206
|
-
let httpErrors = {};
|
|
3207
|
-
httpStatus === 422 && typeof reason.response.data.errors === 'object' && (httpErrors = reason.response.data.errors);
|
|
3208
|
-
if(httpErrors && reason.response){
|
|
3209
|
-
Object.keys(httpErrors).map(key=>validationErrors.value[key] = typeof httpErrors[key] === 'string' ? httpErrors[key]:httpErrors[key][0]);
|
|
3210
|
-
}
|
|
3211
|
-
(httpStatus !== 422 && formError.value) && shRepo.showToast(formError.value,'error');
|
|
3212
|
-
validationErrors.value;
|
|
3194
|
+
formFields.value.map(field=>{
|
|
3195
|
+
data[field.field] = field.value;
|
|
3213
3196
|
});
|
|
3197
|
+
if(props.gqlMutation) {
|
|
3198
|
+
let args = `(`;
|
|
3199
|
+
let selectFields = Object.keys(data);
|
|
3200
|
+
selectFields.forEach(key=>{
|
|
3201
|
+
if(data[key]) {
|
|
3202
|
+
args +=`${key}: "${data[key]}",`;
|
|
3203
|
+
}
|
|
3204
|
+
});
|
|
3205
|
+
args+=`)`;
|
|
3206
|
+
args = args.replace(',)',')');
|
|
3207
|
+
if(args == '()') {
|
|
3208
|
+
args = '';
|
|
3209
|
+
}
|
|
3210
|
+
const mutation = `{\n${props.gqlMutation} ${args} {\n${selectFields.join(`\n`)}\n}\n}`;
|
|
3211
|
+
console.log(mutation);
|
|
3212
|
+
shApis.graphQlMutate(mutation).then(res=>handleSuccessRequest(res)).catch(reason=>handlefailedRequest(reason));
|
|
3213
|
+
} else {
|
|
3214
|
+
shApis.doPost(props.action,data).then(res=>handleSuccessRequest(res)).catch(reason=>handlefailedRequest(reason));
|
|
3215
|
+
}
|
|
3214
3216
|
return false
|
|
3215
3217
|
};
|
|
3218
|
+
|
|
3219
|
+
const handleSuccessRequest = res=>{
|
|
3220
|
+
loading.value = false;
|
|
3221
|
+
emit('formSubmitted',res.data);
|
|
3222
|
+
emit('success',res.data);
|
|
3223
|
+
props.successMessage && shRepo.showToast(props.successMessage);
|
|
3224
|
+
props.successCallback && props.successCallback(res.data);
|
|
3225
|
+
!props.retainDataAfterSubmission && formFields.value.map(field=>field.value = null);
|
|
3226
|
+
closeModal();
|
|
3227
|
+
};
|
|
3228
|
+
|
|
3229
|
+
const handlefailedRequest = reason=>{
|
|
3230
|
+
console.log(reason);
|
|
3231
|
+
loading.value = false;
|
|
3232
|
+
const httpStatus = reason.response ? reason.response.status:0;
|
|
3233
|
+
formError.value = httpStatus === 422 ? formError.value = null:reason.message ?? null;
|
|
3234
|
+
let httpErrors = {};
|
|
3235
|
+
httpStatus === 422 && typeof reason.response.data.errors === 'object' && (httpErrors = reason.response.data.errors);
|
|
3236
|
+
if(httpErrors && reason.response){
|
|
3237
|
+
Object.keys(httpErrors).map(key=>validationErrors.value[key] = typeof httpErrors[key] === 'string' ? httpErrors[key]:httpErrors[key][0]);
|
|
3238
|
+
}
|
|
3239
|
+
(httpStatus !== 422 && formError.value) && shRepo.showToast(formError.value,'error');
|
|
3240
|
+
validationErrors.value;
|
|
3241
|
+
};
|
|
3216
3242
|
const submitBtnWidth = vue.ref(null);
|
|
3217
3243
|
const setExistingData = (existingData)=>{
|
|
3218
3244
|
if (props.currentData) {
|
|
@@ -5616,7 +5642,7 @@ vue.watch(() => route.query.popup, pop => {
|
|
|
5616
5642
|
const component = route.query.comp || '';
|
|
5617
5643
|
PopupComponent.value = vue.defineAsyncComponent({
|
|
5618
5644
|
// the loader function
|
|
5619
|
-
loader: () => (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(`/src/views/popups/${component}Popup.vue`),
|
|
5645
|
+
loader: () => (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(/* @vite-ignore */ `/src/views/popups/${component}Popup.vue`),
|
|
5620
5646
|
|
|
5621
5647
|
// A component to use while the async component is loading
|
|
5622
5648
|
loadingComponent: script$8,
|
|
@@ -6486,6 +6512,10 @@ const ShFrontend = {
|
|
|
6486
6512
|
}
|
|
6487
6513
|
};
|
|
6488
6514
|
|
|
6515
|
+
Object.defineProperty(exports, 'shGql', {
|
|
6516
|
+
enumerable: true,
|
|
6517
|
+
get: function () { return shGql_js__default["default"]; }
|
|
6518
|
+
});
|
|
6489
6519
|
exports.Countries = countries;
|
|
6490
6520
|
exports.ManagePermissions = script$9;
|
|
6491
6521
|
exports.ShAutoForm = script$n;
|
package/dist/library.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import _ from 'lodash';
|
|
|
7
7
|
import { useRoute, useRouter } from 'vue-router';
|
|
8
8
|
import { defineStore, storeToRefs } from 'pinia';
|
|
9
9
|
import { Modal, Offcanvas } from 'bootstrap';
|
|
10
|
+
export { default as shGql } from '@/lib/repo/graphql/shGql.js';
|
|
10
11
|
|
|
11
12
|
function setItem (key, value) {
|
|
12
13
|
let toStore = value;
|
|
@@ -347,6 +348,7 @@ const updateSession = () =>{
|
|
|
347
348
|
ShStorage.setItem('last_activity', timeNow);
|
|
348
349
|
};
|
|
349
350
|
|
|
351
|
+
const graphQlEndpoint = 'sh-ql';
|
|
350
352
|
let apiUrl = import.meta.env.VITE_APP_API_URL;
|
|
351
353
|
// eslint-disable-next-line no-undef
|
|
352
354
|
if (process.env.NODE_ENV === 'production') {
|
|
@@ -383,24 +385,23 @@ function doPost (endPoint, data) {
|
|
|
383
385
|
)
|
|
384
386
|
}
|
|
385
387
|
function graphQlQuery(query) {
|
|
386
|
-
updateSession();
|
|
387
388
|
const data = {
|
|
388
|
-
query
|
|
389
|
+
query
|
|
389
390
|
};
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
})
|
|
391
|
+
return doGet(graphQlEndpoint,data)
|
|
392
|
+
}
|
|
393
|
+
function graphQlMutate(mutation) {
|
|
394
|
+
const data = {
|
|
395
|
+
query: `mutation ${mutation}`
|
|
396
|
+
};
|
|
397
|
+
return doPost(graphQlEndpoint,data)
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
var shApis = {
|
|
401
401
|
doGet,
|
|
402
402
|
doPost,
|
|
403
|
-
graphQlQuery
|
|
403
|
+
graphQlQuery,
|
|
404
|
+
graphQlMutate
|
|
404
405
|
};
|
|
405
406
|
|
|
406
407
|
const countries = [
|
|
@@ -3064,7 +3065,7 @@ var script$n = {
|
|
|
3064
3065
|
'textAreas',
|
|
3065
3066
|
'currentData',
|
|
3066
3067
|
'emails',
|
|
3067
|
-
'phones','numbers','selects','dates'
|
|
3068
|
+
'phones','numbers','selects','dates','gqlMutation'
|
|
3068
3069
|
],
|
|
3069
3070
|
emits: ['success'],
|
|
3070
3071
|
setup(__props, { emit }) {
|
|
@@ -3159,30 +3160,54 @@ const submitForm = e => {
|
|
|
3159
3160
|
e.preventDefault();
|
|
3160
3161
|
loading.value = true;
|
|
3161
3162
|
const data = {};
|
|
3162
|
-
formFields.value.map(field=>
|
|
3163
|
-
|
|
3164
|
-
loading.value = false;
|
|
3165
|
-
emit('formSubmitted',res.data);
|
|
3166
|
-
emit('success',res.data);
|
|
3167
|
-
props.successMessage && shRepo.showToast(props.successMessage);
|
|
3168
|
-
props.successCallback && props.successCallback(res.data);
|
|
3169
|
-
!props.retainDataAfterSubmission && formFields.value.map(field=>field.value = null);
|
|
3170
|
-
closeModal();
|
|
3171
|
-
}).catch(reason=>{
|
|
3172
|
-
console.log(reason);
|
|
3173
|
-
loading.value = false;
|
|
3174
|
-
const httpStatus = reason.response ? reason.response.status:0;
|
|
3175
|
-
formError.value = httpStatus === 422 ? formError.value = null:reason.message ?? null;
|
|
3176
|
-
let httpErrors = {};
|
|
3177
|
-
httpStatus === 422 && typeof reason.response.data.errors === 'object' && (httpErrors = reason.response.data.errors);
|
|
3178
|
-
if(httpErrors && reason.response){
|
|
3179
|
-
Object.keys(httpErrors).map(key=>validationErrors.value[key] = typeof httpErrors[key] === 'string' ? httpErrors[key]:httpErrors[key][0]);
|
|
3180
|
-
}
|
|
3181
|
-
(httpStatus !== 422 && formError.value) && shRepo.showToast(formError.value,'error');
|
|
3182
|
-
validationErrors.value;
|
|
3163
|
+
formFields.value.map(field=>{
|
|
3164
|
+
data[field.field] = field.value;
|
|
3183
3165
|
});
|
|
3166
|
+
if(props.gqlMutation) {
|
|
3167
|
+
let args = `(`;
|
|
3168
|
+
let selectFields = Object.keys(data);
|
|
3169
|
+
selectFields.forEach(key=>{
|
|
3170
|
+
if(data[key]) {
|
|
3171
|
+
args +=`${key}: "${data[key]}",`;
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
args+=`)`;
|
|
3175
|
+
args = args.replace(',)',')');
|
|
3176
|
+
if(args == '()') {
|
|
3177
|
+
args = '';
|
|
3178
|
+
}
|
|
3179
|
+
const mutation = `{\n${props.gqlMutation} ${args} {\n${selectFields.join(`\n`)}\n}\n}`;
|
|
3180
|
+
console.log(mutation);
|
|
3181
|
+
shApis.graphQlMutate(mutation).then(res=>handleSuccessRequest(res)).catch(reason=>handlefailedRequest(reason));
|
|
3182
|
+
} else {
|
|
3183
|
+
shApis.doPost(props.action,data).then(res=>handleSuccessRequest(res)).catch(reason=>handlefailedRequest(reason));
|
|
3184
|
+
}
|
|
3184
3185
|
return false
|
|
3185
3186
|
};
|
|
3187
|
+
|
|
3188
|
+
const handleSuccessRequest = res=>{
|
|
3189
|
+
loading.value = false;
|
|
3190
|
+
emit('formSubmitted',res.data);
|
|
3191
|
+
emit('success',res.data);
|
|
3192
|
+
props.successMessage && shRepo.showToast(props.successMessage);
|
|
3193
|
+
props.successCallback && props.successCallback(res.data);
|
|
3194
|
+
!props.retainDataAfterSubmission && formFields.value.map(field=>field.value = null);
|
|
3195
|
+
closeModal();
|
|
3196
|
+
};
|
|
3197
|
+
|
|
3198
|
+
const handlefailedRequest = reason=>{
|
|
3199
|
+
console.log(reason);
|
|
3200
|
+
loading.value = false;
|
|
3201
|
+
const httpStatus = reason.response ? reason.response.status:0;
|
|
3202
|
+
formError.value = httpStatus === 422 ? formError.value = null:reason.message ?? null;
|
|
3203
|
+
let httpErrors = {};
|
|
3204
|
+
httpStatus === 422 && typeof reason.response.data.errors === 'object' && (httpErrors = reason.response.data.errors);
|
|
3205
|
+
if(httpErrors && reason.response){
|
|
3206
|
+
Object.keys(httpErrors).map(key=>validationErrors.value[key] = typeof httpErrors[key] === 'string' ? httpErrors[key]:httpErrors[key][0]);
|
|
3207
|
+
}
|
|
3208
|
+
(httpStatus !== 422 && formError.value) && shRepo.showToast(formError.value,'error');
|
|
3209
|
+
validationErrors.value;
|
|
3210
|
+
};
|
|
3186
3211
|
const submitBtnWidth = ref(null);
|
|
3187
3212
|
const setExistingData = (existingData)=>{
|
|
3188
3213
|
if (props.currentData) {
|
|
@@ -5586,7 +5611,7 @@ watch(() => route.query.popup, pop => {
|
|
|
5586
5611
|
const component = route.query.comp || '';
|
|
5587
5612
|
PopupComponent.value = defineAsyncComponent({
|
|
5588
5613
|
// the loader function
|
|
5589
|
-
loader: () => import(`/src/views/popups/${component}Popup.vue`),
|
|
5614
|
+
loader: () => import(/* @vite-ignore */ `/src/views/popups/${component}Popup.vue`),
|
|
5590
5615
|
|
|
5591
5616
|
// A component to use while the async component is loading
|
|
5592
5617
|
loadingComponent: script$8,
|