Skip to content

Commit 9108e07

Browse files
committed
feat: Add property title
1 parent e90ecaa commit 9108e07

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

lib/actions/add-model/index.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,27 @@ async function * gatherModelProperty () {
8080
name: 'key',
8181
message: 'Property name (hit Enter to quit)'
8282
},
83+
{
84+
type: 'input',
85+
name: 'title',
86+
message: 'Property title'
87+
},
8388
{
8489
type: 'select',
8590
name: 'typeHint',
86-
message: 'Property type',
91+
message: 'Data type',
8792
choices: Scaffold.ModelTypes()
8893
},
8994
{
9095
type: 'confirm',
9196
name: 'primary',
92-
message: 'Primary Key',
97+
message: 'Is Primary Key',
9398
initial: false
9499
},
95100
{
96101
type: 'confirm',
97102
name: 'required',
98-
message: 'Required',
103+
message: 'Is Required',
99104
initial: false
100105
}
101106
]
@@ -107,6 +112,14 @@ async function * gatherModelProperty () {
107112
return
108113
}
109114
}
115+
116+
// Strip empty string properties
117+
for (const [k, v] of Object.entries(propertyDetails)) {
118+
if (v === '') {
119+
delete propertyDetails[k]
120+
}
121+
}
122+
110123
yield propertyDetails
111124
}
112125
} // gatherModelProperty

test/add-model-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe('tymly add-model', () => {
1111
model title,
1212
model description,
1313
field name,
14+
field title,
1415
field type,
1516
is primary key,
1617
is required,
@@ -23,6 +24,7 @@ describe('tymly add-model', () => {
2324
'Pizza',
2425
'A pizza',
2526
'name',
27+
'',
2628
'string',
2729
'Y',
2830
'Y',
@@ -33,18 +35,22 @@ describe('tymly add-model', () => {
3335
'Pizza',
3436
'A pizza',
3537
'code',
38+
'',
3639
'string',
3740
'Y',
3841
'Y',
3942
'label',
43+
'Customer-facing label',
4044
'',
4145
'',
4246
'Y',
4347
'popularitySeq',
48+
'',
4449
helpers.down,
4550
'',
4651
'',
4752
'vegetarian',
53+
'',
4854
helpers.down+helpers.down,
4955
'',
5056
'',

test/fixtures/add-model/expected/multiple-fields/models/pizza.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"type": "string"
99
},
1010
"label": {
11+
"title": "Customer-facing label",
1112
"type": "string"
1213
},
1314
"popularitySeq": {

0 commit comments

Comments
 (0)