-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathmap.service.ts
55 lines (52 loc) · 1.96 KB
/
map.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* tslint:disable:max-line-length */
/**
* Test Swagger
* v1
* example.com/api-base-path
*/
import {Injectable} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {FormArrayExtended} from '../../../common/formArrayExtended';
import {FormMap} from '../../../common/formMap';
import {StructuresService} from '../../../controllers/Structures';
@Injectable()
export class MapFormService {
form: FormGroup;
constructor(
private structuresService: StructuresService,
) {
this.form = new FormGroup({
mapSection: new FormMap(() => (
new FormGroup({
control: new FormControl(undefined, []),
group: new FormGroup({
id: new FormControl(undefined, [Validators.pattern(/^([+-]?[1-9]\d*|0)$/), Validators.required]),
name: new FormControl(undefined, []),
}, []),
arrayOfObjects: new FormArrayExtended(() => (
new FormGroup({
id: new FormControl(undefined, [Validators.pattern(/^([+-]?[1-9]\d*|0)$/), Validators.required]),
name: new FormControl(undefined, []),
}, [])), [], []),
mapRef: new FormMap(() => (
new FormControl(undefined, [])), {}, []),
mapInlinePrimitive: new FormMap(() => (
new FormControl(undefined, [])), {}, []),
mapInlineRef: new FormMap(() => (
new FormGroup({
id: new FormControl(undefined, [Validators.pattern(/^([+-]?[1-9]\d*|0)$/), Validators.required]),
name: new FormControl(undefined, []),
}, [])), {}, []),
arrayOfMaps: new FormArrayExtended(() => (
new FormMap(() => (
new FormControl(undefined, [])), {}, [])), [], []),
}, [Validators.required])), {}, [Validators.required]),
});
}
submit(raw = false) {
const data = raw ?
this.form.getRawValue() :
this.form.value;
return this.structuresService.map(data);
}
}