@antelopejs/dms 0.3.6 → 0.3.8
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/CHANGELOG.md +48 -0
- package/dist/implementations/dms/page.js +2 -2
- package/dist/implementations/dms/page.js.map +1 -1
- package/dist/test/antelope.test.js +16 -5
- package/dist/test/antelope.test.js.map +1 -1
- package/dist/test/api-endpoint/index.d.ts +5 -0
- package/dist/test/api-endpoint/index.js +8 -0
- package/dist/test/api-endpoint/index.js.map +1 -0
- package/dist/test/helpers/http.d.ts +1 -0
- package/dist/test/helpers/http.js +16 -4
- package/dist/test/helpers/http.js.map +1 -1
- package/dist/test/unit/implementations/dms/notify-menu-changed.test.js +21 -0
- package/dist/test/unit/implementations/dms/notify-menu-changed.test.js.map +1 -1
- package/dist/test/unit/interfaces/dms-base/table-view-form-page-urls.test.d.ts +1 -0
- package/dist/test/unit/interfaces/dms-base/table-view-form-page-urls.test.js +308 -0
- package/dist/test/unit/interfaces/dms-base/table-view-form-page-urls.test.js.map +1 -0
- package/dist/test/unit/interfaces/dms-base/table-view-form-redirect.test.d.ts +1 -0
- package/dist/test/unit/interfaces/dms-base/table-view-form-redirect.test.js +241 -0
- package/dist/test/unit/interfaces/dms-base/table-view-form-redirect.test.js.map +1 -0
- package/dist/test/unit/interfaces/dms-base/table-view-route-param-filter-defaults.test.d.ts +1 -0
- package/dist/test/unit/interfaces/dms-base/table-view-route-param-filter-defaults.test.js +254 -0
- package/dist/test/unit/interfaces/dms-base/table-view-route-param-filter-defaults.test.js.map +1 -0
- package/frontend-vue/layers/dms-layout/app/composables/page/useSiteLayout.ts +49 -20
- package/frontend-vue/layers/dms-ui/app/build/components/table/Table.vue +6 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table/useTable.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/table/useTableColumns.ts +13 -7
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/registerDefaultFunctions.ts +49 -20
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableViewConfig.ts +43 -5
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableViewRowActions.ts +23 -29
- package/frontend-vue/layers/dms-ui/app/components/grid/Grid.vue +10 -1
- package/frontend-vue/layers/dms-ui/app/components/grid/GridRow.vue +16 -6
- package/frontend-vue/layers/dms-ui/app/components/grid/columns.ts +29 -0
- package/frontend-vue/layers/dms-ui/app/components/grid/constants.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/components/table-view/TableView.vue +3 -0
- package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +35 -25
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/config.ts +5 -1
- package/frontend-vue/pnpm-lock.yaml +4 -4
- package/frontend-vue/tests/form-page-url-fill.test.ts +63 -0
- package/frontend-vue/tests/form-redirect-placeholders.test.ts +69 -0
- package/frontend-vue/tests/grid-responsive-columns.test.ts +105 -0
- package/frontend-vue/tests/route-param-filter-defaults.test.ts +59 -0
- package/frontend-vue/tests/route-param-occurrences.test.ts +109 -0
- package/package.json +2 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { extractRouteParams } from "../layers/dms-layout/app/composables/page/useSiteLayout";
|
|
3
|
+
import { replaceUrlVariables } from "../layers/dms-ui/app/composables/form/useForm";
|
|
4
|
+
|
|
5
|
+
// A page-mode form sub-page under a page whose own slug is `:id`: the carrying
|
|
6
|
+
// page contributes one `:id` and the form slug appends another.
|
|
7
|
+
const NESTED_FORM_PATTERN = "/workspaces/:id/invoiceTable/:id/edit";
|
|
8
|
+
const NESTED_FORM_PATH = "/workspaces/ws-1/invoiceTable/row-7/edit";
|
|
9
|
+
|
|
10
|
+
describe("extractRouteParams", () => {
|
|
11
|
+
it("keeps a single placeholder under its bare name and nothing else", () => {
|
|
12
|
+
expect(
|
|
13
|
+
extractRouteParams("/customers/:id/edit", "/customers/c-1/edit"),
|
|
14
|
+
).toEqual({ id: "c-1" });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("keeps distinct placeholders under their own names and nothing else", () => {
|
|
18
|
+
expect(
|
|
19
|
+
extractRouteParams(
|
|
20
|
+
"/projects/:project/members/:id/view",
|
|
21
|
+
"/projects/p-1/members/m-2/view",
|
|
22
|
+
),
|
|
23
|
+
).toEqual({ project: "p-1", id: "m-2" });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("reaches both values when one name occurs twice", () => {
|
|
27
|
+
expect(extractRouteParams(NESTED_FORM_PATTERN, NESTED_FORM_PATH)).toEqual({
|
|
28
|
+
id: "row-7",
|
|
29
|
+
"id:1": "ws-1",
|
|
30
|
+
"id:2": "row-7",
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("numbers every occurrence of a name repeated more than twice", () => {
|
|
35
|
+
expect(
|
|
36
|
+
extractRouteParams(
|
|
37
|
+
"/a/:id/b/:id/c/:id/view",
|
|
38
|
+
"/a/one/b/two/c/three/view",
|
|
39
|
+
),
|
|
40
|
+
).toEqual({
|
|
41
|
+
id: "three",
|
|
42
|
+
"id:1": "one",
|
|
43
|
+
"id:2": "two",
|
|
44
|
+
"id:3": "three",
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("indexes only the repeated name, leaving its neighbours untouched", () => {
|
|
49
|
+
expect(
|
|
50
|
+
extractRouteParams(
|
|
51
|
+
"/workspaces/:id/:tenant/invoiceTable/:id/edit",
|
|
52
|
+
"/workspaces/ws-1/t-9/invoiceTable/row-7/edit",
|
|
53
|
+
),
|
|
54
|
+
).toEqual({
|
|
55
|
+
id: "row-7",
|
|
56
|
+
"id:1": "ws-1",
|
|
57
|
+
"id:2": "row-7",
|
|
58
|
+
tenant: "t-9",
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("still refuses a path the pattern does not match", () => {
|
|
63
|
+
expect(extractRouteParams(NESTED_FORM_PATTERN, "/workspaces/ws-1")).toBe(
|
|
64
|
+
null,
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("form URL variables on a repeated placeholder", () => {
|
|
70
|
+
const context = {
|
|
71
|
+
routeParams: extractRouteParams(NESTED_FORM_PATTERN, NESTED_FORM_PATH)!,
|
|
72
|
+
routeQuery: {},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// What the TableView factory generates for the edit form: the bare name has
|
|
76
|
+
// to stay the row id, on a nested route as on a flat one.
|
|
77
|
+
it("resolves the bare name to the row id", () => {
|
|
78
|
+
expect(
|
|
79
|
+
replaceUrlVariables("/invoices/edit?id={{params.id}}", context),
|
|
80
|
+
).toBe("/invoices/edit?id=row-7");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("resolves an indexed name to the id of the carrying page", () => {
|
|
84
|
+
expect(
|
|
85
|
+
replaceUrlVariables(
|
|
86
|
+
"/workspaces/{{params.id:1}}/invoices/{{params.id}}",
|
|
87
|
+
context,
|
|
88
|
+
),
|
|
89
|
+
).toBe("/workspaces/ws-1/invoices/row-7");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("leaves an indexed token that no occurrence answers alone", () => {
|
|
93
|
+
expect(replaceUrlVariables("/invoices/{{params.id:3}}", context)).toBe(
|
|
94
|
+
"/invoices/{{params.id:3}}",
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("resolves the bare name on a single-placeholder route as before", () => {
|
|
99
|
+
expect(
|
|
100
|
+
replaceUrlVariables("/customers/edit?id={{params.id}}", {
|
|
101
|
+
routeParams: extractRouteParams(
|
|
102
|
+
"/customers/:id/edit",
|
|
103
|
+
"/customers/c-1/edit",
|
|
104
|
+
)!,
|
|
105
|
+
routeQuery: {},
|
|
106
|
+
}),
|
|
107
|
+
).toBe("/customers/edit?id=c-1");
|
|
108
|
+
});
|
|
109
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/AntelopeJS/dms.git"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"zod": "~3.24.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@antelopejs/core": ">=1.
|
|
54
|
+
"@antelopejs/core": ">=1.9.0 <2",
|
|
55
55
|
"@antelopejs/tooling-configs": ">=0.0.6 <1.0.0",
|
|
56
56
|
"@types/archiver": "^6.0.4",
|
|
57
57
|
"@types/chai": "^4.3.20",
|