This the command line interface for ddata-core
and ddata-ui-input
, ddata-ui-dialog
and other ddata packages Schematic implementation that serves as boilerplate codes to your project based on ddata packages.
npm install --save-dev ddata-cli
If you did'nt installed yet, you need to install ddata-core
, ddata-ui-input
and ddata-ui-dialog
packages:
npm install --save ddata-core ddata-ui-input ddata-ui-dialog
And don't forget add this modules to your app.module.ts
file.
import { DdataCoreModule } from 'ddata-core';
import { DdataUiInputModule } from 'ddata-ui-input';
@NgModule({
// ...
imports: [
// ...
DdataCoreModule,
DdataUiInputModule,
],
// ...
})
export class AppModule { }
Follow these packages installation instructions.
You need to extend your tsconfig.app.json
file with this settings:
{
// ...
"include": [
"src/**/*.ts",
"src/**/*.d.ts"
]
}
Extend your tslint.json
to allow snake case naming convention:
{
"rules": {
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case",
"allow-snake-case"
]
},
}
}
ng add ddata-cli:all [ModelName] --fields=[field,definition,list]
Use the capitalize and singular naming convention on your model's name.
For example:
TaskType
(and not task_type nor tasktype)Company
(and not Companies)
With fields
option you can define your model's fields with data type and default value.
The fields
definition is a comma separated list. Each list element built from three information blocks:
- field name
- field data type
- field default value
The information blocks are separated by color characters (:
). For example an information block looks like this:
name:string:Little John
Note: you need to put your fields
option's value into quotes if you use space characters in the value
- string (default)
- number
- boolean
- color
- isodate
- time
- text
Converted as string, but in frontend will use color picker (with dd-input-color
component).
Converted as string, but in frontend will use date picker (with dd-input-date
component).
Converted as string, but in frontend will use time picker (with dd-input-time
component).
Converted as string, but in frontend will use textarea (with dd-textarea
component).
You can use any words as your data type. In this case you need to follow the singular naming convetion on your field name, and capitalize and singular naming convention on your data type.
In this case if you're not set default value, the default will be null
.
For example:
address:Address
billing_address:BillingAddress:new BillingAddress().init()
billing_address_type:BillingAddressType
You can use any words as your array data type with []
postfix. In this case you need to follow the plural naming convention on your field name, and capitalize and singular naming convention on your data type.
In this case you can define default value, but it will be ignored. All array data's default will be an empty array.
For example:
addresses:Address[]
billing_addresses:BillingAddress[]
companies:Company[]
ng g ddata-cli:all Company --fields="id:number,name,billing_address:Address,shipping_address:Address,employees:Employee[],products:Product[],is_inactive:boolean"
ng g ddata-cli:all Employee --fields="id:number,name,phone,email,is_inactive:boolean"
ng g ddata-cli:all Product --fields="id:number,name,sku,color:color,expiration_date:isodate,is_inactive:boolean"
ng g ddata-cli:model Product --fields="id:number,name,sku,color:color,expiration_date:isodate,is_inactive:boolean"
ng g ddata-cli:components Product --fields="id:number,name,sku,color:color,expiration_date:isodate,is_inactive:boolean"
ng g ddata-cli:lang Product --fields="id:number,name,sku,color:color,expiration_date:isodate,is_inactive:boolean"
Have fun!