@postxl/generator 0.47.0 → 0.47.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.
|
@@ -10,6 +10,9 @@ const imports_1 = require("../../../lib/imports");
|
|
|
10
10
|
function generateModelLibraryComponents({ model, meta }) {
|
|
11
11
|
const { react: { context, components }, } = meta;
|
|
12
12
|
const selectorCollector = id_collector_1.SelectorCollector.from(meta.seed.constantName + '-card');
|
|
13
|
+
const titleProp = model.nameField.isRequired
|
|
14
|
+
? `title={item.${model.nameField.name}}`
|
|
15
|
+
: `title={item.${model.nameField.name} ?? item.${model.idField.name}}`;
|
|
13
16
|
const imports = imports_1.ImportsGenerator.from(meta.react.folderPath)
|
|
14
17
|
.addTypeImport({
|
|
15
18
|
items: [model.typeName],
|
|
@@ -52,7 +55,7 @@ function generateModelLibraryComponents({ model, meta }) {
|
|
|
52
55
|
<>
|
|
53
56
|
<Card
|
|
54
57
|
ref={forwardedRef}
|
|
55
|
-
|
|
58
|
+
${titleProp}
|
|
56
59
|
actions={[
|
|
57
60
|
{
|
|
58
61
|
label: 'Edit',
|
|
@@ -20,7 +20,9 @@ function generateModelLookupComponents({ model, meta }) {
|
|
|
20
20
|
});
|
|
21
21
|
const typeName = model.typeName;
|
|
22
22
|
const tsOmittedFields = `'label' | 'options' | 'loading'`;
|
|
23
|
-
const
|
|
23
|
+
const labelProp = model.nameField.isRequired
|
|
24
|
+
? `label={(l) => l.${model.nameField.name}}`
|
|
25
|
+
: `label={(l) => l.${model.nameField.name} ?? l.${model.idField.name}}`;
|
|
24
26
|
let description = '';
|
|
25
27
|
if (model.description) {
|
|
26
28
|
description = `
|
|
@@ -50,7 +52,7 @@ export const ${components.forms.selectInputName} = ({
|
|
|
50
52
|
const { list, ready } = ${context.hookFnName}()
|
|
51
53
|
return <SelectInput<${typeName}>
|
|
52
54
|
options={list}
|
|
53
|
-
${
|
|
55
|
+
${labelProp}
|
|
54
56
|
loading={!ready}
|
|
55
57
|
__cypress_field_selector__={
|
|
56
58
|
delegated.__cypress_field_selector__
|
|
@@ -67,7 +69,7 @@ export const ${components.forms.selectFieldName} = ({
|
|
|
67
69
|
const { list, ready } = ${context.hookFnName}()
|
|
68
70
|
return <SelectField<${typeName}>
|
|
69
71
|
options={list}
|
|
70
|
-
${
|
|
72
|
+
${labelProp}
|
|
71
73
|
loading={!ready}
|
|
72
74
|
__cypress_field_selector__={
|
|
73
75
|
delegated.__cypress_field_selector__
|
|
@@ -86,7 +88,7 @@ export const ${components.forms.menuSelectInputName} = ({
|
|
|
86
88
|
const { list, ready } = ${context.hookFnName}()
|
|
87
89
|
return <MenuSelectInput<${typeName}>
|
|
88
90
|
options={list}
|
|
89
|
-
${
|
|
91
|
+
${labelProp}
|
|
90
92
|
loading={!ready}
|
|
91
93
|
__cypress_options_selector__={
|
|
92
94
|
delegated.__cypress_options_selector__
|
|
@@ -103,7 +105,7 @@ export const ${components.forms.menuSelectFieldName} = ({
|
|
|
103
105
|
const { list, ready } = ${context.hookFnName}()
|
|
104
106
|
return <MenuSelectField<${typeName}>
|
|
105
107
|
options={list}
|
|
106
|
-
${
|
|
108
|
+
${labelProp}
|
|
107
109
|
loading={!ready}
|
|
108
110
|
__cypress_options_selector__={
|
|
109
111
|
delegated.__cypress_options_selector__
|
|
@@ -122,7 +124,7 @@ export const ${components.forms.searchInputName} = ({
|
|
|
122
124
|
const { list, ready } = ${context.hookFnName}()
|
|
123
125
|
return <SearchInput<${typeName}>
|
|
124
126
|
options={list}
|
|
125
|
-
${
|
|
127
|
+
${labelProp}
|
|
126
128
|
loading={!ready}
|
|
127
129
|
__cypress_combobox_selector__={
|
|
128
130
|
delegated.__cypress_combobox_selector__
|
|
@@ -143,7 +145,7 @@ export const ${components.forms.searchFieldName} = ({
|
|
|
143
145
|
const { list, ready } = ${context.hookFnName}()
|
|
144
146
|
return <SearchField<${typeName}>
|
|
145
147
|
options={list}
|
|
146
|
-
${
|
|
148
|
+
${labelProp}
|
|
147
149
|
loading={!ready}
|
|
148
150
|
__cypress_combobox_selector__={
|
|
149
151
|
delegated.__cypress_combobox_selector__
|
|
@@ -165,7 +167,7 @@ export const ${components.forms.tableSelectInputName} = ({
|
|
|
165
167
|
const { list, ready } = ${context.hookFnName}()
|
|
166
168
|
return <TableSelectInput<${typeName}>
|
|
167
169
|
options={list}
|
|
168
|
-
${
|
|
170
|
+
${labelProp}
|
|
169
171
|
loading={!ready}
|
|
170
172
|
__cypress_input_field_selector__={
|
|
171
173
|
delegated.__cypress_input_field_selector__
|
|
@@ -182,7 +184,7 @@ export const ${components.forms.tableSelectFieldName} = ({
|
|
|
182
184
|
const { list, ready } = ${context.hookFnName}()
|
|
183
185
|
return <TableSelectField<${typeName}>
|
|
184
186
|
options={list}
|
|
185
|
-
${
|
|
187
|
+
${labelProp}
|
|
186
188
|
loading={!ready}
|
|
187
189
|
__cypress_input_field_selector__={
|
|
188
190
|
delegated.__cypress_input_field_selector__
|