@iankibetsh/shframework 5.8.0 → 5.8.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/README.md CHANGED
@@ -45,6 +45,7 @@ Enable multi-row selection and perform collective actions by passing the `multi-
45
45
  label: 'Delete Selected',
46
46
  class: 'btn-outline-danger',
47
47
  icon: 'bi-trash',
48
+ permission: 'delete_users',
48
49
  callback: (selectedRecords) => {
49
50
  // Handle action, e.g., send IDs to backend
50
51
  const ids = selectedRecords.map(r => r.id);
@@ -1,36 +1,4 @@
1
1
 
2
- .sh-phone{
3
- display: flex;
4
- width: 100%;
5
- align-items: center;
6
- padding: 0 0.25rem;
7
- }
8
- .phone-country{
9
- width: 2rem;
10
- border: none;
11
- align-self: center;
12
- outline: none !important;
13
- padding: 0.4rem;
14
- border-right: 1px solid #0003;
15
- }
16
- .phone-number{
17
- width: calc(100% - 2.2rem);
18
- border: none;
19
- align-self: center;
20
- outline: none;
21
- margin-bottom: 0;
22
- padding: 0.4rem;
23
- }
24
- .sh-phone img{
25
- padding: 0.125rem;
26
- width: 2rem;
27
- height: 2rem;
28
- }
29
- .phone-number::placeholder{
30
- font-weight: 300;
31
- opacity: 0.5;
32
- }
33
-
34
2
  /* Step Container */
35
3
  .sh-form-steps-container {
36
4
  margin-bottom: 2.5rem;
@@ -292,6 +260,38 @@
292
260
  }
293
261
  }
294
262
 
263
+ .sh-phone{
264
+ display: flex;
265
+ width: 100%;
266
+ align-items: center;
267
+ padding: 0 0.25rem;
268
+ }
269
+ .phone-country{
270
+ width: 2rem;
271
+ border: none;
272
+ align-self: center;
273
+ outline: none !important;
274
+ padding: 0.4rem;
275
+ border-right: 1px solid #0003;
276
+ }
277
+ .phone-number{
278
+ width: calc(100% - 2.2rem);
279
+ border: none;
280
+ align-self: center;
281
+ outline: none;
282
+ margin-bottom: 0;
283
+ padding: 0.4rem;
284
+ }
285
+ .sh-phone img{
286
+ padding: 0.125rem;
287
+ width: 2rem;
288
+ height: 2rem;
289
+ }
290
+ .phone-number::placeholder{
291
+ font-weight: 300;
292
+ opacity: 0.5;
293
+ }
294
+
295
295
  .colored-toast.swal2-icon-success {
296
296
  background-color: #a5dc86 !important;
297
297
  }
@@ -333,22 +333,6 @@
333
333
  min-width: 300px;
334
334
  }
335
335
 
336
- .sh-selected-item{
337
- line-height: unset!important;
338
- }
339
- .sh-suggestion-input{
340
- padding: 0.375rem 0.75rem;
341
- }
342
- .sh-suggest{
343
- margin-bottom: 1rem;
344
- padding: 0rem 0rem;
345
- }
346
- .sh-suggest-control::after{
347
- margin-top: auto;
348
- margin-bottom: auto;
349
- margin-right: 0.255em;
350
- }
351
-
352
336
  .permissions-main {
353
337
  background: #edeff2;
354
338
  }
@@ -381,6 +365,22 @@
381
365
  flex-grow: 1;
382
366
  }
383
367
 
368
+ .sh-selected-item{
369
+ line-height: unset!important;
370
+ }
371
+ .sh-suggestion-input{
372
+ padding: 0.375rem 0.75rem;
373
+ }
374
+ .sh-suggest{
375
+ margin-bottom: 1rem;
376
+ padding: 0rem 0rem;
377
+ }
378
+ .sh-suggest-control::after{
379
+ margin-top: auto;
380
+ margin-bottom: auto;
381
+ margin-right: 0.255em;
382
+ }
383
+
384
384
  .callout{
385
385
  --bs-link-color-rgb: 110,168,254;
386
386
  --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 pinia = require('pinia');
13
12
  var vueRouter = require('vue-router');
13
+ var pinia = require('pinia');
14
14
 
15
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
16
 
@@ -4494,6 +4494,108 @@ return (_ctx, _cache) => {
4494
4494
 
4495
4495
  script$l.__file = "src/lib/components/ShCanvas.vue";
4496
4496
 
4497
+ const useUserStore = pinia.defineStore('user-store', {
4498
+ state: () => ({
4499
+ user: null,
4500
+ role: null,
4501
+ permissions: null,
4502
+ menus: [],
4503
+ loggedOut: false
4504
+ }),
4505
+ actions: {
4506
+ setUser (defaultEndpoint) {
4507
+ let user = null;
4508
+ try {
4509
+ user = shStorage.getItem('user') ? shStorage.getItem('user') : null;
4510
+ } catch (error) {
4511
+ user= null;
4512
+ }
4513
+ if(typeof user !== 'object'){
4514
+ user = null;
4515
+ }
4516
+ if (user ) {
4517
+ user.isAllowedTo = function (slug) {
4518
+ if (this.permissions) {
4519
+ let permissions = [];
4520
+ if (typeof this.permissions === 'string') {
4521
+ permissions = this.permissions;
4522
+ } else {
4523
+ permissions = this.permissions;
4524
+ }
4525
+ return permissions.includes(slug)
4526
+ }
4527
+ return false
4528
+ };
4529
+ }
4530
+ this.user = user;
4531
+ const userEndpoint = defaultEndpoint ?? vue.inject('userEndpoint','auth/user') ?? 'auth/user?defaults=1';
4532
+
4533
+ shApis.doGet(userEndpoint).then(res => {
4534
+ let user = res.data.user;
4535
+ if (typeof(user) === 'undefined') {
4536
+ user = res.data;
4537
+ }
4538
+ shStorage.setItem('user',user);
4539
+ user.signOut = this.signOut;
4540
+ user.logout = this.signOut;
4541
+ user.logOut = this.signOut;
4542
+ user.isAllowedTo = function (slug) {
4543
+ if(!slug){
4544
+ return true
4545
+ }
4546
+ if (this.permissions) {
4547
+ let permissions = [];
4548
+ if (typeof this.permissions === 'string') {
4549
+ permissions = this.permissions;
4550
+ } else {
4551
+ permissions = this.permissions;
4552
+ }
4553
+ return permissions.includes(slug)
4554
+ }
4555
+ return false
4556
+ };
4557
+ user.can = user.isAllowedTo;
4558
+ this.user = user;
4559
+ }).catch((reason) => {
4560
+ if (reason.response && reason.response.status) {
4561
+ if(reason.response.status === 401) {
4562
+ shStorage.setItem('user',null);
4563
+ this.user = null;
4564
+ }
4565
+ this.loggedOut = true;
4566
+ }
4567
+ });
4568
+ if (this.user) {
4569
+ if (typeof this.user.permissions === 'string') {
4570
+ this.permissions = this.user.permissions;
4571
+ } else {
4572
+ this.permissions = this.user.permissions;
4573
+ }
4574
+ }
4575
+ const timeNow = luxon.DateTime.now().toISO();
4576
+ shStorage.setItem('session_start',timeNow);
4577
+ },
4578
+ signOut () {
4579
+ shRepo.signOutUser();
4580
+ },
4581
+ logOut () {
4582
+ this.signOut();
4583
+ },
4584
+ getUser () {
4585
+ this.setUser();
4586
+ },
4587
+ setAccessToken (accessToken) {
4588
+ shStorage.setItem('access_token', accessToken);
4589
+ this.setUser();
4590
+ }
4591
+ },
4592
+ getters: {
4593
+ userId (state) {
4594
+ return state.user === null ? null:state.user.id
4595
+ }
4596
+ }
4597
+ });
4598
+
4497
4599
  const _hoisted_1$g = { class: "callout callout-info" };
4498
4600
 
4499
4601
  function render$2(_ctx, _cache) {
@@ -4702,108 +4804,6 @@ return (_ctx, _cache) => {
4702
4804
 
4703
4805
  script$i.__file = "src/lib/components/ShSilentAction.vue";
4704
4806
 
4705
- const useUserStore = pinia.defineStore('user-store', {
4706
- state: () => ({
4707
- user: null,
4708
- role: null,
4709
- permissions: null,
4710
- menus: [],
4711
- loggedOut: false
4712
- }),
4713
- actions: {
4714
- setUser (defaultEndpoint) {
4715
- let user = null;
4716
- try {
4717
- user = shStorage.getItem('user') ? shStorage.getItem('user') : null;
4718
- } catch (error) {
4719
- user= null;
4720
- }
4721
- if(typeof user !== 'object'){
4722
- user = null;
4723
- }
4724
- if (user ) {
4725
- user.isAllowedTo = function (slug) {
4726
- if (this.permissions) {
4727
- let permissions = [];
4728
- if (typeof this.permissions === 'string') {
4729
- permissions = this.permissions;
4730
- } else {
4731
- permissions = this.permissions;
4732
- }
4733
- return permissions.includes(slug)
4734
- }
4735
- return false
4736
- };
4737
- }
4738
- this.user = user;
4739
- const userEndpoint = defaultEndpoint ?? vue.inject('userEndpoint','auth/user') ?? 'auth/user?defaults=1';
4740
-
4741
- shApis.doGet(userEndpoint).then(res => {
4742
- let user = res.data.user;
4743
- if (typeof(user) === 'undefined') {
4744
- user = res.data;
4745
- }
4746
- shStorage.setItem('user',user);
4747
- user.signOut = this.signOut;
4748
- user.logout = this.signOut;
4749
- user.logOut = this.signOut;
4750
- user.isAllowedTo = function (slug) {
4751
- if(!slug){
4752
- return true
4753
- }
4754
- if (this.permissions) {
4755
- let permissions = [];
4756
- if (typeof this.permissions === 'string') {
4757
- permissions = this.permissions;
4758
- } else {
4759
- permissions = this.permissions;
4760
- }
4761
- return permissions.includes(slug)
4762
- }
4763
- return false
4764
- };
4765
- user.can = user.isAllowedTo;
4766
- this.user = user;
4767
- }).catch((reason) => {
4768
- if (reason.response && reason.response.status) {
4769
- if(reason.response.status === 401) {
4770
- shStorage.setItem('user',null);
4771
- this.user = null;
4772
- }
4773
- this.loggedOut = true;
4774
- }
4775
- });
4776
- if (this.user) {
4777
- if (typeof this.user.permissions === 'string') {
4778
- this.permissions = this.user.permissions;
4779
- } else {
4780
- this.permissions = this.user.permissions;
4781
- }
4782
- }
4783
- const timeNow = luxon.DateTime.now().toISO();
4784
- shStorage.setItem('session_start',timeNow);
4785
- },
4786
- signOut () {
4787
- shRepo.signOutUser();
4788
- },
4789
- logOut () {
4790
- this.signOut();
4791
- },
4792
- getUser () {
4793
- this.setUser();
4794
- },
4795
- setAccessToken (accessToken) {
4796
- shStorage.setItem('access_token', accessToken);
4797
- this.setUser();
4798
- }
4799
- },
4800
- getters: {
4801
- userId (state) {
4802
- return state.user === null ? null:state.user.id
4803
- }
4804
- }
4805
- });
4806
-
4807
4807
  const _hoisted_1$f = ["href"];
4808
4808
  const _hoisted_2$c = ["title"];
4809
4809
 
@@ -5741,6 +5741,15 @@ const getSlotName = (key) => {
5741
5741
  return ''
5742
5742
  };
5743
5743
 
5744
+ const {user} = pinia.storeToRefs(useUserStore());
5745
+
5746
+ const activeMultiActions = vue.computed(() => {
5747
+ return props.multiActions.filter(action => {
5748
+ if (!action.permission) return true
5749
+ return user.value.isAllowedTo(action.permission)
5750
+ })
5751
+ });
5752
+
5744
5753
  const cleanColumn = (col) => {
5745
5754
  const newCol = {...col};
5746
5755
  delete newCol.component;
@@ -6150,7 +6159,7 @@ return (_ctx, _cache) => {
6150
6159
  }, [
6151
6160
  vue.createElementVNode("thead", _hoisted_13$1, [
6152
6161
  vue.createElementVNode("tr", null, [
6153
- (__props.multiActions.length > 0)
6162
+ (activeMultiActions.value.length > 0)
6154
6163
  ? (vue.openBlock(), vue.createElementBlock("th", _hoisted_14$1, [
6155
6164
  vue.withDirectives(vue.createElementVNode("input", {
6156
6165
  type: "checkbox",
@@ -6204,7 +6213,7 @@ return (_ctx, _cache) => {
6204
6213
  (loading.value === 'loading')
6205
6214
  ? (vue.openBlock(), vue.createElementBlock("tr", _hoisted_22, [
6206
6215
  vue.createElementVNode("td", {
6207
- colspan: __props.multiActions.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6216
+ colspan: activeMultiActions.value.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6208
6217
  }, [...(_cache[16] || (_cache[16] = [
6209
6218
  vue.createElementVNode("div", { class: "text-center" }, [
6210
6219
  vue.createElementVNode("div", {
@@ -6219,13 +6228,13 @@ return (_ctx, _cache) => {
6219
6228
  : (loading.value === 'error')
6220
6229
  ? (vue.openBlock(), vue.createElementBlock("tr", _hoisted_24, [
6221
6230
  vue.createElementVNode("td", {
6222
- colspan: __props.multiActions.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6231
+ colspan: activeMultiActions.value.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6223
6232
  }, vue.toDisplayString(loading_error.value), 9 /* TEXT, PROPS */, _hoisted_25)
6224
6233
  ]))
6225
6234
  : (records.value.length === 0)
6226
6235
  ? (vue.openBlock(), vue.createElementBlock("tr", _hoisted_26, [
6227
6236
  vue.createElementVNode("td", {
6228
- colspan: __props.actions ? tableHeaders.value.length + (__props.multiActions.length > 0 ? 2:1) : tableHeaders.value.length + (__props.multiActions.length > 0 ? 1:0)
6237
+ colspan: __props.actions ? tableHeaders.value.length + (activeMultiActions.value.length > 0 ? 2:1) : tableHeaders.value.length + (activeMultiActions.value.length > 0 ? 1:0)
6229
6238
  }, [...(_cache[17] || (_cache[17] = [
6230
6239
  vue.createElementVNode("div", { class: "text-center bg-primary-light px-2 py-1 rounded no_records_div" }, [
6231
6240
  vue.createElementVNode("i", { class: "bi-info-circle" }),
@@ -6240,7 +6249,7 @@ return (_ctx, _cache) => {
6240
6249
  class: vue.normalizeClass(record.class),
6241
6250
  onClick: $event => (rowSelected(record))
6242
6251
  }, [
6243
- (__props.multiActions.length > 0)
6252
+ (activeMultiActions.value.length > 0)
6244
6253
  ? (vue.openBlock(), vue.createElementBlock("td", {
6245
6254
  key: 0,
6246
6255
  onClick: _cache[5] || (_cache[5] = vue.withModifiers(() => {}, ["stop"]))
@@ -6353,7 +6362,7 @@ return (_ctx, _cache) => {
6353
6362
  class: "single-mobile-req bg-light p-3",
6354
6363
  onClick: $event => (rowSelected(record))
6355
6364
  }, [
6356
- (__props.multiActions.length > 0)
6365
+ (activeMultiActions.value.length > 0)
6357
6366
  ? (vue.openBlock(), vue.createElementBlock("div", {
6358
6367
  key: 0,
6359
6368
  class: "mb-2",
@@ -6500,14 +6509,14 @@ return (_ctx, _cache) => {
6500
6509
  ], 64 /* STABLE_FRAGMENT */))
6501
6510
  }), 128 /* KEYED_FRAGMENT */))
6502
6511
  : vue.createCommentVNode("v-if", true),
6503
- (selectedItems.value.length > 0)
6512
+ (selectedItems.value.length > 0 && activeMultiActions.value.length > 0)
6504
6513
  ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_63, [
6505
6514
  vue.createElementVNode("div", null, [
6506
6515
  vue.createElementVNode("span", _hoisted_64, vue.toDisplayString(selectedItems.value.length), 1 /* TEXT */),
6507
6516
  _cache[20] || (_cache[20] = vue.createTextVNode(" items selected ", -1 /* CACHED */))
6508
6517
  ]),
6509
6518
  vue.createElementVNode("div", _hoisted_65, [
6510
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.multiActions, (action) => {
6519
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(activeMultiActions.value, (action) => {
6511
6520
  return (vue.openBlock(), vue.createElementBlock("button", {
6512
6521
  key: action.label,
6513
6522
  class: vue.normalizeClass(["btn btn-sm", action.class ?? 'btn-outline-primary']),
package/dist/library.mjs CHANGED
@@ -5,8 +5,8 @@ import { Modal, Offcanvas } from 'bootstrap';
5
5
  import NProgress from 'nprogress';
6
6
  import { ref, computed, watch, onMounted, openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, unref, vModelSelect, vModelText, normalizeClass, createBlock, resolveDynamicComponent, resolveComponent, inject, useTemplateRef, mergeProps, vShow, renderSlot, normalizeStyle, Teleport, createVNode, withCtx, useSlots, onBeforeUnmount, reactive, vModelCheckbox, withModifiers, resolveDirective, shallowRef, markRaw, isRef } from 'vue';
7
7
  import _ from 'lodash';
8
- import { defineStore, storeToRefs } from 'pinia';
9
8
  import { useRoute, useRouter } from 'vue-router';
9
+ import { defineStore, storeToRefs } from 'pinia';
10
10
 
11
11
  function setItem (key, value) {
12
12
  let toStore = value;
@@ -4483,6 +4483,108 @@ return (_ctx, _cache) => {
4483
4483
 
4484
4484
  script$l.__file = "src/lib/components/ShCanvas.vue";
4485
4485
 
4486
+ const useUserStore = defineStore('user-store', {
4487
+ state: () => ({
4488
+ user: null,
4489
+ role: null,
4490
+ permissions: null,
4491
+ menus: [],
4492
+ loggedOut: false
4493
+ }),
4494
+ actions: {
4495
+ setUser (defaultEndpoint) {
4496
+ let user = null;
4497
+ try {
4498
+ user = shStorage.getItem('user') ? shStorage.getItem('user') : null;
4499
+ } catch (error) {
4500
+ user= null;
4501
+ }
4502
+ if(typeof user !== 'object'){
4503
+ user = null;
4504
+ }
4505
+ if (user ) {
4506
+ user.isAllowedTo = function (slug) {
4507
+ if (this.permissions) {
4508
+ let permissions = [];
4509
+ if (typeof this.permissions === 'string') {
4510
+ permissions = this.permissions;
4511
+ } else {
4512
+ permissions = this.permissions;
4513
+ }
4514
+ return permissions.includes(slug)
4515
+ }
4516
+ return false
4517
+ };
4518
+ }
4519
+ this.user = user;
4520
+ const userEndpoint = defaultEndpoint ?? inject('userEndpoint','auth/user') ?? 'auth/user?defaults=1';
4521
+
4522
+ shApis.doGet(userEndpoint).then(res => {
4523
+ let user = res.data.user;
4524
+ if (typeof(user) === 'undefined') {
4525
+ user = res.data;
4526
+ }
4527
+ shStorage.setItem('user',user);
4528
+ user.signOut = this.signOut;
4529
+ user.logout = this.signOut;
4530
+ user.logOut = this.signOut;
4531
+ user.isAllowedTo = function (slug) {
4532
+ if(!slug){
4533
+ return true
4534
+ }
4535
+ if (this.permissions) {
4536
+ let permissions = [];
4537
+ if (typeof this.permissions === 'string') {
4538
+ permissions = this.permissions;
4539
+ } else {
4540
+ permissions = this.permissions;
4541
+ }
4542
+ return permissions.includes(slug)
4543
+ }
4544
+ return false
4545
+ };
4546
+ user.can = user.isAllowedTo;
4547
+ this.user = user;
4548
+ }).catch((reason) => {
4549
+ if (reason.response && reason.response.status) {
4550
+ if(reason.response.status === 401) {
4551
+ shStorage.setItem('user',null);
4552
+ this.user = null;
4553
+ }
4554
+ this.loggedOut = true;
4555
+ }
4556
+ });
4557
+ if (this.user) {
4558
+ if (typeof this.user.permissions === 'string') {
4559
+ this.permissions = this.user.permissions;
4560
+ } else {
4561
+ this.permissions = this.user.permissions;
4562
+ }
4563
+ }
4564
+ const timeNow = DateTime.now().toISO();
4565
+ shStorage.setItem('session_start',timeNow);
4566
+ },
4567
+ signOut () {
4568
+ shRepo.signOutUser();
4569
+ },
4570
+ logOut () {
4571
+ this.signOut();
4572
+ },
4573
+ getUser () {
4574
+ this.setUser();
4575
+ },
4576
+ setAccessToken (accessToken) {
4577
+ shStorage.setItem('access_token', accessToken);
4578
+ this.setUser();
4579
+ }
4580
+ },
4581
+ getters: {
4582
+ userId (state) {
4583
+ return state.user === null ? null:state.user.id
4584
+ }
4585
+ }
4586
+ });
4587
+
4486
4588
  const _hoisted_1$g = { class: "callout callout-info" };
4487
4589
 
4488
4590
  function render$2(_ctx, _cache) {
@@ -4691,108 +4793,6 @@ return (_ctx, _cache) => {
4691
4793
 
4692
4794
  script$i.__file = "src/lib/components/ShSilentAction.vue";
4693
4795
 
4694
- const useUserStore = defineStore('user-store', {
4695
- state: () => ({
4696
- user: null,
4697
- role: null,
4698
- permissions: null,
4699
- menus: [],
4700
- loggedOut: false
4701
- }),
4702
- actions: {
4703
- setUser (defaultEndpoint) {
4704
- let user = null;
4705
- try {
4706
- user = shStorage.getItem('user') ? shStorage.getItem('user') : null;
4707
- } catch (error) {
4708
- user= null;
4709
- }
4710
- if(typeof user !== 'object'){
4711
- user = null;
4712
- }
4713
- if (user ) {
4714
- user.isAllowedTo = function (slug) {
4715
- if (this.permissions) {
4716
- let permissions = [];
4717
- if (typeof this.permissions === 'string') {
4718
- permissions = this.permissions;
4719
- } else {
4720
- permissions = this.permissions;
4721
- }
4722
- return permissions.includes(slug)
4723
- }
4724
- return false
4725
- };
4726
- }
4727
- this.user = user;
4728
- const userEndpoint = defaultEndpoint ?? inject('userEndpoint','auth/user') ?? 'auth/user?defaults=1';
4729
-
4730
- shApis.doGet(userEndpoint).then(res => {
4731
- let user = res.data.user;
4732
- if (typeof(user) === 'undefined') {
4733
- user = res.data;
4734
- }
4735
- shStorage.setItem('user',user);
4736
- user.signOut = this.signOut;
4737
- user.logout = this.signOut;
4738
- user.logOut = this.signOut;
4739
- user.isAllowedTo = function (slug) {
4740
- if(!slug){
4741
- return true
4742
- }
4743
- if (this.permissions) {
4744
- let permissions = [];
4745
- if (typeof this.permissions === 'string') {
4746
- permissions = this.permissions;
4747
- } else {
4748
- permissions = this.permissions;
4749
- }
4750
- return permissions.includes(slug)
4751
- }
4752
- return false
4753
- };
4754
- user.can = user.isAllowedTo;
4755
- this.user = user;
4756
- }).catch((reason) => {
4757
- if (reason.response && reason.response.status) {
4758
- if(reason.response.status === 401) {
4759
- shStorage.setItem('user',null);
4760
- this.user = null;
4761
- }
4762
- this.loggedOut = true;
4763
- }
4764
- });
4765
- if (this.user) {
4766
- if (typeof this.user.permissions === 'string') {
4767
- this.permissions = this.user.permissions;
4768
- } else {
4769
- this.permissions = this.user.permissions;
4770
- }
4771
- }
4772
- const timeNow = DateTime.now().toISO();
4773
- shStorage.setItem('session_start',timeNow);
4774
- },
4775
- signOut () {
4776
- shRepo.signOutUser();
4777
- },
4778
- logOut () {
4779
- this.signOut();
4780
- },
4781
- getUser () {
4782
- this.setUser();
4783
- },
4784
- setAccessToken (accessToken) {
4785
- shStorage.setItem('access_token', accessToken);
4786
- this.setUser();
4787
- }
4788
- },
4789
- getters: {
4790
- userId (state) {
4791
- return state.user === null ? null:state.user.id
4792
- }
4793
- }
4794
- });
4795
-
4796
4796
  const _hoisted_1$f = ["href"];
4797
4797
  const _hoisted_2$c = ["title"];
4798
4798
 
@@ -5730,6 +5730,15 @@ const getSlotName = (key) => {
5730
5730
  return ''
5731
5731
  };
5732
5732
 
5733
+ const {user} = storeToRefs(useUserStore());
5734
+
5735
+ const activeMultiActions = computed(() => {
5736
+ return props.multiActions.filter(action => {
5737
+ if (!action.permission) return true
5738
+ return user.value.isAllowedTo(action.permission)
5739
+ })
5740
+ });
5741
+
5733
5742
  const cleanColumn = (col) => {
5734
5743
  const newCol = {...col};
5735
5744
  delete newCol.component;
@@ -6139,7 +6148,7 @@ return (_ctx, _cache) => {
6139
6148
  }, [
6140
6149
  createElementVNode("thead", _hoisted_13$1, [
6141
6150
  createElementVNode("tr", null, [
6142
- (__props.multiActions.length > 0)
6151
+ (activeMultiActions.value.length > 0)
6143
6152
  ? (openBlock(), createElementBlock("th", _hoisted_14$1, [
6144
6153
  withDirectives(createElementVNode("input", {
6145
6154
  type: "checkbox",
@@ -6193,7 +6202,7 @@ return (_ctx, _cache) => {
6193
6202
  (loading.value === 'loading')
6194
6203
  ? (openBlock(), createElementBlock("tr", _hoisted_22, [
6195
6204
  createElementVNode("td", {
6196
- colspan: __props.multiActions.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6205
+ colspan: activeMultiActions.value.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6197
6206
  }, [...(_cache[16] || (_cache[16] = [
6198
6207
  createElementVNode("div", { class: "text-center" }, [
6199
6208
  createElementVNode("div", {
@@ -6208,13 +6217,13 @@ return (_ctx, _cache) => {
6208
6217
  : (loading.value === 'error')
6209
6218
  ? (openBlock(), createElementBlock("tr", _hoisted_24, [
6210
6219
  createElementVNode("td", {
6211
- colspan: __props.multiActions.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6220
+ colspan: activeMultiActions.value.length > 0 ? tableHeaders.value.length + 1 : tableHeaders.value.length
6212
6221
  }, toDisplayString(loading_error.value), 9 /* TEXT, PROPS */, _hoisted_25)
6213
6222
  ]))
6214
6223
  : (records.value.length === 0)
6215
6224
  ? (openBlock(), createElementBlock("tr", _hoisted_26, [
6216
6225
  createElementVNode("td", {
6217
- colspan: __props.actions ? tableHeaders.value.length + (__props.multiActions.length > 0 ? 2:1) : tableHeaders.value.length + (__props.multiActions.length > 0 ? 1:0)
6226
+ colspan: __props.actions ? tableHeaders.value.length + (activeMultiActions.value.length > 0 ? 2:1) : tableHeaders.value.length + (activeMultiActions.value.length > 0 ? 1:0)
6218
6227
  }, [...(_cache[17] || (_cache[17] = [
6219
6228
  createElementVNode("div", { class: "text-center bg-primary-light px-2 py-1 rounded no_records_div" }, [
6220
6229
  createElementVNode("i", { class: "bi-info-circle" }),
@@ -6229,7 +6238,7 @@ return (_ctx, _cache) => {
6229
6238
  class: normalizeClass(record.class),
6230
6239
  onClick: $event => (rowSelected(record))
6231
6240
  }, [
6232
- (__props.multiActions.length > 0)
6241
+ (activeMultiActions.value.length > 0)
6233
6242
  ? (openBlock(), createElementBlock("td", {
6234
6243
  key: 0,
6235
6244
  onClick: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"]))
@@ -6342,7 +6351,7 @@ return (_ctx, _cache) => {
6342
6351
  class: "single-mobile-req bg-light p-3",
6343
6352
  onClick: $event => (rowSelected(record))
6344
6353
  }, [
6345
- (__props.multiActions.length > 0)
6354
+ (activeMultiActions.value.length > 0)
6346
6355
  ? (openBlock(), createElementBlock("div", {
6347
6356
  key: 0,
6348
6357
  class: "mb-2",
@@ -6489,14 +6498,14 @@ return (_ctx, _cache) => {
6489
6498
  ], 64 /* STABLE_FRAGMENT */))
6490
6499
  }), 128 /* KEYED_FRAGMENT */))
6491
6500
  : createCommentVNode("v-if", true),
6492
- (selectedItems.value.length > 0)
6501
+ (selectedItems.value.length > 0 && activeMultiActions.value.length > 0)
6493
6502
  ? (openBlock(), createElementBlock("div", _hoisted_63, [
6494
6503
  createElementVNode("div", null, [
6495
6504
  createElementVNode("span", _hoisted_64, toDisplayString(selectedItems.value.length), 1 /* TEXT */),
6496
6505
  _cache[20] || (_cache[20] = createTextVNode(" items selected ", -1 /* CACHED */))
6497
6506
  ]),
6498
6507
  createElementVNode("div", _hoisted_65, [
6499
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.multiActions, (action) => {
6508
+ (openBlock(true), createElementBlock(Fragment, null, renderList(activeMultiActions.value, (action) => {
6500
6509
  return (openBlock(), createElementBlock("button", {
6501
6510
  key: action.label,
6502
6511
  class: normalizeClass(["btn btn-sm", action.class ?? 'btn-outline-primary']),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "5.8.0",
3
+ "version": "5.8.1",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "repository": {
6
6
  "type": "git",