Skip to content

Commit f3c43bc

Browse files
authored
Merge pull request #29 from robust-team/v1.0.0
v1.0.0
2 parents 6b4c276 + 698eb4c commit f3c43bc

78 files changed

Lines changed: 4544 additions & 2023 deletions

File tree

Some content is hidden

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

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
<a name="1.0.0"></a>
6+
## [1.0.0](https://github.com/robust-team/angular-forms/compare/v0.5.2...v1.0.0) (2017-09-01)
7+
8+
### Features
9+
10+
* Addition of *asterisk* to required form controls.
11+
* Addition of the **editableOption** attribute in **Select**.
12+
* Addition of the **disabled** attribute in **Questions** into **Fieldset**.
13+
14+
### Changes
15+
16+
* Creation of the **styles.css** file and deletion of the inline styles into the components.
17+
* **String** updated to **StringUtils**.
18+
* Constructors of the **Groups**, **Questions** and **Validations** updated.
19+
* Methods into **DependencyService** updated to static methods.
20+
* **GroupType**, **QuestionType**, **ValidationType** and **DependencyCriteria** Enum created.
21+
* **ValidationFactory** created.
22+
523
<a name="0.5.2"></a>
624
## [0.5.2](https://github.com/robust-team/angular-forms/compare/v0.5.1...v0.5.2) (2017-07-19)
725

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A Simple Form Generator for Angular.
1717
- **@angular/forms**: 4.0.0 or higher,
1818
- **@fagnerlima/ng-mask**: 2.2.1 or higher,
1919
- **@ngx-translate/core**: 7.0.0 or higher,
20-
- **rxjs**: 5.0.1 or higher.
20+
- **rxjs**: 5.4.2 or higher.
2121

2222
## Usage
2323

