@valtimo/form-management 4.15.3-next-main.16 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/valtimo-form-management.umd.js +980 -936
- package/bundles/valtimo-form-management.umd.js.map +1 -1
- package/bundles/valtimo-form-management.umd.min.js +1 -1
- package/bundles/valtimo-form-management.umd.min.js.map +1 -1
- package/esm2015/lib/form-management-create/form-management-create.component.js +87 -87
- package/esm2015/lib/form-management-edit/form-management-edit.component.js +149 -149
- package/esm2015/lib/form-management-list/form-management-list.component.js +72 -72
- package/esm2015/lib/form-management-routing.module.js +54 -54
- package/esm2015/lib/form-management-upload/form-management-upload.component.js +148 -148
- package/esm2015/lib/form-management.component.js +29 -29
- package/esm2015/lib/form-management.module.js +55 -55
- package/esm2015/lib/form-management.service.js +57 -57
- package/esm2015/lib/models/form-definition.model.js +25 -0
- package/esm2015/lib/models/index.js +19 -0
- package/esm2015/public-api.js +23 -22
- package/esm2015/valtimo-form-management.js +10 -10
- package/fesm2015/valtimo-form-management.js +647 -605
- package/fesm2015/valtimo-form-management.js.map +1 -1
- package/lib/form-management-create/form-management-create.component.d.ts +20 -20
- package/lib/form-management-edit/form-management-edit.component.d.ts +31 -31
- package/lib/form-management-list/form-management-list.component.d.ts +24 -24
- package/lib/form-management-routing.module.d.ts +2 -2
- package/lib/form-management-upload/form-management-upload.component.d.ts +37 -37
- package/lib/form-management.component.d.ts +5 -5
- package/lib/form-management.module.d.ts +2 -2
- package/lib/form-management.service.d.ts +15 -15
- package/lib/models/form-definition.model.d.ts +17 -0
- package/lib/models/index.d.ts +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -3
- package/valtimo-form-management.d.ts +9 -9
- package/valtimo-form-management.metadata.json +1 -1
|
@@ -1,639 +1,681 @@
|
|
|
1
1
|
import { ɵɵdefineInjectable, ɵɵinject, Injectable, Component, ViewEncapsulation, NgModule, EventEmitter, ViewChild, Input, Output } from '@angular/core';
|
|
2
2
|
import { HttpClient } from '@angular/common/http';
|
|
3
|
-
import { ConfigService } from '@valtimo/config';
|
|
3
|
+
import { ConfigService, ROLE_ADMIN } from '@valtimo/config';
|
|
4
4
|
import { Router, ActivatedRoute, RouterModule } from '@angular/router';
|
|
5
5
|
import { AuthGuardService } from '@valtimo/security';
|
|
6
6
|
import { FormControl, Validators, FormBuilder, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
7
7
|
import { AlertService, FormIoModule, WidgetModule, ListModule, DropzoneModule, ModalModule } from '@valtimo/components';
|
|
8
8
|
import { combineLatest, BehaviorSubject, Subscription, Subject } from 'rxjs';
|
|
9
9
|
import { take, first } from 'rxjs/operators';
|
|
10
|
-
import { ROLE_ADMIN } from '@valtimo/contract';
|
|
11
10
|
import { CommonModule } from '@angular/common';
|
|
12
11
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
13
12
|
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
|
14
13
|
import { DocumentService } from '@valtimo/document';
|
|
15
14
|
|
|
16
|
-
/*
|
|
17
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
18
|
-
*
|
|
19
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
20
|
-
* you may not use this file except in compliance with the License.
|
|
21
|
-
* You may obtain a copy of the License at
|
|
22
|
-
*
|
|
23
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
24
|
-
*
|
|
25
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
27
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
-
* See the License for the specific language governing permissions and
|
|
29
|
-
* limitations under the License.
|
|
30
|
-
*/
|
|
31
|
-
class FormManagementService {
|
|
32
|
-
constructor(http, configService) {
|
|
33
|
-
this.http = http;
|
|
34
|
-
this.configService = configService;
|
|
35
|
-
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
36
|
-
}
|
|
37
|
-
getFormDefinition(formDefinitionId) {
|
|
38
|
-
return this.http.get(`${this.valtimoApiConfig.endpointUri}form-management/${formDefinitionId}`);
|
|
39
|
-
}
|
|
40
|
-
queryFormDefinitions(params) {
|
|
41
|
-
return this.http.get(`${this.valtimoApiConfig.endpointUri}form-management`, {
|
|
42
|
-
observe: 'response',
|
|
43
|
-
params: params,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
createFormDefinition(request) {
|
|
47
|
-
return this.http.post(`${this.valtimoApiConfig.endpointUri}form-management`, request);
|
|
48
|
-
}
|
|
49
|
-
modifyFormDefinition(request) {
|
|
50
|
-
return this.http.put(`${this.valtimoApiConfig.endpointUri}form-management`, request);
|
|
51
|
-
}
|
|
52
|
-
deleteFormDefinition(formDefinitionId) {
|
|
53
|
-
return this.http.delete(`${this.valtimoApiConfig.endpointUri}form-management/${formDefinitionId}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
FormManagementService.ɵprov = ɵɵdefineInjectable({ factory: function FormManagementService_Factory() { return new FormManagementService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: FormManagementService, providedIn: "root" });
|
|
57
|
-
FormManagementService.decorators = [
|
|
58
|
-
{ type: Injectable, args: [{
|
|
59
|
-
providedIn: 'root',
|
|
60
|
-
},] }
|
|
61
|
-
];
|
|
62
|
-
FormManagementService.ctorParameters = () => [
|
|
63
|
-
{ type: HttpClient },
|
|
64
|
-
{ type: ConfigService }
|
|
15
|
+
/*
|
|
16
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
17
|
+
*
|
|
18
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License.
|
|
20
|
+
* You may obtain a copy of the License at
|
|
21
|
+
*
|
|
22
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
26
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
* See the License for the specific language governing permissions and
|
|
28
|
+
* limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
class FormManagementService {
|
|
31
|
+
constructor(http, configService) {
|
|
32
|
+
this.http = http;
|
|
33
|
+
this.configService = configService;
|
|
34
|
+
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
35
|
+
}
|
|
36
|
+
getFormDefinition(formDefinitionId) {
|
|
37
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}form-management/${formDefinitionId}`);
|
|
38
|
+
}
|
|
39
|
+
queryFormDefinitions(params) {
|
|
40
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}form-management`, {
|
|
41
|
+
observe: 'response',
|
|
42
|
+
params: params,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
createFormDefinition(request) {
|
|
46
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}form-management`, request);
|
|
47
|
+
}
|
|
48
|
+
modifyFormDefinition(request) {
|
|
49
|
+
return this.http.put(`${this.valtimoApiConfig.endpointUri}form-management`, request);
|
|
50
|
+
}
|
|
51
|
+
deleteFormDefinition(formDefinitionId) {
|
|
52
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}form-management/${formDefinitionId}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
FormManagementService.ɵprov = ɵɵdefineInjectable({ factory: function FormManagementService_Factory() { return new FormManagementService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: FormManagementService, providedIn: "root" });
|
|
56
|
+
FormManagementService.decorators = [
|
|
57
|
+
{ type: Injectable, args: [{
|
|
58
|
+
providedIn: 'root',
|
|
59
|
+
},] }
|
|
60
|
+
];
|
|
61
|
+
FormManagementService.ctorParameters = () => [
|
|
62
|
+
{ type: HttpClient },
|
|
63
|
+
{ type: ConfigService }
|
|
65
64
|
];
|
|
66
65
|
|
|
67
|
-
/*
|
|
68
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
69
|
-
*
|
|
70
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
71
|
-
* you may not use this file except in compliance with the License.
|
|
72
|
-
* You may obtain a copy of the License at
|
|
73
|
-
*
|
|
74
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
75
|
-
*
|
|
76
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
77
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
78
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
79
|
-
* See the License for the specific language governing permissions and
|
|
80
|
-
* limitations under the License.
|
|
81
|
-
*/
|
|
82
|
-
class FormManagementComponent {
|
|
83
|
-
constructor() { }
|
|
84
|
-
ngOnInit() { }
|
|
85
|
-
}
|
|
86
|
-
FormManagementComponent.decorators = [
|
|
87
|
-
{ type: Component, args: [{
|
|
88
|
-
selector: 'valtimo-form-management',
|
|
89
|
-
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content pt-0\">\n <div class=\"container-fluid\">\n <div class=\"text-right\">\n <div class=\"btn-group mt-m3px mb-3\">\n <button\n [routerLink]=\"'create'\"\n [queryParams]=\"{upload: 'true'}\"\n class=\"btn btn-secondary btn-space\"\n >\n <i class=\"icon mdi mdi-upload\"></i> \n {{ 'Upload' | translate }}\n </button>\n <button [routerLink]=\"'create'\" class=\"btn btn-primary btn-space mr-0\">\n <i class=\"icon mdi mdi-plus\"></i> \n <span>{{ 'Create new Form' | translate }}</span>\n </button>\n </div>\n </div>\n <valtimo-widget>\n <valtimo-form-management-list></valtimo-form-management-list>\n </valtimo-widget>\n </div>\n</div>\n",
|
|
90
|
-
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
|
|
91
|
-
},] }
|
|
92
|
-
];
|
|
66
|
+
/*
|
|
67
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
68
|
+
*
|
|
69
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
70
|
+
* you may not use this file except in compliance with the License.
|
|
71
|
+
* You may obtain a copy of the License at
|
|
72
|
+
*
|
|
73
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
74
|
+
*
|
|
75
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
76
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
77
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
78
|
+
* See the License for the specific language governing permissions and
|
|
79
|
+
* limitations under the License.
|
|
80
|
+
*/
|
|
81
|
+
class FormManagementComponent {
|
|
82
|
+
constructor() { }
|
|
83
|
+
ngOnInit() { }
|
|
84
|
+
}
|
|
85
|
+
FormManagementComponent.decorators = [
|
|
86
|
+
{ type: Component, args: [{
|
|
87
|
+
selector: 'valtimo-form-management',
|
|
88
|
+
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content pt-0\">\n <div class=\"container-fluid\">\n <div class=\"text-right\">\n <div class=\"btn-group mt-m3px mb-3\">\n <button\n [routerLink]=\"'create'\"\n [queryParams]=\"{upload: 'true'}\"\n class=\"btn btn-secondary btn-space\"\n >\n <i class=\"icon mdi mdi-upload\"></i> \n {{ 'Upload' | translate }}\n </button>\n <button [routerLink]=\"'create'\" class=\"btn btn-primary btn-space mr-0\">\n <i class=\"icon mdi mdi-plus\"></i> \n <span>{{ 'Create new Form' | translate }}</span>\n </button>\n </div>\n </div>\n <valtimo-widget>\n <valtimo-form-management-list></valtimo-form-management-list>\n </valtimo-widget>\n </div>\n</div>\n",
|
|
89
|
+
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
|
|
90
|
+
},] }
|
|
91
|
+
];
|
|
93
92
|
FormManagementComponent.ctorParameters = () => [];
|
|
94
93
|
|
|
95
|
-
/*
|
|
96
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
97
|
-
*
|
|
98
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
99
|
-
* you may not use this file except in compliance with the License.
|
|
100
|
-
* You may obtain a copy of the License at
|
|
101
|
-
*
|
|
102
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
103
|
-
*
|
|
104
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
105
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
106
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
107
|
-
* See the License for the specific language governing permissions and
|
|
108
|
-
* limitations under the License.
|
|
109
|
-
*/
|
|
110
|
-
class FormManagementCreateComponent {
|
|
111
|
-
constructor(formManagementService, formBuilder, router, alertService, route) {
|
|
112
|
-
this.formManagementService = formManagementService;
|
|
113
|
-
this.formBuilder = formBuilder;
|
|
114
|
-
this.router = router;
|
|
115
|
-
this.alertService = alertService;
|
|
116
|
-
this.route = route;
|
|
117
|
-
}
|
|
118
|
-
get formControls() {
|
|
119
|
-
return this.form.controls;
|
|
120
|
-
}
|
|
121
|
-
ngOnInit() {
|
|
122
|
-
this.form = this.formBuilder.group({
|
|
123
|
-
name: new FormControl('', Validators.required),
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
reset() {
|
|
127
|
-
this.form.setValue({
|
|
128
|
-
name: '',
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
createFormDefinition() {
|
|
132
|
-
const emptyForm = {
|
|
133
|
-
display: 'form',
|
|
134
|
-
components: [],
|
|
135
|
-
};
|
|
136
|
-
const request = {
|
|
137
|
-
name: this.form.value.name,
|
|
138
|
-
formDefinition: JSON.stringify(emptyForm),
|
|
139
|
-
};
|
|
140
|
-
combineLatest([
|
|
141
|
-
this.formManagementService.createFormDefinition(request),
|
|
142
|
-
this.route.queryParams,
|
|
143
|
-
])
|
|
144
|
-
.pipe(take(1))
|
|
145
|
-
.subscribe(([formDefinition, params]) => {
|
|
146
|
-
this.alertService.success('Created new Form');
|
|
147
|
-
if ((params === null || params === void 0 ? void 0 : params.upload) === 'true') {
|
|
148
|
-
this.router.navigate(['/form-management/edit', formDefinition.id], {
|
|
149
|
-
queryParams: { upload: 'true' },
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
this.router.navigate(['/form-management/edit', formDefinition.id]);
|
|
154
|
-
}
|
|
155
|
-
}, err => {
|
|
156
|
-
this.alertService.error('Error creating new Form');
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
FormManagementCreateComponent.decorators = [
|
|
161
|
-
{ type: Component, args: [{
|
|
162
|
-
selector: 'valtimo-form-management-create',
|
|
163
|
-
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content\">\n <div class=\"container-fluid\">\n <div class=\"col-12 px-0 mb-5\">\n <valtimo-widget>\n <div class=\"bg-white p-5\">\n <form [formGroup]=\"form\" (ngSubmit)=\"createFormDefinition()\">\n <div class=\"form-group row\">\n <label class=\"col-12 col-sm-3 col-form-label text-sm-right\" for=\"name\">Name</label>\n <div class=\"col-12 col-sm-8 col-lg-6\">\n <input\n type=\"text\"\n id=\"name\"\n formControlName=\"name\"\n class=\"form-control\"\n placeholder=\"Form definition name\"\n [ngClass]=\"{\n 'is-valid': formControls.name.touched && formControls.name.valid,\n 'is-invalid': formControls.name.touched && formControls.name.errors\n }\"\n required\n />\n <div\n *ngIf=\"formControls.name.touched && formControls.name.errors\"\n class=\"invalid-feedback\"\n >\n <div *ngIf=\"formControls.name.errors.required\">Name is required</div>\n </div>\n </div>\n </div>\n <div class=\"row pt-3 mt-1\">\n <div class=\"col-12 col-sm-6 text-left\">\n <a [routerLink]=\"'/forms'\" class=\"btn btn-space btn-default\">Back</a>\n </div>\n <div class=\"col-12 col-sm-6 text-right\">\n <button class=\"btn btn-space btn-secondary\" type=\"button\" (click)=\"reset()\">\n Reset\n </button>\n <button class=\"btn btn-space btn-primary\" type=\"submit\" [disabled]=\"form.invalid\">\n Submit\n </button>\n </div>\n </div>\n </form>\n </div>\n </valtimo-widget>\n </div>\n </div>\n</div>\n",
|
|
164
|
-
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
|
|
165
|
-
},] }
|
|
166
|
-
];
|
|
167
|
-
FormManagementCreateComponent.ctorParameters = () => [
|
|
168
|
-
{ type: FormManagementService },
|
|
169
|
-
{ type: FormBuilder },
|
|
170
|
-
{ type: Router },
|
|
171
|
-
{ type: AlertService },
|
|
172
|
-
{ type: ActivatedRoute }
|
|
94
|
+
/*
|
|
95
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
96
|
+
*
|
|
97
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
98
|
+
* you may not use this file except in compliance with the License.
|
|
99
|
+
* You may obtain a copy of the License at
|
|
100
|
+
*
|
|
101
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
102
|
+
*
|
|
103
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
104
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
105
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
106
|
+
* See the License for the specific language governing permissions and
|
|
107
|
+
* limitations under the License.
|
|
108
|
+
*/
|
|
109
|
+
class FormManagementCreateComponent {
|
|
110
|
+
constructor(formManagementService, formBuilder, router, alertService, route) {
|
|
111
|
+
this.formManagementService = formManagementService;
|
|
112
|
+
this.formBuilder = formBuilder;
|
|
113
|
+
this.router = router;
|
|
114
|
+
this.alertService = alertService;
|
|
115
|
+
this.route = route;
|
|
116
|
+
}
|
|
117
|
+
get formControls() {
|
|
118
|
+
return this.form.controls;
|
|
119
|
+
}
|
|
120
|
+
ngOnInit() {
|
|
121
|
+
this.form = this.formBuilder.group({
|
|
122
|
+
name: new FormControl('', Validators.required),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
reset() {
|
|
126
|
+
this.form.setValue({
|
|
127
|
+
name: '',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
createFormDefinition() {
|
|
131
|
+
const emptyForm = {
|
|
132
|
+
display: 'form',
|
|
133
|
+
components: [],
|
|
134
|
+
};
|
|
135
|
+
const request = {
|
|
136
|
+
name: this.form.value.name,
|
|
137
|
+
formDefinition: JSON.stringify(emptyForm),
|
|
138
|
+
};
|
|
139
|
+
combineLatest([
|
|
140
|
+
this.formManagementService.createFormDefinition(request),
|
|
141
|
+
this.route.queryParams,
|
|
142
|
+
])
|
|
143
|
+
.pipe(take(1))
|
|
144
|
+
.subscribe(([formDefinition, params]) => {
|
|
145
|
+
this.alertService.success('Created new Form');
|
|
146
|
+
if ((params === null || params === void 0 ? void 0 : params.upload) === 'true') {
|
|
147
|
+
this.router.navigate(['/form-management/edit', formDefinition.id], {
|
|
148
|
+
queryParams: { upload: 'true' },
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.router.navigate(['/form-management/edit', formDefinition.id]);
|
|
153
|
+
}
|
|
154
|
+
}, err => {
|
|
155
|
+
this.alertService.error('Error creating new Form');
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
FormManagementCreateComponent.decorators = [
|
|
160
|
+
{ type: Component, args: [{
|
|
161
|
+
selector: 'valtimo-form-management-create',
|
|
162
|
+
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content\">\n <div class=\"container-fluid\">\n <div class=\"col-12 px-0 mb-5\">\n <valtimo-widget>\n <div class=\"bg-white p-5\">\n <form [formGroup]=\"form\" (ngSubmit)=\"createFormDefinition()\">\n <div class=\"form-group row\">\n <label class=\"col-12 col-sm-3 col-form-label text-sm-right\" for=\"name\">Name</label>\n <div class=\"col-12 col-sm-8 col-lg-6\">\n <input\n type=\"text\"\n id=\"name\"\n formControlName=\"name\"\n class=\"form-control\"\n placeholder=\"Form definition name\"\n [ngClass]=\"{\n 'is-valid': formControls.name.touched && formControls.name.valid,\n 'is-invalid': formControls.name.touched && formControls.name.errors\n }\"\n required\n />\n <div\n *ngIf=\"formControls.name.touched && formControls.name.errors\"\n class=\"invalid-feedback\"\n >\n <div *ngIf=\"formControls.name.errors.required\">Name is required</div>\n </div>\n </div>\n </div>\n <div class=\"row pt-3 mt-1\">\n <div class=\"col-12 col-sm-6 text-left\">\n <a [routerLink]=\"'/forms'\" class=\"btn btn-space btn-default\">Back</a>\n </div>\n <div class=\"col-12 col-sm-6 text-right\">\n <button class=\"btn btn-space btn-secondary\" type=\"button\" (click)=\"reset()\">\n Reset\n </button>\n <button class=\"btn btn-space btn-primary\" type=\"submit\" [disabled]=\"form.invalid\">\n Submit\n </button>\n </div>\n </div>\n </form>\n </div>\n </valtimo-widget>\n </div>\n </div>\n</div>\n",
|
|
163
|
+
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
|
|
164
|
+
},] }
|
|
165
|
+
];
|
|
166
|
+
FormManagementCreateComponent.ctorParameters = () => [
|
|
167
|
+
{ type: FormManagementService },
|
|
168
|
+
{ type: FormBuilder },
|
|
169
|
+
{ type: Router },
|
|
170
|
+
{ type: AlertService },
|
|
171
|
+
{ type: ActivatedRoute }
|
|
173
172
|
];
|
|
174
173
|
|
|
175
|
-
/*
|
|
176
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
177
|
-
*
|
|
178
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
179
|
-
* you may not use this file except in compliance with the License.
|
|
180
|
-
* You may obtain a copy of the License at
|
|
181
|
-
*
|
|
182
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
183
|
-
*
|
|
184
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
185
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
186
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
187
|
-
* See the License for the specific language governing permissions and
|
|
188
|
-
* limitations under the License.
|
|
189
|
-
*/
|
|
190
|
-
class FormManagementEditComponent {
|
|
191
|
-
constructor(formManagementService, alertService, route, router) {
|
|
192
|
-
this.formManagementService = formManagementService;
|
|
193
|
-
this.alertService = alertService;
|
|
194
|
-
this.route = route;
|
|
195
|
-
this.router = router;
|
|
196
|
-
this.showModal$ = new BehaviorSubject(false);
|
|
197
|
-
this.reloading$ = new BehaviorSubject(false);
|
|
198
|
-
this.modifiedFormDefinition = null;
|
|
199
|
-
this.formDefinition = null;
|
|
200
|
-
this.alertSub = Subscription.EMPTY;
|
|
201
|
-
this.formDefinitionId = null;
|
|
202
|
-
}
|
|
203
|
-
ngOnInit() {
|
|
204
|
-
this.loadFormDefinition();
|
|
205
|
-
this.checkToOpenUploadModal();
|
|
206
|
-
}
|
|
207
|
-
ngOnDestroy() {
|
|
208
|
-
this.alertSub.unsubscribe();
|
|
209
|
-
}
|
|
210
|
-
loadFormDefinition() {
|
|
211
|
-
this.formDefinitionId = this.route.snapshot.paramMap.get('id');
|
|
212
|
-
this.formManagementService.getFormDefinition(this.formDefinitionId).subscribe(formDefinition => {
|
|
213
|
-
this.formDefinition = formDefinition;
|
|
214
|
-
}, () => {
|
|
215
|
-
this.alertService.error('Error retrieving Form Definition');
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
modifyFormDefinition() {
|
|
219
|
-
const form = JSON.stringify(this.modifiedFormDefinition != null
|
|
220
|
-
? this.modifiedFormDefinition
|
|
221
|
-
: this.formDefinition.formDefinition);
|
|
222
|
-
const request = {
|
|
223
|
-
id: this.formDefinition.id,
|
|
224
|
-
name: this.formDefinition.name,
|
|
225
|
-
formDefinition: form,
|
|
226
|
-
};
|
|
227
|
-
this.formManagementService.modifyFormDefinition(request).subscribe(() => {
|
|
228
|
-
this.router.navigate(['/form-management']);
|
|
229
|
-
this.alertService.success('Form deployed');
|
|
230
|
-
}, err => {
|
|
231
|
-
this.alertService.error('Error deploying Form');
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
formBuilderChanged(event) {
|
|
235
|
-
this.modifiedFormDefinition = event.form;
|
|
236
|
-
}
|
|
237
|
-
delete() {
|
|
238
|
-
if (!this.alertSub.closed) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const mssg = 'Delete Form?';
|
|
242
|
-
const confirmations = [
|
|
243
|
-
{
|
|
244
|
-
label: 'Cancel',
|
|
245
|
-
class: 'btn btn-default',
|
|
246
|
-
value: false,
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
label: 'Delete',
|
|
250
|
-
class: 'btn btn-primary',
|
|
251
|
-
value: true,
|
|
252
|
-
},
|
|
253
|
-
];
|
|
254
|
-
this.alertService.notification(mssg, confirmations);
|
|
255
|
-
this.alertSub = this.alertService
|
|
256
|
-
.getAlertConfirmChangeEmitter()
|
|
257
|
-
.pipe(first())
|
|
258
|
-
.subscribe(alert => {
|
|
259
|
-
if (alert.confirm === true) {
|
|
260
|
-
this.deleteFormDefinition();
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
deleteFormDefinition() {
|
|
265
|
-
this.formManagementService.deleteFormDefinition(this.formDefinition.id).subscribe(() => {
|
|
266
|
-
this.router.navigate(['/form-management']);
|
|
267
|
-
this.alertService.success('Form deleted');
|
|
268
|
-
}, err => {
|
|
269
|
-
this.alertService.error('Error deleting Form');
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
downloadFormDefinition() {
|
|
273
|
-
const file = new Blob([JSON.stringify(this.formDefinition)], { type: 'text/json' });
|
|
274
|
-
const link = document.createElement('a');
|
|
275
|
-
link.download = `form_${this.formDefinition.name}.json`;
|
|
276
|
-
link.href = window.URL.createObjectURL(file);
|
|
277
|
-
link.click();
|
|
278
|
-
window.URL.revokeObjectURL(link.href);
|
|
279
|
-
link.remove();
|
|
280
|
-
}
|
|
281
|
-
showModal() {
|
|
282
|
-
this.showModal$.next(true);
|
|
283
|
-
}
|
|
284
|
-
setFormDefinition(formDefinition) {
|
|
285
|
-
var _a;
|
|
286
|
-
this.reloading$.next(true);
|
|
287
|
-
const definition = JSON.parse(formDefinition);
|
|
288
|
-
const components = (_a = definition === null || definition === void 0 ? void 0 : definition.formDefinition) === null || _a === void 0 ? void 0 : _a.components;
|
|
289
|
-
const currentDefinition = this.modifiedFormDefinition || this.formDefinition.formDefinition;
|
|
290
|
-
const newDefinition = Object.assign(Object.assign({}, currentDefinition), (components && { components }));
|
|
291
|
-
this.modifiedFormDefinition = newDefinition;
|
|
292
|
-
this.formDefinition.formDefinition = newDefinition;
|
|
293
|
-
this.reloading$.next(false);
|
|
294
|
-
}
|
|
295
|
-
checkToOpenUploadModal() {
|
|
296
|
-
this.route.queryParams.pipe(take(1)).subscribe(params => {
|
|
297
|
-
if ((params === null || params === void 0 ? void 0 : params.upload) === 'true') {
|
|
298
|
-
this.showModal();
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
FormManagementEditComponent.decorators = [
|
|
304
|
-
{ type: Component, args: [{
|
|
305
|
-
selector: 'valtimo-form-management-edit',
|
|
306
|
-
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content pt-0\">\n <div class=\"container-fluid\" *ngIf=\"formDefinition\">\n <div class=\"btn-group mt-m3px mb-3 float-right\">\n <button class=\"btn btn-primary btn-space\" (click)=\"downloadFormDefinition()\">\n <i class=\"fa fa-save\"></i>\n {{ 'Download' | translate }}\n </button>\n <button\n class=\"btn btn-secondary btn-space\"\n (click)=\"showModal()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"icon mdi mdi-upload\"></i> \n {{ 'Upload' | translate }}\n </button>\n <button\n class=\"btn btn-danger btn-space\"\n (click)=\"delete()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"fa fa-trash\"></i> Delete\n </button>\n <button\n class=\"btn btn-success btn-space\"\n (click)=\"modifyFormDefinition()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"fa fa-upload\"></i> Deploy\n </button>\n </div>\n <div class=\"clearfix\"></div>\n <div class=\"bg-light formbuilder-header overflow-auto\">\n <h3 class=\"formbuilder-title\">\n {{ formDefinition.name }}\n <div *ngIf=\"formDefinition.readOnly\" class=\"pull-right\">\n <span class=\"badge badge-pill badge-info increase-size\">Read-only</span>\n </div>\n </h3>\n </div>\n <ng-container *ngIf=\"!(reloading$ | async)\">\n <valtimo-form-io-builder\n [form]=\"formDefinition.formDefinition\"\n (change)=\"formBuilderChanged($event)\"\n ></valtimo-form-io-builder>\n </ng-container>\n </div>\n</div>\n\n<valtimo-form-management-upload\n [show$]=\"showModal$\"\n (definitionUploaded)=\"setFormDefinition($event)\"\n></valtimo-form-management-upload>\n",
|
|
307
|
-
encapsulation: ViewEncapsulation.None,
|
|
308
|
-
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.btn.formcomponent.gu-mirror,.formbuilder .btn.formcomponent.drag-copy{background-color:silver;border-color:silver;color:#fff;font-weight:400}.btn.formcomponent.gu-mirror:active,.btn.formcomponent.gu-mirror:hover,.formbuilder .btn.formcomponent.drag-copy:active,.formbuilder .btn.formcomponent.drag-copy:hover{box-shadow:none}.btn.formcomponent.gu-mirror:active,.formbuilder .btn.formcomponent.drag-copy:active{background-color:silver;border-color:silver}.formbuilder-header{border:1px solid #dee2e6;border-bottom:0;font-size:18px;height:80px;padding-left:18px;padding-right:18px}.formbuilder-header .formbuilder-title{margin-bottom:7px;margin-top:21px}.formbuilder-header .formbuilder-subtitle{margin-bottom:12px;margin-top:0}.formbuilder{background:#fff;border:1px solid #dee2e6;margin-left:0!important;margin-right:0!important;padding:1rem}.formbuilder .form-builder-panel .builder-group-button[aria-expanded=\"\"],.formbuilder .form-builder-panel .builder-group-button[aria-expanded=false]{color:#a9a9a9}.formbuilder .form-builder-panel .builder-group-button[aria-expanded=true]{color:#000}.formbuilder .drag-and-drop-alert{display:none}.formbuilder .formarea{background-color:#fff;border:1px solid silver;padding:10px}.increase-size{font-size:1rem}"]
|
|
309
|
-
},] }
|
|
310
|
-
];
|
|
311
|
-
FormManagementEditComponent.ctorParameters = () => [
|
|
312
|
-
{ type: FormManagementService },
|
|
313
|
-
{ type: AlertService },
|
|
314
|
-
{ type: ActivatedRoute },
|
|
315
|
-
{ type: Router }
|
|
174
|
+
/*
|
|
175
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
176
|
+
*
|
|
177
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
178
|
+
* you may not use this file except in compliance with the License.
|
|
179
|
+
* You may obtain a copy of the License at
|
|
180
|
+
*
|
|
181
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
182
|
+
*
|
|
183
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
184
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
185
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
186
|
+
* See the License for the specific language governing permissions and
|
|
187
|
+
* limitations under the License.
|
|
188
|
+
*/
|
|
189
|
+
class FormManagementEditComponent {
|
|
190
|
+
constructor(formManagementService, alertService, route, router) {
|
|
191
|
+
this.formManagementService = formManagementService;
|
|
192
|
+
this.alertService = alertService;
|
|
193
|
+
this.route = route;
|
|
194
|
+
this.router = router;
|
|
195
|
+
this.showModal$ = new BehaviorSubject(false);
|
|
196
|
+
this.reloading$ = new BehaviorSubject(false);
|
|
197
|
+
this.modifiedFormDefinition = null;
|
|
198
|
+
this.formDefinition = null;
|
|
199
|
+
this.alertSub = Subscription.EMPTY;
|
|
200
|
+
this.formDefinitionId = null;
|
|
201
|
+
}
|
|
202
|
+
ngOnInit() {
|
|
203
|
+
this.loadFormDefinition();
|
|
204
|
+
this.checkToOpenUploadModal();
|
|
205
|
+
}
|
|
206
|
+
ngOnDestroy() {
|
|
207
|
+
this.alertSub.unsubscribe();
|
|
208
|
+
}
|
|
209
|
+
loadFormDefinition() {
|
|
210
|
+
this.formDefinitionId = this.route.snapshot.paramMap.get('id');
|
|
211
|
+
this.formManagementService.getFormDefinition(this.formDefinitionId).subscribe(formDefinition => {
|
|
212
|
+
this.formDefinition = formDefinition;
|
|
213
|
+
}, () => {
|
|
214
|
+
this.alertService.error('Error retrieving Form Definition');
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
modifyFormDefinition() {
|
|
218
|
+
const form = JSON.stringify(this.modifiedFormDefinition != null
|
|
219
|
+
? this.modifiedFormDefinition
|
|
220
|
+
: this.formDefinition.formDefinition);
|
|
221
|
+
const request = {
|
|
222
|
+
id: this.formDefinition.id,
|
|
223
|
+
name: this.formDefinition.name,
|
|
224
|
+
formDefinition: form,
|
|
225
|
+
};
|
|
226
|
+
this.formManagementService.modifyFormDefinition(request).subscribe(() => {
|
|
227
|
+
this.router.navigate(['/form-management']);
|
|
228
|
+
this.alertService.success('Form deployed');
|
|
229
|
+
}, err => {
|
|
230
|
+
this.alertService.error('Error deploying Form');
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
formBuilderChanged(event) {
|
|
234
|
+
this.modifiedFormDefinition = event.form;
|
|
235
|
+
}
|
|
236
|
+
delete() {
|
|
237
|
+
if (!this.alertSub.closed) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const mssg = 'Delete Form?';
|
|
241
|
+
const confirmations = [
|
|
242
|
+
{
|
|
243
|
+
label: 'Cancel',
|
|
244
|
+
class: 'btn btn-default',
|
|
245
|
+
value: false,
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
label: 'Delete',
|
|
249
|
+
class: 'btn btn-primary',
|
|
250
|
+
value: true,
|
|
251
|
+
},
|
|
252
|
+
];
|
|
253
|
+
this.alertService.notification(mssg, confirmations);
|
|
254
|
+
this.alertSub = this.alertService
|
|
255
|
+
.getAlertConfirmChangeEmitter()
|
|
256
|
+
.pipe(first())
|
|
257
|
+
.subscribe(alert => {
|
|
258
|
+
if (alert.confirm === true) {
|
|
259
|
+
this.deleteFormDefinition();
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
deleteFormDefinition() {
|
|
264
|
+
this.formManagementService.deleteFormDefinition(this.formDefinition.id).subscribe(() => {
|
|
265
|
+
this.router.navigate(['/form-management']);
|
|
266
|
+
this.alertService.success('Form deleted');
|
|
267
|
+
}, err => {
|
|
268
|
+
this.alertService.error('Error deleting Form');
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
downloadFormDefinition() {
|
|
272
|
+
const file = new Blob([JSON.stringify(this.formDefinition)], { type: 'text/json' });
|
|
273
|
+
const link = document.createElement('a');
|
|
274
|
+
link.download = `form_${this.formDefinition.name}.json`;
|
|
275
|
+
link.href = window.URL.createObjectURL(file);
|
|
276
|
+
link.click();
|
|
277
|
+
window.URL.revokeObjectURL(link.href);
|
|
278
|
+
link.remove();
|
|
279
|
+
}
|
|
280
|
+
showModal() {
|
|
281
|
+
this.showModal$.next(true);
|
|
282
|
+
}
|
|
283
|
+
setFormDefinition(formDefinition) {
|
|
284
|
+
var _a;
|
|
285
|
+
this.reloading$.next(true);
|
|
286
|
+
const definition = JSON.parse(formDefinition);
|
|
287
|
+
const components = (_a = definition === null || definition === void 0 ? void 0 : definition.formDefinition) === null || _a === void 0 ? void 0 : _a.components;
|
|
288
|
+
const currentDefinition = this.modifiedFormDefinition || this.formDefinition.formDefinition;
|
|
289
|
+
const newDefinition = Object.assign(Object.assign({}, currentDefinition), (components && { components }));
|
|
290
|
+
this.modifiedFormDefinition = newDefinition;
|
|
291
|
+
this.formDefinition.formDefinition = newDefinition;
|
|
292
|
+
this.reloading$.next(false);
|
|
293
|
+
}
|
|
294
|
+
checkToOpenUploadModal() {
|
|
295
|
+
this.route.queryParams.pipe(take(1)).subscribe(params => {
|
|
296
|
+
if ((params === null || params === void 0 ? void 0 : params.upload) === 'true') {
|
|
297
|
+
this.showModal();
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
FormManagementEditComponent.decorators = [
|
|
303
|
+
{ type: Component, args: [{
|
|
304
|
+
selector: 'valtimo-form-management-edit',
|
|
305
|
+
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content pt-0\">\n <div class=\"container-fluid\" *ngIf=\"formDefinition\">\n <div class=\"btn-group mt-m3px mb-3 float-right\">\n <button class=\"btn btn-primary btn-space\" (click)=\"downloadFormDefinition()\">\n <i class=\"fa fa-save\"></i>\n {{ 'Download' | translate }}\n </button>\n <button\n class=\"btn btn-secondary btn-space\"\n (click)=\"showModal()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"icon mdi mdi-upload\"></i> \n {{ 'Upload' | translate }}\n </button>\n <button\n class=\"btn btn-danger btn-space\"\n (click)=\"delete()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"fa fa-trash\"></i> Delete\n </button>\n <button\n class=\"btn btn-success btn-space\"\n (click)=\"modifyFormDefinition()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"fa fa-upload\"></i> Deploy\n </button>\n </div>\n <div class=\"clearfix\"></div>\n <div class=\"bg-light formbuilder-header overflow-auto\">\n <h3 class=\"formbuilder-title\">\n {{ formDefinition.name }}\n <div *ngIf=\"formDefinition.readOnly\" class=\"pull-right\">\n <span class=\"badge badge-pill badge-info increase-size\">Read-only</span>\n </div>\n </h3>\n </div>\n <ng-container *ngIf=\"!(reloading$ | async)\">\n <valtimo-form-io-builder\n [form]=\"formDefinition.formDefinition\"\n (change)=\"formBuilderChanged($event)\"\n ></valtimo-form-io-builder>\n </ng-container>\n </div>\n</div>\n\n<valtimo-form-management-upload\n [show$]=\"showModal$\"\n (definitionUploaded)=\"setFormDefinition($event)\"\n></valtimo-form-management-upload>\n",
|
|
306
|
+
encapsulation: ViewEncapsulation.None,
|
|
307
|
+
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.btn.formcomponent.gu-mirror,.formbuilder .btn.formcomponent.drag-copy{background-color:silver;border-color:silver;color:#fff;font-weight:400}.btn.formcomponent.gu-mirror:active,.btn.formcomponent.gu-mirror:hover,.formbuilder .btn.formcomponent.drag-copy:active,.formbuilder .btn.formcomponent.drag-copy:hover{box-shadow:none}.btn.formcomponent.gu-mirror:active,.formbuilder .btn.formcomponent.drag-copy:active{background-color:silver;border-color:silver}.formbuilder-header{border:1px solid #dee2e6;border-bottom:0;font-size:18px;height:80px;padding-left:18px;padding-right:18px}.formbuilder-header .formbuilder-title{margin-bottom:7px;margin-top:21px}.formbuilder-header .formbuilder-subtitle{margin-bottom:12px;margin-top:0}.formbuilder{background:#fff;border:1px solid #dee2e6;margin-left:0!important;margin-right:0!important;padding:1rem}.formbuilder .form-builder-panel .builder-group-button[aria-expanded=\"\"],.formbuilder .form-builder-panel .builder-group-button[aria-expanded=false]{color:#a9a9a9}.formbuilder .form-builder-panel .builder-group-button[aria-expanded=true]{color:#000}.formbuilder .drag-and-drop-alert{display:none}.formbuilder .formarea{background-color:#fff;border:1px solid silver;padding:10px}.increase-size{font-size:1rem}"]
|
|
308
|
+
},] }
|
|
309
|
+
];
|
|
310
|
+
FormManagementEditComponent.ctorParameters = () => [
|
|
311
|
+
{ type: FormManagementService },
|
|
312
|
+
{ type: AlertService },
|
|
313
|
+
{ type: ActivatedRoute },
|
|
314
|
+
{ type: Router }
|
|
316
315
|
];
|
|
317
316
|
|
|
318
|
-
/*
|
|
319
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
320
|
-
*
|
|
321
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
322
|
-
* you may not use this file except in compliance with the License.
|
|
323
|
-
* You may obtain a copy of the License at
|
|
324
|
-
*
|
|
325
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
326
|
-
*
|
|
327
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
328
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
329
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
330
|
-
* See the License for the specific language governing permissions and
|
|
331
|
-
* limitations under the License.
|
|
332
|
-
*/
|
|
333
|
-
const ɵ0 = { title: 'Form management', roles: [ROLE_ADMIN] }, ɵ1 = { title: 'Create new Form', roles: [ROLE_ADMIN] }, ɵ2 = { title: 'Form Builder', roles: [ROLE_ADMIN] };
|
|
334
|
-
const routes = [
|
|
335
|
-
{
|
|
336
|
-
path: 'form-management',
|
|
337
|
-
component: FormManagementComponent,
|
|
338
|
-
canActivate: [AuthGuardService],
|
|
339
|
-
data: ɵ0,
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
path: 'form-management/create',
|
|
343
|
-
component: FormManagementCreateComponent,
|
|
344
|
-
canActivate: [AuthGuardService],
|
|
345
|
-
data: ɵ1,
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
path: 'form-management/edit/:id',
|
|
349
|
-
component: FormManagementEditComponent,
|
|
350
|
-
canActivate: [AuthGuardService],
|
|
351
|
-
data: ɵ2,
|
|
352
|
-
},
|
|
353
|
-
];
|
|
354
|
-
class FormManagementRoutingModule {
|
|
355
|
-
}
|
|
356
|
-
FormManagementRoutingModule.decorators = [
|
|
357
|
-
{ type: NgModule, args: [{
|
|
358
|
-
imports: [RouterModule.forChild(routes)],
|
|
359
|
-
exports: [RouterModule],
|
|
360
|
-
declarations: [],
|
|
361
|
-
},] }
|
|
317
|
+
/*
|
|
318
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
319
|
+
*
|
|
320
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
321
|
+
* you may not use this file except in compliance with the License.
|
|
322
|
+
* You may obtain a copy of the License at
|
|
323
|
+
*
|
|
324
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
325
|
+
*
|
|
326
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
327
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
328
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
329
|
+
* See the License for the specific language governing permissions and
|
|
330
|
+
* limitations under the License.
|
|
331
|
+
*/
|
|
332
|
+
const ɵ0 = { title: 'Form management', roles: [ROLE_ADMIN] }, ɵ1 = { title: 'Create new Form', roles: [ROLE_ADMIN] }, ɵ2 = { title: 'Form Builder', roles: [ROLE_ADMIN] };
|
|
333
|
+
const routes = [
|
|
334
|
+
{
|
|
335
|
+
path: 'form-management',
|
|
336
|
+
component: FormManagementComponent,
|
|
337
|
+
canActivate: [AuthGuardService],
|
|
338
|
+
data: ɵ0,
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
path: 'form-management/create',
|
|
342
|
+
component: FormManagementCreateComponent,
|
|
343
|
+
canActivate: [AuthGuardService],
|
|
344
|
+
data: ɵ1,
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
path: 'form-management/edit/:id',
|
|
348
|
+
component: FormManagementEditComponent,
|
|
349
|
+
canActivate: [AuthGuardService],
|
|
350
|
+
data: ɵ2,
|
|
351
|
+
},
|
|
352
|
+
];
|
|
353
|
+
class FormManagementRoutingModule {
|
|
354
|
+
}
|
|
355
|
+
FormManagementRoutingModule.decorators = [
|
|
356
|
+
{ type: NgModule, args: [{
|
|
357
|
+
imports: [RouterModule.forChild(routes)],
|
|
358
|
+
exports: [RouterModule],
|
|
359
|
+
declarations: [],
|
|
360
|
+
},] }
|
|
362
361
|
];
|
|
363
362
|
|
|
364
|
-
/*
|
|
365
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
366
|
-
*
|
|
367
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
368
|
-
* you may not use this file except in compliance with the License.
|
|
369
|
-
* You may obtain a copy of the License at
|
|
370
|
-
*
|
|
371
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
372
|
-
*
|
|
373
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
374
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
375
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
376
|
-
* See the License for the specific language governing permissions and
|
|
377
|
-
* limitations under the License.
|
|
378
|
-
*/
|
|
379
|
-
class FormManagementListComponent {
|
|
380
|
-
constructor(formManagementService, router) {
|
|
381
|
-
this.formManagementService = formManagementService;
|
|
382
|
-
this.router = router;
|
|
383
|
-
this.formDefinitions = [];
|
|
384
|
-
this.formDefinitionFields = [
|
|
385
|
-
{ key: 'name', label: 'Name' },
|
|
386
|
-
{ key: 'readOnly', label: 'Read-only' },
|
|
387
|
-
];
|
|
388
|
-
this.pagination = {
|
|
389
|
-
collectionSize: 0,
|
|
390
|
-
page: 1,
|
|
391
|
-
size: 10,
|
|
392
|
-
maxPaginationItemSize: 5,
|
|
393
|
-
};
|
|
394
|
-
this.pageParam = 0;
|
|
395
|
-
}
|
|
396
|
-
paginationClicked(page) {
|
|
397
|
-
this.pageParam = page - 1;
|
|
398
|
-
this.loadFormDefinitions();
|
|
399
|
-
}
|
|
400
|
-
ngOnInit() { }
|
|
401
|
-
paginationSet() {
|
|
402
|
-
this.loadFormDefinitions();
|
|
403
|
-
}
|
|
404
|
-
loadFormDefinitions(searchTerm) {
|
|
405
|
-
const params = { page: this.pageParam, size: this.pagination.size };
|
|
406
|
-
if (searchTerm) {
|
|
407
|
-
params['searchTerm'] = searchTerm;
|
|
408
|
-
}
|
|
409
|
-
this.formManagementService.queryFormDefinitions(params).subscribe(results => {
|
|
410
|
-
this.pagination.collectionSize = results.body.totalElements;
|
|
411
|
-
this.formDefinitions = results.body.content;
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
editFormDefinition(formDefinition) {
|
|
415
|
-
this.router.navigate(['/form-management/edit', formDefinition.id]);
|
|
416
|
-
}
|
|
417
|
-
searchTermEntered(searchTerm) {
|
|
418
|
-
this.loadFormDefinitions(searchTerm);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
FormManagementListComponent.decorators = [
|
|
422
|
-
{ type: Component, args: [{
|
|
423
|
-
selector: 'valtimo-form-management-list',
|
|
424
|
-
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<valtimo-list\n [items]=\"formDefinitions\"\n [fields]=\"formDefinitionFields\"\n [viewMode]=\"true\"\n [isSearchable]=\"true\"\n [pagination]=\"pagination\"\n paginationIdentifier=\"formManagementList\"\n (paginationClicked)=\"paginationClicked($event)\"\n (paginationSet)=\"paginationSet()\"\n (rowClicked)=\"editFormDefinition($event)\"\n [header]=\"true\"\n (search)=\"searchTermEntered($event)\"\n>\n <div header>\n <h3 class=\"list-header-title\">{{ 'Forms' | translate }}</h3>\n <h5 class=\"list-header-description\">{{ 'Overview of all Forms' | translate }}</h5>\n </div>\n</valtimo-list>\n",
|
|
425
|
-
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
|
|
426
|
-
},] }
|
|
427
|
-
];
|
|
428
|
-
FormManagementListComponent.ctorParameters = () => [
|
|
429
|
-
{ type: FormManagementService },
|
|
430
|
-
{ type: Router }
|
|
363
|
+
/*
|
|
364
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
365
|
+
*
|
|
366
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
367
|
+
* you may not use this file except in compliance with the License.
|
|
368
|
+
* You may obtain a copy of the License at
|
|
369
|
+
*
|
|
370
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
371
|
+
*
|
|
372
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
373
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
374
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
375
|
+
* See the License for the specific language governing permissions and
|
|
376
|
+
* limitations under the License.
|
|
377
|
+
*/
|
|
378
|
+
class FormManagementListComponent {
|
|
379
|
+
constructor(formManagementService, router) {
|
|
380
|
+
this.formManagementService = formManagementService;
|
|
381
|
+
this.router = router;
|
|
382
|
+
this.formDefinitions = [];
|
|
383
|
+
this.formDefinitionFields = [
|
|
384
|
+
{ key: 'name', label: 'Name' },
|
|
385
|
+
{ key: 'readOnly', label: 'Read-only' },
|
|
386
|
+
];
|
|
387
|
+
this.pagination = {
|
|
388
|
+
collectionSize: 0,
|
|
389
|
+
page: 1,
|
|
390
|
+
size: 10,
|
|
391
|
+
maxPaginationItemSize: 5,
|
|
392
|
+
};
|
|
393
|
+
this.pageParam = 0;
|
|
394
|
+
}
|
|
395
|
+
paginationClicked(page) {
|
|
396
|
+
this.pageParam = page - 1;
|
|
397
|
+
this.loadFormDefinitions();
|
|
398
|
+
}
|
|
399
|
+
ngOnInit() { }
|
|
400
|
+
paginationSet() {
|
|
401
|
+
this.loadFormDefinitions();
|
|
402
|
+
}
|
|
403
|
+
loadFormDefinitions(searchTerm) {
|
|
404
|
+
const params = { page: this.pageParam, size: this.pagination.size };
|
|
405
|
+
if (searchTerm) {
|
|
406
|
+
params['searchTerm'] = searchTerm;
|
|
407
|
+
}
|
|
408
|
+
this.formManagementService.queryFormDefinitions(params).subscribe(results => {
|
|
409
|
+
this.pagination.collectionSize = results.body.totalElements;
|
|
410
|
+
this.formDefinitions = results.body.content;
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
editFormDefinition(formDefinition) {
|
|
414
|
+
this.router.navigate(['/form-management/edit', formDefinition.id]);
|
|
415
|
+
}
|
|
416
|
+
searchTermEntered(searchTerm) {
|
|
417
|
+
this.loadFormDefinitions(searchTerm);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
FormManagementListComponent.decorators = [
|
|
421
|
+
{ type: Component, args: [{
|
|
422
|
+
selector: 'valtimo-form-management-list',
|
|
423
|
+
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<valtimo-list\n [items]=\"formDefinitions\"\n [fields]=\"formDefinitionFields\"\n [viewMode]=\"true\"\n [isSearchable]=\"true\"\n [pagination]=\"pagination\"\n paginationIdentifier=\"formManagementList\"\n (paginationClicked)=\"paginationClicked($event)\"\n (paginationSet)=\"paginationSet()\"\n (rowClicked)=\"editFormDefinition($event)\"\n [header]=\"true\"\n (search)=\"searchTermEntered($event)\"\n>\n <div header>\n <h3 class=\"list-header-title\">{{ 'Forms' | translate }}</h3>\n <h5 class=\"list-header-description\">{{ 'Overview of all Forms' | translate }}</h5>\n </div>\n</valtimo-list>\n",
|
|
424
|
+
styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"]
|
|
425
|
+
},] }
|
|
426
|
+
];
|
|
427
|
+
FormManagementListComponent.ctorParameters = () => [
|
|
428
|
+
{ type: FormManagementService },
|
|
429
|
+
{ type: Router }
|
|
431
430
|
];
|
|
432
431
|
|
|
433
|
-
/*
|
|
434
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
435
|
-
*
|
|
436
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
437
|
-
* you may not use this file except in compliance with the License.
|
|
438
|
-
* You may obtain a copy of the License at
|
|
439
|
-
*
|
|
440
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
441
|
-
*
|
|
442
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
443
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
444
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
445
|
-
* See the License for the specific language governing permissions and
|
|
446
|
-
* limitations under the License.
|
|
447
|
-
*/
|
|
448
|
-
class FormManagementUploadComponent {
|
|
449
|
-
constructor(documentService, translateService) {
|
|
450
|
-
this.documentService = documentService;
|
|
451
|
-
this.translateService = translateService;
|
|
452
|
-
this.definitionUploaded = new EventEmitter();
|
|
453
|
-
this.clear$ = new Subject();
|
|
454
|
-
this.jsonString$ = new BehaviorSubject('');
|
|
455
|
-
this.error$ = new BehaviorSubject('');
|
|
456
|
-
this.disabled$ = new BehaviorSubject(false);
|
|
457
|
-
this.file$ = new BehaviorSubject(undefined);
|
|
458
|
-
}
|
|
459
|
-
ngAfterViewInit() {
|
|
460
|
-
this.openShowSubscription();
|
|
461
|
-
this.openFileSubscription();
|
|
462
|
-
}
|
|
463
|
-
ngOnDestroy() {
|
|
464
|
-
this.showSubscription.unsubscribe();
|
|
465
|
-
this.fileSubscription.unsubscribe();
|
|
466
|
-
this.closeErrorSubscription();
|
|
467
|
-
}
|
|
468
|
-
setFile(file) {
|
|
469
|
-
this.clearError();
|
|
470
|
-
this.file$.next(file);
|
|
471
|
-
}
|
|
472
|
-
uploadDefinition() {
|
|
473
|
-
this.disable();
|
|
474
|
-
this.jsonString$.pipe(take(1)).subscribe(definition => {
|
|
475
|
-
this.closeErrorSubscription();
|
|
476
|
-
this.clearError();
|
|
477
|
-
this.enable();
|
|
478
|
-
this.hideModal();
|
|
479
|
-
this.definitionUploaded.emit(definition);
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
openErrorSubscription(errorCode) {
|
|
483
|
-
this.closeErrorSubscription();
|
|
484
|
-
this.errorSubscription = this.translateService.stream(errorCode).subscribe(error => {
|
|
485
|
-
this.error$.next(error);
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
closeErrorSubscription() {
|
|
489
|
-
if (this.errorSubscription) {
|
|
490
|
-
this.errorSubscription.unsubscribe();
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
clearError() {
|
|
494
|
-
this.error$.next('');
|
|
495
|
-
}
|
|
496
|
-
openFileSubscription() {
|
|
497
|
-
this.fileSubscription = this.file$.subscribe(file => {
|
|
498
|
-
if (file) {
|
|
499
|
-
const reader = new FileReader();
|
|
500
|
-
reader.onloadend = () => {
|
|
501
|
-
const result = reader.result.toString();
|
|
502
|
-
if (this.stringIsValidJson(result)) {
|
|
503
|
-
this.jsonString$.next(result);
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
reader.readAsText(file);
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
this.clearJsonString();
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
openShowSubscription() {
|
|
514
|
-
this.showSubscription = this.show$.subscribe(show => {
|
|
515
|
-
if (show) {
|
|
516
|
-
this.showModal();
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
this.hideModal();
|
|
520
|
-
}
|
|
521
|
-
this.clearJsonString();
|
|
522
|
-
this.clearError();
|
|
523
|
-
this.clearDropzone();
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
clearJsonString() {
|
|
527
|
-
this.jsonString$.next('');
|
|
528
|
-
}
|
|
529
|
-
clearDropzone() {
|
|
530
|
-
this.clear$.next();
|
|
531
|
-
}
|
|
532
|
-
showModal() {
|
|
533
|
-
this.modal.show();
|
|
534
|
-
}
|
|
535
|
-
hideModal() {
|
|
536
|
-
this.modal.hide();
|
|
537
|
-
}
|
|
538
|
-
stringIsValidJson(string) {
|
|
539
|
-
var _a, _b;
|
|
540
|
-
try {
|
|
541
|
-
// tslint:disable-next-line
|
|
542
|
-
(_b = (_a = JSON.parse(string)) === null || _a === void 0 ? void 0 : _a.formDefinition) === null || _b === void 0 ? void 0 : _b.components;
|
|
543
|
-
}
|
|
544
|
-
catch (e) {
|
|
545
|
-
this.clearDropzone();
|
|
546
|
-
this.openErrorSubscription('dropzone.error.invalidFormDef');
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
return true;
|
|
550
|
-
}
|
|
551
|
-
disable() {
|
|
552
|
-
this.disabled$.next(true);
|
|
553
|
-
}
|
|
554
|
-
enable() {
|
|
555
|
-
this.disabled$.next(false);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
FormManagementUploadComponent.decorators = [
|
|
559
|
-
{ type: Component, args: [{
|
|
560
|
-
selector: 'valtimo-form-management-upload',
|
|
561
|
-
template: "<valtimo-modal\n #uploadFormDefinitionModal\n [title]=\"'uploadFormDefinition' | translate\"\n showFooter=\"true\"\n>\n <div class=\"mt-2\" body>\n <valtimo-dropzone\n [clear$]=\"clear$\"\n (fileSelected)=\"setFile($event)\"\n [disabled]=\"disabled$ | async\"\n [subtitle]=\"'dropzone.formJsonDocDef' | translate\"\n [externalError$]=\"error$\"\n ></valtimo-dropzone>\n </div>\n <div footer>\n <ng-container *ngIf=\"(jsonString$ | async) && !(error$ | async); else pleaseSelect\">\n <button [disabled]=\"disabled$ | async\" class=\"btn btn-primary\" (click)=\"uploadDefinition()\">\n {{ 'Upload' | translate }}\n </button>\n </ng-container>\n </div>\n</valtimo-modal>\n\n<ng-template #pleaseSelect>\n <button class=\"btn btn-primary\" [disabled]=\"true\">\n {{ 'Select a document definition' | translate }}\n </button>\n</ng-template>\n",
|
|
562
|
-
styles: [""]
|
|
563
|
-
},] }
|
|
564
|
-
];
|
|
565
|
-
FormManagementUploadComponent.ctorParameters = () => [
|
|
566
|
-
{ type: DocumentService },
|
|
567
|
-
{ type: TranslateService }
|
|
568
|
-
];
|
|
569
|
-
FormManagementUploadComponent.propDecorators = {
|
|
570
|
-
modal: [{ type: ViewChild, args: ['uploadFormDefinitionModal',] }],
|
|
571
|
-
show$: [{ type: Input }],
|
|
572
|
-
definitionUploaded: [{ type: Output }]
|
|
432
|
+
/*
|
|
433
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
434
|
+
*
|
|
435
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
436
|
+
* you may not use this file except in compliance with the License.
|
|
437
|
+
* You may obtain a copy of the License at
|
|
438
|
+
*
|
|
439
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
440
|
+
*
|
|
441
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
442
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
443
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
444
|
+
* See the License for the specific language governing permissions and
|
|
445
|
+
* limitations under the License.
|
|
446
|
+
*/
|
|
447
|
+
class FormManagementUploadComponent {
|
|
448
|
+
constructor(documentService, translateService) {
|
|
449
|
+
this.documentService = documentService;
|
|
450
|
+
this.translateService = translateService;
|
|
451
|
+
this.definitionUploaded = new EventEmitter();
|
|
452
|
+
this.clear$ = new Subject();
|
|
453
|
+
this.jsonString$ = new BehaviorSubject('');
|
|
454
|
+
this.error$ = new BehaviorSubject('');
|
|
455
|
+
this.disabled$ = new BehaviorSubject(false);
|
|
456
|
+
this.file$ = new BehaviorSubject(undefined);
|
|
457
|
+
}
|
|
458
|
+
ngAfterViewInit() {
|
|
459
|
+
this.openShowSubscription();
|
|
460
|
+
this.openFileSubscription();
|
|
461
|
+
}
|
|
462
|
+
ngOnDestroy() {
|
|
463
|
+
this.showSubscription.unsubscribe();
|
|
464
|
+
this.fileSubscription.unsubscribe();
|
|
465
|
+
this.closeErrorSubscription();
|
|
466
|
+
}
|
|
467
|
+
setFile(file) {
|
|
468
|
+
this.clearError();
|
|
469
|
+
this.file$.next(file);
|
|
470
|
+
}
|
|
471
|
+
uploadDefinition() {
|
|
472
|
+
this.disable();
|
|
473
|
+
this.jsonString$.pipe(take(1)).subscribe(definition => {
|
|
474
|
+
this.closeErrorSubscription();
|
|
475
|
+
this.clearError();
|
|
476
|
+
this.enable();
|
|
477
|
+
this.hideModal();
|
|
478
|
+
this.definitionUploaded.emit(definition);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
openErrorSubscription(errorCode) {
|
|
482
|
+
this.closeErrorSubscription();
|
|
483
|
+
this.errorSubscription = this.translateService.stream(errorCode).subscribe(error => {
|
|
484
|
+
this.error$.next(error);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
closeErrorSubscription() {
|
|
488
|
+
if (this.errorSubscription) {
|
|
489
|
+
this.errorSubscription.unsubscribe();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
clearError() {
|
|
493
|
+
this.error$.next('');
|
|
494
|
+
}
|
|
495
|
+
openFileSubscription() {
|
|
496
|
+
this.fileSubscription = this.file$.subscribe(file => {
|
|
497
|
+
if (file) {
|
|
498
|
+
const reader = new FileReader();
|
|
499
|
+
reader.onloadend = () => {
|
|
500
|
+
const result = reader.result.toString();
|
|
501
|
+
if (this.stringIsValidJson(result)) {
|
|
502
|
+
this.jsonString$.next(result);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
reader.readAsText(file);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
this.clearJsonString();
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
openShowSubscription() {
|
|
513
|
+
this.showSubscription = this.show$.subscribe(show => {
|
|
514
|
+
if (show) {
|
|
515
|
+
this.showModal();
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
this.hideModal();
|
|
519
|
+
}
|
|
520
|
+
this.clearJsonString();
|
|
521
|
+
this.clearError();
|
|
522
|
+
this.clearDropzone();
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
clearJsonString() {
|
|
526
|
+
this.jsonString$.next('');
|
|
527
|
+
}
|
|
528
|
+
clearDropzone() {
|
|
529
|
+
this.clear$.next();
|
|
530
|
+
}
|
|
531
|
+
showModal() {
|
|
532
|
+
this.modal.show();
|
|
533
|
+
}
|
|
534
|
+
hideModal() {
|
|
535
|
+
this.modal.hide();
|
|
536
|
+
}
|
|
537
|
+
stringIsValidJson(string) {
|
|
538
|
+
var _a, _b;
|
|
539
|
+
try {
|
|
540
|
+
// tslint:disable-next-line
|
|
541
|
+
(_b = (_a = JSON.parse(string)) === null || _a === void 0 ? void 0 : _a.formDefinition) === null || _b === void 0 ? void 0 : _b.components;
|
|
542
|
+
}
|
|
543
|
+
catch (e) {
|
|
544
|
+
this.clearDropzone();
|
|
545
|
+
this.openErrorSubscription('dropzone.error.invalidFormDef');
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
disable() {
|
|
551
|
+
this.disabled$.next(true);
|
|
552
|
+
}
|
|
553
|
+
enable() {
|
|
554
|
+
this.disabled$.next(false);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
FormManagementUploadComponent.decorators = [
|
|
558
|
+
{ type: Component, args: [{
|
|
559
|
+
selector: 'valtimo-form-management-upload',
|
|
560
|
+
template: "<valtimo-modal\n #uploadFormDefinitionModal\n [title]=\"'uploadFormDefinition' | translate\"\n showFooter=\"true\"\n>\n <div class=\"mt-2\" body>\n <valtimo-dropzone\n [clear$]=\"clear$\"\n (fileSelected)=\"setFile($event)\"\n [disabled]=\"disabled$ | async\"\n [subtitle]=\"'dropzone.formJsonDocDef' | translate\"\n [externalError$]=\"error$\"\n ></valtimo-dropzone>\n </div>\n <div footer>\n <ng-container *ngIf=\"(jsonString$ | async) && !(error$ | async); else pleaseSelect\">\n <button [disabled]=\"disabled$ | async\" class=\"btn btn-primary\" (click)=\"uploadDefinition()\">\n {{ 'Upload' | translate }}\n </button>\n </ng-container>\n </div>\n</valtimo-modal>\n\n<ng-template #pleaseSelect>\n <button class=\"btn btn-primary\" [disabled]=\"true\">\n {{ 'Select a document definition' | translate }}\n </button>\n</ng-template>\n",
|
|
561
|
+
styles: [""]
|
|
562
|
+
},] }
|
|
563
|
+
];
|
|
564
|
+
FormManagementUploadComponent.ctorParameters = () => [
|
|
565
|
+
{ type: DocumentService },
|
|
566
|
+
{ type: TranslateService }
|
|
567
|
+
];
|
|
568
|
+
FormManagementUploadComponent.propDecorators = {
|
|
569
|
+
modal: [{ type: ViewChild, args: ['uploadFormDefinitionModal',] }],
|
|
570
|
+
show$: [{ type: Input }],
|
|
571
|
+
definitionUploaded: [{ type: Output }]
|
|
573
572
|
};
|
|
574
573
|
|
|
575
|
-
/*
|
|
576
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
577
|
-
*
|
|
578
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
579
|
-
* you may not use this file except in compliance with the License.
|
|
580
|
-
* You may obtain a copy of the License at
|
|
581
|
-
*
|
|
582
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
583
|
-
*
|
|
584
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
585
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
586
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
587
|
-
* See the License for the specific language governing permissions and
|
|
588
|
-
* limitations under the License.
|
|
589
|
-
*/
|
|
590
|
-
class FormManagementModule {
|
|
591
|
-
}
|
|
592
|
-
FormManagementModule.decorators = [
|
|
593
|
-
{ type: NgModule, args: [{
|
|
594
|
-
declarations: [
|
|
595
|
-
FormManagementComponent,
|
|
596
|
-
FormManagementCreateComponent,
|
|
597
|
-
FormManagementListComponent,
|
|
598
|
-
FormManagementEditComponent,
|
|
599
|
-
FormManagementUploadComponent,
|
|
600
|
-
],
|
|
601
|
-
imports: [
|
|
602
|
-
FormManagementRoutingModule,
|
|
603
|
-
FormIoModule,
|
|
604
|
-
CommonModule,
|
|
605
|
-
ReactiveFormsModule,
|
|
606
|
-
FormsModule,
|
|
607
|
-
WidgetModule,
|
|
608
|
-
ListModule,
|
|
609
|
-
TranslateModule,
|
|
610
|
-
NgbTooltipModule,
|
|
611
|
-
DropzoneModule,
|
|
612
|
-
ModalModule,
|
|
613
|
-
],
|
|
614
|
-
exports: [FormManagementComponent],
|
|
615
|
-
},] }
|
|
574
|
+
/*
|
|
575
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
576
|
+
*
|
|
577
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
578
|
+
* you may not use this file except in compliance with the License.
|
|
579
|
+
* You may obtain a copy of the License at
|
|
580
|
+
*
|
|
581
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
582
|
+
*
|
|
583
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
584
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
585
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
586
|
+
* See the License for the specific language governing permissions and
|
|
587
|
+
* limitations under the License.
|
|
588
|
+
*/
|
|
589
|
+
class FormManagementModule {
|
|
590
|
+
}
|
|
591
|
+
FormManagementModule.decorators = [
|
|
592
|
+
{ type: NgModule, args: [{
|
|
593
|
+
declarations: [
|
|
594
|
+
FormManagementComponent,
|
|
595
|
+
FormManagementCreateComponent,
|
|
596
|
+
FormManagementListComponent,
|
|
597
|
+
FormManagementEditComponent,
|
|
598
|
+
FormManagementUploadComponent,
|
|
599
|
+
],
|
|
600
|
+
imports: [
|
|
601
|
+
FormManagementRoutingModule,
|
|
602
|
+
FormIoModule,
|
|
603
|
+
CommonModule,
|
|
604
|
+
ReactiveFormsModule,
|
|
605
|
+
FormsModule,
|
|
606
|
+
WidgetModule,
|
|
607
|
+
ListModule,
|
|
608
|
+
TranslateModule,
|
|
609
|
+
NgbTooltipModule,
|
|
610
|
+
DropzoneModule,
|
|
611
|
+
ModalModule,
|
|
612
|
+
],
|
|
613
|
+
exports: [FormManagementComponent],
|
|
614
|
+
},] }
|
|
616
615
|
];
|
|
617
616
|
|
|
618
|
-
/*
|
|
619
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
620
|
-
*
|
|
621
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
622
|
-
* you may not use this file except in compliance with the License.
|
|
623
|
-
* You may obtain a copy of the License at
|
|
624
|
-
*
|
|
625
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
626
|
-
*
|
|
627
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
628
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
629
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
630
|
-
* See the License for the specific language governing permissions and
|
|
631
|
-
* limitations under the License.
|
|
617
|
+
/*
|
|
618
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
619
|
+
*
|
|
620
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
621
|
+
* you may not use this file except in compliance with the License.
|
|
622
|
+
* You may obtain a copy of the License at
|
|
623
|
+
*
|
|
624
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
625
|
+
*
|
|
626
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
627
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
628
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
629
|
+
* See the License for the specific language governing permissions and
|
|
630
|
+
* limitations under the License.
|
|
631
|
+
*/
|
|
632
|
+
function compareFormDefinitions(fd1, fd2) {
|
|
633
|
+
if (fd1 === null && fd2 === null) {
|
|
634
|
+
return true;
|
|
635
|
+
}
|
|
636
|
+
if (fd1 === null || fd2 === null) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
return fd1.id === fd2.id;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/*
|
|
643
|
+
*
|
|
644
|
+
* * Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
645
|
+
* *
|
|
646
|
+
* * Licensed under EUPL, Version 1.2 (the "License");
|
|
647
|
+
* * you may not use this file except in compliance with the License.
|
|
648
|
+
* * You may obtain a copy of the License at
|
|
649
|
+
* *
|
|
650
|
+
* * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
651
|
+
* *
|
|
652
|
+
* * Unless required by applicable law or agreed to in writing, software
|
|
653
|
+
* * distributed under the License is distributed on an "AS IS" basis,
|
|
654
|
+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
655
|
+
* * See the License for the specific language governing permissions and
|
|
656
|
+
* * limitations under the License.
|
|
657
|
+
*
|
|
658
|
+
*/
|
|
659
|
+
|
|
660
|
+
/*
|
|
661
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
662
|
+
*
|
|
663
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
664
|
+
* you may not use this file except in compliance with the License.
|
|
665
|
+
* You may obtain a copy of the License at
|
|
666
|
+
*
|
|
667
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
668
|
+
*
|
|
669
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
670
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
671
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
672
|
+
* See the License for the specific language governing permissions and
|
|
673
|
+
* limitations under the License.
|
|
632
674
|
*/
|
|
633
675
|
|
|
634
|
-
/**
|
|
635
|
-
* Generated bundle index. Do not edit.
|
|
676
|
+
/**
|
|
677
|
+
* Generated bundle index. Do not edit.
|
|
636
678
|
*/
|
|
637
679
|
|
|
638
|
-
export { FormManagementComponent, FormManagementModule, FormManagementService, FormManagementCreateComponent as ɵa, FormManagementListComponent as ɵb, FormManagementEditComponent as ɵc, FormManagementUploadComponent as ɵd, FormManagementRoutingModule as ɵe };
|
|
680
|
+
export { FormManagementComponent, FormManagementModule, FormManagementService, compareFormDefinitions, FormManagementCreateComponent as ɵa, FormManagementListComponent as ɵb, FormManagementEditComponent as ɵc, FormManagementUploadComponent as ɵd, FormManagementRoutingModule as ɵe };
|
|
639
681
|
//# sourceMappingURL=valtimo-form-management.js.map
|