@iankibetsh/shframework 1.1.4 → 1.1.6

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
@@ -284,8 +284,12 @@ async function shSwalLogout () {
284
284
  }).then((result) => {
285
285
  if (result.isConfirmed) {
286
286
  logoutUser();
287
- } else if (result.isDenied) {
288
- updateSession();
287
+ } else {
288
+ window.ShConfirmation = null;
289
+ clearInterval(window.shInterval);
290
+ const timeNow = moment__default["default"]().toISOString();
291
+ ShStorage.setItem('last_activity', timeNow);
292
+ startSession();
289
293
  }
290
294
  })
291
295
  }
@@ -307,7 +311,6 @@ const updateSession = () =>{
307
311
  }
308
312
  const timeNow = moment__default["default"]().toISOString();
309
313
  ShStorage.setItem('last_activity', timeNow);
310
- window.ShConfirmation = null;
311
314
  };
312
315
 
313
316
  let apiUrl = undefined.VITE_APP_API_URL;
@@ -2195,7 +2198,8 @@ var script$d = {
2195
2198
  'files',
2196
2199
  'phones',
2197
2200
  'numbers',
2198
- 'customComponent'
2201
+ 'customComponent',
2202
+ 'successMessage'
2199
2203
  ],
2200
2204
  data: function () {
2201
2205
  return {
@@ -2384,6 +2388,11 @@ var script$d = {
2384
2388
  Object.keys(this.form_files).forEach(key => {
2385
2389
  this.form_errors[key] = null;
2386
2390
  });
2391
+ this.$emit('formSubmitted',res.data);
2392
+ this.$emit('success',res.data);
2393
+ if(this.successMessage){
2394
+ shRepo.showToast(this.successMessage);
2395
+ }
2387
2396
  if (this.successCallback) {
2388
2397
  if (typeof this.successCallback === 'function') {
2389
2398
  this.successCallback(res.data);
@@ -2897,8 +2906,9 @@ var script$a = {
2897
2906
  'files',
2898
2907
  'phones',
2899
2908
  'numbers',
2900
- 'customComponent','modalTitle','class'],
2901
- setup(__props) {
2909
+ 'customComponent','modalTitle','class','successMessage'],
2910
+ emits: ['success'],
2911
+ setup(__props, { emit }) {
2902
2912
 
2903
2913
  const props = __props;
2904
2914
 
@@ -2907,7 +2917,9 @@ const props = __props;
2907
2917
  vue.ref(props);
2908
2918
  let btnClass=props.class;
2909
2919
  const modalId = 'rand' + (Math.random() + 1).toString(36).substring(2);
2910
-
2920
+ const success = (res)=>{
2921
+ emit('success',res);
2922
+ };
2911
2923
 
2912
2924
  return (_ctx, _cache) => {
2913
2925
  return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
@@ -2923,7 +2935,7 @@ return (_ctx, _cache) => {
2923
2935
  "modal-title": __props.modalTitle
2924
2936
  }, {
2925
2937
  default: vue.withCtx(() => [
2926
- vue.createVNode(script$d, vue.normalizeProps(vue.guardReactiveProps(props)), null, 16 /* FULL_PROPS */)
2938
+ vue.createVNode(script$d, vue.mergeProps({ onSuccess: success }, props), null, 16 /* FULL_PROPS */)
2927
2939
  ]),
2928
2940
  _: 1 /* STABLE */
2929
2941
  }, 8 /* PROPS */, ["modal-title"])
@@ -3158,7 +3170,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3158
3170
  : vue.createCommentVNode("v-if", true)
3159
3171
  ]))
3160
3172
  : (vue.openBlock(), vue.createElementBlock("div", _hoisted_16$1, [
3161
- (this.pagination_data.loading === 1 && $props.loadMore)
3173
+ (this.pagination_data.loading === 1 && $props.loadMore && $props.hideLoadMore)
3162
3174
  ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_17$1, _hoisted_19$1))
3163
3175
  : vue.createCommentVNode("v-if", true),
3164
3176
  (!$props.hideCount)
@@ -3200,36 +3212,56 @@ var script$7 = {
3200
3212
  loadingMessage: {
3201
3213
  type: String,
3202
3214
  default: 'Processing'
3215
+ },
3216
+ successMessage: {
3217
+ type: String,
3218
+ default: 'Action Successful'
3219
+ },
3220
+ failMessage: {
3221
+ type: String,
3222
+ default: 'Action failed'
3203
3223
  }
3204
3224
  },
3205
- emits: ['actionSuccessful', 'actionFailed','actionCanceled'],
3225
+ emits: ['actionSuccessful', 'actionFailed','success','actionCanceled'],
3206
3226
  setup(__props, { emit }) {
3207
3227
 
3208
3228
  const props = __props;
3209
3229
 
3210
3230
 
3231
+
3211
3232
  const processing = vue.ref(false);
3212
3233
 
3234
+ const actionSuccessful = (res)=>{
3235
+ processing.value = false;
3236
+ res.actionType = 'silentAction';
3237
+ emit('actionSuccessful',res);
3238
+ emit('success',res);
3239
+ shRepo.showToast(res.message ?? props.successMessage);
3240
+ };
3213
3241
 
3242
+ const actionFailed = reason =>{
3243
+ console.log(reason);
3244
+ processing.value = false;
3245
+ reason.actionType = 'silentAction';
3246
+ emit('actionFailed', reason);
3247
+ shRepo.showToast(reason.value.error.message ?? props.failMessage,'error');
3248
+ };
3214
3249
  function runAction () {
3215
3250
  processing.value = true;
3216
3251
  shRepo.runPlainRequest(props.url, props.message, props.title, props.data).then(res => {
3217
3252
  if(res.isConfirmed){
3218
3253
  const value = res.value;
3219
- if(value.status){
3220
- emit('actionSuccessful', res);
3221
- processing.value = false;
3254
+ if(value.success){
3255
+ actionSuccessful(res.value.response);
3222
3256
  } else {
3223
- emit('actionFailed', value);
3224
- processing.value = false;
3257
+ actionFailed(res);
3225
3258
  }
3226
3259
  } else {
3227
3260
  emit('actionCanceled');
3228
3261
  processing.value = false;
3229
3262
  }
3230
3263
  }).catch(ex => {
3231
- emit('actionFailed', ex);
3232
- processing.value = false;
3264
+ actionFailed(ex);
3233
3265
  });
3234
3266
  }
3235
3267
 
@@ -3269,6 +3301,14 @@ var script$6 = {
3269
3301
  type: String,
3270
3302
  default: 'Processing'
3271
3303
  },
3304
+ successMessage: {
3305
+ type: String,
3306
+ default: 'Action Successful'
3307
+ },
3308
+ failMessage: {
3309
+ type: String,
3310
+ default: 'Action failed'
3311
+ },
3272
3312
  method: {
3273
3313
  type: String,
3274
3314
  default: 'POST'
@@ -3278,7 +3318,7 @@ var script$6 = {
3278
3318
  required: true
3279
3319
  }
3280
3320
  },
3281
- emits: ['actionSuccessful','actionFailed'],
3321
+ emits: ['actionSuccessful','actionFailed','success'],
3282
3322
  setup(__props, { emit }) {
3283
3323
 
3284
3324
  const props = __props;
@@ -3286,25 +3326,37 @@ const props = __props;
3286
3326
 
3287
3327
  const processing = vue.ref(false);
3288
3328
 
3329
+ const actionSuccessful = (res)=>{
3330
+ processing.value = false;
3331
+ res.actionType = 'silentAction';
3332
+ console.log(res.data,props.successMessage);
3333
+ emit('actionSuccessful',res);
3334
+ emit('success',res);
3335
+ shRepo.showToast(res.data.message ?? props.successMessage);
3336
+ };
3289
3337
 
3338
+ const actionFailed = reason =>{
3339
+ processing.value = false;
3340
+ console.log(reason);
3341
+ shRepo.showToast('Failed');
3342
+ reason.actionType = 'silentAction';
3343
+ emit('actionFailed', reason);
3344
+ shRepo.showToast(reason.message ?? props.failMessage,'error');
3345
+ };
3290
3346
  function runAction(){
3291
3347
  processing.value = true;
3292
3348
  if(props.method === 'POST'){
3293
3349
  shApis.doPost(props.url,props.data).then(res=>{
3294
- emit('actionSuccessful',res);
3295
- processing.value = false;
3350
+ actionSuccessful(res);
3296
3351
  }).catch(reason=>{
3297
- emit('actionFailed', reason);
3298
- processing.value = false;
3352
+ actionFailed(reason);
3299
3353
  });
3300
3354
  }
3301
3355
  if(props.method === 'GET'){
3302
3356
  shApis.doGet(props.url,props.data).then(res=>{
3303
- emit('actionSuccessful',res);
3304
- processing.value = false;
3357
+ actionSuccessful(res);
3305
3358
  }).catch(reason=>{
3306
- emit('actionFailed', reason);
3307
- processing.value = false;
3359
+ actionFailed(reason);
3308
3360
  });
3309
3361
  }
3310
3362
  }
@@ -3966,7 +4018,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3966
4018
  ]),
3967
4019
  _: 2 /* DYNAMIC */
3968
4020
  }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onActionSuccessful", "onActionFailed", "onActionCanceled", "loading-message", "class", "url"]))
3969
- : (act.canvasId)
4021
+ : (act.canvasId || act.type === 'offcanvas')
3970
4022
  ? (vue.openBlock(), vue.createElementBlock("a", {
3971
4023
  key: 2,
3972
4024
  href: '#' + act.canvasId,
@@ -4417,6 +4469,9 @@ const useUserStore = pinia.defineStore('user-store', {
4417
4469
  }
4418
4470
  ShStorage.setItem('user',user);
4419
4471
  user.isAllowedTo = function (slug) {
4472
+ if(!slug){
4473
+ return true
4474
+ }
4420
4475
  if (this.permissions) {
4421
4476
  let permissions = [];
4422
4477
  if (typeof this.permissions === 'string') {
@@ -4596,6 +4651,7 @@ let getModule = vue.computed(()=>{
4596
4651
 
4597
4652
  function moduleAdded () {
4598
4653
  shRepo.showToast('module added successfully', 'success');
4654
+ userStore.setUser();
4599
4655
  reload.value++;
4600
4656
  }
4601
4657
  function showModule (module) {
@@ -4654,6 +4710,7 @@ function submitPermissions() {
4654
4710
  shApis.doPost('admin/departments/department/permissions/' + getModule.value.id, data)
4655
4711
  .then(res => {
4656
4712
  reload.value++;
4713
+ userStore.setUser();
4657
4714
  shRepo.showToast('Permissions updated', 'success');
4658
4715
  });
4659
4716
  }
package/dist/library.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import Axios from 'axios';
2
2
  import moment from 'moment';
3
3
  import Swal from 'sweetalert2';
4
- import { inject, openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, ref, onMounted, unref, normalizeClass, createBlock, resolveDynamicComponent, renderSlot, normalizeProps, guardReactiveProps, withCtx, createStaticVNode, mergeProps, shallowRef, computed, isRef, vModelCheckbox, watch, pushScopeId, popScopeId } from 'vue';
4
+ import { inject, openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, ref, onMounted, unref, normalizeClass, createBlock, resolveDynamicComponent, renderSlot, normalizeProps, guardReactiveProps, withCtx, mergeProps, createStaticVNode, shallowRef, computed, isRef, vModelCheckbox, watch, pushScopeId, popScopeId } from 'vue';
5
5
  import NProgress from 'nprogress';
6
6
  import Editor from '@tinymce/tinymce-vue';
7
7
  import { defineStore, storeToRefs } from 'pinia';
@@ -272,8 +272,12 @@ async function shSwalLogout () {
272
272
  }).then((result) => {
273
273
  if (result.isConfirmed) {
274
274
  logoutUser();
275
- } else if (result.isDenied) {
276
- updateSession();
275
+ } else {
276
+ window.ShConfirmation = null;
277
+ clearInterval(window.shInterval);
278
+ const timeNow = moment().toISOString();
279
+ ShStorage.setItem('last_activity', timeNow);
280
+ startSession();
277
281
  }
278
282
  })
279
283
  }
@@ -295,7 +299,6 @@ const updateSession = () =>{
295
299
  }
296
300
  const timeNow = moment().toISOString();
297
301
  ShStorage.setItem('last_activity', timeNow);
298
- window.ShConfirmation = null;
299
302
  };
300
303
 
301
304
  let apiUrl = import.meta.env.VITE_APP_API_URL;
@@ -2183,7 +2186,8 @@ var script$d = {
2183
2186
  'files',
2184
2187
  'phones',
2185
2188
  'numbers',
2186
- 'customComponent'
2189
+ 'customComponent',
2190
+ 'successMessage'
2187
2191
  ],
2188
2192
  data: function () {
2189
2193
  return {
@@ -2372,6 +2376,11 @@ var script$d = {
2372
2376
  Object.keys(this.form_files).forEach(key => {
2373
2377
  this.form_errors[key] = null;
2374
2378
  });
2379
+ this.$emit('formSubmitted',res.data);
2380
+ this.$emit('success',res.data);
2381
+ if(this.successMessage){
2382
+ shRepo.showToast(this.successMessage);
2383
+ }
2375
2384
  if (this.successCallback) {
2376
2385
  if (typeof this.successCallback === 'function') {
2377
2386
  this.successCallback(res.data);
@@ -2885,8 +2894,9 @@ var script$a = {
2885
2894
  'files',
2886
2895
  'phones',
2887
2896
  'numbers',
2888
- 'customComponent','modalTitle','class'],
2889
- setup(__props) {
2897
+ 'customComponent','modalTitle','class','successMessage'],
2898
+ emits: ['success'],
2899
+ setup(__props, { emit }) {
2890
2900
 
2891
2901
  const props = __props;
2892
2902
 
@@ -2895,7 +2905,9 @@ const props = __props;
2895
2905
  ref(props);
2896
2906
  let btnClass=props.class;
2897
2907
  const modalId = 'rand' + (Math.random() + 1).toString(36).substring(2);
2898
-
2908
+ const success = (res)=>{
2909
+ emit('success',res);
2910
+ };
2899
2911
 
2900
2912
  return (_ctx, _cache) => {
2901
2913
  return (openBlock(), createElementBlock(Fragment, null, [
@@ -2911,7 +2923,7 @@ return (_ctx, _cache) => {
2911
2923
  "modal-title": __props.modalTitle
2912
2924
  }, {
2913
2925
  default: withCtx(() => [
2914
- createVNode(script$d, normalizeProps(guardReactiveProps(props)), null, 16 /* FULL_PROPS */)
2926
+ createVNode(script$d, mergeProps({ onSuccess: success }, props), null, 16 /* FULL_PROPS */)
2915
2927
  ]),
2916
2928
  _: 1 /* STABLE */
2917
2929
  }, 8 /* PROPS */, ["modal-title"])
@@ -3146,7 +3158,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3146
3158
  : createCommentVNode("v-if", true)
3147
3159
  ]))
3148
3160
  : (openBlock(), createElementBlock("div", _hoisted_16$1, [
3149
- (this.pagination_data.loading === 1 && $props.loadMore)
3161
+ (this.pagination_data.loading === 1 && $props.loadMore && $props.hideLoadMore)
3150
3162
  ? (openBlock(), createElementBlock("div", _hoisted_17$1, _hoisted_19$1))
3151
3163
  : createCommentVNode("v-if", true),
3152
3164
  (!$props.hideCount)
@@ -3188,36 +3200,56 @@ var script$7 = {
3188
3200
  loadingMessage: {
3189
3201
  type: String,
3190
3202
  default: 'Processing'
3203
+ },
3204
+ successMessage: {
3205
+ type: String,
3206
+ default: 'Action Successful'
3207
+ },
3208
+ failMessage: {
3209
+ type: String,
3210
+ default: 'Action failed'
3191
3211
  }
3192
3212
  },
3193
- emits: ['actionSuccessful', 'actionFailed','actionCanceled'],
3213
+ emits: ['actionSuccessful', 'actionFailed','success','actionCanceled'],
3194
3214
  setup(__props, { emit }) {
3195
3215
 
3196
3216
  const props = __props;
3197
3217
 
3198
3218
 
3219
+
3199
3220
  const processing = ref(false);
3200
3221
 
3222
+ const actionSuccessful = (res)=>{
3223
+ processing.value = false;
3224
+ res.actionType = 'silentAction';
3225
+ emit('actionSuccessful',res);
3226
+ emit('success',res);
3227
+ shRepo.showToast(res.message ?? props.successMessage);
3228
+ };
3201
3229
 
3230
+ const actionFailed = reason =>{
3231
+ console.log(reason);
3232
+ processing.value = false;
3233
+ reason.actionType = 'silentAction';
3234
+ emit('actionFailed', reason);
3235
+ shRepo.showToast(reason.value.error.message ?? props.failMessage,'error');
3236
+ };
3202
3237
  function runAction () {
3203
3238
  processing.value = true;
3204
3239
  shRepo.runPlainRequest(props.url, props.message, props.title, props.data).then(res => {
3205
3240
  if(res.isConfirmed){
3206
3241
  const value = res.value;
3207
- if(value.status){
3208
- emit('actionSuccessful', res);
3209
- processing.value = false;
3242
+ if(value.success){
3243
+ actionSuccessful(res.value.response);
3210
3244
  } else {
3211
- emit('actionFailed', value);
3212
- processing.value = false;
3245
+ actionFailed(res);
3213
3246
  }
3214
3247
  } else {
3215
3248
  emit('actionCanceled');
3216
3249
  processing.value = false;
3217
3250
  }
3218
3251
  }).catch(ex => {
3219
- emit('actionFailed', ex);
3220
- processing.value = false;
3252
+ actionFailed(ex);
3221
3253
  });
3222
3254
  }
3223
3255
 
@@ -3257,6 +3289,14 @@ var script$6 = {
3257
3289
  type: String,
3258
3290
  default: 'Processing'
3259
3291
  },
3292
+ successMessage: {
3293
+ type: String,
3294
+ default: 'Action Successful'
3295
+ },
3296
+ failMessage: {
3297
+ type: String,
3298
+ default: 'Action failed'
3299
+ },
3260
3300
  method: {
3261
3301
  type: String,
3262
3302
  default: 'POST'
@@ -3266,7 +3306,7 @@ var script$6 = {
3266
3306
  required: true
3267
3307
  }
3268
3308
  },
3269
- emits: ['actionSuccessful','actionFailed'],
3309
+ emits: ['actionSuccessful','actionFailed','success'],
3270
3310
  setup(__props, { emit }) {
3271
3311
 
3272
3312
  const props = __props;
@@ -3274,25 +3314,37 @@ const props = __props;
3274
3314
 
3275
3315
  const processing = ref(false);
3276
3316
 
3317
+ const actionSuccessful = (res)=>{
3318
+ processing.value = false;
3319
+ res.actionType = 'silentAction';
3320
+ console.log(res.data,props.successMessage);
3321
+ emit('actionSuccessful',res);
3322
+ emit('success',res);
3323
+ shRepo.showToast(res.data.message ?? props.successMessage);
3324
+ };
3277
3325
 
3326
+ const actionFailed = reason =>{
3327
+ processing.value = false;
3328
+ console.log(reason);
3329
+ shRepo.showToast('Failed');
3330
+ reason.actionType = 'silentAction';
3331
+ emit('actionFailed', reason);
3332
+ shRepo.showToast(reason.message ?? props.failMessage,'error');
3333
+ };
3278
3334
  function runAction(){
3279
3335
  processing.value = true;
3280
3336
  if(props.method === 'POST'){
3281
3337
  shApis.doPost(props.url,props.data).then(res=>{
3282
- emit('actionSuccessful',res);
3283
- processing.value = false;
3338
+ actionSuccessful(res);
3284
3339
  }).catch(reason=>{
3285
- emit('actionFailed', reason);
3286
- processing.value = false;
3340
+ actionFailed(reason);
3287
3341
  });
3288
3342
  }
3289
3343
  if(props.method === 'GET'){
3290
3344
  shApis.doGet(props.url,props.data).then(res=>{
3291
- emit('actionSuccessful',res);
3292
- processing.value = false;
3345
+ actionSuccessful(res);
3293
3346
  }).catch(reason=>{
3294
- emit('actionFailed', reason);
3295
- processing.value = false;
3347
+ actionFailed(reason);
3296
3348
  });
3297
3349
  }
3298
3350
  }
@@ -3954,7 +4006,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3954
4006
  ]),
3955
4007
  _: 2 /* DYNAMIC */
3956
4008
  }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onActionSuccessful", "onActionFailed", "onActionCanceled", "loading-message", "class", "url"]))
3957
- : (act.canvasId)
4009
+ : (act.canvasId || act.type === 'offcanvas')
3958
4010
  ? (openBlock(), createElementBlock("a", {
3959
4011
  key: 2,
3960
4012
  href: '#' + act.canvasId,
@@ -4405,6 +4457,9 @@ const useUserStore = defineStore('user-store', {
4405
4457
  }
4406
4458
  ShStorage.setItem('user',user);
4407
4459
  user.isAllowedTo = function (slug) {
4460
+ if(!slug){
4461
+ return true
4462
+ }
4408
4463
  if (this.permissions) {
4409
4464
  let permissions = [];
4410
4465
  if (typeof this.permissions === 'string') {
@@ -4584,6 +4639,7 @@ let getModule = computed(()=>{
4584
4639
 
4585
4640
  function moduleAdded () {
4586
4641
  shRepo.showToast('module added successfully', 'success');
4642
+ userStore.setUser();
4587
4643
  reload.value++;
4588
4644
  }
4589
4645
  function showModule (module) {
@@ -4642,6 +4698,7 @@ function submitPermissions() {
4642
4698
  shApis.doPost('admin/departments/department/permissions/' + getModule.value.id, data)
4643
4699
  .then(res => {
4644
4700
  reload.value++;
4701
+ userStore.setUser();
4645
4702
  shRepo.showToast('Permissions updated', 'success');
4646
4703
  });
4647
4704
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",