Skip to content

Commit

Permalink
feat(form): new @delon/form component
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Apr 26, 2018
1 parent 1f4dc69 commit b92747e
Show file tree
Hide file tree
Showing 148 changed files with 7,984 additions and 493 deletions.
10 changes: 7 additions & 3 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"scripts": [
"../node_modules/@antv/g2/dist/g2.min.js",
"../node_modules/@antv/data-set/dist/data-set.min.js",
"../node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js"
"../node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js",
"../node_modules/ajv/dist/ajv.bundle.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
Expand Down Expand Up @@ -50,10 +51,13 @@
],
"scripts": [
"../node_modules/enquire.js/dist/enquire.js",
"../node_modules/docsearch.js/dist/cdn/docsearch.js",
"../node_modules/@antv/g2/dist/g2.min.js",
"../node_modules/@antv/data-set/dist/data-set.min.js",
"../node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js"
"../node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js",
"../node_modules/ace-builds/src-min/ace.js",
"../node_modules/ace-builds/src-min/mode-json.js",
"../node_modules/ace-builds/src-min/theme-github.js",
"../node_modules/ajv/dist/ajv.bundle.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
"files.exclude": {
"**/.lib/*/**": true,
"**/.ng_build/*/**": true
}
},
"docthis.includeTypes": false,
"docthis.includeMemberOfOnInterfaceMembers": false,
"docthis.includeMemberOfOnClassMembers": false
}
1 change: 1 addition & 0 deletions _mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './user';
export * from './chart';
export * from './upload';
6 changes: 6 additions & 0 deletions _mock/upload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

