@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
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
formatDateOnlyValue,
|
|
7
7
|
formatDateOnlyDisplay
|
|
8
8
|
} from "../support/crudListDateFilterSupport.js";
|
|
9
|
+
import { useJskitText } from "../i18n.js";
|
|
9
10
|
|
|
10
11
|
defineOptions({
|
|
11
12
|
inheritAttrs: false
|
|
@@ -26,7 +27,7 @@ const props = defineProps({
|
|
|
26
27
|
},
|
|
27
28
|
placeholder: {
|
|
28
29
|
type: String,
|
|
29
|
-
default:
|
|
30
|
+
default: undefined
|
|
30
31
|
},
|
|
31
32
|
disabled: {
|
|
32
33
|
type: Boolean,
|
|
@@ -39,6 +40,10 @@ const props = defineProps({
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
const emit = defineEmits(["update:modelValue"]);
|
|
43
|
+
const { t } = useJskitText();
|
|
44
|
+
const resolvedPlaceholder = computed(() =>
|
|
45
|
+
props.placeholder === undefined ? t("jskit.http.crud.filters.selectDate") : props.placeholder
|
|
46
|
+
);
|
|
42
47
|
const attrs = useAttrs();
|
|
43
48
|
const { current: currentLocale } = useLocale();
|
|
44
49
|
const generatedId = useId();
|
|
@@ -51,7 +56,7 @@ const pickerValue = computed(() => parseDateOnlyValue(props.modelValue));
|
|
|
51
56
|
const displayValue = computed(() => formatDateOnlyDisplay(props.modelValue, {
|
|
52
57
|
locale: currentLocale?.value
|
|
53
58
|
}));
|
|
54
|
-
const pickerTitle = computed(() =>
|
|
59
|
+
const pickerTitle = computed(() => t("jskit.http.crud.filters.calendar", { label: props.label }));
|
|
55
60
|
|
|
56
61
|
function restoreFocus() {
|
|
57
62
|
void nextTick(() => {
|
|
@@ -113,7 +118,7 @@ function handleActivatorKeydown(event) {
|
|
|
113
118
|
ref="textFieldRef"
|
|
114
119
|
:model-value="displayValue"
|
|
115
120
|
:label="label"
|
|
116
|
-
:placeholder="
|
|
121
|
+
:placeholder="resolvedPlaceholder"
|
|
117
122
|
:aria-label="label"
|
|
118
123
|
:aria-controls="pickerId"
|
|
119
124
|
:aria-expanded="String(menuOpen)"
|
|
@@ -161,10 +166,10 @@ function handleActivatorKeydown(event) {
|
|
|
161
166
|
:disabled="disabled || readonly || !modelValue"
|
|
162
167
|
@click="clearDate"
|
|
163
168
|
>
|
|
164
|
-
|
|
169
|
+
{{ t("jskit.http.actions.clear") }}
|
|
165
170
|
</v-btn>
|
|
166
171
|
<v-spacer />
|
|
167
|
-
<v-btn color="primary" variant="text" @click="closeMenu">
|
|
172
|
+
<v-btn color="primary" variant="text" @click="closeMenu">{{ t("jskit.http.actions.close") }}</v-btn>
|
|
168
173
|
</v-card-actions>
|
|
169
174
|
</v-card>
|
|
170
175
|
</v-menu>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import CrudListDateFilterControl from "./CrudListDateFilterControl.vue";
|
|
4
|
+
import { useJskitText } from "../i18n.js";
|
|
4
5
|
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
filters: {
|
|
@@ -17,14 +18,21 @@ const props = defineProps({
|
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
20
|
|
|
21
|
+
const { t, text } = useJskitText();
|
|
20
22
|
const runtimeValues = computed(() => props.runtime?.values || {});
|
|
21
23
|
|
|
22
24
|
function optionItems(filter = {}) {
|
|
23
25
|
return Array.isArray(filter.options) ? filter.options : [];
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
// Filter labels and placeholders may be message keys.
|
|
29
|
+
function filterLabel(filter = {}, key = "", params = {}) {
|
|
30
|
+
const label = text(filter.label);
|
|
31
|
+
return key ? t(key, { ...params, label }) : label;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function placeholder(filter = {}, fallbackKey = "") {
|
|
35
|
+
return String(text(filter?.ui?.placeholder) || (fallbackKey ? t(fallbackKey) : "")).trim();
|
|
28
36
|
}
|
|
29
37
|
</script>
|
|
30
38
|
|
|
@@ -37,7 +45,7 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
37
45
|
<v-switch
|
|
38
46
|
v-if="filter.type === 'flag'"
|
|
39
47
|
v-model="runtimeValues[filter.key]"
|
|
40
|
-
:label="filter
|
|
48
|
+
:label="filterLabel(filter)"
|
|
41
49
|
color="primary"
|
|
42
50
|
density="comfortable"
|
|
43
51
|
hide-details
|
|
@@ -47,7 +55,7 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
47
55
|
v-else-if="filter.type === 'enum' || filter.type === 'enumMany' || filter.type === 'presence'"
|
|
48
56
|
v-model="runtimeValues[filter.key]"
|
|
49
57
|
:items="optionItems(filter)"
|
|
50
|
-
:label="filter
|
|
58
|
+
:label="filterLabel(filter)"
|
|
51
59
|
:placeholder="placeholder(filter)"
|
|
52
60
|
:multiple="filter.type === 'enumMany'"
|
|
53
61
|
:chips="filter.type === 'enumMany'"
|
|
@@ -63,8 +71,8 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
63
71
|
<v-combobox
|
|
64
72
|
v-else-if="filter.type === 'recordIdMany'"
|
|
65
73
|
v-model="runtimeValues[filter.key]"
|
|
66
|
-
:label="filter
|
|
67
|
-
:placeholder="placeholder(filter, '
|
|
74
|
+
:label="filterLabel(filter)"
|
|
75
|
+
:placeholder="placeholder(filter, 'jskit.http.crud.filters.enterIds')"
|
|
68
76
|
multiple
|
|
69
77
|
chips
|
|
70
78
|
closable-chips
|
|
@@ -77,8 +85,8 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
77
85
|
<v-text-field
|
|
78
86
|
v-else-if="filter.type === 'recordId'"
|
|
79
87
|
v-model="runtimeValues[filter.key]"
|
|
80
|
-
:label="filter
|
|
81
|
-
:placeholder="placeholder(filter, '
|
|
88
|
+
:label="filterLabel(filter)"
|
|
89
|
+
:placeholder="placeholder(filter, 'jskit.http.crud.filters.enterId')"
|
|
82
90
|
clearable
|
|
83
91
|
variant="outlined"
|
|
84
92
|
density="comfortable"
|
|
@@ -89,27 +97,27 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
89
97
|
v-else-if="filter.type === 'dateRange'"
|
|
90
98
|
class="crud-list-filter-surface__range crud-list-filter-surface__range--date"
|
|
91
99
|
role="group"
|
|
92
|
-
:aria-label="
|
|
100
|
+
:aria-label="filterLabel(filter, 'jskit.http.crud.filters.dateRange')"
|
|
93
101
|
:data-filter-key="filter.key"
|
|
94
102
|
data-filter-type="date-range"
|
|
95
103
|
>
|
|
96
104
|
<CrudListDateFilterControl
|
|
97
105
|
v-model="runtimeValues[filter.key].from"
|
|
98
|
-
:label="
|
|
106
|
+
:label="filterLabel(filter, 'jskit.http.crud.filters.rangeFrom')"
|
|
99
107
|
:control-id="`${filter.key}-from`"
|
|
100
|
-
:placeholder="placeholder(filter, '
|
|
108
|
+
:placeholder="placeholder(filter, 'jskit.http.crud.filters.selectStartDate')"
|
|
101
109
|
/>
|
|
102
110
|
<CrudListDateFilterControl
|
|
103
111
|
v-model="runtimeValues[filter.key].to"
|
|
104
|
-
:label="
|
|
112
|
+
:label="filterLabel(filter, 'jskit.http.crud.filters.rangeTo')"
|
|
105
113
|
:control-id="`${filter.key}-to`"
|
|
106
|
-
:placeholder="placeholder(filter, '
|
|
114
|
+
:placeholder="placeholder(filter, 'jskit.http.crud.filters.selectEndDate')"
|
|
107
115
|
/>
|
|
108
116
|
</div>
|
|
109
117
|
<div v-else-if="filter.type === 'numberRange'" class="crud-list-filter-surface__range">
|
|
110
118
|
<v-text-field
|
|
111
119
|
v-model="runtimeValues[filter.key].min"
|
|
112
|
-
:label="
|
|
120
|
+
:label="filterLabel(filter, 'jskit.http.crud.filters.rangeMin')"
|
|
113
121
|
type="number"
|
|
114
122
|
variant="outlined"
|
|
115
123
|
density="comfortable"
|
|
@@ -117,7 +125,7 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
117
125
|
/>
|
|
118
126
|
<v-text-field
|
|
119
127
|
v-model="runtimeValues[filter.key].max"
|
|
120
|
-
:label="
|
|
128
|
+
:label="filterLabel(filter, 'jskit.http.crud.filters.rangeMax')"
|
|
121
129
|
type="number"
|
|
122
130
|
variant="outlined"
|
|
123
131
|
density="comfortable"
|
|
@@ -127,9 +135,9 @@ function placeholder(filter = {}, fallback = "") {
|
|
|
127
135
|
<CrudListDateFilterControl
|
|
128
136
|
v-else-if="filter.type === 'date'"
|
|
129
137
|
v-model="runtimeValues[filter.key]"
|
|
130
|
-
:label="filter
|
|
138
|
+
:label="filterLabel(filter)"
|
|
131
139
|
:control-id="filter.key"
|
|
132
|
-
:placeholder="placeholder(filter, '
|
|
140
|
+
:placeholder="placeholder(filter, 'jskit.http.crud.filters.selectDate')"
|
|
133
141
|
class="crud-list-filter-surface__control"
|
|
134
142
|
/>
|
|
135
143
|
</template>
|
|
@@ -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>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { VAutocomplete, VSelect } from "vuetify/components";
|
|
4
|
+
import { optionTitle, optionValue, selectionFieldState } from "../support/selectFieldSupport.js";
|
|
5
|
+
|
|
6
|
+
// A v-select / v-autocomplete that never shows a stored id as text (see selectFieldSupport.js).
|
|
7
|
+
// Pass `searchable` for VAutocomplete, and `loading` while the options are being fetched.
|
|
8
|
+
defineOptions({ inheritAttrs: false });
|
|
9
|
+
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
searchable: { type: Boolean, default: false },
|
|
12
|
+
modelValue: { type: null, default: null },
|
|
13
|
+
items: { type: Array, default: () => [] },
|
|
14
|
+
itemTitle: { type: [String, Array, Function], default: "title" },
|
|
15
|
+
itemValue: { type: [String, Array, Function], default: "value" },
|
|
16
|
+
multiple: { type: Boolean, default: false },
|
|
17
|
+
returnObject: { type: Boolean, default: false },
|
|
18
|
+
loading: { type: [Boolean, String], default: false }
|
|
19
|
+
});
|
|
20
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
21
|
+
|
|
22
|
+
const field = ref(null);
|
|
23
|
+
const seen = new Map();
|
|
24
|
+
const state = computed(() => selectionFieldState(props, seen));
|
|
25
|
+
const titleOf = (item) => optionTitle(item, props.itemTitle);
|
|
26
|
+
const valueOf = (item) => optionValue(item, props.itemTitle, props.itemValue);
|
|
27
|
+
|
|
28
|
+
function update(value) {
|
|
29
|
+
// A value hidden while its options load is kept when the user edits a multiple selection.
|
|
30
|
+
const hidden = state.value.hiddenValues;
|
|
31
|
+
emit("update:modelValue", props.multiple && hidden.length ? [...hidden, ...[].concat(value ?? [])] : value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
defineExpose({ focus: () => field.value?.focus() });
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<component
|
|
39
|
+
:is="searchable ? VAutocomplete : VSelect"
|
|
40
|
+
ref="field"
|
|
41
|
+
v-bind="$attrs"
|
|
42
|
+
:model-value="state.modelValue"
|
|
43
|
+
:items="state.items"
|
|
44
|
+
:item-title="returnObject ? itemTitle : titleOf"
|
|
45
|
+
:item-value="returnObject ? itemValue : valueOf"
|
|
46
|
+
:multiple="multiple"
|
|
47
|
+
:return-object="returnObject"
|
|
48
|
+
:loading="loading"
|
|
49
|
+
@update:model-value="update"
|
|
50
|
+
>
|
|
51
|
+
<template v-for="(_, name) in $slots" #[name]="slotProps">
|
|
52
|
+
<slot :name="name" v-bind="slotProps || {}" />
|
|
53
|
+
</template>
|
|
54
|
+
</component>
|
|
55
|
+
</template>
|