@vc-shell/framework 1.0.191 → 1.0.193

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.
Files changed (25) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/core/plugins/modularity/index.ts +9 -2
  3. package/dist/core/plugins/modularity/index.d.ts.map +1 -1
  4. package/dist/framework.js +14460 -14304
  5. package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts +7 -2
  6. package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts.map +1 -1
  7. package/dist/shared/components/blade-navigation/types/index.d.ts +0 -1
  8. package/dist/shared/components/blade-navigation/types/index.d.ts.map +1 -1
  9. package/dist/shared/modules/dynamic/index.d.ts.map +1 -1
  10. package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +8 -9
  11. package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts.map +1 -1
  12. package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts.map +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue.d.ts.map +1 -1
  15. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
  16. package/package.json +4 -4
  17. package/shared/components/blade-navigation/composables/useBladeNavigation/index.ts +303 -192
  18. package/shared/components/blade-navigation/plugin.ts +1 -1
  19. package/shared/components/blade-navigation/types/index.ts +0 -1
  20. package/shared/modules/dynamic/index.ts +5 -0
  21. package/shared/modules/dynamic/pages/dynamic-blade-form.vue +4 -1
  22. package/shared/modules/dynamic/pages/dynamic-blade-list.vue +12 -5
  23. package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue +14 -11
  24. package/ui/components/organisms/vc-app/vc-app.vue +8 -1
  25. package/ui/components/organisms/vc-table/vc-table.vue +2 -2
@@ -44,6 +44,7 @@ const register = (
44
44
  composables: { [key: string]: (...args: any[]) => any };
45
45
  json: DynamicSchema;
46
46
  options?: { router: any };
47
+ moduleUid: string;
47
48
  },
48
49
  appModuleContent:
