@jskit-ai/http-web 0.1.96 → 0.2.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/CHANGELOG.md +96 -0
- package/fixtures/select-field/App.vue +56 -0
- package/fixtures/select-field/index.html +12 -0
- package/fixtures/select-field/main.js +24 -0
- package/fixtures/select-field/vite.config.mjs +15 -0
- package/locales/en.json +115 -0
- package/package.json +13 -7
- package/patterns/crud-screen-set/PATTERN.md +46 -0
- package/src/client/components/CrudAddEditScreen.vue +10 -4
- package/src/client/components/CrudDeleteAction.vue +10 -7
- package/src/client/components/CrudListBulkActionSurface.vue +19 -7
- package/src/client/components/CrudListDateFilterControl.vue +10 -5
- package/src/client/components/CrudListFilterControls.vue +25 -17
- package/src/client/components/CrudListFilterSurface.vue +14 -7
- package/src/client/components/CrudListRecordActionMenu.vue +17 -5
- package/src/client/components/CrudListScreen.vue +31 -18
- package/src/client/components/CrudViewScreen.vue +17 -7
- package/src/client/components/SelectField.vue +55 -0
- package/src/client/composables/crud/crudLookupFieldRuntime.js +14 -29
- package/src/client/composables/internal/crudListFilterLookupSupport.js +7 -4
- package/src/client/composables/internal/crudListParentTitleSupport.js +6 -3
- package/src/client/composables/records/useAddEdit.js +13 -7
- package/src/client/composables/records/useList.js +6 -3
- package/src/client/composables/records/useView.js +7 -4
- package/src/client/composables/runtime/operationValidationHelpers.js +16 -11
- package/src/client/composables/runtime/useAddEditCore.js +9 -6
- package/src/client/composables/runtime/useCommandCore.js +8 -5
- package/src/client/composables/runtime/useEndpointResource.js +7 -5
- package/src/client/composables/runtime/useListCore.js +5 -2
- package/src/client/composables/runtime/useUiFeedback.js +1 -1
- package/src/client/composables/runtime/useViewCore.js +5 -2
- package/src/client/composables/support/errorMessageHelpers.js +24 -8
- package/src/client/composables/support/listSearchSupport.js +4 -1
- package/src/client/composables/useAccess.js +4 -1
- package/src/client/composables/useCommand.js +5 -4
- package/src/client/composables/useCrudAddEditScreen.js +5 -2
- package/src/client/composables/useCrudDeleteAction.js +6 -3
- package/src/client/composables/useCrudListFilterLookups.js +6 -3
- package/src/client/composables/useCrudListFilters.js +5 -1
- package/src/client/composables/useCrudListParentTitle.js +5 -2
- package/src/client/composables/useCrudListScreen.js +8 -5
- package/src/client/composables/useCrudViewScreen.js +7 -4
- package/src/client/composables/usePagedCollection.js +5 -2
- package/src/client/composables/useScopeRuntime.js +7 -1
- package/src/client/i18n.js +8 -0
- package/src/client/support/crudListDateFilterSupport.js +18 -9
- package/src/client/support/selectFieldSupport.js +71 -0
- package/test/crudListBulkActionSurface.test.js +1 -1
- package/test/crudListFilterSurface.test.js +2 -2
- package/test/crudLookupFieldRuntime.test.js +42 -0
- package/test/crudScreenComponents.test.js +1 -1
- package/test/exportsContract.test.js +4 -1
- package/test/i18nCatalog.test.js +16 -0
- package/test/selectField.browser.test.js +63 -0
- package/test/selectFieldSupport.test.js +68 -0
- package/test/translation.test.js +164 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 - 2026-10-29
|
|
4
|
+
|
|
5
|
+
- Translation ready: every user-visible text is a message key with its English in `locales/en.json`, so an app translates it by supplying translation files only. With no translations, texts and behaviour are unchanged. See the guide "Translating a JSKIT app".
|
|
6
|
+
- HTTP, network and validation errors render through the server code when its English matches JSKIT's, otherwise as sent.
|
|
7
|
+
- `useAddEdit`, `useCommand` and `useEndpointResource` message defaults are message keys rendered when shown; plain-text messages passed in still show as written.
|
|
8
|
+
|
|
9
|
+
### New message keys (80)
|
|
10
|
+
|
|
11
|
+
All keys in `locales/en.json` (exported as `./locales/en.json`) are new in this version.
|
|
12
|
+
|
|
13
|
+
<details><summary>Key list</summary>
|
|
14
|
+
|
|
15
|
+
- `jskit.http.access.permissionsUnavailable`
|
|
16
|
+
- `jskit.http.access.routeParamsRequired`
|
|
17
|
+
- `jskit.http.actions.actions`
|
|
18
|
+
- `jskit.http.actions.apply`
|
|
19
|
+
- `jskit.http.actions.cancel`
|
|
20
|
+
- `jskit.http.actions.clear`
|
|
21
|
+
- `jskit.http.actions.clearAll`
|
|
22
|
+
- `jskit.http.actions.close`
|
|
23
|
+
- `jskit.http.actions.delete`
|
|
24
|
+
- `jskit.http.actions.deleting`
|
|
25
|
+
- `jskit.http.actions.edit`
|
|
26
|
+
- `jskit.http.actions.loadMore`
|
|
27
|
+
- `jskit.http.actions.loadingMore`
|
|
28
|
+
- `jskit.http.actions.more`
|
|
29
|
+
- `jskit.http.actions.open`
|
|
30
|
+
- `jskit.http.actions.refresh`
|
|
31
|
+
- `jskit.http.actions.refreshing`
|
|
32
|
+
- `jskit.http.actions.retry`
|
|
33
|
+
- `jskit.http.actions.retrying`
|
|
34
|
+
- `jskit.http.actions.running`
|
|
35
|
+
- `jskit.http.actions.save`
|
|
36
|
+
- `jskit.http.actions.saving`
|
|
37
|
+
- `jskit.http.crud.bulk.actions`
|
|
38
|
+
- `jskit.http.crud.bulk.selected`
|
|
39
|
+
- `jskit.http.crud.bulk.selection`
|
|
40
|
+
- `jskit.http.crud.delete.button`
|
|
41
|
+
- `jskit.http.crud.delete.description`
|
|
42
|
+
- `jskit.http.crud.delete.failed`
|
|
43
|
+
- `jskit.http.crud.delete.listRouteUnavailable`
|
|
44
|
+
- `jskit.http.crud.delete.title`
|
|
45
|
+
- `jskit.http.crud.filters.calendar`
|
|
46
|
+
- `jskit.http.crud.filters.chipDate`
|
|
47
|
+
- `jskit.http.crud.filters.chipFrom`
|
|
48
|
+
- `jskit.http.crud.filters.chipRange`
|
|
49
|
+
- `jskit.http.crud.filters.chipTo`
|
|
50
|
+
- `jskit.http.crud.filters.dateRange`
|
|
51
|
+
- `jskit.http.crud.filters.enterId`
|
|
52
|
+
- `jskit.http.crud.filters.enterIds`
|
|
53
|
+
- `jskit.http.crud.filters.option`
|
|
54
|
+
- `jskit.http.crud.filters.optionValue`
|
|
55
|
+
- `jskit.http.crud.filters.optionsLoadFailed`
|
|
56
|
+
- `jskit.http.crud.filters.rangeFrom`
|
|
57
|
+
- `jskit.http.crud.filters.rangeMax`
|
|
58
|
+
- `jskit.http.crud.filters.rangeMin`
|
|
59
|
+
- `jskit.http.crud.filters.rangeTo`
|
|
60
|
+
- `jskit.http.crud.filters.selectDate`
|
|
61
|
+
- `jskit.http.crud.filters.selectEndDate`
|
|
62
|
+
- `jskit.http.crud.filters.selectStartDate`
|
|
63
|
+
- `jskit.http.crud.filters.title`
|
|
64
|
+
- `jskit.http.crud.list.emptyBody`
|
|
65
|
+
- `jskit.http.crud.list.loadErrorBody`
|
|
66
|
+
- `jskit.http.crud.list.loadFailed`
|
|
67
|
+
- `jskit.http.crud.list.newRecord`
|
|
68
|
+
- `jskit.http.crud.list.selectRecord`
|
|
69
|
+
- `jskit.http.crud.list.selectVisibleRows`
|
|
70
|
+
- `jskit.http.crud.lookup.optionsLoadFailed`
|
|
71
|
+
- `jskit.http.crud.no`
|
|
72
|
+
- `jskit.http.crud.parent.loadFailed`
|
|
73
|
+
- `jskit.http.crud.parent.notFound`
|
|
74
|
+
- `jskit.http.crud.parent.recordWithId`
|
|
75
|
+
- `jskit.http.crud.record`
|
|
76
|
+
- `jskit.http.crud.recordNotFound`
|
|
77
|
+
- `jskit.http.crud.records`
|
|
78
|
+
- `jskit.http.crud.view.backTo`
|
|
79
|
+
- `jskit.http.crud.view.loadFailed`
|
|
80
|
+
- `jskit.http.crud.view.notFound`
|
|
81
|
+
- `jskit.http.crud.yes`
|
|
82
|
+
- `jskit.http.feedback.actionFailed`
|
|
83
|
+
- `jskit.http.feedback.completed`
|
|
84
|
+
- `jskit.http.feedback.fixInvalidValues`
|
|
85
|
+
- `jskit.http.feedback.requestFailed`
|
|
86
|
+
- `jskit.http.feedback.saveFailed`
|
|
87
|
+
- `jskit.http.feedback.saved`
|
|
88
|
+
- `jskit.http.feedback.validationFailed`
|
|
89
|
+
- `jskit.http.list.label`
|
|
90
|
+
- `jskit.http.list.loadFailed`
|
|
91
|
+
- `jskit.http.list.search`
|
|
92
|
+
- `jskit.http.resource.label`
|
|
93
|
+
- `jskit.http.resource.loadFailed`
|
|
94
|
+
- `jskit.http.resource.saveFailed`
|
|
95
|
+
|
|
96
|
+
</details>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import SelectField from "../../src/client/components/SelectField.vue";
|
|
4
|
+
|
|
5
|
+
const bath = { value: 7, label: "Bath" };
|
|
6
|
+
const daycare = { value: 53, label: "Daycare - One Day" };
|
|
7
|
+
const loading = ref(true);
|
|
8
|
+
const services = ref([]);
|
|
9
|
+
const extras = ref([bath]);
|
|
10
|
+
const service = ref(53);
|
|
11
|
+
const retired = ref(99);
|
|
12
|
+
const serviceIds = ref([7, 53]);
|
|
13
|
+
|
|
14
|
+
// The test releases the delayed options request deterministically.
|
|
15
|
+
window.releaseOptions = () => {
|
|
16
|
+
services.value = [bath, daycare];
|
|
17
|
+
extras.value = [bath, daycare];
|
|
18
|
+
loading.value = false;
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<v-app>
|
|
24
|
+
<v-main class="pa-4">
|
|
25
|
+
<SelectField
|
|
26
|
+
v-model="service"
|
|
27
|
+
label="Service"
|
|
28
|
+
:items="services"
|
|
29
|
+
item-title="label"
|
|
30
|
+
item-value="value"
|
|
31
|
+
:loading="loading"
|
|
32
|
+
/>
|
|
33
|
+
<SelectField
|
|
34
|
+
v-model="retired"
|
|
35
|
+
searchable
|
|
36
|
+
label="Retired service"
|
|
37
|
+
:items="services"
|
|
38
|
+
item-title="label"
|
|
39
|
+
item-value="value"
|
|
40
|
+
:loading="loading"
|
|
41
|
+
/>
|
|
42
|
+
<SelectField
|
|
43
|
+
v-model="serviceIds"
|
|
44
|
+
label="Extras"
|
|
45
|
+
multiple
|
|
46
|
+
chips
|
|
47
|
+
closable-chips
|
|
48
|
+
:items="extras"
|
|
49
|
+
item-title="label"
|
|
50
|
+
item-value="value"
|
|
51
|
+
:loading="loading"
|
|
52
|
+
/>
|
|
53
|
+
<pre data-testid="select-field-models">{{ JSON.stringify({ service, retired, serviceIds }) }}</pre>
|
|
54
|
+
</v-main>
|
|
55
|
+
</v-app>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Select field display regression</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="/main.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createApp } from "vue";
|
|
2
|
+
import "vuetify/styles";
|
|
3
|
+
import { createVuetify } from "vuetify";
|
|
4
|
+
import * as components from "vuetify/components";
|
|
5
|
+
import * as directives from "vuetify/directives";
|
|
6
|
+
import { aliases as mdiAliases, mdi } from "vuetify/iconsets/mdi-svg";
|
|
7
|
+
import App from "./App.vue";
|
|
8
|
+
|
|
9
|
+
const vuetify = createVuetify({
|
|
10
|
+
components,
|
|
11
|
+
directives,
|
|
12
|
+
theme: {
|
|
13
|
+
defaultTheme: "light"
|
|
14
|
+
},
|
|
15
|
+
icons: {
|
|
16
|
+
defaultSet: "mdi",
|
|
17
|
+
aliases: mdiAliases,
|
|
18
|
+
sets: { mdi }
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
createApp(App)
|
|
23
|
+
.use(vuetify)
|
|
24
|
+
.mount("#app");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { defineConfig } from "vite";
|
|
4
|
+
import vue from "@vitejs/plugin-vue";
|
|
5
|
+
|
|
6
|
+
const fixtureRoot = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
root: fixtureRoot,
|
|
10
|
+
plugins: [vue()],
|
|
11
|
+
server: {
|
|
12
|
+
host: "127.0.0.1",
|
|
13
|
+
strictPort: true
|
|
14
|
+
}
|
|
15
|
+
});
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jskit": {
|
|
3
|
+
"http": {
|
|
4
|
+
"access": {
|
|
5
|
+
"permissionsUnavailable": "Permissions are unavailable in placement context.",
|
|
6
|
+
"routeParamsRequired": "Route parameters {params} are required for surface \"{surface}\"."
|
|
7
|
+
},
|
|
8
|
+
"actions": {
|
|
9
|
+
"actions": "Actions",
|
|
10
|
+
"apply": "Apply",
|
|
11
|
+
"cancel": "Cancel",
|
|
12
|
+
"clear": "Clear",
|
|
13
|
+
"clearAll": "Clear all",
|
|
14
|
+
"close": "Close",
|
|
15
|
+
"delete": "Delete",
|
|
16
|
+
"deleting": "Deleting…",
|
|
17
|
+
"edit": "Edit",
|
|
18
|
+
"loadMore": "Load more",
|
|
19
|
+
"loadingMore": "Loading more…",
|
|
20
|
+
"more": "More",
|
|
21
|
+
"open": "Open",
|
|
22
|
+
"refresh": "Refresh",
|
|
23
|
+
"refreshing": "Refreshing…",
|
|
24
|
+
"retry": "Retry",
|
|
25
|
+
"retrying": "Retrying…",
|
|
26
|
+
"running": "{label}…",
|
|
27
|
+
"save": "Save",
|
|
28
|
+
"saving": "Saving…"
|
|
29
|
+
},
|
|
30
|
+
"crud": {
|
|
31
|
+
"bulk": {
|
|
32
|
+
"actions": "Bulk actions",
|
|
33
|
+
"selected": "{count} selected",
|
|
34
|
+
"selection": "Selection"
|
|
35
|
+
},
|
|
36
|
+
"delete": {
|
|
37
|
+
"button": "Delete {resource}",
|
|
38
|
+
"description": "This permanently deletes this {resource}. This action cannot be undone.",
|
|
39
|
+
"failed": "Unable to delete record.",
|
|
40
|
+
"listRouteUnavailable": "Deleted the record, but the generated list route is unavailable.",
|
|
41
|
+
"title": "Delete {resource}?"
|
|
42
|
+
},
|
|
43
|
+
"filters": {
|
|
44
|
+
"calendar": "{label} calendar",
|
|
45
|
+
"chipDate": "{label}: {date}",
|
|
46
|
+
"chipFrom": "{label}: from {from}",
|
|
47
|
+
"chipRange": "{label}: {from} to {to}",
|
|
48
|
+
"chipTo": "{label}: to {to}",
|
|
49
|
+
"dateRange": "{label} date range",
|
|
50
|
+
"enterId": "Enter id",
|
|
51
|
+
"enterIds": "Enter ids",
|
|
52
|
+
"option": "Option",
|
|
53
|
+
"optionValue": "{label} {value}",
|
|
54
|
+
"optionsLoadFailed": "Unable to load filter options ({path}).",
|
|
55
|
+
"rangeFrom": "{label} from",
|
|
56
|
+
"rangeMax": "{label} max",
|
|
57
|
+
"rangeMin": "{label} min",
|
|
58
|
+
"rangeTo": "{label} to",
|
|
59
|
+
"selectDate": "Select date",
|
|
60
|
+
"selectEndDate": "Select end date",
|
|
61
|
+
"selectStartDate": "Select start date",
|
|
62
|
+
"title": "Filters"
|
|
63
|
+
},
|
|
64
|
+
"list": {
|
|
65
|
+
"emptyBody": "Create the first record to start using this workflow.",
|
|
66
|
+
"loadErrorBody": "Check the connection and try again.",
|
|
67
|
+
"loadFailed": "Unable to load records.",
|
|
68
|
+
"newRecord": "New record",
|
|
69
|
+
"selectRecord": "Select {title}",
|
|
70
|
+
"selectVisibleRows": "Select visible rows"
|
|
71
|
+
},
|
|
72
|
+
"lookup": {
|
|
73
|
+
"optionsLoadFailed": "Unable to load lookup options ({path})."
|
|
74
|
+
},
|
|
75
|
+
"no": "No",
|
|
76
|
+
"parent": {
|
|
77
|
+
"loadFailed": "Unable to load parent record.",
|
|
78
|
+
"notFound": "Parent record not found.",
|
|
79
|
+
"recordWithId": "{label} #{id}"
|
|
80
|
+
},
|
|
81
|
+
"record": "Record",
|
|
82
|
+
"recordNotFound": "Record not found.",
|
|
83
|
+
"records": "Records",
|
|
84
|
+
"view": {
|
|
85
|
+
"backTo": "Back to {resources}",
|
|
86
|
+
"loadFailed": "Unable to load record.",
|
|
87
|
+
"notFound": "This {resource} could not be found."
|
|
88
|
+
},
|
|
89
|
+
"yes": "Yes"
|
|
90
|
+
},
|
|
91
|
+
"feedback": {
|
|
92
|
+
"actionFailed": "Unable to complete action.",
|
|
93
|
+
"completed": "Completed.",
|
|
94
|
+
"fixInvalidValues": "Fix invalid values and try again.",
|
|
95
|
+
"requestFailed": "Request failed.",
|
|
96
|
+
"saveFailed": "Unable to save.",
|
|
97
|
+
"saved": "Saved.",
|
|
98
|
+
"validationFailed": "Validation failed."
|
|
99
|
+
},
|
|
100
|
+
"list": {
|
|
101
|
+
"label": "List",
|
|
102
|
+
"loadFailed": "Unable to load list.",
|
|
103
|
+
"search": "Search"
|
|
104
|
+
},
|
|
105
|
+
"resource": {
|
|
106
|
+
"label": "Resource",
|
|
107
|
+
"loadFailed": "Unable to load resource.",
|
|
108
|
+
"saveFailed": "Unable to save resource."
|
|
109
|
+
},
|
|
110
|
+
"selectField": {
|
|
111
|
+
"unavailableOption": "Unavailable option"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/http-web",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"./client/components/CrudListFilterSurface": "./src/client/components/CrudListFilterSurface.vue",
|
|
14
14
|
"./client/components/CrudListScreen": "./src/client/components/CrudListScreen.vue",
|
|
15
15
|
"./client/components/CrudViewScreen": "./src/client/components/CrudViewScreen.vue",
|
|
16
|
+
"./client/components/SelectField": "./src/client/components/SelectField.vue",
|
|
16
17
|
"./client/bulkActions": "./src/client/bulkActions.js",
|
|
17
18
|
"./client/filters": "./src/client/filters.js",
|
|
18
19
|
"./client/rowActions": "./src/client/rowActions.js",
|
|
@@ -41,17 +42,18 @@
|
|
|
41
42
|
"./client/crudHttpClient": "./src/client/composables/crud/crudHttpClientSupport.js",
|
|
42
43
|
"./client/lib/httpClient": "./src/client/lib/httpClient.js",
|
|
43
44
|
"./client/lib/permissions": "./src/client/lib/permissions.js",
|
|
44
|
-
"./client/support/contractGuards": "./src/client/support/contractGuards.js"
|
|
45
|
+
"./client/support/contractGuards": "./src/client/support/contractGuards.js",
|
|
46
|
+
"./locales/en.json": "./locales/en.json"
|
|
45
47
|
},
|
|
46
48
|
"dependencies": {
|
|
47
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
49
|
+
"@jskit-ai/resource-crud-core": "0.1.191",
|
|
48
50
|
"@mdi/js": "^7.4.47"
|
|
49
51
|
},
|
|
50
52
|
"peerDependencies": {
|
|
51
|
-
"@jskit-ai/http-runtime": "0.
|
|
52
|
-
"@jskit-ai/kernel": "0.
|
|
53
|
-
"@jskit-ai/realtime": "0.
|
|
54
|
-
"@jskit-ai/shell-web": "0.
|
|
53
|
+
"@jskit-ai/http-runtime": "0.2.0",
|
|
54
|
+
"@jskit-ai/kernel": "0.2.0",
|
|
55
|
+
"@jskit-ai/realtime": "0.2.0",
|
|
56
|
+
"@jskit-ai/shell-web": "0.2.0",
|
|
55
57
|
"@tanstack/vue-query": "^5.90.5",
|
|
56
58
|
"vue": "^3.5.13",
|
|
57
59
|
"vue-router": "^5.0.4",
|
|
@@ -116,6 +118,10 @@
|
|
|
116
118
|
{
|
|
117
119
|
"subpath": "./client/components/CrudAddEditScreen",
|
|
118
120
|
"summary": "Exports the shared CRUD add/edit screen."
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"subpath": "./client/components/SelectField",
|
|
124
|
+
"summary": "Exports the select/autocomplete field that never shows a stored id as its title."
|
|
119
125
|
}
|
|
120
126
|
]
|
|
121
127
|
},
|
|
@@ -108,12 +108,58 @@ realtime events, delete availability, and action definitions. Use the screen
|
|
|
108
108
|
slots for domain-specific content. Use a lower-level request composable only
|
|
109
109
|
when the wire contract genuinely is not CRUD.
|
|
110
110
|
|
|
111
|
+
### Lookup and selection fields
|
|
112
|
+
|
|
113
|
+
A form field whose `relation` is a `lookup` takes its options from
|
|
114
|
+
`createCrudLookupFieldRuntime({ formFields })` in
|
|
115
|
+
`@jskit-ai/http-web/client/composables/crudLookupFieldRuntime`.
|
|
116
|
+
`resolveLookupItems(fieldKey, { selectedValue, selectedRecord })` returns
|
|
117
|
+
`{ value, label, record }` options. When the loaded record carries a hydrated
|
|
118
|
+
lookup label for a selected value missing from the current options, that option
|
|
119
|
+
is listed first; a selected value without a label is not listed.
|
|
120
|
+
|
|
121
|
+
Render selection fields whose options load from the server, or whose value is a
|
|
122
|
+
record id, with `SelectField` from
|
|
123
|
+
`@jskit-ai/http-web/client/components/SelectField`, not a raw `v-select`,
|
|
124
|
+
`v-autocomplete` or `v-combobox`. Vuetify titles a value missing from `items`
|
|
125
|
+
with the value itself, so a stored id such as `53` shows until the options
|
|
126
|
+
arrive. `SelectField` hides an unresolved value while `loading` is true, shows
|
|
127
|
+
"Unavailable option" once the options settle, and remembers titles it has seen
|
|
128
|
+
so a narrowing search does not blank a chosen value. Display never changes the
|
|
129
|
+
stored value. `searchable` renders an autocomplete; other props and slots pass
|
|
130
|
+
through to Vuetify.
|
|
131
|
+
|
|
132
|
+
```vue
|
|
133
|
+
<CrudAddEditScreen :screen="screen" v-bind="lookups">
|
|
134
|
+
<template #fields="{ formState, addEdit, resolveLookupItems, resolveLookupLoading, resolveLookupSearch, setLookupSearch }">
|
|
135
|
+
<v-col cols="12" md="6">
|
|
136
|
+
<SelectField
|
|
137
|
+
v-model="formState.serviceId"
|
|
138
|
+
searchable
|
|
139
|
+
no-filter
|
|
140
|
+
label="Service"
|
|
141
|
+
item-title="label"
|
|
142
|
+
item-value="value"
|
|
143
|
+
:items="resolveLookupItems('serviceId', { selectedValue: formState.serviceId, selectedRecord: addEdit.resource.data.value })"
|
|
144
|
+
:loading="resolveLookupLoading('serviceId')"
|
|
145
|
+
:search="resolveLookupSearch('serviceId')"
|
|
146
|
+
@update:search="setLookupSearch('serviceId', $event)"
|
|
147
|
+
/>
|
|
148
|
+
</v-col>
|
|
149
|
+
</template>
|
|
150
|
+
</CrudAddEditScreen>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Here `lookups` is the page's `createCrudLookupFieldRuntime()` result for the
|
|
154
|
+
same form fields.
|
|
155
|
+
|
|
111
156
|
## Verification
|
|
112
157
|
|
|
113
158
|
- Mount each route with a representative resource response.
|
|
114
159
|
- Verify skeleton, empty, success, local load-error, and retry states.
|
|
115
160
|
- Verify create, edit, validation failure, delete confirmation, and navigation.
|
|
116
161
|
- Verify filters and actions when declared.
|
|
162
|
+
- Delay lookup options and confirm a selection field never shows a stored id.
|
|
117
163
|
- Exercise compact, medium, and expanded widths with Playwright.
|
|
118
164
|
- Confirm keyboard access, 48 CSS-pixel compact targets, no horizontal overflow,
|
|
119
165
|
and toast-based mutation feedback.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, unref } from "vue";
|
|
3
|
+
import { useJskitText } from "../i18n.js";
|
|
3
4
|
|
|
4
5
|
const props = defineProps({
|
|
5
6
|
screen: {
|
|
@@ -24,11 +25,14 @@ const props = defineProps({
|
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
const { t, text } = useJskitText();
|
|
27
29
|
const formRuntime = computed(() => props.screen?.formRuntime || {});
|
|
28
30
|
const addEdit = computed(() => props.screen?.addEdit || formRuntime.value?.addEdit || {});
|
|
29
31
|
const formState = computed(() => props.screen?.formState || formRuntime.value?.form || {});
|
|
30
32
|
const mode = computed(() => String(unref(props.screen?.mode) || "new").trim() || "new");
|
|
31
|
-
const saveLabel = computed(() =>
|
|
33
|
+
const saveLabel = computed(() =>
|
|
34
|
+
String(text(unref(props.screen?.saveLabel)) || "").trim() || t("jskit.http.actions.save")
|
|
35
|
+
);
|
|
32
36
|
const cancelTo = computed(() => unref(props.screen?.cancelTo) || "");
|
|
33
37
|
|
|
34
38
|
function resolveFieldErrors(fieldKey) {
|
|
@@ -63,14 +67,16 @@ function resolveCancelTo(target = cancelTo.value) {
|
|
|
63
67
|
:cancel-to="resolveCancelTo()"
|
|
64
68
|
:submit="addEdit.submit"
|
|
65
69
|
>
|
|
66
|
-
<v-btn v-if="cancelTo" color="primary" variant="outlined" :to="resolveCancelTo(cancelTo)">
|
|
70
|
+
<v-btn v-if="cancelTo" color="primary" variant="outlined" :to="resolveCancelTo(cancelTo)">
|
|
71
|
+
{{ t("jskit.http.actions.cancel") }}
|
|
72
|
+
</v-btn>
|
|
67
73
|
<v-btn
|
|
68
74
|
color="primary"
|
|
69
75
|
variant="flat"
|
|
70
76
|
:disabled="addEdit.isSubmitDisabled"
|
|
71
77
|
@click="addEdit.submit"
|
|
72
78
|
>
|
|
73
|
-
{{ addEdit.isSaving ? "
|
|
79
|
+
{{ addEdit.isSaving ? t("jskit.http.actions.saving") : saveLabel }}
|
|
74
80
|
</v-btn>
|
|
75
81
|
</slot>
|
|
76
82
|
</div>
|
|
@@ -87,7 +93,7 @@ function resolveCancelTo(target = cancelTo.value) {
|
|
|
87
93
|
:disabled="addEdit.isFetching"
|
|
88
94
|
@click="addEdit.refresh"
|
|
89
95
|
>
|
|
90
|
-
{{ addEdit.isFetching ? "
|
|
96
|
+
{{ addEdit.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
|
|
91
97
|
</v-btn>
|
|
92
98
|
</div>
|
|
93
99
|
<template v-else-if="formRuntime.showFormSkeleton">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, useId } from "vue";
|
|
3
3
|
import { mdiDeleteOutline } from "@mdi/js";
|
|
4
|
+
import { useJskitText } from "../i18n.js";
|
|
4
5
|
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
action: {
|
|
@@ -9,12 +10,14 @@ const props = defineProps({
|
|
|
9
10
|
},
|
|
10
11
|
resourceSingularTitle: {
|
|
11
12
|
type: String,
|
|
12
|
-
default: "
|
|
13
|
+
default: ""
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
|
|
17
|
+
const { t, text } = useJskitText();
|
|
18
|
+
|
|
16
19
|
const resourceLabel = computed(() =>
|
|
17
|
-
String(props.resourceSingularTitle || "
|
|
20
|
+
String(text(props.resourceSingularTitle) || "").trim() || t("jskit.http.crud.record")
|
|
18
21
|
);
|
|
19
22
|
const componentId = useId();
|
|
20
23
|
const titleId = `${componentId}-delete-title`;
|
|
@@ -40,7 +43,7 @@ function handleDialogModelUpdate(isOpen) {
|
|
|
40
43
|
:disabled="!action.canDelete"
|
|
41
44
|
@click="action.request"
|
|
42
45
|
>
|
|
43
|
-
|
|
46
|
+
{{ t("jskit.http.crud.delete.button", { resource: resourceLabel }) }}
|
|
44
47
|
</v-btn>
|
|
45
48
|
|
|
46
49
|
<v-dialog
|
|
@@ -54,10 +57,10 @@ function handleDialogModelUpdate(isOpen) {
|
|
|
54
57
|
@update:model-value="handleDialogModelUpdate"
|
|
55
58
|
>
|
|
56
59
|
<v-card>
|
|
57
|
-
<v-card-title :id="titleId">
|
|
60
|
+
<v-card-title :id="titleId">{{ t("jskit.http.crud.delete.title", { resource: resourceLabel }) }}</v-card-title>
|
|
58
61
|
<v-card-text>
|
|
59
62
|
<p :id="descriptionId" class="mb-0">
|
|
60
|
-
|
|
63
|
+
{{ t("jskit.http.crud.delete.description", { resource: resourceLabel.toLowerCase() }) }}
|
|
61
64
|
</p>
|
|
62
65
|
<v-alert
|
|
63
66
|
v-if="action.error"
|
|
@@ -76,7 +79,7 @@ function handleDialogModelUpdate(isOpen) {
|
|
|
76
79
|
:disabled="action.isDeleting"
|
|
77
80
|
@click="closeDialog"
|
|
78
81
|
>
|
|
79
|
-
|
|
82
|
+
{{ t("jskit.http.actions.cancel") }}
|
|
80
83
|
</v-btn>
|
|
81
84
|
<v-btn
|
|
82
85
|
color="error"
|
|
@@ -84,7 +87,7 @@ function handleDialogModelUpdate(isOpen) {
|
|
|
84
87
|
:disabled="!action.canDelete"
|
|
85
88
|
@click="action.confirm"
|
|
86
89
|
>
|
|
87
|
-
{{ action.isDeleting ? "
|
|
90
|
+
{{ action.isDeleting ? t("jskit.http.actions.deleting") : t("jskit.http.actions.delete") }}
|
|
88
91
|
</v-btn>
|
|
89
92
|
</v-card-actions>
|
|
90
93
|
</v-card>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { useDisplay } from "vuetify";
|
|
4
|
+
import { useJskitText } from "../i18n.js";
|
|
4
5
|
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
runtime: {
|
|
@@ -9,10 +10,15 @@ const props = defineProps({
|
|
|
9
10
|
},
|
|
10
11
|
title: {
|
|
11
12
|
type: String,
|
|
12
|
-
default:
|
|
13
|
+
default: undefined
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
|
|
17
|
+
const { t, text } = useJskitText();
|
|
18
|
+
const resolvedTitle = computed(() =>
|
|
19
|
+
props.title === undefined ? t("jskit.http.crud.bulk.selection") : text(props.title)
|
|
20
|
+
);
|
|
21
|
+
|
|
16
22
|
const { smAndDown: isCompactLayout } = useDisplay();
|
|
17
23
|
|
|
18
24
|
const actions = computed(() => Array.isArray(props.runtime?.actions) ? props.runtime.actions : []);
|
|
@@ -38,16 +44,22 @@ function isActionDisabled(action = {}) {
|
|
|
38
44
|
function isActionExecuting(action = {}) {
|
|
39
45
|
return Boolean(props.runtime?.isActionExecuting?.(action));
|
|
40
46
|
}
|
|
47
|
+
|
|
48
|
+
// Action labels may be message keys.
|
|
49
|
+
function actionLabel(action = {}) {
|
|
50
|
+
const label = text(action.label);
|
|
51
|
+
return isActionExecuting(action) ? t("jskit.http.actions.running", { label }) : label;
|
|
52
|
+
}
|
|
41
53
|
</script>
|
|
42
54
|
|
|
43
55
|
<template>
|
|
44
56
|
<section v-if="shouldRender" class="crud-list-bulk-action-surface">
|
|
45
57
|
<div class="crud-list-bulk-action-surface__summary">
|
|
46
58
|
<div class="crud-list-bulk-action-surface__copy">
|
|
47
|
-
<span class="text-overline text-medium-emphasis">{{
|
|
48
|
-
<strong>{{ selectedCount }}
|
|
59
|
+
<span class="text-overline text-medium-emphasis">{{ resolvedTitle }}</span>
|
|
60
|
+
<strong>{{ t("jskit.http.crud.bulk.selected", { count: selectedCount }) }}</strong>
|
|
49
61
|
</div>
|
|
50
|
-
<v-btn size="small" variant="text" @click="clearSelection">
|
|
62
|
+
<v-btn size="small" variant="text" @click="clearSelection">{{ t("jskit.http.actions.clear") }}</v-btn>
|
|
51
63
|
</div>
|
|
52
64
|
|
|
53
65
|
<div v-if="!isCompactLayout" class="crud-list-bulk-action-surface__actions">
|
|
@@ -60,19 +72,19 @@ function isActionExecuting(action = {}) {
|
|
|
60
72
|
:disabled="isActionDisabled(action)"
|
|
61
73
|
@click="execute(action)"
|
|
62
74
|
>
|
|
63
|
-
{{
|
|
75
|
+
{{ actionLabel(action) }}
|
|
64
76
|
</v-btn>
|
|
65
77
|
</div>
|
|
66
78
|
|
|
67
79
|
<v-menu v-else location="bottom end">
|
|
68
80
|
<template #activator="{ props: menuProps }">
|
|
69
|
-
<v-btn v-bind="menuProps" color="primary" variant="tonal">
|
|
81
|
+
<v-btn v-bind="menuProps" color="primary" variant="tonal">{{ t("jskit.http.crud.bulk.actions") }}</v-btn>
|
|
70
82
|
</template>
|
|
71
83
|
<v-list density="compact" min-width="180">
|
|
72
84
|
<v-list-item
|
|
73
85
|
v-for="action in actions"
|
|
74
86
|
:key="action.key"
|
|
75
|
-
:title="
|
|
87
|
+
:title="actionLabel(action)"
|
|
76
88
|
:prepend-icon="action.icon || undefined"
|
|
77
89
|
:disabled="isActionDisabled(action)"
|
|
78
90
|
@click="execute(action)"
|