@iankibetsh/shframework 4.0.2 → 4.0.4
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 +204 -186
- package/dist/library.mjs +204 -186
- package/package.json +1 -1
package/dist/library.js
CHANGED
|
@@ -5,12 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var Axios = require('axios');
|
|
6
6
|
var moment = require('moment');
|
|
7
7
|
var Swal = require('sweetalert2');
|
|
8
|
+
var bootstrap = require('bootstrap');
|
|
8
9
|
var NProgress = require('nprogress');
|
|
9
10
|
var vue = require('vue');
|
|
10
11
|
var _ = require('lodash');
|
|
11
12
|
var vueRouter = require('vue-router');
|
|
12
13
|
var pinia = require('pinia');
|
|
13
|
-
var bootstrap = require('bootstrap');
|
|
14
14
|
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
16
|
|
|
@@ -44,221 +44,238 @@ var ShStorage = {
|
|
|
44
44
|
removeItem
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
function swalSuccess
|
|
48
|
-
|
|
47
|
+
function swalSuccess(message){
|
|
48
|
+
Swal__default["default"].fire('Success!', message, 'success');
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
|
|
51
|
+
function swalError(message){
|
|
52
|
+
Swal__default["default"].fire('Error!', message, 'error');
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
function swalHttpError
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} else {
|
|
73
|
-
if (typeof reason !== 'string') {
|
|
74
|
-
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
55
|
+
function swalHttpError(reason){
|
|
56
|
+
let error = '';
|
|
57
|
+
if (typeof reason !== 'undefined') {
|
|
58
|
+
if (typeof reason.response !== 'undefined') {
|
|
59
|
+
let reasonString = '';
|
|
60
|
+
if (typeof reason.response.data === 'string') {
|
|
61
|
+
reasonString = reason.response.data;
|
|
62
|
+
} else {
|
|
63
|
+
reasonString = JSON.stringify(reason.response.data);
|
|
64
|
+
}
|
|
65
|
+
error = reason.response.status + ': ' + reason.response.statusText + '<br/>' + reasonString;
|
|
66
|
+
} else {
|
|
67
|
+
if (typeof reason !== 'string') {
|
|
68
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
69
|
+
} else {
|
|
70
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
75
73
|
} else {
|
|
76
|
-
|
|
74
|
+
if (typeof reason !== 'string') {
|
|
75
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
76
|
+
} else {
|
|
77
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
78
|
+
}
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
Swal__default["default"].fire('Error!', error, 'error');
|
|
80
|
+
Swal__default["default"].fire('Error!', error, 'error');
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
function runSilentRequest
|
|
83
|
-
|
|
83
|
+
function runSilentRequest(url){
|
|
84
|
+
return shApis.doPost(url)
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
function setTabCounts
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
function setTabCounts(url){
|
|
88
|
+
shApis.doGet(url).then(res => {
|
|
89
|
+
Object.keys(res.data).forEach(key => {
|
|
90
|
+
const elem = document.getElementById(key);
|
|
91
|
+
if (elem === null) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
if (typeof elem !== 'undefined') {
|
|
95
|
+
let txt = elem.innerHTML;
|
|
96
|
+
txt = txt.split('<i class="d-none"></i>')[0];
|
|
97
|
+
if (parseInt(res.data[key]) > 0) {
|
|
98
|
+
elem.innerHTML = txt + '<i class="d-none"></i><sup class="rounded-circle p-1 bg-info text-white">' + res.data[key] + '</sup>';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// document.getElementById(key).innerHTML res.data[key]
|
|
102
|
+
});
|
|
101
103
|
});
|
|
102
|
-
});
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (typeof reason
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (typeof reason !== 'string') {
|
|
126
|
-
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
105
|
+
|
|
106
|
+
function formatHttpCatchError(reason){
|
|
107
|
+
console.log(reason);
|
|
108
|
+
let error = '';
|
|
109
|
+
if (typeof reason !== 'undefined') {
|
|
110
|
+
if (typeof reason.response !== 'undefined') {
|
|
111
|
+
alert('here');
|
|
112
|
+
let reasonString = '';
|
|
113
|
+
if (typeof reason.response.data === 'string') {
|
|
114
|
+
reasonString = reason.response.data;
|
|
115
|
+
} else {
|
|
116
|
+
reasonString = JSON.stringify(reason.response.data);
|
|
117
|
+
}
|
|
118
|
+
error = reason.response.status + ': ' + reason.response.statusText + '<br/>' + reasonString;
|
|
119
|
+
} else {
|
|
120
|
+
if (typeof reason !== 'string') {
|
|
121
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
122
|
+
} else {
|
|
123
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
127
126
|
} else {
|
|
128
|
-
|
|
127
|
+
if (typeof reason !== 'string') {
|
|
128
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
129
|
+
} else {
|
|
130
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
131
|
+
}
|
|
129
132
|
}
|
|
130
|
-
|
|
131
|
-
return error
|
|
133
|
+
return error
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
|
|
136
|
+
function getMenuCount(url){
|
|
137
|
+
shApis.doGet(url).then(res => {
|
|
138
|
+
console.log(res);
|
|
139
|
+
});
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
const signOutUser = ()=>{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
const signOutUser = () => {
|
|
143
|
+
const loginUrl = getShConfig('loginUrl', 'auth/login');
|
|
144
|
+
const logoutApiEndPoint = getShConfig('logoutApiEndpoint', 'auth/logout');
|
|
145
|
+
console.log(loginUrl, logoutApiEndPoint);
|
|
146
|
+
shApis.doPost(logoutApiEndPoint).then(res => {
|
|
147
|
+
ShStorage.removeItem('access_token');
|
|
148
|
+
ShStorage.removeItem('user');
|
|
149
|
+
ShStorage.removeItem('last_activity');
|
|
150
|
+
window.location.href = loginUrl;
|
|
151
|
+
}).catch(ex => {
|
|
152
|
+
ShStorage.removeItem('access_token');
|
|
153
|
+
ShStorage.removeItem('user');
|
|
154
|
+
ShStorage.removeItem('last_activity');
|
|
155
|
+
window.location.href = loginUrl;
|
|
156
|
+
});
|
|
154
157
|
};
|
|
155
158
|
|
|
156
159
|
|
|
160
|
+
function getShConfig(key = null, def = ''){
|
|
157
161
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if(key) {
|
|
162
|
-
return config[key] ?? def
|
|
163
|
-
}
|
|
164
|
-
return config
|
|
165
|
-
}
|
|
166
|
-
function showToast (message, toastType, config) {
|
|
167
|
-
const mixinConfig = {
|
|
168
|
-
toast: true,
|
|
169
|
-
position: 'top-end',
|
|
170
|
-
showConfirmButton: false,
|
|
171
|
-
customClass: {
|
|
172
|
-
popup: 'colored-toast'
|
|
173
|
-
},
|
|
174
|
-
iconColor: 'white',
|
|
175
|
-
timer: 2000,
|
|
176
|
-
timerProgressBar: true,
|
|
177
|
-
didOpen: (toast) => {
|
|
178
|
-
toast.addEventListener('mouseenter', Swal__default["default"].stopTimer);
|
|
179
|
-
toast.addEventListener('mouseleave', Swal__default["default"].resumeTimer);
|
|
162
|
+
const config = ShStorage.getItem('ShConfig') ?? {};
|
|
163
|
+
if (key) {
|
|
164
|
+
return config[key] ?? def
|
|
180
165
|
}
|
|
181
|
-
|
|
182
|
-
if (!toastType) {
|
|
183
|
-
toastType = 'success';
|
|
184
|
-
}
|
|
185
|
-
if(config){
|
|
186
|
-
Object.keys(config).map(key=>mixinConfig[key] = config[key]);
|
|
187
|
-
}
|
|
188
|
-
console.log(mixinConfig);
|
|
189
|
-
const Toast = Swal__default["default"].mixin(mixinConfig);
|
|
190
|
-
// Toast.mixin({
|
|
191
|
-
// position: 'top'
|
|
192
|
-
// })
|
|
193
|
-
Toast.fire({
|
|
194
|
-
icon: toastType,
|
|
195
|
-
title: message,
|
|
196
|
-
postion: 'bottom'
|
|
197
|
-
});
|
|
166
|
+
return config
|
|
198
167
|
}
|
|
199
168
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return shApis.doPost(url, data).then(function (response) {
|
|
215
|
-
return {
|
|
216
|
-
response: response.data,
|
|
217
|
-
success: true
|
|
169
|
+
function showToast(message, toastType, config){
|
|
170
|
+
const mixinConfig = {
|
|
171
|
+
toast: true,
|
|
172
|
+
position: 'top-end',
|
|
173
|
+
showConfirmButton: false,
|
|
174
|
+
customClass: {
|
|
175
|
+
popup: 'colored-toast'
|
|
176
|
+
},
|
|
177
|
+
iconColor: 'white',
|
|
178
|
+
timer: 2000,
|
|
179
|
+
timerProgressBar: true,
|
|
180
|
+
didOpen: (toast) => {
|
|
181
|
+
toast.addEventListener('mouseenter', Swal__default["default"].stopTimer);
|
|
182
|
+
toast.addEventListener('mouseleave', Swal__default["default"].resumeTimer);
|
|
218
183
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
184
|
+
};
|
|
185
|
+
if (!toastType) {
|
|
186
|
+
toastType = 'success';
|
|
187
|
+
}
|
|
188
|
+
if (config) {
|
|
189
|
+
Object.keys(config).map(key => mixinConfig[key] = config[key]);
|
|
190
|
+
}
|
|
191
|
+
console.log(mixinConfig);
|
|
192
|
+
const Toast = Swal__default["default"].mixin(mixinConfig);
|
|
193
|
+
// Toast.mixin({
|
|
194
|
+
// position: 'top'
|
|
195
|
+
// })
|
|
196
|
+
Toast.fire({
|
|
197
|
+
icon: toastType,
|
|
198
|
+
title: message,
|
|
199
|
+
postion: 'bottom'
|
|
200
|
+
});
|
|
229
201
|
}
|
|
230
202
|
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
203
|
+
async function runPlainRequest(url, message, title, data){
|
|
204
|
+
if (typeof title === 'undefined') {
|
|
205
|
+
title = null;
|
|
206
|
+
}
|
|
207
|
+
return Swal__default["default"].fire({
|
|
208
|
+
title: title !== null ? title : 'Are you sure?',
|
|
209
|
+
html: message,
|
|
210
|
+
showCancelButton: true,
|
|
211
|
+
confirmButtonColor: '#32c787',
|
|
212
|
+
cancelButtonText: 'No, cancel',
|
|
213
|
+
confirmButtonText: 'Yes, Proceed!',
|
|
214
|
+
reverseButtons: true,
|
|
215
|
+
showLoaderOnConfirm: true,
|
|
216
|
+
preConfirm: () => {
|
|
217
|
+
return shApis.doPost(url, data).then(function (response){
|
|
218
|
+
return {
|
|
219
|
+
response: response.data,
|
|
220
|
+
success: true
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
.catch(error => {
|
|
224
|
+
return {
|
|
225
|
+
success: false,
|
|
226
|
+
error: error
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
},
|
|
230
|
+
allowOutsideClick: () => !Swal__default["default"].isLoading()
|
|
231
|
+
})
|
|
236
232
|
}
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
|
|
234
|
+
function formatDate(date, format){
|
|
235
|
+
if (!format) {
|
|
236
|
+
format = 'lll';
|
|
237
|
+
}
|
|
238
|
+
return moment__default["default"](date).format(format)
|
|
239
239
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const formattedArr = formatted.split('.');
|
|
244
|
-
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] +'.' + (formattedArr[1] || '0').padEnd(decimalPoints,0)
|
|
240
|
+
|
|
241
|
+
function formatNumber(amount, decimalPoints = 0){
|
|
242
|
+
return numberFormat(amount, decimalPoints)
|
|
245
243
|
}
|
|
246
244
|
|
|
245
|
+
function numberFormat(amount, decimalPoints = 0){
|
|
246
|
+
let formatted = parseFloat(amount).toFixed(decimalPoints);
|
|
247
|
+
formatted = new Intl.NumberFormat().format(formatted);
|
|
248
|
+
const formattedArr = formatted.split('.');
|
|
249
|
+
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] + '.' + (formattedArr[1] || '0').padEnd(decimalPoints, 0)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const showModal = modalId => {
|
|
253
|
+
const modal = new bootstrap.Modal(document.getElementById(modalId));
|
|
254
|
+
modal.show();
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const hideModal = modalId => {
|
|
258
|
+
const modal = new bootstrap.Modal(document.getElementById(modalId));
|
|
259
|
+
modal.hide();
|
|
260
|
+
};
|
|
261
|
+
|
|
247
262
|
var shRepo = {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
swalSuccess,
|
|
264
|
+
swalError,
|
|
265
|
+
runPlainRequest,
|
|
266
|
+
getMenuCount,
|
|
267
|
+
setTabCounts,
|
|
268
|
+
getShConfig,
|
|
269
|
+
showToast,
|
|
270
|
+
runSilentRequest,
|
|
271
|
+
swalHttpError,
|
|
272
|
+
formatHttpCatchError,
|
|
273
|
+
formatDate,
|
|
274
|
+
numberFormat,
|
|
275
|
+
formatNumber,
|
|
276
|
+
signOutUser,
|
|
277
|
+
showModal,
|
|
278
|
+
hideModal
|
|
262
279
|
};
|
|
263
280
|
|
|
264
281
|
startSession();
|
|
@@ -3114,7 +3131,7 @@ const getFieldComponent = (fieldObj)=>{
|
|
|
3114
3131
|
if(fieldObj.component){
|
|
3115
3132
|
return fieldObj.component
|
|
3116
3133
|
}
|
|
3117
|
-
const field = fieldObj.field;
|
|
3134
|
+
const field = fieldObj.field ?? fieldObj.name;
|
|
3118
3135
|
const defaultTextareas = ['message', 'meta_description', 'comment', 'call_response', 'comments', 'description'];
|
|
3119
3136
|
const defaultNumbers = ['age'];
|
|
3120
3137
|
const passwords = ['password','password_confirmation','pin'];
|
|
@@ -3266,6 +3283,7 @@ vue.onMounted((ev)=>{
|
|
|
3266
3283
|
props.fields && props.fields.map(field=>{
|
|
3267
3284
|
if(typeof field === 'object') {
|
|
3268
3285
|
const fieldObj = {...field};
|
|
3286
|
+
fieldObj.field = fieldObj.field ?? fieldObj.name;
|
|
3269
3287
|
// fieldObj.label && getLabel(fieldObj.field)
|
|
3270
3288
|
fieldObj.helper = fieldObj.helperText ?? fieldObj.helper;
|
|
3271
3289
|
// !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field)
|
package/dist/library.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Axios from 'axios';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import Swal from 'sweetalert2';
|
|
4
|
+
import { Modal, Offcanvas } from 'bootstrap';
|
|
4
5
|
import NProgress from 'nprogress';
|
|
5
6
|
import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, ref, onMounted, unref, normalizeClass, resolveComponent, createBlock, resolveDynamicComponent, watch, inject, mergeProps, normalizeStyle, renderSlot, createVNode, normalizeProps, guardReactiveProps, withCtx, createStaticVNode, vModelCheckbox, shallowRef, pushScopeId, popScopeId, markRaw, computed, isRef } from 'vue';
|
|
6
7
|
import _ from 'lodash';
|
|
7
8
|
import { useRoute, useRouter } from 'vue-router';
|
|
8
9
|
import { defineStore, storeToRefs } from 'pinia';
|
|
9
|
-
import { Modal, Offcanvas } from 'bootstrap';
|
|
10
10
|
|
|
11
11
|
function setItem (key, value) {
|
|
12
12
|
let toStore = value;
|
|
@@ -32,221 +32,238 @@ var ShStorage = {
|
|
|
32
32
|
removeItem
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
function swalSuccess
|
|
36
|
-
|
|
35
|
+
function swalSuccess(message){
|
|
36
|
+
Swal.fire('Success!', message, 'success');
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
function swalError(message){
|
|
40
|
+
Swal.fire('Error!', message, 'error');
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
function swalHttpError
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
if (typeof reason !== 'string') {
|
|
62
|
-
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
43
|
+
function swalHttpError(reason){
|
|
44
|
+
let error = '';
|
|
45
|
+
if (typeof reason !== 'undefined') {
|
|
46
|
+
if (typeof reason.response !== 'undefined') {
|
|
47
|
+
let reasonString = '';
|
|
48
|
+
if (typeof reason.response.data === 'string') {
|
|
49
|
+
reasonString = reason.response.data;
|
|
50
|
+
} else {
|
|
51
|
+
reasonString = JSON.stringify(reason.response.data);
|
|
52
|
+
}
|
|
53
|
+
error = reason.response.status + ': ' + reason.response.statusText + '<br/>' + reasonString;
|
|
54
|
+
} else {
|
|
55
|
+
if (typeof reason !== 'string') {
|
|
56
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
57
|
+
} else {
|
|
58
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
63
61
|
} else {
|
|
64
|
-
|
|
62
|
+
if (typeof reason !== 'string') {
|
|
63
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
64
|
+
} else {
|
|
65
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
Swal.fire('Error!', error, 'error');
|
|
68
|
+
Swal.fire('Error!', error, 'error');
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
function runSilentRequest
|
|
71
|
-
|
|
71
|
+
function runSilentRequest(url){
|
|
72
|
+
return shApis.doPost(url)
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
function setTabCounts
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
function setTabCounts(url){
|
|
76
|
+
shApis.doGet(url).then(res => {
|
|
77
|
+
Object.keys(res.data).forEach(key => {
|
|
78
|
+
const elem = document.getElementById(key);
|
|
79
|
+
if (elem === null) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
if (typeof elem !== 'undefined') {
|
|
83
|
+
let txt = elem.innerHTML;
|
|
84
|
+
txt = txt.split('<i class="d-none"></i>')[0];
|
|
85
|
+
if (parseInt(res.data[key]) > 0) {
|
|
86
|
+
elem.innerHTML = txt + '<i class="d-none"></i><sup class="rounded-circle p-1 bg-info text-white">' + res.data[key] + '</sup>';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// document.getElementById(key).innerHTML res.data[key]
|
|
90
|
+
});
|
|
89
91
|
});
|
|
90
|
-
});
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (typeof reason
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (typeof reason !== 'string') {
|
|
114
|
-
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
93
|
+
|
|
94
|
+
function formatHttpCatchError(reason){
|
|
95
|
+
console.log(reason);
|
|
96
|
+
let error = '';
|
|
97
|
+
if (typeof reason !== 'undefined') {
|
|
98
|
+
if (typeof reason.response !== 'undefined') {
|
|
99
|
+
alert('here');
|
|
100
|
+
let reasonString = '';
|
|
101
|
+
if (typeof reason.response.data === 'string') {
|
|
102
|
+
reasonString = reason.response.data;
|
|
103
|
+
} else {
|
|
104
|
+
reasonString = JSON.stringify(reason.response.data);
|
|
105
|
+
}
|
|
106
|
+
error = reason.response.status + ': ' + reason.response.statusText + '<br/>' + reasonString;
|
|
107
|
+
} else {
|
|
108
|
+
if (typeof reason !== 'string') {
|
|
109
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
110
|
+
} else {
|
|
111
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
115
114
|
} else {
|
|
116
|
-
|
|
115
|
+
if (typeof reason !== 'string') {
|
|
116
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
117
|
+
} else {
|
|
118
|
+
error = 'A Unexpected script error occurred<br/>' + JSON.stringify(reason);
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
return error
|
|
121
|
+
return error
|
|
120
122
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
|
|
124
|
+
function getMenuCount(url){
|
|
125
|
+
shApis.doGet(url).then(res => {
|
|
126
|
+
console.log(res);
|
|
127
|
+
});
|
|
125
128
|
}
|
|
126
129
|
|
|
127
|
-
const signOutUser = ()=>{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
const signOutUser = () => {
|
|
131
|
+
const loginUrl = getShConfig('loginUrl', 'auth/login');
|
|
132
|
+
const logoutApiEndPoint = getShConfig('logoutApiEndpoint', 'auth/logout');
|
|
133
|
+
console.log(loginUrl, logoutApiEndPoint);
|
|
134
|
+
shApis.doPost(logoutApiEndPoint).then(res => {
|
|
135
|
+
ShStorage.removeItem('access_token');
|
|
136
|
+
ShStorage.removeItem('user');
|
|
137
|
+
ShStorage.removeItem('last_activity');
|
|
138
|
+
window.location.href = loginUrl;
|
|
139
|
+
}).catch(ex => {
|
|
140
|
+
ShStorage.removeItem('access_token');
|
|
141
|
+
ShStorage.removeItem('user');
|
|
142
|
+
ShStorage.removeItem('last_activity');
|
|
143
|
+
window.location.href = loginUrl;
|
|
144
|
+
});
|
|
142
145
|
};
|
|
143
146
|
|
|
144
147
|
|
|
148
|
+
function getShConfig(key = null, def = ''){
|
|
145
149
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if(key) {
|
|
150
|
-
return config[key] ?? def
|
|
151
|
-
}
|
|
152
|
-
return config
|
|
153
|
-
}
|
|
154
|
-
function showToast (message, toastType, config) {
|
|
155
|
-
const mixinConfig = {
|
|
156
|
-
toast: true,
|
|
157
|
-
position: 'top-end',
|
|
158
|
-
showConfirmButton: false,
|
|
159
|
-
customClass: {
|
|
160
|
-
popup: 'colored-toast'
|
|
161
|
-
},
|
|
162
|
-
iconColor: 'white',
|
|
163
|
-
timer: 2000,
|
|
164
|
-
timerProgressBar: true,
|
|
165
|
-
didOpen: (toast) => {
|
|
166
|
-
toast.addEventListener('mouseenter', Swal.stopTimer);
|
|
167
|
-
toast.addEventListener('mouseleave', Swal.resumeTimer);
|
|
150
|
+
const config = ShStorage.getItem('ShConfig') ?? {};
|
|
151
|
+
if (key) {
|
|
152
|
+
return config[key] ?? def
|
|
168
153
|
}
|
|
169
|
-
|
|
170
|
-
if (!toastType) {
|
|
171
|
-
toastType = 'success';
|
|
172
|
-
}
|
|
173
|
-
if(config){
|
|
174
|
-
Object.keys(config).map(key=>mixinConfig[key] = config[key]);
|
|
175
|
-
}
|
|
176
|
-
console.log(mixinConfig);
|
|
177
|
-
const Toast = Swal.mixin(mixinConfig);
|
|
178
|
-
// Toast.mixin({
|
|
179
|
-
// position: 'top'
|
|
180
|
-
// })
|
|
181
|
-
Toast.fire({
|
|
182
|
-
icon: toastType,
|
|
183
|
-
title: message,
|
|
184
|
-
postion: 'bottom'
|
|
185
|
-
});
|
|
154
|
+
return config
|
|
186
155
|
}
|
|
187
156
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return shApis.doPost(url, data).then(function (response) {
|
|
203
|
-
return {
|
|
204
|
-
response: response.data,
|
|
205
|
-
success: true
|
|
157
|
+
function showToast(message, toastType, config){
|
|
158
|
+
const mixinConfig = {
|
|
159
|
+
toast: true,
|
|
160
|
+
position: 'top-end',
|
|
161
|
+
showConfirmButton: false,
|
|
162
|
+
customClass: {
|
|
163
|
+
popup: 'colored-toast'
|
|
164
|
+
},
|
|
165
|
+
iconColor: 'white',
|
|
166
|
+
timer: 2000,
|
|
167
|
+
timerProgressBar: true,
|
|
168
|
+
didOpen: (toast) => {
|
|
169
|
+
toast.addEventListener('mouseenter', Swal.stopTimer);
|
|
170
|
+
toast.addEventListener('mouseleave', Swal.resumeTimer);
|
|
206
171
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
172
|
+
};
|
|
173
|
+
if (!toastType) {
|
|
174
|
+
toastType = 'success';
|
|
175
|
+
}
|
|
176
|
+
if (config) {
|
|
177
|
+
Object.keys(config).map(key => mixinConfig[key] = config[key]);
|
|
178
|
+
}
|
|
179
|
+
console.log(mixinConfig);
|
|
180
|
+
const Toast = Swal.mixin(mixinConfig);
|
|
181
|
+
// Toast.mixin({
|
|
182
|
+
// position: 'top'
|
|
183
|
+
// })
|
|
184
|
+
Toast.fire({
|
|
185
|
+
icon: toastType,
|
|
186
|
+
title: message,
|
|
187
|
+
postion: 'bottom'
|
|
188
|
+
});
|
|
217
189
|
}
|
|
218
190
|
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
191
|
+
async function runPlainRequest(url, message, title, data){
|
|
192
|
+
if (typeof title === 'undefined') {
|
|
193
|
+
title = null;
|
|
194
|
+
}
|
|
195
|
+
return Swal.fire({
|
|
196
|
+
title: title !== null ? title : 'Are you sure?',
|
|
197
|
+
html: message,
|
|
198
|
+
showCancelButton: true,
|
|
199
|
+
confirmButtonColor: '#32c787',
|
|
200
|
+
cancelButtonText: 'No, cancel',
|
|
201
|
+
confirmButtonText: 'Yes, Proceed!',
|
|
202
|
+
reverseButtons: true,
|
|
203
|
+
showLoaderOnConfirm: true,
|
|
204
|
+
preConfirm: () => {
|
|
205
|
+
return shApis.doPost(url, data).then(function (response){
|
|
206
|
+
return {
|
|
207
|
+
response: response.data,
|
|
208
|
+
success: true
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
.catch(error => {
|
|
212
|
+
return {
|
|
213
|
+
success: false,
|
|
214
|
+
error: error
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
},
|
|
218
|
+
allowOutsideClick: () => !Swal.isLoading()
|
|
219
|
+
})
|
|
224
220
|
}
|
|
225
|
-
|
|
226
|
-
|
|
221
|
+
|
|
222
|
+
function formatDate(date, format){
|
|
223
|
+
if (!format) {
|
|
224
|
+
format = 'lll';
|
|
225
|
+
}
|
|
226
|
+
return moment(date).format(format)
|
|
227
227
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const formattedArr = formatted.split('.');
|
|
232
|
-
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] +'.' + (formattedArr[1] || '0').padEnd(decimalPoints,0)
|
|
228
|
+
|
|
229
|
+
function formatNumber(amount, decimalPoints = 0){
|
|
230
|
+
return numberFormat(amount, decimalPoints)
|
|
233
231
|
}
|
|
234
232
|
|
|
233
|
+
function numberFormat(amount, decimalPoints = 0){
|
|
234
|
+
let formatted = parseFloat(amount).toFixed(decimalPoints);
|
|
235
|
+
formatted = new Intl.NumberFormat().format(formatted);
|
|
236
|
+
const formattedArr = formatted.split('.');
|
|
237
|
+
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] + '.' + (formattedArr[1] || '0').padEnd(decimalPoints, 0)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const showModal = modalId => {
|
|
241
|
+
const modal = new Modal(document.getElementById(modalId));
|
|
242
|
+
modal.show();
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const hideModal = modalId => {
|
|
246
|
+
const modal = new Modal(document.getElementById(modalId));
|
|
247
|
+
modal.hide();
|
|
248
|
+
};
|
|
249
|
+
|
|
235
250
|
var shRepo = {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
251
|
+
swalSuccess,
|
|
252
|
+
swalError,
|
|
253
|
+
runPlainRequest,
|
|
254
|
+
getMenuCount,
|
|
255
|
+
setTabCounts,
|
|
256
|
+
getShConfig,
|
|
257
|
+
showToast,
|
|
258
|
+
runSilentRequest,
|
|
259
|
+
swalHttpError,
|
|
260
|
+
formatHttpCatchError,
|
|
261
|
+
formatDate,
|
|
262
|
+
numberFormat,
|
|
263
|
+
formatNumber,
|
|
264
|
+
signOutUser,
|
|
265
|
+
showModal,
|
|
266
|
+
hideModal
|
|
250
267
|
};
|
|
251
268
|
|
|
252
269
|
startSession();
|
|
@@ -3102,7 +3119,7 @@ const getFieldComponent = (fieldObj)=>{
|
|
|
3102
3119
|
if(fieldObj.component){
|
|
3103
3120
|
return fieldObj.component
|
|
3104
3121
|
}
|
|
3105
|
-
const field = fieldObj.field;
|
|
3122
|
+
const field = fieldObj.field ?? fieldObj.name;
|
|
3106
3123
|
const defaultTextareas = ['message', 'meta_description', 'comment', 'call_response', 'comments', 'description'];
|
|
3107
3124
|
const defaultNumbers = ['age'];
|
|
3108
3125
|
const passwords = ['password','password_confirmation','pin'];
|
|
@@ -3254,6 +3271,7 @@ onMounted((ev)=>{
|
|
|
3254
3271
|
props.fields && props.fields.map(field=>{
|
|
3255
3272
|
if(typeof field === 'object') {
|
|
3256
3273
|
const fieldObj = {...field};
|
|
3274
|
+
fieldObj.field = fieldObj.field ?? fieldObj.name;
|
|
3257
3275
|
// fieldObj.label && getLabel(fieldObj.field)
|
|
3258
3276
|
fieldObj.helper = fieldObj.helperText ?? fieldObj.helper;
|
|
3259
3277
|
// !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field)
|