Skip to content

Commit 0f2f329

Browse files
michelu89pavel-s-epamlarisaVasilesha4be
authored
Feature/generate dynamic forms (#48)
* Add WIP for generation dynamic forms * Add material design into form * Extend some features into material design * Add date time functionality into html component * WIP dynamic forms * Fix table generation * Fix some bugs and remove un used table functionality * ADD: main functionality of generating a form Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: minor layout inconsistencies Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: handle validation errors in templates Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: change ngx-mat-datetime-picker to an input of 'datetime-local' type Reason: h2qutc/angular-material-components#348 Signed-off-by: Pavel Shalamkov <[email protected]> * add readOnlyForm question to prompter * remove questions from form prompter * add disabled true if readOnlyForm is true * start refactoring prompter * remove choose complex props to hide from form * remove question from form prompter * add back question * fix table * FIX: inconsistencies with base data types of the form Signed-off-by: Pavel Shalamkov <[email protected]> * REFACTOR: generate form groups/controls as separate components Signed-off-by: Pavel Shalamkov <[email protected]> * REFACTOR: remove "readOnlyForm" option from "fieldConfig" Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: unnecessary imports while generating a form Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: parsing of control's value Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: incorrect naming of controls Signed-off-by: Pavel Shalamkov <[email protected]> * REFACTOR: optimize RootFormFieldStrategy Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: handling of dates Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: handling "readOnlyForm" Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: align form controls "disabled" state Signed-off-by: Pavel Shalamkov <[email protected]> * fix getting selected element * fix getExcludedProperties * ADD: handle date/time type fields Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: hide hints on disabled fields Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: incorrect target elements Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: missed copyright on "form" files Signed-off-by: Pavel Shalamkov <[email protected]> * do not show entities that are of type single entity * fix excluding properties for entity * allow for form generation to select collection aspect * FIX: compilation errors with generated components Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: stub for "list" type Signed-off-by: Pavel Shalamkov <[email protected]> * REMOVE: unnecessary options for form generation Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: handler for "structured value" type Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: example value to form fields Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: disable "submit" based on form availability Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: interface of a generated form Signed-off-by: Pavel Shalamkov <[email protected]> * REMOVE: unused code Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: show example values as placeholders for non-strict input types Signed-off-by: Pavel Shalamkov <[email protected]> * fix form generation * refactor prompter * refactor prompter * ADD: logic for "list" type Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: styles for groups of controls Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: exclude unnecessary generators for "form" Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: incorrect detection of the target FormFieldStrategy Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: support complex types in form fields of type "list" Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: handle "disabled" state and communication interface Signed-off-by: Pavel Shalamkov <[email protected]> * start documentation for form * update documentation * finish form documentation * add the environments files for form * UPDATE: "form" components selectors Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: split BaseFormFieldConfig interface Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: unhandled scalar types Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: handle import path for both versioned and non-versioned generation Signed-off-by: Pavel Shalamkov <[email protected]> * UPDATE: styles for "legend" tag Signed-off-by: Pavel Shalamkov <[email protected]> * FIX: incorrect import path for form types Signed-off-by: Pavel Shalamkov <[email protected]> * ADD: output overview to "form" README.md Signed-off-by: Pavel Shalamkov <[email protected]> * Fix overwrite problems for static files and run prettier * Fix unit tests * Prevent raise condition on request data, shpw error on data load error see #40 see #41 * Fix unit tests * FIX: linting errors Signed-off-by: Pavel Shalamkov <[email protected]> --------- Signed-off-by: Pavel Shalamkov <[email protected]> Co-authored-by: Pavel Shalamkov <[email protected]> Co-authored-by: Larisa Vasile <[email protected]> Co-authored-by: Anton Shabatin <[email protected]>
1 parent 94a167d commit 0f2f329

File tree

111 files changed

+4787
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4787
-703
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- [The _card_ schematics](#the-card-schematics)
1919
- [Features provided by the schematics card](#features-provided-by-the-schematics-card)
2020
- [Howto generate a card component with the schematics command](#howto-generate-a-card-component-with-the-schematics-command)
21+
- [The _form_ schematics](#the-form-schematics)
22+
- [Features provided by the schematics form](#features-provided-by-the-schematics-form)
23+
- [Howto generate a form component with the schematics command](#howto-generate-a-form-component-with-the-schematics-command)
2124
- [Documentation](#documentation)
2225
- [License](#license)
2326

@@ -125,6 +128,7 @@ where `<schematics-name>` can be replaced by:
125128

126129
- table
127130
- card
131+
- form
128132
- i18n
129133
- types
130134

@@ -153,11 +157,13 @@ And in assets folder an i18n folder should be generated. And i18n folder should
153157
en.movement-table.translation.json, en.json.
154158

155159
7. add environment files
160+
156161
```bash
157162
ng generate environments
158163
```
159164

160165
8. add default translation language to root component.
166+
161167
```typescript
162168
constructor(private translate: TranslateService)
163169
{
@@ -293,6 +299,25 @@ the [angular material package](https://v16.material.angular.io/components/card/o
293299

294300
---
295301

302+
## The _form_ schematics
303+
304+
The form schematics can be used for form generation.
305+
306+
### Features provided by the schematics form
307+
308+
1. Types generation
309+
2. Aspect model multiple version support
310+
3. Form generation for the entire aspect or just an entity of user's choice
311+
4. Multiple aspect models selection
312+
5. Wizard output to regenerate the same form without going through the wizard again
313+
6. Possibility to set the form as read only
314+
315+
### How to generate a form component with the schematics command
316+
317+
[Link to readme](src/ng-generate/components/form/README.md)
318+
319+
---
320+
296321
## Documentation
297322

298323
Further documentation and howto's are provided in the
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/** Generated form ESMF JS SDK Angular Schematics - PLEASE DO NOT CHANGE IT **/
2+
3+
export interface MultiLanguageText {
4+
/** key defines the locale. Value is the translated text for that locale. */
5+
[key: string]: string;
6+
}
7+
8+
/**
9+
* Aspect for movement information
10+
*/
11+
export interface Movement {
12+
/**
13+
* Flag indicating if the position is changing
14+
*/
15+
moving: boolean;
16+
/**
17+
* Indicates if speed limit is adhered to.
18+
*/
19+
speedLimitWarning: WarningLevel;
20+
/**
21+
* Indicates a position
22+
*/
23+
position: SpatialPosition;
24+
/**
25+
* Date, when the batch was started
26+
*/
27+
startDate: Date;
28+
/**
29+
* Date, when the last part of the batch was produced
30+
*/
31+
endDate: Date;
32+
property1: Array<string>;
33+
}
34+
35+
/**
36+
* Represents if speed of position change is within specification (green), within tolerance (yellow), or outside specification (red).
37+
*/
38+
export enum WarningLevel {
39+
Green = 'green',
40+
Yellow = 'yellow',
41+
Red = 'red',
42+
}
43+
44+
/**
45+
* Position in space, described along three axis, with the third axis optional, if all positions are in a plane.
46+
*/
47+
export interface SpatialPosition {
48+
/**
49+
* x coordinate in space
50+
*/
51+
x: number;
52+
/**
53+
* y coordinate in space
54+
*/
55+
y: number;
56+
/**
57+
* z coordinate in space
58+
*/
59+
z: number;
60+
}

src/collection.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@
3333
"factory": "./ng-generate/components/card/index#generateCard",
3434
"schema": "./ng-generate/components/card/schema.json"
3535
},
36+
"form": {
37+
"description": "Create a component that generate a form",
38+
"factory": "./ng-generate/components/form/index",
39+
"schema": "./ng-generate/components/form/schema.json"
40+
},
41+
"form-prompter": {
42+
"description": "generate custom prompter",
43+
"factory": "./ng-generate/prompter/form/index"
44+
},
45+
"form-generation": {
46+
"description": "Executes the form generation",
47+
"factory": "./ng-generate/components/form/index#generateForm",
48+
"schema": "./ng-generate/components/form/schema.json"
49+
},
3650
"i18n": {
3751
"description": "Add i18n strategy to the application",
3852
"factory": "./ng-generate/i18n/index",

src/ng-generate/components/card/generators/components/card/files/__name@dasherize__.component.html.template

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
<!--
2-
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
3-
*
4-
* See the AUTHORS file(s) distributed with this work for
5-
* additional information regarding authorship.
6-
*
7-
* This Source Code Form is subject to the terms of the Mozilla Public
8-
* License, v. 2.0. If a copy of the MPL was not distributed with this
9-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
10-
*
11-
* SPDX-License-Identifier: MPL-2.0
12-
-->
13-
141
<div class="js-sdk-component-container">
152
<% if (options.addCommandBar) { %>
163
<command-bar

0 commit comments

Comments
 (0)