@vc-shell/create-vc-app 2.0.3-pr227.0c4f2c3 → 2.0.3-pr229.9dc1748

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.
@@ -1,9 +1,8 @@
1
1
  import { ref } from "vue";
2
- import { useAsync, useLoading, useModificationTracker } from "@vc-shell/framework";
2
+ import { useAsync, useLoading } from "@vc-shell/framework";
3
3
 
4
4
  export default function use<%- ModuleNamePascalCase %>Details() {
5
5
  const item = ref<Record<string, any>>({});
6
- const { isModified, resetModificationState } = useModificationTracker(item);
7
6
 
8
7
  const { loading: itemLoading, action: fetchItem } = useAsync(async (id?: string) => {
9
8
  // TODO: Replace with real API call
@@ -35,7 +34,5 @@ export default function use<%- ModuleNamePascalCase %>Details() {
35
34
  loading,
36
35
  getItem,
37
36
  saveItem,
38
- isModified,
39
- resetModificationState,
40
37
  };
41
38
  }
@@ -19,17 +19,8 @@
19
19
  </template>
20
20
 
21
21
  <script setup lang="ts">
22
- import {
23
- VcBlade,
24
- VcContainer,
25
- VcForm,
26
- VcInput,
27
- useBlade,
28
- useModificationTracker,
29
- usePopup,
30
- useBeforeUnload,
31
- type IBladeToolbar,
32
- } from "@vc-shell/framework";
22
+ import { useBlade, useBladeForm, type IBladeToolbar } from "@vc-shell/framework";
23
+ import { VcBlade, VcContainer, VcForm, VcInput } from "@vc-shell/framework/ui";
33
24
  import { ref, computed, onMounted } from "vue";
34
25
  import use<%- ModuleNamePascalCase %>Details from "../composables/useDetails";
35
26
  import { useI18n } from "vue-i18n";
@@ -40,11 +31,14 @@ defineBlade({
40
31
  });
41
32
 
42
33
  const { t } = useI18n({ useScope: "global" });
43
- const { param, closeSelf, callParent, onBeforeClose } = useBlade();
34
+ const { param, callParent } = useBlade();
44
35
 
45
- const { showConfirmation } = usePopup();
36
+ const { item, loading, getItem, saveItem } = use<%- ModuleNamePascalCase %>Details();
46
37
 
47
- const { item, loading, getItem, saveItem, isModified, resetModificationState } = use<%- ModuleNamePascalCase %>Details();
38
+ const form = useBladeForm({
39
+ data: item,
40
+ closeConfirmMessage: computed(() => t("<%- ModuleNameScreamingSnake %>.ALERTS.CLOSE_CONFIRMATION")),
41
+ });
48
42
 
49
43
  const title = computed(() => {
50
44
  return param.value
@@ -57,10 +51,10 @@ const bladeToolbar = ref<IBladeToolbar[]>([
57
51
  id: "save",
58
52
  title: t("<%- ModuleNameScreamingSnake %>.PAGES.DETAILS.TOOLBAR.SAVE"),
59
53
  icon: "lucide-save",
60
- disabled: computed(() => !isModified.value),
54
+ disabled: computed(() => !form.canSave.value),
61
55
  async clickHandler() {
62
56
  await saveItem();
63
- resetModificationState();
57
+ form.setBaseline();
64
58
  callParent("reload");
65
59
  },
66
60
  },
@@ -69,15 +63,7 @@ const bladeToolbar = ref<IBladeToolbar[]>([
69
63
  onMounted(async () => {
70
64
  if (param.value) {
71
65
  await getItem(param.value);
66
+ form.setBaseline();
72
67
  }
73
68
  });
74
-
75
- onBeforeClose(async () => {
76
- if (isModified.value) {
77
- return !(await showConfirmation(t("<%- ModuleNameScreamingSnake %>.ALERTS.CLOSE_CONFIRMATION")));
78
- }
79
- return false;
80
- });
81
-
82
- useBeforeUnload(computed(() => isModified.value));
83
69
  </script>
@@ -23,14 +23,9 @@
23
23
  </template>
24
24
 
25
25
  <script setup lang="ts">
26
- import {
27
- VcBlade,
28
- VcDataTable,
29
- VcColumn,
30
- useBlade,
31
- type IBladeToolbar,
32
- } from "@vc-shell/framework";
33
- import { ref } from "vue";
26
+ import { useBlade, type IBladeToolbar } from "@vc-shell/framework";
27
+ import { VcBlade, VcDataTable, VcColumn } from "@vc-shell/framework/ui";
28
+ import { ref, onMounted } from "vue";
34
29
  import use<%- ModuleNamePascalCase %>List from "../composables/useList";
35
30
  import { useI18n } from "vue-i18n";
36
31
 
@@ -76,13 +71,16 @@ function openDetails(item?: { id?: string }) {
76
71
  openBlade({
77
72
  name: "<%- ModuleNamePascalCase %>Details",
78
73
  param: item?.id,
79
- onClose() {
80
- getItems();
74
+ async onClose() {
75
+ await getItems();
81
76
  },
82
77
  });
83
78
  }
84
79
 
85
- getItems();
80
+ onMounted(async () => {
81
+ await getItems();
82
+ })
83
+
86
84
 
87
85
  exposeToChildren({ reload: getItems });
88
86
  </script>
@@ -1,5 +1,5 @@
1
1
  import { Ref, computed, ref } from "vue";
2
- import { useAsync, useLoading, useModificationTracker } from "@vc-shell/framework";
2
+ import { useAsync, useLoading } from "@vc-shell/framework";
3
3
  import {
4
4
  MockedItem,
5
5
  addNewMockItem,
@@ -12,8 +12,6 @@ import {
12
12
  export default () => {
13
13
  const item = ref({}) as Ref<MockedItem>;
14
14
 
15
- const { isModified, currentValue, resetModificationState } = useModificationTracker(item);
16
-
17
15
  const { loading: itemLoading, action: getItem } = useAsync<{ id: string }>(async (payload) => {
18
16
  item.value = await loadMockItem(payload);
19
17
  });
@@ -21,14 +19,12 @@ export default () => {
21
19
  const { loading: saveLoading, action: saveItem } = useAsync<MockedItem, MockedItem | void>(async (payload) => {
22
20
  if (payload) {
23
21
  if (payload.id) {
24
- const _res = await updateMockItem(payload)
25
-
26
- resetModificationState(_res);
27
- return _res;
22
+ const _res = await updateMockItem(payload);
23
+ item.value = _res;
24
+ return _res;
28
25
  } else {
29
26
  const _res = await addNewMockItem(payload);
30
-
31
- resetModificationState(_res);
27
+ item.value = _res;
32
28
  return _res;
33
29
  }
34
30
  }
@@ -43,10 +39,9 @@ export default () => {
43
39
  const loading = useLoading(itemLoading, saveLoading, removeLoading);
44
40
 
45
41
  return {
46
- item: currentValue,
42
+ item,
47
43
  loading: computed(() => loading.value),
48
44
  currencyOptions: computed(() => currencyOptions),
49
- isModified,
50
45
  getItem,
51
46
  saveItem,
52
47
  removeItem,
@@ -125,30 +125,37 @@
125
125
  </template>
126
126
 
127
127
  <script lang="ts" setup>
128
- import { IBladeToolbar, useBlade, useBeforeUnload, usePopup } from "@vc-shell/framework";
128
+ import { IBladeToolbar, useBlade, useBladeForm, usePopup } from "@vc-shell/framework";
129
+ import {
130
+ VcBlade,
131
+ VcCard,
132
+ VcCol,
133
+ VcContainer,
134
+ VcForm,
135
+ VcInput,
136
+ VcInputCurrency,
137
+ VcRow,
138
+ VcTextarea,
139
+ } from "@vc-shell/framework/ui";
129
140
  import { useDetails } from "./../composables";
130
141
  import { computed, onMounted, ref } from "vue";
131
- import { Field, useForm } from "vee-validate";
142
+ import { Field } from "vee-validate";
132
143
  import { useI18n } from "vue-i18n";
133
- import * as _ from "lodash-es";
134
144
 
135
145
  defineBlade({
136
146
  name: "SampleDetails",
137
147
  url: "/sample-details",
138
148
  });
139
149
 
140
- const { param, closeSelf, callParent, onBeforeClose } = useBlade();
150
+ const { param, closeSelf, callParent } = useBlade();
141
151
 
142
- const { loading, getItem, saveItem, removeItem, item, currencyOptions, isModified } = useDetails();
152
+ const { loading, getItem, saveItem, removeItem, item, currencyOptions } = useDetails();
143
153
  const { showConfirmation } = usePopup();
144
154
  const { t } = useI18n({ useScope: "global" });
145
155
 
146
- const { meta } = useForm({
147
- validateOnMount: false,
148
- });
149
-
150
- const isDisabled = computed(() => {
151
- return !meta.value.dirty || !meta.value.valid;
156
+ const form = useBladeForm({
157
+ data: item,
158
+ closeConfirmMessage: computed(() => t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION")),
152
159
  });
153
160
 
154
161
  const title = computed(() => {
@@ -166,11 +173,11 @@ const bladeToolbar = ref<IBladeToolbar[]>([
166
173
  title: "Save",
167
174
  async clickHandler() {
168
175
  await saveItem(item.value);
169
-
176
+ form.setBaseline();
170
177
  callParent("reload");
171
178
  closeSelf();
172
179
  },
173
- disabled: computed(() => !(isModified.value && !isDisabled.value)),
180
+ disabled: computed(() => !form.canSave.value),
174
181
  },
175
182
  {
176
183
  id: "delete",
@@ -192,20 +199,7 @@ const bladeToolbar = ref<IBladeToolbar[]>([
192
199
  onMounted(async () => {
193
200
  if (param.value) {
194
201
  await getItem({ id: param.value });
202
+ form.setBaseline();
195
203
  }
196
204
  });
197
-
198
- onBeforeClose(async () => {
199
- if (!isDisabled.value && isModified.value) {
200
- return !(await showConfirmation(t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION")));
201
- }
202
- return false;
203
- });
204
-
205
-
206
-
207
-
208
-
209
-
210
- useBeforeUnload(computed(() => !isDisabled.value && isModified.value));
211
205
  </script>
@@ -5,7 +5,6 @@
5
5
  :toolbar-items="bladeToolbar"
6
6
  >
7
7
  <!-- Blade contents -->
8
- <!-- @vue-generic {MockedItem} -->
9
8
  <VcDataTable
10
9
  v-model:search-value="searchValue"
11
10
  v-model:active-item-id="selectedItemId"
@@ -75,16 +74,9 @@
75
74
 
76
75
  <script lang="ts" setup>
77
76
  import { computed, ref, onMounted, watch } from "vue";
78
- import {
79
- IBladeToolbar,
80
- useBlade,
81
- usePopup,
82
- useTableSort,
83
- useFunctions,
84
- VcColumn,
85
- VcDataTable,
86
- } from "@vc-shell/framework";
77
+ import { IBladeToolbar, useBlade, usePopup, useTableSort, useFunctions } from "@vc-shell/framework";
87
78
  import type { TableAction } from "@vc-shell/framework";
79
+ import { VcColumn, VcDataTable, VcBlade } from "@vc-shell/framework/ui";
88
80
  import { useI18n } from "vue-i18n";
89
81
  import { useList } from "./../composables";
90
82
  import { MockedItem } from "./../composables/useList";
@@ -10,11 +10,6 @@
10
10
  <p class="dashboard-widget-welcome__welcome-description">
11
11
  {{ $t("SHELL.DASHBOARD.WELCOME.DESCRIPTION") }}
12
12
  </p>
13
- <VcButton
14
- variant="secondary"
15
- size="base"
16
- >{{ $t("SHELL.DASHBOARD.WELCOME.GET_STARTED") }}</VcButton
17
- >
18
13
  </div>
19
14
  </template>
20
15
 
@@ -8,8 +8,7 @@
8
8
  "TITLE": "Dashboard",
9
9
  "WELCOME": {
10
10
  "TITLE": "Welcome",
11
- "DESCRIPTION": "Welcome to Vendor portal! We're so excited to have you on board. \n To get started, we recommend exploring the dashboard and personalizing your settings to match your preferences.",
12
- "GET_STARTED": "Get started"
11
+ "DESCRIPTION": "Welcome to your VC Shell app! Get oriented by exploring the dashboard and personalizing your settings to match your preferences."
13
12
  }
14
13
  }
15
14
  }
@@ -10,8 +10,8 @@
10
10
 
11
11
  <script lang="ts" setup>
12
12
  import { useUser, useBroadcastFilter } from "@vc-shell/framework";
13
+ import { VcApp } from "@vc-shell/framework/ui";
13
14
  import { onMounted, ref } from "vue";
14
- // eslint-disable-next-line import/no-unresolved
15
15
  import logoImage from "/assets/logo.svg";
16
16
 
17
17
  const isReady = ref(false);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vc-shell/create-vc-app",
3
3
  "description": "Application scaffolding",
4
- "version": "2.0.3-pr227.0c4f2c3",
4
+ "version": "2.0.3-pr229.9dc1748",
5
5
  "type": "module",
6
6
  "bin": "./dist/index.js",
7
7
  "files": [
@@ -16,7 +16,7 @@
16
16
  "devDependencies": {
17
17
  "@types/ejs": "^3.1.5",
18
18
  "@types/prompts": "^2.4.4",
19
- "@vc-shell/ts-config": "2.0.3-pr227.0c4f2c3",
19
+ "@vc-shell/ts-config": "2.0.3-pr229.9dc1748",
20
20
  "copyfiles": "^2.4.1",
21
21
  "cross-env": "^7.0.3",
22
22
  "shx": "^0.3.4",