@jskit-ai/http-web 0.1.95 → 0.2.0
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/locales/en.json +112 -0
- package/package.json +8 -7
- 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/composables/crud/crudLookupFieldRuntime.js +4 -1
- 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/useCrudList.js +6 -0
- package/src/client/composables/records/useCrudView.js +6 -0
- 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/test/crudListBulkActionSurface.test.js +1 -1
- package/test/crudListFilterSurface.test.js +2 -2
- package/test/crudScreenComponents.test.js +1 -1
- package/test/exportsContract.test.js +3 -1
- package/test/i18nCatalog.test.js +16 -0
- package/test/translation.test.js +164 -0
- package/test/useCrudListScreen.test.js +3 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
3
|
import { useDisplay } from "vuetify";
|
|
4
4
|
import CrudListFilterControls from "./CrudListFilterControls.vue";
|
|
5
|
+
import { useJskitText } from "../i18n.js";
|
|
5
6
|
|
|
6
7
|
const props = defineProps({
|
|
7
8
|
filters: {
|
|
@@ -14,10 +15,15 @@ const props = defineProps({
|
|
|
14
15
|
},
|
|
15
16
|
title: {
|
|
16
17
|
type: String,
|
|
17
|
-
default:
|
|
18
|
+
default: undefined
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
|
|
22
|
+
const { t, text } = useJskitText();
|
|
23
|
+
const resolvedTitle = computed(() =>
|
|
24
|
+
props.title === undefined ? t("jskit.http.crud.filters.title") : text(props.title)
|
|
25
|
+
);
|
|
26
|
+
|
|
21
27
|
const { smAndDown: isCompactLayout } = useDisplay();
|
|
22
28
|
|
|
23
29
|
const sheetOpen = ref(false);
|
|
@@ -51,7 +57,7 @@ function clearFilters() {
|
|
|
51
57
|
class="crud-list-filter-surface__open"
|
|
52
58
|
@click="sheetOpen = true"
|
|
53
59
|
>
|
|
54
|
-
{{
|
|
60
|
+
{{ resolvedTitle }}
|
|
55
61
|
<v-chip v-if="activeChips.length > 0" class="ml-2" size="x-small" color="primary" variant="flat">
|
|
56
62
|
{{ activeChips.length }}
|
|
57
63
|
</v-chip>
|
|
@@ -62,13 +68,14 @@ function clearFilters() {
|
|
|
62
68
|
v-for="chip in activeChips"
|
|
63
69
|
:key="chip.id"
|
|
64
70
|
closable
|
|
71
|
+
:close-label="t('jskit.http.actions.close')"
|
|
65
72
|
size="small"
|
|
66
73
|
variant="tonal"
|
|
67
74
|
@click:close="clearChip(chip)"
|
|
68
75
|
>
|
|
69
76
|
{{ chip.label }}
|
|
70
77
|
</v-chip>
|
|
71
|
-
<v-btn size="small" variant="text" @click="clearFilters">
|
|
78
|
+
<v-btn size="small" variant="text" @click="clearFilters">{{ t("jskit.http.actions.clearAll") }}</v-btn>
|
|
72
79
|
</div>
|
|
73
80
|
</div>
|
|
74
81
|
|
|
@@ -79,15 +86,15 @@ function clearFilters() {
|
|
|
79
86
|
<v-dialog v-model="sheetOpen" max-width="640" location="bottom">
|
|
80
87
|
<v-card rounded="lg" class="crud-list-filter-surface__sheet">
|
|
81
88
|
<v-card-title class="d-flex align-center justify-space-between">
|
|
82
|
-
<span>{{
|
|
83
|
-
<v-btn variant="text" @click="sheetOpen = false">
|
|
89
|
+
<span>{{ resolvedTitle }}</span>
|
|
90
|
+
<v-btn variant="text" @click="sheetOpen = false">{{ t("jskit.http.actions.close") }}</v-btn>
|
|
84
91
|
</v-card-title>
|
|
85
92
|
<v-card-text>
|
|
86
93
|
<CrudListFilterControls :filters="filterEntries" :runtime="runtime" stacked />
|
|
87
94
|
</v-card-text>
|
|
88
95
|
<v-card-actions class="justify-space-between">
|
|
89
|
-
<v-btn variant="text" @click="clearFilters">
|
|
90
|
-
<v-btn color="primary" variant="flat" @click="sheetOpen = false">
|
|
96
|
+
<v-btn variant="text" @click="clearFilters">{{ t("jskit.http.actions.clearAll") }}</v-btn>
|
|
97
|
+
<v-btn color="primary" variant="flat" @click="sheetOpen = false">{{ t("jskit.http.actions.apply") }}</v-btn>
|
|
91
98
|
</v-card-actions>
|
|
92
99
|
</v-card>
|
|
93
100
|
</v-dialog>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
import { useJskitText } from "../i18n.js";
|
|
3
4
|
|
|
4
5
|
const props = defineProps({
|
|
5
6
|
record: {
|
|
@@ -32,7 +33,7 @@ const props = defineProps({
|
|
|
32
33
|
},
|
|
33
34
|
buttonLabel: {
|
|
34
35
|
type: String,
|
|
35
|
-
default:
|
|
36
|
+
default: undefined
|
|
36
37
|
},
|
|
37
38
|
buttonVariant: {
|
|
38
39
|
type: String,
|
|
@@ -44,6 +45,11 @@ const props = defineProps({
|
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
|
|
48
|
+
const { t, text } = useJskitText();
|
|
49
|
+
const resolvedButtonLabel = computed(() =>
|
|
50
|
+
props.buttonLabel === undefined ? t("jskit.http.actions.actions") : text(props.buttonLabel)
|
|
51
|
+
);
|
|
52
|
+
|
|
47
53
|
const visibleRowActions = computed(() => {
|
|
48
54
|
if (typeof props.rowActions?.visibleActionsFor !== "function") {
|
|
49
55
|
return [];
|
|
@@ -61,6 +67,12 @@ function isRowActionLoading(action = {}) {
|
|
|
61
67
|
props.rowActions.isActionLoading(action, props.record, props.index);
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
// Action labels may be message keys.
|
|
71
|
+
function rowActionLabel(action = {}) {
|
|
72
|
+
const label = text(action.label);
|
|
73
|
+
return isRowActionLoading(action) ? t("jskit.http.actions.running", { label }) : label;
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
function isRowActionDisabled(action = {}) {
|
|
65
77
|
return typeof props.rowActions?.isActionDisabled !== "function" ||
|
|
66
78
|
props.rowActions.isActionDisabled(action, props.record, props.index);
|
|
@@ -82,25 +94,25 @@ function runRowAction(action = {}) {
|
|
|
82
94
|
:variant="buttonVariant"
|
|
83
95
|
:size="buttonSize"
|
|
84
96
|
>
|
|
85
|
-
{{
|
|
97
|
+
{{ resolvedButtonLabel }}
|
|
86
98
|
</v-btn>
|
|
87
99
|
</template>
|
|
88
100
|
<v-list density="compact" min-width="150">
|
|
89
101
|
<v-list-item
|
|
90
102
|
v-if="hasViewAction"
|
|
91
|
-
title="
|
|
103
|
+
:title="t('jskit.http.actions.open')"
|
|
92
104
|
:to="viewLocation"
|
|
93
105
|
/>
|
|
94
106
|
<v-list-item
|
|
95
107
|
v-if="hasEditAction"
|
|
96
|
-
title="
|
|
108
|
+
:title="t('jskit.http.actions.edit')"
|
|
97
109
|
:to="editLocation"
|
|
98
110
|
/>
|
|
99
111
|
<v-divider v-if="(hasViewAction || hasEditAction) && visibleRowActions.length > 0" />
|
|
100
112
|
<v-list-item
|
|
101
113
|
v-for="action in visibleRowActions"
|
|
102
114
|
:key="action.key"
|
|
103
|
-
:title="
|
|
115
|
+
:title="rowActionLabel(action)"
|
|
104
116
|
:base-color="action.color"
|
|
105
117
|
:disabled="isRowActionDisabled(action)"
|
|
106
118
|
@click="runRowAction(action)"
|
|
@@ -4,7 +4,9 @@ import { useRoute } from "vue-router";
|
|
|
4
4
|
import CrudListBulkActionSurface from "./CrudListBulkActionSurface.vue";
|
|
5
5
|
import CrudListFilterSurface from "./CrudListFilterSurface.vue";
|
|
6
6
|
import CrudListRecordActionMenu from "./CrudListRecordActionMenu.vue";
|
|
7
|
+
import { useJskitText } from "../i18n.js";
|
|
7
8
|
|
|
9
|
+
// Unset copy comes from the catalog; passed copy may be a message key.
|
|
8
10
|
const props = defineProps({
|
|
9
11
|
screen: {
|
|
10
12
|
type: Object,
|
|
@@ -12,18 +14,29 @@ const props = defineProps({
|
|
|
12
14
|
},
|
|
13
15
|
createLabel: {
|
|
14
16
|
type: String,
|
|
15
|
-
default:
|
|
17
|
+
default: undefined
|
|
16
18
|
},
|
|
17
19
|
loadErrorBody: {
|
|
18
20
|
type: String,
|
|
19
|
-
default:
|
|
21
|
+
default: undefined
|
|
20
22
|
},
|
|
21
23
|
emptyBody: {
|
|
22
24
|
type: String,
|
|
23
|
-
default:
|
|
25
|
+
default: undefined
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
|
|
29
|
+
const { t, text } = useJskitText();
|
|
30
|
+
const resolvedCreateLabel = computed(() =>
|
|
31
|
+
props.createLabel === undefined ? t("jskit.http.crud.list.newRecord") : text(props.createLabel)
|
|
32
|
+
);
|
|
33
|
+
const resolvedLoadErrorBody = computed(() =>
|
|
34
|
+
props.loadErrorBody === undefined ? t("jskit.http.crud.list.loadErrorBody") : text(props.loadErrorBody)
|
|
35
|
+
);
|
|
36
|
+
const resolvedEmptyBody = computed(() =>
|
|
37
|
+
props.emptyBody === undefined ? t("jskit.http.crud.list.emptyBody") : text(props.emptyBody)
|
|
38
|
+
);
|
|
39
|
+
|
|
27
40
|
const route = useRoute();
|
|
28
41
|
const records = computed(() => props.screen?.records || {});
|
|
29
42
|
const bulkActions = computed(() => props.screen?.bulkActions || {});
|
|
@@ -42,7 +55,7 @@ function resolveListRecordTitle(record) {
|
|
|
42
55
|
if (typeof props.screen?.resolveRecordTitle === "function") {
|
|
43
56
|
return props.screen.resolveRecordTitle(record);
|
|
44
57
|
}
|
|
45
|
-
return "
|
|
58
|
+
return t("jskit.http.crud.record");
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
function formatListCardValue(value) {
|
|
@@ -110,7 +123,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
110
123
|
:disabled="records.isFetching"
|
|
111
124
|
@click="records.reload"
|
|
112
125
|
>
|
|
113
|
-
{{ records.isFetching ? "
|
|
126
|
+
{{ records.isFetching ? t("jskit.http.actions.refreshing") : t("jskit.http.actions.refresh") }}
|
|
114
127
|
</v-btn>
|
|
115
128
|
<v-btn
|
|
116
129
|
v-if="listPrimaryAction"
|
|
@@ -119,7 +132,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
119
132
|
variant="flat"
|
|
120
133
|
:to="listPrimaryAction"
|
|
121
134
|
>
|
|
122
|
-
{{
|
|
135
|
+
{{ resolvedCreateLabel }}
|
|
123
136
|
</v-btn>
|
|
124
137
|
</div>
|
|
125
138
|
|
|
@@ -151,21 +164,21 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
151
164
|
</template>
|
|
152
165
|
<template v-else>
|
|
153
166
|
<div v-if="records.loadError" class="crud-list-state">
|
|
154
|
-
<p class="text-body-2 text-medium-emphasis mb-4">{{
|
|
167
|
+
<p class="text-body-2 text-medium-emphasis mb-4">{{ resolvedLoadErrorBody }}</p>
|
|
155
168
|
<v-btn
|
|
156
169
|
color="primary"
|
|
157
170
|
variant="tonal"
|
|
158
171
|
:disabled="records.isFetching"
|
|
159
172
|
@click="records.reload"
|
|
160
173
|
>
|
|
161
|
-
{{ records.isFetching ? "
|
|
174
|
+
{{ records.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
|
|
162
175
|
</v-btn>
|
|
163
176
|
</div>
|
|
164
177
|
|
|
165
178
|
<div v-else-if="displayRows.length < 1" class="crud-list-state">
|
|
166
|
-
<p class="text-body-2 text-medium-emphasis mb-4">{{
|
|
179
|
+
<p class="text-body-2 text-medium-emphasis mb-4">{{ resolvedEmptyBody }}</p>
|
|
167
180
|
<v-btn v-if="listPrimaryAction" color="primary" variant="flat" :to="listPrimaryAction">
|
|
168
|
-
{{
|
|
181
|
+
{{ resolvedCreateLabel }}
|
|
169
182
|
</v-btn>
|
|
170
183
|
</div>
|
|
171
184
|
|
|
@@ -182,7 +195,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
182
195
|
<v-checkbox-btn
|
|
183
196
|
v-if="hasBulkActions && row.selectable !== false"
|
|
184
197
|
:model-value="isBulkRowSelected(row)"
|
|
185
|
-
:aria-label="
|
|
198
|
+
:aria-label="t('jskit.http.crud.list.selectRecord', { title: resolveListRecordTitle(row.record) })"
|
|
186
199
|
class="crud-list-card__select"
|
|
187
200
|
@update:model-value="setBulkRowSelected(row, $event)"
|
|
188
201
|
/>
|
|
@@ -227,7 +240,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
227
240
|
someSelectableRowsSelected() &&
|
|
228
241
|
!allSelectableRowsSelected()
|
|
229
242
|
"
|
|
230
|
-
aria-label="
|
|
243
|
+
:aria-label="t('jskit.http.crud.list.selectVisibleRows')"
|
|
231
244
|
@update:model-value="setSelectableRowsSelected($event)"
|
|
232
245
|
/>
|
|
233
246
|
</th>
|
|
@@ -243,7 +256,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
243
256
|
<v-checkbox-btn
|
|
244
257
|
v-if="row.selectable !== false"
|
|
245
258
|
:model-value="isBulkRowSelected(row)"
|
|
246
|
-
:aria-label="
|
|
259
|
+
:aria-label="t('jskit.http.crud.list.selectRecord', { title: resolveListRecordTitle(row.record) })"
|
|
247
260
|
@update:model-value="setBulkRowSelected(row, $event)"
|
|
248
261
|
/>
|
|
249
262
|
</td>
|
|
@@ -263,7 +276,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
263
276
|
:to="resolveViewLocation(row.record)"
|
|
264
277
|
:disabled="!resolveViewLocation(row.record)"
|
|
265
278
|
>
|
|
266
|
-
|
|
279
|
+
{{ t("jskit.http.actions.open") }}
|
|
267
280
|
</v-btn>
|
|
268
281
|
</td>
|
|
269
282
|
<td v-if="hasEditUrl" class="text-right">
|
|
@@ -275,7 +288,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
275
288
|
:to="resolveEditLocation(row.record)"
|
|
276
289
|
:disabled="!resolveEditLocation(row.record)"
|
|
277
290
|
>
|
|
278
|
-
|
|
291
|
+
{{ t("jskit.http.actions.edit") }}
|
|
279
292
|
</v-btn>
|
|
280
293
|
</td>
|
|
281
294
|
<td v-if="hasRowActions" class="text-right">
|
|
@@ -284,7 +297,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
284
297
|
:record="row.record"
|
|
285
298
|
:index="row.index"
|
|
286
299
|
:row-actions="rowActions"
|
|
287
|
-
button-label="
|
|
300
|
+
:button-label="t('jskit.http.actions.more')"
|
|
288
301
|
button-variant="outlined"
|
|
289
302
|
/>
|
|
290
303
|
</td>
|
|
@@ -301,7 +314,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
301
314
|
:disabled="records.isLoadingMore"
|
|
302
315
|
@click="records.loadMore"
|
|
303
316
|
>
|
|
304
|
-
{{ records.isLoadingMore ? "
|
|
317
|
+
{{ records.isLoadingMore ? t("jskit.http.actions.loadingMore") : t("jskit.http.actions.loadMore") }}
|
|
305
318
|
</v-btn>
|
|
306
319
|
</div>
|
|
307
320
|
</template>
|
|
@@ -314,7 +327,7 @@ function setSelectableRowsSelected(selected = true) {
|
|
|
314
327
|
variant="flat"
|
|
315
328
|
:to="listPrimaryAction"
|
|
316
329
|
>
|
|
317
|
-
{{
|
|
330
|
+
{{ resolvedCreateLabel }}
|
|
318
331
|
</v-btn>
|
|
319
332
|
</section>
|
|
320
333
|
</template>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, unref } from "vue";
|
|
3
|
+
import { useJskitText } from "../i18n.js";
|
|
3
4
|
|
|
5
|
+
// Unset titles come from the catalog; passed titles may be message keys.
|
|
4
6
|
const props = defineProps({
|
|
5
7
|
screen: {
|
|
6
8
|
type: Object,
|
|
@@ -8,14 +10,22 @@ const props = defineProps({
|
|
|
8
10
|
},
|
|
9
11
|
resourceSingularTitle: {
|
|
10
12
|
type: String,
|
|
11
|
-
default:
|
|
13
|
+
default: undefined
|
|
12
14
|
},
|
|
13
15
|
resourcePluralTitle: {
|
|
14
16
|
type: String,
|
|
15
|
-
default:
|
|
17
|
+
default: undefined
|
|
16
18
|
}
|
|
17
19
|
});
|
|
18
20
|
|
|
21
|
+
const { t, text } = useJskitText();
|
|
22
|
+
const singularTitle = computed(() =>
|
|
23
|
+
props.resourceSingularTitle === undefined ? t("jskit.http.crud.record") : text(props.resourceSingularTitle)
|
|
24
|
+
);
|
|
25
|
+
const pluralTitle = computed(() =>
|
|
26
|
+
props.resourcePluralTitle === undefined ? t("jskit.http.crud.records") : text(props.resourcePluralTitle)
|
|
27
|
+
);
|
|
28
|
+
|
|
19
29
|
const view = computed(() => props.screen?.view || {});
|
|
20
30
|
const listLocation = computed(() => unref(props.screen?.listLocation) || null);
|
|
21
31
|
const editLocation = computed(() => unref(props.screen?.editLocation) || null);
|
|
@@ -30,7 +40,7 @@ const editLocation = computed(() => unref(props.screen?.editLocation) || null);
|
|
|
30
40
|
variant="outlined"
|
|
31
41
|
:to="listLocation"
|
|
32
42
|
>
|
|
33
|
-
|
|
43
|
+
{{ t("jskit.http.crud.view.backTo", { resources: pluralTitle }) }}
|
|
34
44
|
</v-btn>
|
|
35
45
|
<slot name="actions" :screen="screen" :view="view" />
|
|
36
46
|
<v-btn
|
|
@@ -39,14 +49,14 @@ const editLocation = computed(() => unref(props.screen?.editLocation) || null);
|
|
|
39
49
|
variant="flat"
|
|
40
50
|
:to="editLocation"
|
|
41
51
|
>
|
|
42
|
-
|
|
52
|
+
{{ t("jskit.http.actions.edit") }}
|
|
43
53
|
</v-btn>
|
|
44
54
|
</div>
|
|
45
55
|
|
|
46
56
|
<v-sheet rounded="lg" border class="crud-view-panel">
|
|
47
57
|
<div v-if="view.loadError || view.isNotFound" class="crud-view-state">
|
|
48
58
|
<p class="text-body-2 text-medium-emphasis mb-4">
|
|
49
|
-
{{ view.loadError ||
|
|
59
|
+
{{ view.loadError || t("jskit.http.crud.view.notFound", { resource: singularTitle }) }}
|
|
50
60
|
</p>
|
|
51
61
|
<div class="crud-view-state__actions">
|
|
52
62
|
<v-btn
|
|
@@ -56,7 +66,7 @@ const editLocation = computed(() => unref(props.screen?.editLocation) || null);
|
|
|
56
66
|
:disabled="view.isFetching"
|
|
57
67
|
@click="view.refresh"
|
|
58
68
|
>
|
|
59
|
-
{{ view.isFetching ? "
|
|
69
|
+
{{ view.isFetching ? t("jskit.http.actions.retrying") : t("jskit.http.actions.retry") }}
|
|
60
70
|
</v-btn>
|
|
61
71
|
<v-btn
|
|
62
72
|
v-else-if="listLocation"
|
|
@@ -64,7 +74,7 @@ const editLocation = computed(() => unref(props.screen?.editLocation) || null);
|
|
|
64
74
|
variant="tonal"
|
|
65
75
|
:to="listLocation"
|
|
66
76
|
>
|
|
67
|
-
|
|
77
|
+
{{ t("jskit.http.crud.view.backTo", { resources: pluralTitle }) }}
|
|
68
78
|
</v-btn>
|
|
69
79
|
</div>
|
|
70
80
|
</div>
|
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
} from "./crudLookupFieldLabelSupport.js";
|
|
14
14
|
import { inferCrudLookupJsonApiTransport } from "./crudJsonApiTransportSupport.js";
|
|
15
15
|
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
16
|
+
import { useJskitText } from "../../i18n.js";
|
|
17
|
+
|
|
18
|
+
const { t } = useJskitText();
|
|
16
19
|
|
|
17
20
|
function normalizeQueryKeyPrefix(value) {
|
|
18
21
|
const source = Array.isArray(value) ? value : [];
|
|
@@ -129,7 +132,7 @@ function createCrudLookupFieldRuntime({
|
|
|
129
132
|
placementSource: normalizedPlacementSourcePrefix
|
|
130
133
|
? `${normalizedPlacementSourcePrefix}.${key}`
|
|
131
134
|
: `lookup.${key}`,
|
|
132
|
-
fallbackLoadError:
|
|
135
|
+
fallbackLoadError: t("jskit.http.crud.lookup.optionsLoadFailed", { path: apiPath }),
|
|
133
136
|
recordIdParam: normalizedRecordIdParam,
|
|
134
137
|
recordIdSelector: (item = {}) => item[valueKey],
|
|
135
138
|
viewUrlTemplate: "",
|
|
@@ -2,6 +2,9 @@ import { normalizeText, normalizeUniqueTextList } from "@jskit-ai/kernel/shared/
|
|
|
2
2
|
import { CRUD_LIST_FILTER_TYPE_RECORD_ID_MANY } from "@jskit-ai/resource-crud-core/shared/crudListFilters";
|
|
3
3
|
import { resolveLookupItemLabel } from "../crud/crudLookupFieldLabelSupport.js";
|
|
4
4
|
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
5
|
+
import { useJskitText } from "../../i18n.js";
|
|
6
|
+
|
|
7
|
+
const { t } = useJskitText();
|
|
5
8
|
|
|
6
9
|
function normalizeLookupQueryKeyPrefix(value = []) {
|
|
7
10
|
const source = Array.isArray(value) ? value : [];
|
|
@@ -129,10 +132,10 @@ function mergeSelectedLookupOptions(options = [], selectedValues = [], cachedOpt
|
|
|
129
132
|
);
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
function resolveLookupOptionLabel(options = [], cachedOptions = new Map(), value = "", fallback = "
|
|
135
|
+
function resolveLookupOptionLabel(options = [], cachedOptions = new Map(), value = "", fallback = "") {
|
|
133
136
|
const normalizedValue = normalizeText(value);
|
|
134
137
|
if (!normalizedValue) {
|
|
135
|
-
return normalizeText(fallback) || "
|
|
138
|
+
return normalizeText(fallback) || t("jskit.http.crud.filters.option");
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
const matchingOption = (Array.isArray(options) ? options : [])
|
|
@@ -147,8 +150,8 @@ function resolveLookupOptionLabel(options = [], cachedOptions = new Map(), value
|
|
|
147
150
|
return String(cachedOption.label);
|
|
148
151
|
}
|
|
149
152
|
|
|
150
|
-
const normalizedFallback = normalizeText(fallback) || "
|
|
151
|
-
return
|
|
153
|
+
const normalizedFallback = normalizeText(fallback) || t("jskit.http.crud.filters.option");
|
|
154
|
+
return t("jskit.http.crud.filters.optionValue", { label: normalizedFallback, value: normalizedValue });
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
export {
|
|
@@ -7,6 +7,9 @@ import { buildCrudFieldContractMap } from "@jskit-ai/resource-crud-core/shared/c
|
|
|
7
7
|
import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
8
8
|
import { resolveLookupFieldDisplayValue, resolveRecordTitle } from "../crud/crudLookupFieldLabelSupport.js";
|
|
9
9
|
import { resolveRouteParamNamesInOrder, toRouteParamValue } from "../support/routeTemplateHelpers.js";
|
|
10
|
+
import { useJskitText } from "../../i18n.js";
|
|
11
|
+
|
|
12
|
+
const { t } = useJskitText();
|
|
10
13
|
|
|
11
14
|
function singularizeLabel(value = "") {
|
|
12
15
|
const normalizedValue = normalizeText(value);
|
|
@@ -50,7 +53,7 @@ function resolveEntityLabel(routeParamKey = "", relationNamespace = "") {
|
|
|
50
53
|
return namespaceLabel;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
return "
|
|
56
|
+
return t("jskit.http.crud.record");
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
function resolveLookupFieldMeta(resource = {}, fieldKey = "") {
|
|
@@ -155,10 +158,10 @@ function resolveCrudListParentRecordTitle(record = {}, descriptor = null) {
|
|
|
155
158
|
return resolvedTitle;
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
const entityLabel = normalizeText(descriptor?.entityLabel) || "
|
|
161
|
+
const entityLabel = normalizeText(descriptor?.entityLabel) || t("jskit.http.crud.record");
|
|
159
162
|
const recordId = toRouteParamValue(record?.id);
|
|
160
163
|
if (recordId) {
|
|
161
|
-
return
|
|
164
|
+
return t("jskit.http.crud.parent.recordWithId", { label: entityLabel, id: recordId });
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
return "";
|
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
} from "../support/scopeHelpers.js";
|
|
17
17
|
import { createRequestQueryRuntime } from "../support/requestQueryRuntimeSupport.js";
|
|
18
18
|
import { resolveRouteParamNamesInOrder } from "../support/routeTemplateHelpers.js";
|
|
19
|
+
import { useJskitText } from "../../i18n.js";
|
|
20
|
+
|
|
21
|
+
const { t } = useJskitText();
|
|
19
22
|
|
|
20
23
|
function useAddEdit({
|
|
21
24
|
ownershipFilter = ROUTE_VISIBILITY_WORKSPACE,
|
|
@@ -32,9 +35,9 @@ function useAddEdit({
|
|
|
32
35
|
client = null,
|
|
33
36
|
transport = null,
|
|
34
37
|
requestRecovery = null,
|
|
35
|
-
requestRecoveryLabel = "
|
|
38
|
+
requestRecoveryLabel = t("jskit.http.resource.label"),
|
|
36
39
|
placementSource = "http-web.add-edit",
|
|
37
|
-
fallbackLoadError = "
|
|
40
|
+
fallbackLoadError = t("jskit.http.resource.loadFailed"),
|
|
38
41
|
fallbackSaveError = "",
|
|
39
42
|
fieldErrorKeys = [],
|
|
40
43
|
clearOnRouteChange = true,
|
|
@@ -87,9 +90,10 @@ function useAddEdit({
|
|
|
87
90
|
const routeContext = operationScope.routeContext;
|
|
88
91
|
const resolvedMessages = {
|
|
89
92
|
...resolveResourceMessages(resource, {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
// Keys, rendered when shown so they follow a language switch.
|
|
94
|
+
validation: "jskit.http.feedback.fixInvalidValues",
|
|
95
|
+
saveSuccess: "jskit.http.feedback.saved",
|
|
96
|
+
saveError: "jskit.http.feedback.saveFailed"
|
|
93
97
|
}),
|
|
94
98
|
...(messages && typeof messages === "object" ? messages : {})
|
|
95
99
|
};
|
|
@@ -97,7 +101,9 @@ function useAddEdit({
|
|
|
97
101
|
// fallbackSaveError, otherwise the resolved resource/messages saveError.
|
|
98
102
|
const effectiveMessages = {
|
|
99
103
|
...resolvedMessages,
|
|
100
|
-
saveError: String(fallbackSaveError || "").trim() ||
|
|
104
|
+
saveError: String(fallbackSaveError || "").trim() ||
|
|
105
|
+
String(resolvedMessages.saveError || "").trim() ||
|
|
106
|
+
"jskit.http.feedback.saveFailed"
|
|
101
107
|
};
|
|
102
108
|
|
|
103
109
|
const canView = operationScope.permissionGate("view");
|
|
@@ -188,7 +194,7 @@ function useAddEdit({
|
|
|
188
194
|
dedupeWindowMs: 0,
|
|
189
195
|
loadActionFactory: () => canRetryLoad.value
|
|
190
196
|
? {
|
|
191
|
-
label: "
|
|
197
|
+
label: t("jskit.http.actions.retry"),
|
|
192
198
|
dismissOnRun: true,
|
|
193
199
|
handler() {
|
|
194
200
|
void refresh();
|
|
@@ -2,6 +2,10 @@ import { computed, unref } from "vue";
|
|
|
2
2
|
import { useRoute } from "vue-router";
|
|
3
3
|
import { resolveCrudJsonApiTransport } from "../crud/crudJsonApiTransportSupport.js";
|
|
4
4
|
import { resolveCrudHttpClient } from "../crud/crudHttpClientSupport.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveLookupFieldDisplayValue,
|
|
7
|
+
resolveRecordTitle
|
|
8
|
+
} from "../crud/crudLookupFieldLabelSupport.js";
|
|
5
9
|
import { resolveCrudBoundValues } from "../crud/crudBindingSupport.js";
|
|
6
10
|
import { resolveCrudListParentDescriptor } from "../internal/crudListParentTitleSupport.js";
|
|
7
11
|
import {
|
|
@@ -89,6 +93,8 @@ function useCrudList({
|
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
|
|
96
|
+
records.resolveFieldDisplay = resolveLookupFieldDisplayValue;
|
|
97
|
+
records.resolveRecordTitle = resolveRecordTitle;
|
|
92
98
|
return records;
|
|
93
99
|
}
|
|
94
100
|
|
|
@@ -4,6 +4,10 @@ import {
|
|
|
4
4
|
resolveCrudJsonApiTransport
|
|
5
5
|
} from "../crud/crudJsonApiTransportSupport.js";
|
|
6
6
|
import { resolveCrudHttpClient } from "../crud/crudHttpClientSupport.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveLookupFieldDisplayValue,
|
|
9
|
+
resolveRecordTitle
|
|
10
|
+
} from "../crud/crudLookupFieldLabelSupport.js";
|
|
7
11
|
import { resolveCrudBoundValues } from "../crud/crudBindingSupport.js";
|
|
8
12
|
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
9
13
|
import { useView } from "./useView.js";
|
|
@@ -35,6 +39,8 @@ function useCrudView({
|
|
|
35
39
|
}),
|
|
36
40
|
routeParams: boundRouteParams
|
|
37
41
|
});
|
|
42
|
+
view.resolveFieldDisplay = resolveLookupFieldDisplayValue;
|
|
43
|
+
view.resolveRecordTitle = resolveRecordTitle;
|
|
38
44
|
return view;
|
|
39
45
|
}
|
|
40
46
|
|
|
@@ -30,6 +30,9 @@ import {
|
|
|
30
30
|
import {
|
|
31
31
|
resolveRouteParamNamesInOrder,
|
|
32
32
|
} from "../support/routeTemplateHelpers.js";
|
|
33
|
+
import { useJskitText } from "../../i18n.js";
|
|
34
|
+
|
|
35
|
+
const { t } = useJskitText();
|
|
33
36
|
|
|
34
37
|
const EMPTY_ROUTE_SYNC_QUERY_PARAM_BLACKLIST = Object.freeze([]);
|
|
35
38
|
|
|
@@ -42,7 +45,7 @@ function useList({
|
|
|
42
45
|
viewPermissions = [],
|
|
43
46
|
readEnabled = true,
|
|
44
47
|
placementSource = "http-web.list",
|
|
45
|
-
fallbackLoadError = "
|
|
48
|
+
fallbackLoadError = t("jskit.http.list.loadFailed"),
|
|
46
49
|
initialPageParam = null,
|
|
47
50
|
getNextPageParam,
|
|
48
51
|
selectItems,
|
|
@@ -51,7 +54,7 @@ function useList({
|
|
|
51
54
|
requestOptions,
|
|
52
55
|
queryOptions,
|
|
53
56
|
requestRecovery,
|
|
54
|
-
requestRecoveryLabel = "
|
|
57
|
+
requestRecoveryLabel = t("jskit.http.list.label"),
|
|
55
58
|
realtime = null,
|
|
56
59
|
recordIdParam = "recordId",
|
|
57
60
|
recordIdSelector = null,
|
|
@@ -453,7 +456,7 @@ function useList({
|
|
|
453
456
|
loadError,
|
|
454
457
|
dedupeWindowMs: 0,
|
|
455
458
|
loadActionFactory: () => ({
|
|
456
|
-
label: "
|
|
459
|
+
label: t("jskit.http.actions.retry"),
|
|
457
460
|
dismissOnRun: true,
|
|
458
461
|
handler() {
|
|
459
462
|
void list.reload();
|
|
@@ -9,6 +9,9 @@ import { createViewUiRuntime } from "../runtime/viewUiRuntime.js";
|
|
|
9
9
|
import { createRequestQueryRuntime } from "../support/requestQueryRuntimeSupport.js";
|
|
10
10
|
import { resolveRouteParamNamesInOrder } from "../support/routeTemplateHelpers.js";
|
|
11
11
|
import { resolveOperationRealtimeOptions } from "../useRealtimeQueryInvalidation.js";
|
|
12
|
+
import { useJskitText } from "../../i18n.js";
|
|
13
|
+
|
|
14
|
+
const { t } = useJskitText();
|
|
12
15
|
|
|
13
16
|
function useView({
|
|
14
17
|
resource = null,
|
|
@@ -23,11 +26,11 @@ function useView({
|
|
|
23
26
|
client = null,
|
|
24
27
|
transport = null,
|
|
25
28
|
requestRecovery = null,
|
|
26
|
-
requestRecoveryLabel = "
|
|
29
|
+
requestRecoveryLabel = t("jskit.http.resource.label"),
|
|
27
30
|
placementSource = "http-web.view",
|
|
28
|
-
fallbackLoadError = "
|
|
31
|
+
fallbackLoadError = t("jskit.http.resource.loadFailed"),
|
|
29
32
|
notFoundStatuses = [404],
|
|
30
|
-
notFoundMessage = "
|
|
33
|
+
notFoundMessage = t("jskit.http.crud.recordNotFound"),
|
|
31
34
|
model,
|
|
32
35
|
mapLoadedToModel,
|
|
33
36
|
requestQueryParams = null,
|
|
@@ -130,7 +133,7 @@ function useView({
|
|
|
130
133
|
notFoundError: view.notFoundError,
|
|
131
134
|
dedupeWindowMs: 0,
|
|
132
135
|
loadActionFactory: () => ({
|
|
133
|
-
label: "
|
|
136
|
+
label: t("jskit.http.actions.retry"),
|
|
134
137
|
dismissOnRun: true,
|
|
135
138
|
handler() {
|
|
136
139
|
void view.refresh();
|