@iankibetsh/shframework 5.0.6 → 5.0.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
@@ -166,6 +166,9 @@ function getShConfig(key = null, def = ''){
166
166
  }
167
167
 
168
168
  function showToast(message, toastType, config){
169
+ if(!message){
170
+ return
171
+ }
169
172
  const mixinConfig = {
170
173
  toast: true,
171
174
  position: 'top-end',
@@ -222,22 +225,41 @@ async function runPlainRequest(url, message, title, data){
222
225
  reverseButtons: true,
223
226
  showLoaderOnConfirm: true,
224
227
  preConfirm: () => {
225
- return shApis.doPost(url, data).then(function (response){
226
- return {
227
- response: response.data,
228
- success: true
229
- }
230
- })
228
+ return shApis.doPost(url, data)
229
+ .then(response => {
230
+ return {
231
+ response: response.data,
232
+ success: true
233
+ };
234
+ })
231
235
  .catch(error => {
232
236
  return {
233
237
  success: false,
234
238
  error: error,
235
239
  message: error.message
236
- }
237
- })
240
+ };
241
+ });
238
242
  },
239
243
  allowOutsideClick: () => !Swal__default["default"].isLoading()
240
- })
244
+ }).then((result) => {
245
+ if (result.isDismissed) {
246
+ // Handle the cancel action
247
+ throw new Error();
248
+ }
249
+
250
+ // Continue processing on confirm
251
+ if (result.isConfirmed) {
252
+ const { success, response, error } = result.value;
253
+ if (!success) {
254
+ // Handle the API error
255
+ console.error('API error:', error);
256
+ throw new Error('API request failed: ' + error.message);
257
+ }
258
+ // Handle the successful response
259
+ return response;
260
+ }
261
+ });
262
+
241
263
  }
242
264
  async function confirmAction(title,message){
243
265
  if (typeof title === 'undefined') {
@@ -2192,6 +2214,7 @@ function updateModelValue(){
2192
2214
  if(selectedItems.length === 0) {
2193
2215
  if(props.allowUserInput){
2194
2216
  emit('update:modelValue', searchText.value);
2217
+ showDropDown();
2195
2218
  return
2196
2219
  } else {
2197
2220
  emit('update:modelValue', null);
package/dist/library.mjs CHANGED
@@ -154,6 +154,9 @@ function getShConfig(key = null, def = ''){
154
154
  }
155
155
 
156
156
  function showToast(message, toastType, config){
157
+ if(!message){
158
+ return
159
+ }
157
160
  const mixinConfig = {
158
161
  toast: true,
159
162
  position: 'top-end',
@@ -210,22 +213,41 @@ async function runPlainRequest(url, message, title, data){
210
213
  reverseButtons: true,
211
214
  showLoaderOnConfirm: true,
212
215
  preConfirm: () => {
213
- return shApis.doPost(url, data).then(function (response){
214
- return {
215
- response: response.data,
216
- success: true
217
- }
218
- })
216
+ return shApis.doPost(url, data)
217
+ .then(response => {
218
+ return {
219
+ response: response.data,
220
+ success: true
221
+ };
222
+ })
219
223
  .catch(error => {
220
224
  return {
221
225
  success: false,
222
226
  error: error,
223
227
  message: error.message
224
- }
225
- })
228
+ };
229
+ });
226
230
  },
227
231
  allowOutsideClick: () => !Swal.isLoading()
228
- })
232
+ }).then((result) => {
233
+ if (result.isDismissed) {
234
+ // Handle the cancel action
235
+ throw new Error();
236
+ }
237
+
238
+ // Continue processing on confirm
239
+ if (result.isConfirmed) {
240
+ const { success, response, error } = result.value;
241
+ if (!success) {
242
+ // Handle the API error
243
+ console.error('API error:', error);
244
+ throw new Error('API request failed: ' + error.message);
245
+ }
246
+ // Handle the successful response
247
+ return response;
248
+ }
249
+ });
250
+
229
251
  }
230
252
  async function confirmAction(title,message){
231
253
  if (typeof title === 'undefined') {
@@ -2180,6 +2202,7 @@ function updateModelValue(){
2180
2202
  if(selectedItems.length === 0) {
2181
2203
  if(props.allowUserInput){
2182
2204
  emit('update:modelValue', searchText.value);
2205
+ showDropDown();
2183
2206
  return
2184
2207
  } else {
2185
2208
  emit('update:modelValue', null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "5.0.6",
3
+ "version": "5.0.8",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",