@iankibetsh/shframework 4.1.5 → 4.1.7

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.
@@ -63,6 +63,21 @@
63
63
  color: white;
64
64
  }
65
65
 
66
+ .sh-selected-item{
67
+ line-height: unset!important;
68
+ }
69
+ .sh-suggestion-input{
70
+ padding: 0.375rem 0.75rem;
71
+ }
72
+ .sh-suggest{
73
+ margin-bottom: 1rem;
74
+ }
75
+ .sh-suggest-control::after{
76
+ margin-top: auto;
77
+ margin-bottom: auto;
78
+ margin-right: 0.255em;
79
+ }
80
+
66
81
  .permissions-main {
67
82
  background: #edeff2;
68
83
  }
@@ -95,21 +110,6 @@
95
110
  flex-grow: 1;
96
111
  }
97
112
 
98
- .sh-selected-item{
99
- line-height: unset!important;
100
- }
101
- .sh-suggestion-input{
102
- padding: 0.375rem 0.75rem;
103
- }
104
- .sh-suggest{
105
- margin-bottom: 1rem;
106
- }
107
- .sh-suggest-control::after{
108
- margin-top: auto;
109
- margin-bottom: auto;
110
- margin-right: 0.255em;
111
- }
112
-
113
113
  .callout{
114
114
  --bs-link-color-rgb: 110,168,254;
115
115
  --bs-code-color: #e685b5;
package/dist/library.js CHANGED
@@ -9,8 +9,8 @@ var bootstrap = require('bootstrap');
9
9
  var NProgress = require('nprogress');
10
10
  var vue = require('vue');
11
11
  var _ = require('lodash');
12
- var vueRouter = require('vue-router');
13
12
  var pinia = require('pinia');
13
+ var vueRouter = require('vue-router');
14
14
 
15
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
16
 
@@ -3754,6 +3754,102 @@ script$g.render = render$1;
3754
3754
  script$g.__scopeId = "data-v-55cf77fb";
3755
3755
  script$g.__file = "src/lib/components/others/NoRecords.vue";
3756
3756
 
3757
+ const useUserStore = pinia.defineStore('user-store', {
3758
+ state: () => ({
3759
+ user: null,
3760
+ role: null,
3761
+ permissions: null,
3762
+ menus: [],
3763
+ loggedOut: false
3764
+ }),
3765
+ actions: {
3766
+ setUser (){
3767
+ let user = null;
3768
+ try {
3769
+ user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
3770
+ } catch (error) {
3771
+ user= null;
3772
+ }
3773
+ if (user) {
3774
+ user.isAllowedTo = function (slug) {
3775
+ if (this.permissions) {
3776
+ let permissions = [];
3777
+ if (typeof this.permissions === 'string') {
3778
+ permissions = this.permissions;
3779
+ } else {
3780
+ permissions = this.permissions;
3781
+ }
3782
+ return permissions.includes(slug)
3783
+ }
3784
+ return false
3785
+ };
3786
+ }
3787
+ this.user = user;
3788
+ shApis.doGet('auth/user').then(res => {
3789
+ let user = res.data.user;
3790
+ if (typeof(user) === 'undefined') {
3791
+ user = res.data;
3792
+ }
3793
+ ShStorage.setItem('user',user);
3794
+ user.signOut = this.signOut;
3795
+ user.logout = this.signOut;
3796
+ user.logOut = this.signOut;
3797
+ user.isAllowedTo = function (slug) {
3798
+ if(!slug){
3799
+ return true
3800
+ }
3801
+ if (this.permissions) {
3802
+ let permissions = [];
3803
+ if (typeof this.permissions === 'string') {
3804
+ permissions = this.permissions;
3805
+ } else {
3806
+ permissions = this.permissions;
3807
+ }
3808
+ return permissions.includes(slug)
3809
+ }
3810
+ return false
3811
+ };
3812
+ this.user = user;
3813
+ }).catch((reason) => {
3814
+ if (reason.response && reason.response.status) {
3815
+ if(reason.response.status === 401) {
3816
+ ShStorage.setItem('user',null);
3817
+ this.user = null;
3818
+ }
3819
+ this.loggedOut = true;
3820
+ }
3821
+ });
3822
+ if (this.user) {
3823
+ if (typeof this.user.permissions === 'string') {
3824
+ this.permissions = this.user.permissions;
3825
+ } else {
3826
+ this.permissions = this.user.permissions;
3827
+ }
3828
+ }
3829
+ const timeNow = moment__default["default"]().toISOString();
3830
+ ShStorage.setItem('session_start',timeNow);
3831
+ },
3832
+ signOut () {
3833
+ shRepo.signOutUser();
3834
+ },
3835
+ logOut () {
3836
+ this.signOut();
3837
+ },
3838
+ getUser () {
3839
+ this.setUser();
3840
+ },
3841
+ setAccessToken (accessToken) {
3842
+ ShStorage.setItem('access_token', accessToken);
3843
+ this.setUser();
3844
+ }
3845
+ },
3846
+ getters: {
3847
+ userId (state) {
3848
+ return state.user === null ? null:state.user.id
3849
+ }
3850
+ }
3851
+ });
3852
+
3757
3853
  var script$f = {
3758
3854
  name: 'Pagination',
3759
3855
  props: ['pagination_data', 'loadMore', 'hideCount', 'hideLoadMore', 'paginationStyle'],
@@ -4815,6 +4911,8 @@ var script$b = /*#__PURE__*/Object.assign(__default__, {
4815
4911
 
4816
4912
  const noRecordsComponent = vue.inject('noRecordsComponent', script$g);
4817
4913
 
4914
+ const {user} = pinia.storeToRefs(useUserStore());
4915
+
4818
4916
  return (_ctx, _cache) => {
4819
4917
  const _component_router_link = vue.resolveComponent("router-link");
4820
4918
 
@@ -4906,7 +5004,7 @@ return (_ctx, _cache) => {
4906
5004
  : vue.createCommentVNode("v-if", true),
4907
5005
  (_ctx.loading === 'done' || __props.cacheKey)
4908
5006
  ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
4909
- (_ctx.records.length === 0)
5007
+ (!_ctx.records || _ctx.records.length === 0)
4910
5008
  ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(noRecordsComponent)), { key: 0 }, {
4911
5009
  default: vue.withCtx(() => [
4912
5010
  _hoisted_21,
@@ -5021,7 +5119,7 @@ return (_ctx, _cache) => {
5021
5119
  return (vue.openBlock(), vue.createElementBlock(vue.Fragment, {
5022
5120
  key: act.path
5023
5121
  }, [
5024
- (!act.permission || _ctx.user.isAllowedTo(act.permission))
5122
+ (!act.permission || vue.unref(user).isAllowedTo(act.permission))
5025
5123
  ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
5026
5124
  (!act.validator || act.validator(record))
5027
5125
  ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
@@ -5191,7 +5289,7 @@ return (_ctx, _cache) => {
5191
5289
  return (vue.openBlock(), vue.createElementBlock(vue.Fragment, {
5192
5290
  key: act.path
5193
5291
  }, [
5194
- (!act.permission || _ctx.user.isAllowedTo(act.permission))
5292
+ (!act.permission || vue.unref(user).isAllowedTo(act.permission))
5195
5293
  ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
5196
5294
  (!act.validator || act.validator(record))
5197
5295
  ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
@@ -5576,102 +5674,6 @@ return (_ctx, _cache) => {
5576
5674
 
5577
5675
  script$7.__file = "src/lib/components/ShCanvasBtn.vue";
5578
5676
 
5579
- const useUserStore = pinia.defineStore('user-store', {
5580
- state: () => ({
5581
- user: null,
5582
- role: null,
5583
- permissions: null,
5584
- menus: [],
5585
- loggedOut: false
5586
- }),
5587
- actions: {
5588
- setUser (){
5589
- let user = null;
5590
- try {
5591
- user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
5592
- } catch (error) {
5593
- user= null;
5594
- }
5595
- if (user) {
5596
- user.isAllowedTo = function (slug) {
5597
- if (this.permissions) {
5598
- let permissions = [];
5599
- if (typeof this.permissions === 'string') {
5600
- permissions = this.permissions;
5601
- } else {
5602
- permissions = this.permissions;
5603
- }
5604
- return permissions.includes(slug)
5605
- }
5606
- return false
5607
- };
5608
- }
5609
- this.user = user;
5610
- shApis.doGet('auth/user').then(res => {
5611
- let user = res.data.user;
5612
- if (typeof(user) === 'undefined') {
5613
- user = res.data;
5614
- }
5615
- ShStorage.setItem('user',user);
5616
- user.signOut = this.signOut;
5617
- user.logout = this.signOut;
5618
- user.logOut = this.signOut;
5619
- user.isAllowedTo = function (slug) {
5620
- if(!slug){
5621
- return true
5622
- }
5623
- if (this.permissions) {
5624
- let permissions = [];
5625
- if (typeof this.permissions === 'string') {
5626
- permissions = this.permissions;
5627
- } else {
5628
- permissions = this.permissions;
5629
- }
5630
- return permissions.includes(slug)
5631
- }
5632
- return false
5633
- };
5634
- this.user = user;
5635
- }).catch((reason) => {
5636
- if (reason.response && reason.response.status) {
5637
- if(reason.response.status === 401) {
5638
- ShStorage.setItem('user',null);
5639
- this.user = null;
5640
- }
5641
- this.loggedOut = true;
5642
- }
5643
- });
5644
- if (this.user) {
5645
- if (typeof this.user.permissions === 'string') {
5646
- this.permissions = this.user.permissions;
5647
- } else {
5648
- this.permissions = this.user.permissions;
5649
- }
5650
- }
5651
- const timeNow = moment__default["default"]().toISOString();
5652
- ShStorage.setItem('session_start',timeNow);
5653
- },
5654
- signOut () {
5655
- shRepo.signOutUser();
5656
- },
5657
- logOut () {
5658
- this.signOut();
5659
- },
5660
- getUser () {
5661
- this.setUser();
5662
- },
5663
- setAccessToken (accessToken) {
5664
- ShStorage.setItem('access_token', accessToken);
5665
- this.setUser();
5666
- }
5667
- },
5668
- getters: {
5669
- userId (state) {
5670
- return state.user === null ? null:state.user.id
5671
- }
5672
- }
5673
- });
5674
-
5675
5677
  const _withScopeId$1 = n => (vue.pushScopeId("data-v-0d4fa0ac"),n=n(),vue.popScopeId(),n);
5676
5678
  const _hoisted_1$4 = { class: "row permissions-main d-flex" };
5677
5679
  const _hoisted_2$3 = {
package/dist/library.mjs CHANGED
@@ -5,8 +5,8 @@ import { Modal, Offcanvas } from 'bootstrap';
5
5
  import NProgress from 'nprogress';
6
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';
7
7
  import _ from 'lodash';
8
- import { useRoute, useRouter } from 'vue-router';
9
8
  import { defineStore, storeToRefs } from 'pinia';
9
+ import { useRoute, useRouter } from 'vue-router';
10
10
 
11
11
  function setItem (key, value) {
12
12
  let toStore = value;
@@ -3742,6 +3742,102 @@ script$g.render = render$1;
3742
3742
  script$g.__scopeId = "data-v-55cf77fb";
3743
3743
  script$g.__file = "src/lib/components/others/NoRecords.vue";
3744
3744
 
3745
+ const useUserStore = defineStore('user-store', {
3746
+ state: () => ({
3747
+ user: null,
3748
+ role: null,
3749
+ permissions: null,
3750
+ menus: [],
3751
+ loggedOut: false
3752
+ }),
3753
+ actions: {
3754
+ setUser (){
3755
+ let user = null;
3756
+ try {
3757
+ user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
3758
+ } catch (error) {
3759
+ user= null;
3760
+ }
3761
+ if (user) {
3762
+ user.isAllowedTo = function (slug) {
3763
+ if (this.permissions) {
3764
+ let permissions = [];
3765
+ if (typeof this.permissions === 'string') {
3766
+ permissions = this.permissions;
3767
+ } else {
3768
+ permissions = this.permissions;
3769
+ }
3770
+ return permissions.includes(slug)
3771
+ }
3772
+ return false
3773
+ };
3774
+ }
3775
+ this.user = user;
3776
+ shApis.doGet('auth/user').then(res => {
3777
+ let user = res.data.user;
3778
+ if (typeof(user) === 'undefined') {
3779
+ user = res.data;
3780
+ }
3781
+ ShStorage.setItem('user',user);
3782
+ user.signOut = this.signOut;
3783
+ user.logout = this.signOut;
3784
+ user.logOut = this.signOut;
3785
+ user.isAllowedTo = function (slug) {
3786
+ if(!slug){
3787
+ return true
3788
+ }
3789
+ if (this.permissions) {
3790
+ let permissions = [];
3791
+ if (typeof this.permissions === 'string') {
3792
+ permissions = this.permissions;
3793
+ } else {
3794
+ permissions = this.permissions;
3795
+ }
3796
+ return permissions.includes(slug)
3797
+ }
3798
+ return false
3799
+ };
3800
+ this.user = user;
3801
+ }).catch((reason) => {
3802
+ if (reason.response && reason.response.status) {
3803
+ if(reason.response.status === 401) {
3804
+ ShStorage.setItem('user',null);
3805
+ this.user = null;
3806
+ }
3807
+ this.loggedOut = true;
3808
+ }
3809
+ });
3810
+ if (this.user) {
3811
+ if (typeof this.user.permissions === 'string') {
3812
+ this.permissions = this.user.permissions;
3813
+ } else {
3814
+ this.permissions = this.user.permissions;
3815
+ }
3816
+ }
3817
+ const timeNow = moment().toISOString();
3818
+ ShStorage.setItem('session_start',timeNow);
3819
+ },
3820
+ signOut () {
3821
+ shRepo.signOutUser();
3822
+ },
3823
+ logOut () {
3824
+ this.signOut();
3825
+ },
3826
+ getUser () {
3827
+ this.setUser();
3828
+ },
3829
+ setAccessToken (accessToken) {
3830
+ ShStorage.setItem('access_token', accessToken);
3831
+ this.setUser();
3832
+ }
3833
+ },
3834
+ getters: {
3835
+ userId (state) {
3836
+ return state.user === null ? null:state.user.id
3837
+ }
3838
+ }
3839
+ });
3840
+
3745
3841
  var script$f = {
3746
3842
  name: 'Pagination',
3747
3843
  props: ['pagination_data', 'loadMore', 'hideCount', 'hideLoadMore', 'paginationStyle'],
@@ -4803,6 +4899,8 @@ var script$b = /*#__PURE__*/Object.assign(__default__, {
4803
4899
 
4804
4900
  const noRecordsComponent = inject('noRecordsComponent', script$g);
4805
4901
 
4902
+ const {user} = storeToRefs(useUserStore());
4903
+
4806
4904
  return (_ctx, _cache) => {
4807
4905
  const _component_router_link = resolveComponent("router-link");
4808
4906
 
@@ -4894,7 +4992,7 @@ return (_ctx, _cache) => {
4894
4992
  : createCommentVNode("v-if", true),
4895
4993
  (_ctx.loading === 'done' || __props.cacheKey)
4896
4994
  ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
4897
- (_ctx.records.length === 0)
4995
+ (!_ctx.records || _ctx.records.length === 0)
4898
4996
  ? (openBlock(), createBlock(resolveDynamicComponent(unref(noRecordsComponent)), { key: 0 }, {
4899
4997
  default: withCtx(() => [
4900
4998
  _hoisted_21,
@@ -5009,7 +5107,7 @@ return (_ctx, _cache) => {
5009
5107
  return (openBlock(), createElementBlock(Fragment, {
5010
5108
  key: act.path
5011
5109
  }, [
5012
- (!act.permission || _ctx.user.isAllowedTo(act.permission))
5110
+ (!act.permission || unref(user).isAllowedTo(act.permission))
5013
5111
  ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
5014
5112
  (!act.validator || act.validator(record))
5015
5113
  ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
@@ -5179,7 +5277,7 @@ return (_ctx, _cache) => {
5179
5277
  return (openBlock(), createElementBlock(Fragment, {
5180
5278
  key: act.path
5181
5279
  }, [
5182
- (!act.permission || _ctx.user.isAllowedTo(act.permission))
5280
+ (!act.permission || unref(user).isAllowedTo(act.permission))
5183
5281
  ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
5184
5282
  (!act.validator || act.validator(record))
5185
5283
  ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
@@ -5564,102 +5662,6 @@ return (_ctx, _cache) => {
5564
5662
 
5565
5663
  script$7.__file = "src/lib/components/ShCanvasBtn.vue";
5566
5664
 
5567
- const useUserStore = defineStore('user-store', {
5568
- state: () => ({
5569
- user: null,
5570
- role: null,
5571
- permissions: null,
5572
- menus: [],
5573
- loggedOut: false
5574
- }),
5575
- actions: {
5576
- setUser (){
5577
- let user = null;
5578
- try {
5579
- user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
5580
- } catch (error) {
5581
- user= null;
5582
- }
5583
- if (user) {
5584
- user.isAllowedTo = function (slug) {
5585
- if (this.permissions) {
5586
- let permissions = [];
5587
- if (typeof this.permissions === 'string') {
5588
- permissions = this.permissions;
5589
- } else {
5590
- permissions = this.permissions;
5591
- }
5592
- return permissions.includes(slug)
5593
- }
5594
- return false
5595
- };
5596
- }
5597
- this.user = user;
5598
- shApis.doGet('auth/user').then(res => {
5599
- let user = res.data.user;
5600
- if (typeof(user) === 'undefined') {
5601
- user = res.data;
5602
- }
5603
- ShStorage.setItem('user',user);
5604
- user.signOut = this.signOut;
5605
- user.logout = this.signOut;
5606
- user.logOut = this.signOut;
5607
- user.isAllowedTo = function (slug) {
5608
- if(!slug){
5609
- return true
5610
- }
5611
- if (this.permissions) {
5612
- let permissions = [];
5613
- if (typeof this.permissions === 'string') {
5614
- permissions = this.permissions;
5615
- } else {
5616
- permissions = this.permissions;
5617
- }
5618
- return permissions.includes(slug)
5619
- }
5620
- return false
5621
- };
5622
- this.user = user;
5623
- }).catch((reason) => {
5624
- if (reason.response && reason.response.status) {
5625
- if(reason.response.status === 401) {
5626
- ShStorage.setItem('user',null);
5627
- this.user = null;
5628
- }
5629
- this.loggedOut = true;
5630
- }
5631
- });
5632
- if (this.user) {
5633
- if (typeof this.user.permissions === 'string') {
5634
- this.permissions = this.user.permissions;
5635
- } else {
5636
- this.permissions = this.user.permissions;
5637
- }
5638
- }
5639
- const timeNow = moment().toISOString();
5640
- ShStorage.setItem('session_start',timeNow);
5641
- },
5642
- signOut () {
5643
- shRepo.signOutUser();
5644
- },
5645
- logOut () {
5646
- this.signOut();
5647
- },
5648
- getUser () {
5649
- this.setUser();
5650
- },
5651
- setAccessToken (accessToken) {
5652
- ShStorage.setItem('access_token', accessToken);
5653
- this.setUser();
5654
- }
5655
- },
5656
- getters: {
5657
- userId (state) {
5658
- return state.user === null ? null:state.user.id
5659
- }
5660
- }
5661
- });
5662
-
5663
5665
  const _withScopeId$1 = n => (pushScopeId("data-v-0d4fa0ac"),n=n(),popScopeId(),n);
5664
5666
  const _hoisted_1$4 = { class: "row permissions-main d-flex" };
5665
5667
  const _hoisted_2$3 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",