@@ -27,7 +27,13 @@ A Simple Form Generator for Angular.
2727
npm i @robust-team/angular-forms
2828
```
2929

30-
2. Import the AngularFormsModule into Module class.
30+
2. Import the styles.css:
31+
32+
```
33+
node_modules/@robust-team/angular-forms/assets/css/styles.css
34+
```
35+
36+
3. Import the AngularFormsModule into Module class.
3137

3238
```typescript
3339
import { AngularFormsModule } from '@robust-team/angular-forms';
@@ -42,7 +48,7 @@ import { AngularFormsModule } from '@robust-team/angular-forms';
4248
export class MyModule { }
4349
```
4450

45-
3. Insert the AngularFormsComponent into template.
51+
4. Insert the AngularFormsComponent into template.
4652

4753
```html
4854
<rb-angular-forms [groups]="customForm"></rb-angular-forms>
@@ -81,6 +87,7 @@ The **customForm** attribute represents the JSON coming from API. For example:
8187
"description": "Select Question 0103",
8288
"type": "select",
8389
"options": ["Option 1", "Option 2"],
90+
"editableOption": "Option 2",
8491
"placeholder": "Select",
8592
"validations": [
8693
{ "type": "required", "message": "Required field." }
@@ -183,7 +190,7 @@ The **customForm** attribute represents the JSON coming from API. For example:
183190

184191
![screen](docs/screens/angular-forms-01.png)
185192

186-
4. Get form values by adding a local variable to the component and calling the **getForm()** method. For example:
193+
5. Get form values by adding a local variable to the component and calling the **getForm()** method. For example:
187194

188195
```html
189196
<rb-angular-forms #angularForms [groups]="customForm"></rb-angular-forms>
@@ -236,15 +243,15 @@ Example output:
236243
| **getForm()** | Returns an object with two attributes: **valid** (return of **isValid** method) and **value** (return of **getAnswersGroups** method. |
237244
| **submit()** | Send the form, enabling the validation of all questions. |
238245

239-
5. If you want only to show the answers from JSON, use the **readOnly** input with **true** value (your default value is **false**).
246+
6. If you want only to show the answers from JSON, use the **readOnly** input with **true** value (your default value is **false**).
240247

241248
```html
242249
<rb-angular-forms #angularForms [groups]="customForm" [readOnly]="true"></rb-angular-forms>
243250
```
244251

245252
![screen](docs/screens/angular-forms-02.png)
246253

247-
6. For you config the language to be used by AngularForms, use the **lang** input. There are two langs available: **en-US** (default) and **pt-BR**.
254+
7. For you config the language to be used by AngularForms, use the **lang** input. There are two langs available: **en-US** (default) and **pt-BR**.
248255

249256
```html
250257
<rb-angular-forms #angularForms [groups]="customForm" lang="pt-BR"></rb-angular-forms>
@@ -333,6 +340,7 @@ The **Group** represents a grouping of questions, which can be of two types: **F
333340
"type": "checkbox",
334341
"answer": null,
335342
"validations": [],
343+
"disabled": false,
336344
"defaultOption": "false"
337345
}
338346
```
@@ -349,6 +357,7 @@ The **Group** represents a grouping of questions, which can be of two types: **F
349357
"type": "radio",
350358
"answer": null,
351359
"validations": [],
360+
"disabled": false,
352361
"options": ["Option 1", "Option 2"],
353362
"defaultOption": null
354363
}
@@ -366,8 +375,10 @@ The **Group** represents a grouping of questions, which can be of two types: **F
366375
"type": "select",
367376
"answer": null,
368377
"validations": [],
378+
"disabled": false,
369379
"options": ["Option 1", "Option 2"],
370380
"defaultOption": null,
381+
"editableOption": "Option 2",
371382
"placeholder": "Select an option"
372383
}
373384
```
@@ -384,6 +395,7 @@ The **Group** represents a grouping of questions, which can be of two types: **F
384395
"type": "text",
385396
"answer": null,
386397
"validations": [],
398+
"disabled": false,
387399
"mask": null,
388400
"placeholder": null
389401
}
@@ -420,6 +432,7 @@ Read more in [https://fagnerlima.github.io/ng-mask/](https://fagnerlima.github.i
420432
"type": "textarea",
421433
"answer": null,
422434
"validations": [],
435+
"disabled": false,
423436
"placeholder": null
424437
}
425438
```

assets/css/styles.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* Icons */
2+
.rb-ico { font-style: normal }
3+
.rb-ico:after { font-size: 1.6rem }
4+
.rb-ico.rb-ico-add:after { content: '✚' }
5+
.rb-ico.rb-ico-remove:after { content: '✖' }
6+
.rb-ico.rb-ico-square:after {
7+
background: linear-gradient(to bottom, #fff 0px, #e6e6e6 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);
8+
border: 1px solid #888;
9+
border-radius: .3rem;
10+
content: '';
11+
cursor: default;
12+
display: inline-block;
13+
font-size: 1.6rem;
14+
height: 1.4rem;
15+
line-height: 1.4rem;
16+
margin-right: .5rem;
17+
text-align: center;
18+
width: 1.4rem;
19+
}
20+
.rb-ico.rb-ico-square.rb-ico-checked:after { content: '✔' }
21+
.rb-ico.rb-ico-square.rb-ico-unchecked:after { content: '' }
22+
23+
/* DataTable */
24+
.rb-data-table {
25+
border: 1px solid #ccc;
26+
margin-bottom: 15px;
27+
padding: 0 15px 15px;
28+
}
29+
.rb-data-table legend {
30+
border: 1px solid #ccc;
31+
padding: 5px 10px;
32+
}
33+
34+
/* Validation */
35+
.rb-validation-message {
36+
margin: 0;
37+
padding: 0;
38+
}
39+
.rb-validation-message li {
40+
border-left: 3px solid #a00;
41+
color: #a00;
42+
font-size: .9em;
43+
list-style: none;
44+
margin-bottom: 3px;
45+
padding: 1px 0 1px 5px;
46+
}
47+
.rb-validation-message li:first-of-type { margin-top: 5px }
48+
49+
.required-control::after {
50+
color: #a00;
51+
content: '*';
52+
}
53+
54+
/* Choice Question */
55+
.editable-option { margin-top: 10px; }

demo/demo.service.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ const groups: any[] = [
2323
'defaultOption': 'Option 1',
2424
'validations': [
2525
{ 'type': 'required', 'message': 'Required field.' }
26-
]
26+
],
27+
'disabled': true
2728
},
2829
{
2930
'name': 'Q-0103',
3031
'description': 'Select Question 0103',
3132
'type': 'select',
3233
'options': ['Option 1', 'Option 2'],
34+
'editableOption': 'Option 2',
3335
'placeholder': 'Select',
3436
'validations': [
3537
{ 'type': 'required', 'message': 'Required field.' }
@@ -39,6 +41,7 @@ const groups: any[] = [
3941
'name': 'Q-0104',
4042
'description': 'Text Question 0104',
4143
'type': 'text',
44+
'answer': 200,
4245
'placeholder': 'Text Question 0104',
4346
'validations': [
4447
{ 'type': 'required', 'message': 'Required field.' },
@@ -68,6 +71,40 @@ const groups: any[] = [
6871
'dependencies': [
6972
{ 'code': 'Q-0103', 'criteria': 'equals', 'expectedAnswer': 'Option 1' }
7073
]
74+
},
75+
{
76+
'name': 'Q-0107',
77+
'description': 'Text Question 0107',
78+
'type': 'text',
79+
'placeholder': 'Text Question 0107',
80+
'validations': [
81+
{ 'type': 'required', 'message': 'Required field.' }
82+
],
83+
'dependencies': [
84+
{ 'code': 'Q-0104', 'criteria': 'lessthan', 'expectedAnswer': '300' },
85+
{ 'code': 'Q-0104', 'criteria': 'notequals', 'expectedAnswer': '100' },
86+
{ 'code': 'Q-0104', 'criteria': 'greaterthan', 'expectedAnswer': '100' },
87+
{ 'code': 'Q-0104', 'criteria': 'lessthanorequals', 'expectedAnswer': '300' }
88+
]
89+
},
90+
{
91+
'name': 'Q-0108',
92+
'description': 'Text Question 0108',
93+
'type': 'text',
94+
'placeholder': 'Text Question 0108',
95+
'validations': [
96+
{ 'type': 'min', 'message': 'Min value: 1.', 'value': '1' },
97+
{ 'type': 'max', 'message': 'Min value: 10.', 'value': '10' }
98+
]
99+
},
100+
{
101+
'name': 'Q-0109',
102+
'description': 'Text Question 0109',
103+
'type': 'text',
104+
'placeholder': 'Text Question 0109',
105+
'validations': [
106+
{ 'type': 'email', 'message': 'Invalid e-mail.' }
107+
]
71108
}
72109
]
73110
},
@@ -90,20 +127,9 @@ const groups: any[] = [
90127
{ 'type': 'required', 'message': 'Required field.' }
91128
],
92129
'options': ['Option 1', 'Option 2', 'Option 3'],
130+
'editableOption': 'Option 3',
93131
'placeholder': 'Select'
94132
},
95-
{
96-
'name': 'Q-020201',
97-
'description': 'Text Question 020201',
98-
'type': 'text',
99-
'validations': [
100-
{ 'type': 'required', 'message': 'Required field.' }
101-
],
102-
'dependencies': [
103-
{ 'code': 'Q-0201', 'criteria': 'equals', 'expectedAnswer': 'Option 3' }
104-
],
105-
'placeholder': 'Text Question 020201'
106-
},
107133
{
108134
'name': 'Q-0202',
109135
'description': 'Text Question 0202',
@@ -126,19 +152,6 @@ const groups: any[] = [
126152
'placeholder': 'Select',
127153
'answer': 'Option 2'
128154
},
129-
{
130-
'name': 'Q-020201',
131-
'description': 'Text Question 020201',
132-
'type': 'text',
133-
'validations': [
134-
{ 'type': 'required', 'message': 'Required field.' }
135-
],
136-
'dependencies': [
137-
{ 'code': 'Q-0201', 'criteria': 'equals', 'expectedAnswer': 'Option 3' }
138-
],
139-
'placeholder': 'Text Question 020201',
140-
'answer': null
141-
},
142155
{
143156
'name': 'Q-0202',
144157
'description': 'Text Question 0202',
@@ -162,19 +175,6 @@ const groups: any[] = [
162175
'placeholder': 'Select',
163176
'answer': 'Option 3'
164177
},
165-
{
166-
'name': 'Q-020201',
167-
'description': 'Text Question 020201',
168-
'type': 'text',
169-
'validations': [
170-
{ 'type': 'required', 'message': 'Required field.' }
171-
],
172-
'dependencies': [
173-
{ 'code': 'Q-0201', 'criteria': 'equals', 'expectedAnswer': 'Option 3' }
174-
],
175-
'placeholder': 'Text Question 020201',
176-
'answer': 'Anwer 3'
177-
},
178178
{
179179
'name': 'Q-0202',
180180
'description': 'Text Question 0202',

demo/index.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta http-equiv="x-ua-compatible" content="ie=edge">
77
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
8+
<link rel="stylesheet" href="../assets/css/styles.css">
89
<title>AngularForms</title>
910
<style type="text/css">
1011
.container-demo {

docs/uml/angular-forms.asta

366 Bytes
Binary file not shown.

docs/uml/class-diagram.png

4.54 KB
Loading

0 commit comments

Comments
 (0)