@iankibetsh/shframework 5.6.5 → 5.6.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.
package/dist/library.js CHANGED
@@ -6280,25 +6280,47 @@ var script$b = {
6280
6280
  addTabQuery: {
6281
6281
  type: Boolean,
6282
6282
  default: false
6283
+ },
6284
+ tabCounts: {
6285
+ type: Object,
6286
+ default: () => ({})
6283
6287
  }
6284
6288
  },
6285
6289
  setup(__props) {
6286
6290
 
6287
6291
  const props = __props;
6292
+ const {user} = pinia.storeToRefs(useUserStore());
6288
6293
  const route = vueRouter.useRoute();
6289
6294
  const router = vueRouter.useRouter();
6290
6295
  const formattedTabs = vue.computed(() => {
6291
6296
  if (!props.tabs || props.tabs.length === 0) {
6292
6297
  return []
6293
6298
  }
6294
- return props.tabs.map(tab => {
6299
+ return props.tabs.filter(tab => {
6300
+ let newTab = tab;
6295
6301
  if (typeof tab === 'string') {
6296
- return {key: tab, label: tab.replace(/_/g, ' ')}
6302
+ newTab = {key: tab, label: tab.replace(/_/g, ' ')};
6297
6303
  }
6298
6304
  if (typeof tab === 'function') {
6299
- return tab(props.data)
6305
+ newTab = tab(props.data);
6300
6306
  }
6301
- return tab
6307
+ if(newTab.validator){
6308
+ if(!newTab.validator()){
6309
+ return false
6310
+ }
6311
+ }
6312
+ if(newTab.permission){
6313
+ if(!user.value || !user.value.isAllowedTo(newTab.permission)){
6314
+ return false
6315
+ }
6316
+ }
6317
+ console.log(newTab);
6318
+ // check if there are tabCounts for this tab
6319
+ // const tabKey = getTabKey(newTab)
6320
+ // if (!newTab.count && props.tabCounts && props.tabCounts[tabKey] !== undefined) {
6321
+ // newTab.count = props.tabCounts[tabKey]
6322
+ // }
6323
+ return newTab
6302
6324
  })
6303
6325
  });
6304
6326
  const tabsBaseUrl = props.baseUrl ?? route.path;
@@ -6334,6 +6356,7 @@ const getTabKey = (tab) => {
6334
6356
  return tab.key ?? tab.label.replace(/\s+/g, '_').toLowerCase()
6335
6357
  };
6336
6358
 
6359
+
6337
6360
  return (_ctx, _cache) => {
6338
6361
  const _component_router_link = vue.resolveComponent("router-link");
6339
6362
 
@@ -6382,7 +6405,7 @@ return (_ctx, _cache) => {
6382
6405
  (vue.unref(currentTab))
6383
6406
  ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(currentTab).component ?? __props.defaultComponent), vue.mergeProps({
6384
6407
  key: getTabKey(vue.unref(currentTab))
6385
- }, vue.unref(currentTab)), null, 16 /* FULL_PROPS */))
6408
+ }, {..._ctx.$attrs, ...vue.unref(currentTab)}), null, 16 /* FULL_PROPS */))
6386
6409
  : vue.createCommentVNode("v-if", true)
6387
6410
  ])
6388
6411
  ], 64 /* STABLE_FRAGMENT */))
package/dist/library.mjs CHANGED
@@ -6269,25 +6269,47 @@ var script$b = {
6269
6269
  addTabQuery: {
6270
6270
  type: Boolean,
6271
6271
  default: false
6272
+ },
6273
+ tabCounts: {
6274
+ type: Object,
6275
+ default: () => ({})
6272
6276
  }
6273
6277
  },
6274
6278
  setup(__props) {
6275
6279
 
6276
6280
  const props = __props;
6281
+ const {user} = storeToRefs(useUserStore());
6277
6282
  const route = useRoute();
6278
6283
  const router = useRouter();
6279
6284
  const formattedTabs = computed(() => {
6280
6285
  if (!props.tabs || props.tabs.length === 0) {
6281
6286
  return []
6282
6287
  }
6283
- return props.tabs.map(tab => {
6288
+ return props.tabs.filter(tab => {
6289
+ let newTab = tab;
6284
6290
  if (typeof tab === 'string') {
6285
- return {key: tab, label: tab.replace(/_/g, ' ')}
6291
+ newTab = {key: tab, label: tab.replace(/_/g, ' ')};
6286
6292
  }
6287
6293
  if (typeof tab === 'function') {
6288
- return tab(props.data)
6294
+ newTab = tab(props.data);
6289
6295
  }
6290
- return tab
6296
+ if(newTab.validator){
6297
+ if(!newTab.validator()){
6298
+ return false
6299
+ }
6300
+ }
6301
+ if(newTab.permission){
6302
+ if(!user.value || !user.value.isAllowedTo(newTab.permission)){
6303
+ return false
6304
+ }
6305
+ }
6306
+ console.log(newTab);
6307
+ // check if there are tabCounts for this tab
6308
+ // const tabKey = getTabKey(newTab)
6309
+ // if (!newTab.count && props.tabCounts && props.tabCounts[tabKey] !== undefined) {
6310
+ // newTab.count = props.tabCounts[tabKey]
6311
+ // }
6312
+ return newTab
6291
6313
  })
6292
6314
  });
6293
6315
  const tabsBaseUrl = props.baseUrl ?? route.path;
@@ -6323,6 +6345,7 @@ const getTabKey = (tab) => {
6323
6345
  return tab.key ?? tab.label.replace(/\s+/g, '_').toLowerCase()
6324
6346
  };
6325
6347
 
6348
+
6326
6349
  return (_ctx, _cache) => {
6327
6350
  const _component_router_link = resolveComponent("router-link");
6328
6351
 
@@ -6371,7 +6394,7 @@ return (_ctx, _cache) => {
6371
6394
  (unref(currentTab))
6372
6395
  ? (openBlock(), createBlock(resolveDynamicComponent(unref(currentTab).component ?? __props.defaultComponent), mergeProps({
6373
6396
  key: getTabKey(unref(currentTab))
6374
- }, unref(currentTab)), null, 16 /* FULL_PROPS */))
6397
+ }, {..._ctx.$attrs, ...unref(currentTab)}), null, 16 /* FULL_PROPS */))
6375
6398
  : createCommentVNode("v-if", true)
6376
6399
  ])
6377
6400
  ], 64 /* STABLE_FRAGMENT */))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "5.6.5",
3
+ "version": "5.6.7",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",