export const UPLOADS = {
'POST /upload': () => {
return { resource_id: +new Date, url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' };
}
};
4 changes: 3 additions & 1 deletion _mock/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { MockStatusError } from '@delon/mock';
import { MockStatusError, MockRequest } from '@delon/mock';
// import * as Mock from 'mockjs';

export const USERS = {
// 支持值为 Object 和 Array
'GET /users': { users: [1, 2] },
'GET /user/check/': () => false,
'GET /user/check/:name': (req: MockRequest) => req.params.name === 'cipchk',
// GET POST 可省略
// '/users/1': Mock.mock({ id: 1, 'rank|3': '★★★' }),
// 发送 Status 错误
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PACKAGES=(acl
auth
cache
mock
form
cli)
NODE_PACKAGES=(cli)

Expand Down Expand Up @@ -76,6 +77,7 @@ compileCli() {
"${1}src/app/layout/default/header/components/task.component.ts|${2}application/other-files/layout/default/header/components/"
"${1}src/app/layout/default/header/components/user.component.ts|${2}application/other-files/layout/default/header/components/"
"${1}src/app/shared/README.md|${2}application/other-files/shared/"
"${1}src/app/shared/json-schema/index.md|${2}application/other-files/shared/json-schema/"
"${1}src/app/routes/callback|${2}application/other-files/routes/"
"${1}src/app/routes/exception|${2}application/other-files/routes/"
"${1}src/app/routes/passport|${2}application/other-files/routes/"
Expand Down
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ng serve
| `-di` | `--delon-i18n` | `false` | 是否需要国际化支持 |
| `-dm` | `--delon-mock` | `true` | 是否需要 mock 功能 |
| `-g2` | `--delon-g2` | `false` | Support G2 chart. 是否需要 G2 图表 |
| `-js` | `--json-schema` | `false` | 是否需要 json-schema 动态表单 |
| `-df` | `--delon-form` | `true` | 是否需要 `@delon/form` 动态表单 |
| - | `--delon-electron` | `false` | 是否需要 electron 打包 |

例如生成一个带有国际化的项目:
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
"mkdirp": "^0.5.1",
"mockjs": "^1.0.1-beta3",
"mustache": "^2.3.0",
"ng-github-button": "^0.0.1",
"ng2-ace-editor": "^0.3.7",
"ngx-tinymce": "^1.0.1",
"ngx-ueditor": "^1.1.0",
"npm-run-all": "^4.1.1",
Expand All @@ -123,8 +125,7 @@
"tslint-language-service": "^0.9.6",
"typescript": "~2.6.0",
"webpack-bundle-analyzer": "^2.9.2",
"xlsx": "^0.11.16",
"ng-github-button": "^0.0.1"
"xlsx": "^0.11.16"
},
"lint-staged": {
"src/**/*.ts": "lint:ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/application/files/__dot__angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"scripts": [<% if (delonG2) { %>
"../node_modules/@antv/g2/dist/g2.min.js",
"../node_modules/@antv/data-set/dist/data-set.min.js",
"../node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js"<% } %>
"../node_modules/@antv/g2-plugin-slider/dist/g2-plugin-slider.min.js",<% } %>
<% if (delonForm) { %>"../node_modules/ajv/dist/ajv.bundle.js"<% } %>
],
"environmentSource": "environments/environment.ts",
"environments": {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/application/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@
"@delon/auth": "PEER-0.0.0-PLACEHOLDER",
"@delon/theme": "PEER-0.0.0-PLACEHOLDER",
"@delon/mock": "PEER-0.0.0-PLACEHOLDER",
"@delon/form": "PEER-0.0.0-PLACEHOLDER",
"@delon/cache": "PEER-0.0.0-PLACEHOLDER",<% } else { %>
"@delon/abc": "PEER-0.0.0-PLACEHOLDER",
"@delon/acl": "PEER-0.0.0-PLACEHOLDER",
"@delon/auth": "PEER-0.0.0-PLACEHOLDER",
"@delon/theme": "PEER-0.0.0-PLACEHOLDER",
"@delon/mock": "PEER-0.0.0-PLACEHOLDER",
"@delon/form": "PEER-0.0.0-PLACEHOLDER",
"@delon/cache": "PEER-0.0.0-PLACEHOLDER",<% } %><% if (delonI18n) { %>
"@ngx-translate/core": "^9.0.0",
"@ngx-translate/http-loader": "^2.0.0",<% } %>
"@types/ajv": "^1.0.0",
"ajv": "^6.4.0",
"core-js": "^2.5.1",
"file-saver": "^1.3.3",
"ng-zorro-antd": "ZORRO-0.0.0-PLACEHOLDER",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function default_1(options) {
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./files'), [
// =====@delon/cli=====
options.delonI18n ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('i18n.') === -1),
options.jsonSchema ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('json-schema') === -1),
options.delonForm ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('json-schema') === -1),
options.delonElectron ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('electron') === -1 && path.indexOf('gulpfile.js') === -1),
// =====@delon/cli=====
options.minimal ? schematics_1.filter(minimalPathFilter) : schematics_1.noop(),
Expand All @@ -89,7 +89,7 @@ function default_1(options) {
schematics_1.mergeWith(schematics_1.apply(schematics_1.url('./other-files'), [
// =====@delon/cli=====
options.delonI18n ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('i18n.') === -1),
options.jsonSchema ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('json-schema') === -1),
options.delonForm ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('json-schema') === -1),
options.delonElectron ? schematics_1.noop() : schematics_1.filter(path => path.indexOf('electron') === -1 && path.indexOf('gulpfile.js') === -1),
// =====@delon/cli=====
componentOptions.inlineTemplate ? schematics_1.filter(path => !path.endsWith('.html')) : schematics_1.noop(),
Expand Down
9 changes: 5 additions & 4 deletions packages/cli/application/other-files/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { I18NService } from '@core/i18n/i18n.service';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, `assets/i18n/`, '.json');
}<% } %>
<% if (jsonSchema) { %>
// JSON-Schema form
<% if (delonForm) { %>
// @delon/form: JSON Schema form
import { JsonSchemaModule } from '@shared/json-schema/json-schema.module';<% } %>

export function StartupServiceFactory(startupService: StartupService): Function {
Expand All @@ -47,7 +47,6 @@ export function StartupServiceFactory(startupService: StartupService): Function
CoreModule,
SharedModule,
LayoutModule,
<% if (jsonSchema) { %>JsonSchemaModule,<% } %>
RoutesModule<% if (delonI18n) { %>,
// i18n
TranslateModule.forRoot({
Expand All @@ -56,7 +55,9 @@ export function StartupServiceFactory(startupService: StartupService): Function
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})<% } %>
})<% } %><% if (delonForm) { %>,
// JSON-Schema form
JsonSchemaModule<% } %>
],
providers: [
{ provide: LOCALE_ID, useValue: 'zh-Hans' },
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '@shared/shared.module';
import { NzSchemaFormModule, WidgetRegistry } from 'nz-schema-form';
import { DelonFormModule, WidgetRegistry } from '@delon/form';

// import { TinymceWidget } from './widgets/tinymce/tinymce.widget';
// import { UEditorWidget } from './widgets/ueditor/ueditor.widget';
Expand All @@ -15,9 +15,7 @@ export const SCHEMA_THIRDS_COMPONENTS = [
entryComponents: SCHEMA_THIRDS_COMPONENTS,
imports: [
SharedModule,
NzSchemaFormModule.forRoot({

})
DelonFormModule.forRoot()
],
exports: [
...SCHEMA_THIRDS_COMPONENTS
Expand Down
13 changes: 7 additions & 6 deletions packages/cli/application/other-files/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ import { RouterModule } from '@angular/router';
// delon
import { AlainThemeModule } from '@delon/theme';
import { DelonABCModule } from '@delon/abc';
import { DelonACLModule } from '@delon/acl';<% if (delonI18n) { %>
import { DelonACLModule } from '@delon/acl';
<% if (delonForm) { %>import { DelonFormModule } from '@delon/form';<% } %><% if (delonI18n) { %>
// i18n
import { TranslateModule } from '@ngx-translate/core';<% } %>

// region: third libs
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { CountdownModule } from 'ngx-countdown';
<% if (jsonSchema) { %>import { NzSchemaFormModule } from 'nz-schema-form';<% } %>
const THIRDMODULES = [
NgZorroAntdModule,
CountdownModule<% if (jsonSchema) { %>,
NzSchemaFormModule<% } %>
CountdownModule
];
// endregion

Expand All @@ -33,7 +32,8 @@ const DIRECTIVES = [];
ReactiveFormsModule,
AlainThemeModule.forChild(),
DelonABCModule,
DelonACLModule,
DelonACLModule,<% if (delonForm) { %>
DelonFormModule,<% } %>
// third libs
...THIRDMODULES
],
Expand All @@ -49,7 +49,8 @@ const DIRECTIVES = [];
RouterModule,
AlainThemeModule,
DelonABCModule,
DelonACLModule,<% if (delonI18n) { %>
DelonACLModule,<% if (delonForm) { %>
DelonFormModule,<% } %><% if (delonI18n) { %>
// i18n
TranslateModule,<% } %>
// third libs
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@
"default": true,
"alias": "dm"
},
"jsonSchema": {
"description": "Support json-schema. 是否需要 json-schema 动态表单",
"delonForm": {
"description": "Support json-schema. 是否需要 @delon/form 动态表单",
"type": "boolean",
"default": false,
"alias": "js"
"default": true,
"alias": "df"
},
"delonG2": {
"description": "Support G2 chart. 是否需要 G2 图表",
Expand Down
20 changes: 20 additions & 0 deletions packages/form/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @delon/form module

[Document](http://ng-alain.com/docs/form)

## Architecture

![Architecture](https://github.com/cipchk/delon/blob/master/_screenshot/architecture.png)

## Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

1. Use [GitHub Issues](https://github.com/cipchk/delon/issues) board to report bugs and feature requests (not our email address)
2. Please **always** write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

### License

The MIT License (see the [LICENSE](https://github.com/cipchk/delon/blob/master/LICENSE) file for the full text)
Loading

0 comments on commit b92747e

Please sign in to comment.