49
50
  | {
@@ -73,7 +74,9 @@ const register = (
73
74
  name: bladeName,
74
75
  isWorkspace: "isWorkspace" in json.settings && json.settings.isWorkspace,
75
76
  menuItem: ("menuItem" in json.settings && json.settings.menuItem) ?? undefined,
77
+ moduleUid: args.moduleUid,
76
78
  routable: json.settings.routable ?? true,
79
+ composables: args.composables,
77
80
  setup: (props: ComponentProps<typeof bladeComponent>, ctx) =>
78
81
  (bladeComponent?.setup &&
79
82
  bladeComponent.setup(
@@ -146,6 +149,7 @@ export const createDynamicAppModule = (args: {
146
149
  notificationTemplates: args?.notificationTemplates,
147
150
  moduleComponents: args?.moduleComponents,
148
151
  };
152
+ const moduleUid = _.uniqueId("module_");
149
153
  Object.entries(schemaCopy).forEach(([, JsonSchema], index) => {
150
154
  const blade = register(
151
155
  {
@@ -154,6 +158,7 @@ export const createDynamicAppModule = (args: {
154
158
  composables: { ...args.composables },
155
159
  json: JsonSchema,
156
160
  options,
161
+ moduleUid,
157
162
  },
158
163
  index === 0 ? appModuleContent : undefined,
159
164
  );
@@ -97,7 +97,6 @@ import { VcSelect } from "../../../../ui/components";
97
97
  import { useToolbarReducer } from "../composables/useToolbarReducer";
98
98
  import { useBeforeUnload } from "../../../../core/composables/useBeforeUnload";
99
99
  import * as _ from "lodash-es";
100
- import { IBladeToolbar } from "../../../../core/types";
101
100
  import { useNotifications } from "../../../../core/composables";
102
101
  import { notification } from "../../../components";
103
102
 
@@ -132,6 +131,9 @@ const { showConfirmation } = usePopup();
132
131
 
133
132
  const widgetsRefs = useTemplateRefsList<{ el: HTMLDivElement; component: ConcreteComponent }>();
134
133
 
134
+ if (typeof props.composables?.[props.model?.settings?.composable ?? ""] === "undefined") {
135
+ throw new Error(`Composable ( ${props.model?.settings?.composable} ) is not defined`);
136
+ }
135
137
  const { loading, item, validationState, scope, load, remove, saveChanges, bladeTitle } = props.composables
136
138
  ? (props.composables?.[props.model?.settings?.composable ?? ""]({ emit, props, mounted: useMounted() }) as UseDetails<
137
139
  Record<string, any>,
@@ -147,6 +149,7 @@ const { loading, item, validationState, scope, load, remove, saveChanges, bladeT
147
149
  saveChanges: undefined,
148
150
  bladeTitle: undefined,
149
151
  } as unknown as UseDetails<Record<string, any>, DetailsBaseBladeScope>);
152
+
150
153
  const { onBeforeClose } = useBladeNavigation();
151
154
  const title = ref();
152
155
  const isReady = ref(false);
@@ -169,11 +169,11 @@ import { useFilterBuilder, useTableTemplates } from "../composables";
169
169
  import { useFunctions, useNotifications } from "../../../../core/composables";
170
170
  import { IActionBuilderResult, ITableColumns } from "../../../../core/types";
171
171
  import { useToolbarReducer } from "../composables/useToolbarReducer";
172
- import { notification, usePopup } from "../../../components";
172
+ import { notification, useBladeNavigation, usePopup } from "../../../components";
173
173
  import { ListBaseBladeScope, ListBladeContext, UseList } from "../factories/types";
174
174
  import { IParentCallArgs } from "../../../index";
175
175
  import * as _ from "lodash-es";
176
- import { reactiveComputed, toReactive, useMounted } from "@vueuse/core";
176
+ import { toReactive, useMounted } from "@vueuse/core";
177
177
  import { safeIn } from "../helpers/safeIn";
178
178
 
179
179
  export interface Props {
@@ -219,6 +219,7 @@ const itemsProxy = ref<Record<string, any>[]>();
219
219
  const modified = shallowRef(false);
220
220
 
221
221
  const { moduleNotifications, markAsRead } = useNotifications(settings.value?.pushNotificationType);
222
+ const { setNavigationQuery, getNavigationQuery } = useBladeNavigation();
222
223
 
223
224
  watch(
224
225
  moduleNotifications,
@@ -252,6 +253,10 @@ const stateKey =
252
253
  throw new Error('Table id is not defined. Please provide "id" property in table schema');
253
254
  });
254
255
 
256
+ if (typeof props.composables?.[props.model?.settings?.composable ?? ""] === "undefined") {
257
+ throw new Error(`Composable ( ${props.model?.settings?.composable} ) is not defined`);
258
+ }
259
+
255
260
  const { load, remove, items, loading, pagination, query, scope } = props.composables
256
261
  ? (props.composables?.[props.model?.settings?.composable ?? ""]({
257
262
  emit,
@@ -377,7 +382,7 @@ const toolbarComputed =
377
382
  [];
378
383
 
379
384
  onBeforeMount(async () => {
380
- if (props.composables) await load({ sort: sort.value, ...query.value });
385
+ if (props.composables) await load({ sort: sort.value, ...query.value, ...getNavigationQuery() });
381
386
  });
382
387
 
383
388
  watch(
@@ -526,10 +531,12 @@ const onPaginationClick = async (page: number) => {
526
531
 
527
532
  return;
528
533
  }
529
- await load({
534
+ const queryObj = {
530
535
  ...query.value,
531
536
  skip: (page - 1) * query.value.take,
532
- });
537
+ };
538
+ setNavigationQuery(queryObj);
539
+ await load(queryObj);
533
540
  }
534
541
  };
535
542
 
@@ -48,15 +48,15 @@
48
48
  :key="i"
49
49
  >
50
50
  <router-link
51
- v-if="$hasAccess(nested.permissions!)"
52
- :to="nested.url!"
51
+ v-if="$hasAccess(nested.permissions!) && nested.url"
52
+ :to="nested.url"
53
53
  custom
54
54
  >
55
55
  <div
56
56
  :key="i"
57
57
  :class="[
58
58
  {
59
- 'vc-app-menu-item__child-item_active': isActive(nested.url!),
59
+ 'vc-app-menu-item__child-item_active': isActive(nested.url ?? ''),
60
60
  },
61
61
  'vc-app-menu-item__child-item',
62
62
  ]"
@@ -94,6 +94,7 @@ const emit = defineEmits<Emits>();
94
94
 
95
95
  const isOpened = ref(false);
96
96
  const route = useRoute();
97
+ const params = Object.fromEntries(Object.entries(route.params).filter(([key]) => key !== "pathMatch"));
97
98
 
98
99
  watch(
99
100
  () => route.path,
@@ -114,16 +115,18 @@ function onMenuItemClick() {
114
115
  }
115
116
 
116
117
  const isActive = (url: string) => {
117
- if (url) {
118
- const splitted = url.split("/").filter((part) => part !== "");
119
- const active = route.path.split("/").filter((part) => part !== "")[0] === splitted[0];
118
+ let path = route.path;
119
+ if (Object.values(params).length) {
120
+ path = path.replace(Object.values(params)[0] as string, "");
121
+ }
120
122
 
121
- if (active && props.children?.length) {
122
- isOpened.value = true;
123
- }
123
+ const active = path.endsWith(url);
124
+
125
+ if (active && props.children?.length) {
126
+ isOpened.value = true;
127
+ }
124
128
 
125
- return active;
126
- } else return false;
129
+ return active;
127
130
  };
128
131
  </script>
129
132
 
@@ -167,7 +167,14 @@ const onMenuItemClick = function (item: MenuItem) {
167
167
  true,
168
168
  );
169
169
  } else if (!item.routeId && item.url) {
170
- router.push(item.url);
170
+ const menuRoute = router.getRoutes().find((r) => {
171
+ return "/" + r.path.split("/").filter((part) => part !== "")[1] === item.url || r.path === item.url;
172
+ });
173
+ if (typeof menuRoute === "undefined") {
174
+ openRoot();
175
+ } else {
176
+ router.replace({ name: menuRoute?.name, params: route.params });
177
+ }
171
178
  }
172
179
  };
173
180
 
@@ -382,7 +382,7 @@
382
382
  </div>
383
383
  <VcButton
384
384
  v-if="notfound?.action"
385
- @click="notfound.clickHandler"
385
+ @click="notfound?.clickHandler"
386
386
  >
387
387
  {{ notfound.action }}
388
388
  </VcButton>
@@ -402,7 +402,7 @@
402
402
  </div>
403
403
  <VcButton
404
404
  v-if="empty?.action"
405
- @click="empty.clickHandler"
405
+ @click="empty?.clickHandler"
406
406
  >
407
407
  {{ empty.action }}
408
408
  </VcButton>