@iankibetsh/shframework 4.1.0 → 4.1.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/library.js +236 -198
- package/dist/library.mjs +236 -198
- 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,239 @@ 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
|
+
message: error.message
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
},
|
|
231
|
+
allowOutsideClick: () => !Swal__default["default"].isLoading()
|
|
232
|
+
})
|
|
236
233
|
}
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
|
|
235
|
+
function formatDate(date, format){
|
|
236
|
+
if (!format) {
|
|
237
|
+
format = 'lll';
|
|
238
|
+
}
|
|
239
|
+
return moment__default["default"](date).format(format)
|
|
239
240
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const formattedArr = formatted.split('.');
|
|
244
|
-
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] +'.' + (formattedArr[1] || '0').padEnd(decimalPoints,0)
|
|
241
|
+
|
|
242
|
+
function formatNumber(amount, decimalPoints = 0){
|
|
243
|
+
return numberFormat(amount, decimalPoints)
|
|
245
244
|
}
|
|
246
245
|
|
|
246
|
+
function numberFormat(amount, decimalPoints = 0){
|
|
247
|
+
let formatted = parseFloat(amount).toFixed(decimalPoints);
|
|
248
|
+
formatted = new Intl.NumberFormat().format(formatted);
|
|
249
|
+
const formattedArr = formatted.split('.');
|
|
250
|
+
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] + '.' + (formattedArr[1] || '0').padEnd(decimalPoints, 0)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const showModal = modalId => {
|
|
254
|
+
const modal = new bootstrap.Modal(document.getElementById(modalId));
|
|
255
|
+
modal.show();
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const hideModal = modalId => {
|
|
259
|
+
const modal = new bootstrap.Modal(document.getElementById(modalId));
|
|
260
|
+
modal.hide();
|
|
261
|
+
};
|
|
262
|
+
|
|
247
263
|
var shRepo = {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
264
|
+
swalSuccess,
|
|
265
|
+
swalError,
|
|
266
|
+
runPlainRequest,
|
|
267
|
+
getMenuCount,
|
|
268
|
+
setTabCounts,
|
|
269
|
+
getShConfig,
|
|
270
|
+
showToast,
|
|
271
|
+
runSilentRequest,
|
|
272
|
+
swalHttpError,
|
|
273
|
+
formatHttpCatchError,
|
|
274
|
+
formatDate,
|
|
275
|
+
numberFormat,
|
|
276
|
+
formatNumber,
|
|
277
|
+
signOutUser,
|
|
278
|
+
showModal,
|
|
279
|
+
hideModal
|
|
262
280
|
};
|
|
263
281
|
|
|
264
282
|
startSession();
|
|
@@ -2094,7 +2112,6 @@ function filterData(e){
|
|
|
2094
2112
|
}
|
|
2095
2113
|
let filterValue = e.target.innerText;
|
|
2096
2114
|
searchText.value = filterValue;
|
|
2097
|
-
console.log(props);
|
|
2098
2115
|
if (props.url) {
|
|
2099
2116
|
shApis.doGet(props.url, { all: 1,filter_value: filterValue }).then(res => {
|
|
2100
2117
|
suggestions.value = res.data.data ?? res.data;
|
|
@@ -2107,6 +2124,8 @@ function filterData(e){
|
|
|
2107
2124
|
return item
|
|
2108
2125
|
}
|
|
2109
2126
|
});
|
|
2127
|
+
} else {
|
|
2128
|
+
console.log("Error: no data or url provided");
|
|
2110
2129
|
}
|
|
2111
2130
|
}
|
|
2112
2131
|
|
|
@@ -2245,7 +2264,8 @@ var script$s = {
|
|
|
2245
2264
|
if(this.customComponent && this.customComponent[field]){
|
|
2246
2265
|
return 'component'
|
|
2247
2266
|
}
|
|
2248
|
-
if(this.suggests && this.suggests
|
|
2267
|
+
if(this.suggests && this.suggests[field]){
|
|
2268
|
+
// alert('found')
|
|
2249
2269
|
return 'suggest'
|
|
2250
2270
|
}
|
|
2251
2271
|
if(this.editors && this.editors.includes(field)){
|
|
@@ -2473,12 +2493,12 @@ var script$s = {
|
|
|
2473
2493
|
if (!this.suggests) {
|
|
2474
2494
|
this.suggests = [];
|
|
2475
2495
|
}
|
|
2476
|
-
this.suggests[key] = this.fillSelects[key]
|
|
2496
|
+
this.suggests[key] = this.fillSelects[key];
|
|
2477
2497
|
} else if (this.fillSelects[key].data) {
|
|
2478
2498
|
this.selectData[key] = this.fillSelects[key].data;
|
|
2479
2499
|
} else {
|
|
2480
2500
|
shApis.doGet(this.fillSelects[key].url, { all: 1 }).then(res => {
|
|
2481
|
-
this.selectData[key] = res.data;
|
|
2501
|
+
this.selectData[key] = res.data.data ?? res.data;
|
|
2482
2502
|
}).catch(res => {
|
|
2483
2503
|
console.log(res);
|
|
2484
2504
|
});
|
|
@@ -2694,8 +2714,10 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2694
2714
|
"fill-selects": $props.fillSelects[field],
|
|
2695
2715
|
class: vue.normalizeClass(_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field),
|
|
2696
2716
|
modelValue: _ctx.form_elements[field],
|
|
2697
|
-
"onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event)
|
|
2698
|
-
|
|
2717
|
+
"onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event),
|
|
2718
|
+
url: _ctx.suggests[field].url ?? false,
|
|
2719
|
+
data: _ctx.suggests[field].data ?? false
|
|
2720
|
+
}, null, 8 /* PROPS */, ["select-data", "fill-selects", "class", "modelValue", "onUpdate:modelValue", "url", "data"]))
|
|
2699
2721
|
: vue.createCommentVNode("v-if", true),
|
|
2700
2722
|
($options.getFieldType(field) === 'text')
|
|
2701
2723
|
? vue.withDirectives((vue.openBlock(), vue.createElementBlock("input", {
|
|
@@ -3110,7 +3132,7 @@ const getFieldComponent = (fieldObj)=>{
|
|
|
3110
3132
|
if(fieldObj.component){
|
|
3111
3133
|
return fieldObj.component
|
|
3112
3134
|
}
|
|
3113
|
-
const field = fieldObj.field;
|
|
3135
|
+
const field = fieldObj.field ?? fieldObj.name;
|
|
3114
3136
|
const defaultTextareas = ['message', 'meta_description', 'comment', 'call_response', 'comments', 'description'];
|
|
3115
3137
|
const defaultNumbers = ['age'];
|
|
3116
3138
|
const passwords = ['password','password_confirmation','pin'];
|
|
@@ -3128,6 +3150,9 @@ const getFieldComponent = (fieldObj)=>{
|
|
|
3128
3150
|
return props.customComponents[field]
|
|
3129
3151
|
}
|
|
3130
3152
|
if(fieldObj.type){
|
|
3153
|
+
if(fieldObj.type === 'suggest' || fieldObj.type === 'suggests'){
|
|
3154
|
+
return script$t
|
|
3155
|
+
}
|
|
3131
3156
|
return fieldObj.type === 'number' ? NumberComponent:fieldObj.type === 'textarea' ? TextAreaComponent : fieldObj.type === 'email' ? EmailComponent : fieldObj.type === 'phone' ? PhoneComponent : fieldObj.type === 'password' ? PasswordComponent:fieldObj.type === 'select' ? SelectComponent:TextComponent
|
|
3132
3157
|
}else
|
|
3133
3158
|
if(passwords.includes(field)){
|
|
@@ -3262,11 +3287,12 @@ vue.onMounted((ev)=>{
|
|
|
3262
3287
|
props.fields && props.fields.map(field=>{
|
|
3263
3288
|
if(typeof field === 'object') {
|
|
3264
3289
|
const fieldObj = {...field};
|
|
3290
|
+
fieldObj.field = fieldObj.field ?? fieldObj.name;
|
|
3265
3291
|
// fieldObj.label && getLabel(fieldObj.field)
|
|
3266
3292
|
fieldObj.helper = fieldObj.helperText ?? fieldObj.helper;
|
|
3267
3293
|
// !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field)
|
|
3268
3294
|
// fieldObj.helperText === undefined && ()
|
|
3269
|
-
fieldObj.label = fieldObj.label ?? getLabel(fieldObj.field);
|
|
3295
|
+
fieldObj.label = fieldObj.label ?? getLabel(fieldObj.field ?? fieldObj.name);
|
|
3270
3296
|
// fieldObj.placeholder && fieldObj.placeHolder && getPlaceholder(fieldObj.field)
|
|
3271
3297
|
fieldObj.value = null;
|
|
3272
3298
|
formFields.value.push(fieldObj);
|
|
@@ -4302,7 +4328,7 @@ script$c.__file = "src/lib/components/ShRange.vue";
|
|
|
4302
4328
|
|
|
4303
4329
|
var script$b = {
|
|
4304
4330
|
name: 'sh-table',
|
|
4305
|
-
props: ['endPoint', 'headers', 'query', 'pageCount', 'actions', 'hideCount', 'hideLoadMore', 'links', 'reload', 'hideSearch', 'sharedData', 'searchPlaceholder', 'event', 'displayMore', 'displayMoreBtnClass', 'moreDetailsColumns', 'moreDetailsFields', 'hasDownload', 'downloadFields', 'tableHover', 'hideIds', 'paginationStyle', 'hasRange'],
|
|
4331
|
+
props: ['endPoint', 'headers','cacheKey', 'query', 'pageCount', 'actions', 'hideCount', 'hideLoadMore', 'links', 'reload', 'hideSearch', 'sharedData', 'searchPlaceholder', 'event', 'displayMore', 'displayMoreBtnClass', 'moreDetailsColumns', 'moreDetailsFields', 'hasDownload', 'downloadFields', 'tableHover', 'hideIds', 'paginationStyle', 'hasRange'],
|
|
4306
4332
|
data() {
|
|
4307
4333
|
return {
|
|
4308
4334
|
order_by: '',
|
|
@@ -4335,6 +4361,7 @@ var script$b = {
|
|
|
4335
4361
|
if (this.headers) {
|
|
4336
4362
|
this.tableHeaders = this.headers;
|
|
4337
4363
|
}
|
|
4364
|
+
|
|
4338
4365
|
if (this.actions && this.actions.actions) {
|
|
4339
4366
|
this.actions.actions.forEach(action => {
|
|
4340
4367
|
if (action.canvasComponent) {
|
|
@@ -4342,6 +4369,10 @@ var script$b = {
|
|
|
4342
4369
|
}
|
|
4343
4370
|
});
|
|
4344
4371
|
}
|
|
4372
|
+
if(this.cacheKey){
|
|
4373
|
+
this.setCachedData();
|
|
4374
|
+
}
|
|
4375
|
+
this.reloadData();
|
|
4345
4376
|
},
|
|
4346
4377
|
methods: {
|
|
4347
4378
|
rangeChanged: function (newRange) {
|
|
@@ -4488,11 +4519,18 @@ var script$b = {
|
|
|
4488
4519
|
shRepo.swalError('Error', error);
|
|
4489
4520
|
});
|
|
4490
4521
|
},
|
|
4522
|
+
setCachedData: function () {
|
|
4523
|
+
if (this.cacheKey) {
|
|
4524
|
+
this.records = ShStorage.getItem('sh_table_cache_' + this.cacheKey, []);
|
|
4525
|
+
}
|
|
4526
|
+
},
|
|
4491
4527
|
reloadData: function (page, append) {
|
|
4492
4528
|
if (typeof page !== 'undefined') {
|
|
4493
4529
|
this.page = page;
|
|
4494
4530
|
}
|
|
4495
|
-
if (
|
|
4531
|
+
if (this.cacheKey && this.records && this.records.length > 0 && this.page < 2 ) {
|
|
4532
|
+
this.loading = 'done';
|
|
4533
|
+
} else if(!append){
|
|
4496
4534
|
this.loading = 'loading';
|
|
4497
4535
|
}
|
|
4498
4536
|
const data = {
|
|
@@ -4520,6 +4558,9 @@ var script$b = {
|
|
|
4520
4558
|
this.$emit('dataReloaded', this.pagination_data);
|
|
4521
4559
|
this.loading = 'done';
|
|
4522
4560
|
const response = req.data.data;
|
|
4561
|
+
if(this.page < 2 && this.cacheKey){
|
|
4562
|
+
ShStorage.setItem('sh_table_cache_' + this.cacheKey, response.data);
|
|
4563
|
+
}
|
|
4523
4564
|
this.pagination_data = {
|
|
4524
4565
|
current: response.current_page,
|
|
4525
4566
|
start: response.from,
|
|
@@ -4565,9 +4606,6 @@ var script$b = {
|
|
|
4565
4606
|
this.reloadData();
|
|
4566
4607
|
}
|
|
4567
4608
|
},
|
|
4568
|
-
created() {
|
|
4569
|
-
this.reloadData();
|
|
4570
|
-
},
|
|
4571
4609
|
components: {
|
|
4572
4610
|
ShRange: script$c,
|
|
4573
4611
|
ShSilentAction: script$d,
|
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,239 @@ 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
|
+
message: error.message
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
},
|
|
219
|
+
allowOutsideClick: () => !Swal.isLoading()
|
|
220
|
+
})
|
|
224
221
|
}
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
|
|
223
|
+
function formatDate(date, format){
|
|
224
|
+
if (!format) {
|
|
225
|
+
format = 'lll';
|
|
226
|
+
}
|
|
227
|
+
return moment(date).format(format)
|
|
227
228
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const formattedArr = formatted.split('.');
|
|
232
|
-
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] +'.' + (formattedArr[1] || '0').padEnd(decimalPoints,0)
|
|
229
|
+
|
|
230
|
+
function formatNumber(amount, decimalPoints = 0){
|
|
231
|
+
return numberFormat(amount, decimalPoints)
|
|
233
232
|
}
|
|
234
233
|
|
|
234
|
+
function numberFormat(amount, decimalPoints = 0){
|
|
235
|
+
let formatted = parseFloat(amount).toFixed(decimalPoints);
|
|
236
|
+
formatted = new Intl.NumberFormat().format(formatted);
|
|
237
|
+
const formattedArr = formatted.split('.');
|
|
238
|
+
return decimalPoints === 0 ? formattedArr[0] : formattedArr[0] + '.' + (formattedArr[1] || '0').padEnd(decimalPoints, 0)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const showModal = modalId => {
|
|
242
|
+
const modal = new Modal(document.getElementById(modalId));
|
|
243
|
+
modal.show();
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const hideModal = modalId => {
|
|
247
|
+
const modal = new Modal(document.getElementById(modalId));
|
|
248
|
+
modal.hide();
|
|
249
|
+
};
|
|
250
|
+
|
|
235
251
|
var shRepo = {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
252
|
+
swalSuccess,
|
|
253
|
+
swalError,
|
|
254
|
+
runPlainRequest,
|
|
255
|
+
getMenuCount,
|
|
256
|
+
setTabCounts,
|
|
257
|
+
getShConfig,
|
|
258
|
+
showToast,
|
|
259
|
+
runSilentRequest,
|
|
260
|
+
swalHttpError,
|
|
261
|
+
formatHttpCatchError,
|
|
262
|
+
formatDate,
|
|
263
|
+
numberFormat,
|
|
264
|
+
formatNumber,
|
|
265
|
+
signOutUser,
|
|
266
|
+
showModal,
|
|
267
|
+
hideModal
|
|
250
268
|
};
|
|
251
269
|
|
|
252
270
|
startSession();
|
|
@@ -2082,7 +2100,6 @@ function filterData(e){
|
|
|
2082
2100
|
}
|
|
2083
2101
|
let filterValue = e.target.innerText;
|
|
2084
2102
|
searchText.value = filterValue;
|
|
2085
|
-
console.log(props);
|
|
2086
2103
|
if (props.url) {
|
|
2087
2104
|
shApis.doGet(props.url, { all: 1,filter_value: filterValue }).then(res => {
|
|
2088
2105
|
suggestions.value = res.data.data ?? res.data;
|
|
@@ -2095,6 +2112,8 @@ function filterData(e){
|
|
|
2095
2112
|
return item
|
|
2096
2113
|
}
|
|
2097
2114
|
});
|
|
2115
|
+
} else {
|
|
2116
|
+
console.log("Error: no data or url provided");
|
|
2098
2117
|
}
|
|
2099
2118
|
}
|
|
2100
2119
|
|
|
@@ -2233,7 +2252,8 @@ var script$s = {
|
|
|
2233
2252
|
if(this.customComponent && this.customComponent[field]){
|
|
2234
2253
|
return 'component'
|
|
2235
2254
|
}
|
|
2236
|
-
if(this.suggests && this.suggests
|
|
2255
|
+
if(this.suggests && this.suggests[field]){
|
|
2256
|
+
// alert('found')
|
|
2237
2257
|
return 'suggest'
|
|
2238
2258
|
}
|
|
2239
2259
|
if(this.editors && this.editors.includes(field)){
|
|
@@ -2461,12 +2481,12 @@ var script$s = {
|
|
|
2461
2481
|
if (!this.suggests) {
|
|
2462
2482
|
this.suggests = [];
|
|
2463
2483
|
}
|
|
2464
|
-
this.suggests[key] = this.fillSelects[key]
|
|
2484
|
+
this.suggests[key] = this.fillSelects[key];
|
|
2465
2485
|
} else if (this.fillSelects[key].data) {
|
|
2466
2486
|
this.selectData[key] = this.fillSelects[key].data;
|
|
2467
2487
|
} else {
|
|
2468
2488
|
shApis.doGet(this.fillSelects[key].url, { all: 1 }).then(res => {
|
|
2469
|
-
this.selectData[key] = res.data;
|
|
2489
|
+
this.selectData[key] = res.data.data ?? res.data;
|
|
2470
2490
|
}).catch(res => {
|
|
2471
2491
|
console.log(res);
|
|
2472
2492
|
});
|
|
@@ -2682,8 +2702,10 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2682
2702
|
"fill-selects": $props.fillSelects[field],
|
|
2683
2703
|
class: normalizeClass(_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field),
|
|
2684
2704
|
modelValue: _ctx.form_elements[field],
|
|
2685
|
-
"onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event)
|
|
2686
|
-
|
|
2705
|
+
"onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event),
|
|
2706
|
+
url: _ctx.suggests[field].url ?? false,
|
|
2707
|
+
data: _ctx.suggests[field].data ?? false
|
|
2708
|
+
}, null, 8 /* PROPS */, ["select-data", "fill-selects", "class", "modelValue", "onUpdate:modelValue", "url", "data"]))
|
|
2687
2709
|
: createCommentVNode("v-if", true),
|
|
2688
2710
|
($options.getFieldType(field) === 'text')
|
|
2689
2711
|
? withDirectives((openBlock(), createElementBlock("input", {
|
|
@@ -3098,7 +3120,7 @@ const getFieldComponent = (fieldObj)=>{
|
|
|
3098
3120
|
if(fieldObj.component){
|
|
3099
3121
|
return fieldObj.component
|
|
3100
3122
|
}
|
|
3101
|
-
const field = fieldObj.field;
|
|
3123
|
+
const field = fieldObj.field ?? fieldObj.name;
|
|
3102
3124
|
const defaultTextareas = ['message', 'meta_description', 'comment', 'call_response', 'comments', 'description'];
|
|
3103
3125
|
const defaultNumbers = ['age'];
|
|
3104
3126
|
const passwords = ['password','password_confirmation','pin'];
|
|
@@ -3116,6 +3138,9 @@ const getFieldComponent = (fieldObj)=>{
|
|
|
3116
3138
|
return props.customComponents[field]
|
|
3117
3139
|
}
|
|
3118
3140
|
if(fieldObj.type){
|
|
3141
|
+
if(fieldObj.type === 'suggest' || fieldObj.type === 'suggests'){
|
|
3142
|
+
return script$t
|
|
3143
|
+
}
|
|
3119
3144
|
return fieldObj.type === 'number' ? NumberComponent:fieldObj.type === 'textarea' ? TextAreaComponent : fieldObj.type === 'email' ? EmailComponent : fieldObj.type === 'phone' ? PhoneComponent : fieldObj.type === 'password' ? PasswordComponent:fieldObj.type === 'select' ? SelectComponent:TextComponent
|
|
3120
3145
|
}else
|
|
3121
3146
|
if(passwords.includes(field)){
|
|
@@ -3250,11 +3275,12 @@ onMounted((ev)=>{
|
|
|
3250
3275
|
props.fields && props.fields.map(field=>{
|
|
3251
3276
|
if(typeof field === 'object') {
|
|
3252
3277
|
const fieldObj = {...field};
|
|
3278
|
+
fieldObj.field = fieldObj.field ?? fieldObj.name;
|
|
3253
3279
|
// fieldObj.label && getLabel(fieldObj.field)
|
|
3254
3280
|
fieldObj.helper = fieldObj.helperText ?? fieldObj.helper;
|
|
3255
3281
|
// !fieldObj.helper && fieldObj.helperText ? fieldObj.helper = fieldObj.helperText : fieldObj.helper = getHelperText(fieldObj.field)
|
|
3256
3282
|
// fieldObj.helperText === undefined && ()
|
|
3257
|
-
fieldObj.label = fieldObj.label ?? getLabel(fieldObj.field);
|
|
3283
|
+
fieldObj.label = fieldObj.label ?? getLabel(fieldObj.field ?? fieldObj.name);
|
|
3258
3284
|
// fieldObj.placeholder && fieldObj.placeHolder && getPlaceholder(fieldObj.field)
|
|
3259
3285
|
fieldObj.value = null;
|
|
3260
3286
|
formFields.value.push(fieldObj);
|
|
@@ -4290,7 +4316,7 @@ script$c.__file = "src/lib/components/ShRange.vue";
|
|
|
4290
4316
|
|
|
4291
4317
|
var script$b = {
|
|
4292
4318
|
name: 'sh-table',
|
|
4293
|
-
props: ['endPoint', 'headers', 'query', 'pageCount', 'actions', 'hideCount', 'hideLoadMore', 'links', 'reload', 'hideSearch', 'sharedData', 'searchPlaceholder', 'event', 'displayMore', 'displayMoreBtnClass', 'moreDetailsColumns', 'moreDetailsFields', 'hasDownload', 'downloadFields', 'tableHover', 'hideIds', 'paginationStyle', 'hasRange'],
|
|
4319
|
+
props: ['endPoint', 'headers','cacheKey', 'query', 'pageCount', 'actions', 'hideCount', 'hideLoadMore', 'links', 'reload', 'hideSearch', 'sharedData', 'searchPlaceholder', 'event', 'displayMore', 'displayMoreBtnClass', 'moreDetailsColumns', 'moreDetailsFields', 'hasDownload', 'downloadFields', 'tableHover', 'hideIds', 'paginationStyle', 'hasRange'],
|
|
4294
4320
|
data() {
|
|
4295
4321
|
return {
|
|
4296
4322
|
order_by: '',
|
|
@@ -4323,6 +4349,7 @@ var script$b = {
|
|
|
4323
4349
|
if (this.headers) {
|
|
4324
4350
|
this.tableHeaders = this.headers;
|
|
4325
4351
|
}
|
|
4352
|
+
|
|
4326
4353
|
if (this.actions && this.actions.actions) {
|
|
4327
4354
|
this.actions.actions.forEach(action => {
|
|
4328
4355
|
if (action.canvasComponent) {
|
|
@@ -4330,6 +4357,10 @@ var script$b = {
|
|
|
4330
4357
|
}
|
|
4331
4358
|
});
|
|
4332
4359
|
}
|
|
4360
|
+
if(this.cacheKey){
|
|
4361
|
+
this.setCachedData();
|
|
4362
|
+
}
|
|
4363
|
+
this.reloadData();
|
|
4333
4364
|
},
|
|
4334
4365
|
methods: {
|
|
4335
4366
|
rangeChanged: function (newRange) {
|
|
@@ -4476,11 +4507,18 @@ var script$b = {
|
|
|
4476
4507
|
shRepo.swalError('Error', error);
|
|
4477
4508
|
});
|
|
4478
4509
|
},
|
|
4510
|
+
setCachedData: function () {
|
|
4511
|
+
if (this.cacheKey) {
|
|
4512
|
+
this.records = ShStorage.getItem('sh_table_cache_' + this.cacheKey, []);
|
|
4513
|
+
}
|
|
4514
|
+
},
|
|
4479
4515
|
reloadData: function (page, append) {
|
|
4480
4516
|
if (typeof page !== 'undefined') {
|
|
4481
4517
|
this.page = page;
|
|
4482
4518
|
}
|
|
4483
|
-
if (
|
|
4519
|
+
if (this.cacheKey && this.records && this.records.length > 0 && this.page < 2 ) {
|
|
4520
|
+
this.loading = 'done';
|
|
4521
|
+
} else if(!append){
|
|
4484
4522
|
this.loading = 'loading';
|
|
4485
4523
|
}
|
|
4486
4524
|
const data = {
|
|
@@ -4508,6 +4546,9 @@ var script$b = {
|
|
|
4508
4546
|
this.$emit('dataReloaded', this.pagination_data);
|
|
4509
4547
|
this.loading = 'done';
|
|
4510
4548
|
const response = req.data.data;
|
|
4549
|
+
if(this.page < 2 && this.cacheKey){
|
|
4550
|
+
ShStorage.setItem('sh_table_cache_' + this.cacheKey, response.data);
|
|
4551
|
+
}
|
|
4511
4552
|
this.pagination_data = {
|
|
4512
4553
|
current: response.current_page,
|
|
4513
4554
|
start: response.from,
|
|
@@ -4553,9 +4594,6 @@ var script$b = {
|
|
|
4553
4594
|
this.reloadData();
|
|
4554
4595
|
}
|
|
4555
4596
|
},
|
|
4556
|
-
created() {
|
|
4557
|
-
this.reloadData();
|
|
4558
|
-
},
|
|
4559
4597
|
components: {
|
|
4560
4598
|
ShRange: script$c,
|
|
4561
4599
|
ShSilentAction: script$d,
|