@valtimo/form-management 4.21.0 → 5.0.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.
Files changed (60) hide show
  1. package/esm2020/lib/form-management-create/form-management-create.component.mjs +83 -0
  2. package/esm2020/lib/form-management-edit/form-management-edit.component.mjs +144 -0
  3. package/esm2020/lib/form-management-list/form-management-list.component.mjs +70 -0
  4. package/esm2020/lib/form-management-routing.module.mjs +58 -0
  5. package/esm2020/lib/form-management-upload/form-management-upload.component.mjs +146 -0
  6. package/esm2020/lib/form-management.component.mjs +32 -0
  7. package/esm2020/lib/form-management.module.mjs +86 -0
  8. package/esm2020/lib/form-management.service.mjs +53 -0
  9. package/esm2020/lib/models/form-definition.model.mjs +25 -0
  10. package/esm2020/lib/models/index.mjs +19 -0
  11. package/esm2020/public-api.mjs +23 -0
  12. package/esm2020/valtimo-form-management.mjs +5 -0
  13. package/fesm2015/valtimo-form-management.mjs +693 -0
  14. package/fesm2015/valtimo-form-management.mjs.map +1 -0
  15. package/fesm2020/valtimo-form-management.mjs +691 -0
  16. package/fesm2020/valtimo-form-management.mjs.map +1 -0
  17. package/lib/form-management-create/form-management-create.component.d.ts +4 -0
  18. package/lib/form-management-create/form-management-create.component.d.ts.map +1 -0
  19. package/lib/form-management-edit/form-management-edit.component.d.ts +4 -0
  20. package/lib/form-management-edit/form-management-edit.component.d.ts.map +1 -0
  21. package/lib/form-management-list/form-management-list.component.d.ts +4 -0
  22. package/lib/form-management-list/form-management-list.component.d.ts.map +1 -0
  23. package/lib/form-management-routing.module.d.ts +6 -0
  24. package/lib/form-management-routing.module.d.ts.map +1 -0
  25. package/lib/form-management-upload/form-management-upload.component.d.ts +4 -0
  26. package/lib/form-management-upload/form-management-upload.component.d.ts.map +1 -0
  27. package/lib/form-management.component.d.ts +4 -0
  28. package/lib/form-management.component.d.ts.map +1 -0
  29. package/lib/form-management.module.d.ts +16 -0
  30. package/lib/form-management.module.d.ts.map +1 -0
  31. package/lib/form-management.service.d.ts +4 -0
  32. package/lib/form-management.service.d.ts.map +1 -0
  33. package/lib/models/form-definition.model.d.ts +1 -0
  34. package/lib/models/form-definition.model.d.ts.map +1 -0
  35. package/lib/models/index.d.ts +1 -0
  36. package/lib/models/index.d.ts.map +1 -0
  37. package/package.json +22 -10
  38. package/public-api.d.ts +1 -0
  39. package/public-api.d.ts.map +1 -0
  40. package/valtimo-form-management.d.ts +2 -5
  41. package/valtimo-form-management.d.ts.map +1 -0
  42. package/bundles/valtimo-form-management.umd.js +0 -1017
  43. package/bundles/valtimo-form-management.umd.js.map +0 -1
  44. package/bundles/valtimo-form-management.umd.min.js +0 -2
  45. package/bundles/valtimo-form-management.umd.min.js.map +0 -1
  46. package/esm2015/lib/form-management-create/form-management-create.component.js +0 -87
  47. package/esm2015/lib/form-management-edit/form-management-edit.component.js +0 -149
  48. package/esm2015/lib/form-management-list/form-management-list.component.js +0 -72
  49. package/esm2015/lib/form-management-routing.module.js +0 -54
  50. package/esm2015/lib/form-management-upload/form-management-upload.component.js +0 -148
  51. package/esm2015/lib/form-management.component.js +0 -29
  52. package/esm2015/lib/form-management.module.js +0 -55
  53. package/esm2015/lib/form-management.service.js +0 -57
  54. package/esm2015/lib/models/form-definition.model.js +0 -25
  55. package/esm2015/lib/models/index.js +0 -19
  56. package/esm2015/public-api.js +0 -23
  57. package/esm2015/valtimo-form-management.js +0 -10
  58. package/fesm2015/valtimo-form-management.js +0 -681
  59. package/fesm2015/valtimo-form-management.js.map +0 -1
  60. package/valtimo-form-management.metadata.json +0 -1
@@ -1,681 +0,0 @@
1
- import { ɵɵdefineInjectable, ɵɵinject, Injectable, Component, ViewEncapsulation, NgModule, EventEmitter, ViewChild, Input, Output } from '@angular/core';
2
- import { HttpClient } from '@angular/common/http';
3
- import { ConfigService, ROLE_ADMIN } from '@valtimo/config';
4
- import { Router, ActivatedRoute, RouterModule } from '@angular/router';
5
- import { AuthGuardService } from '@valtimo/security';
6
- import { FormControl, Validators, FormBuilder, ReactiveFormsModule, FormsModule } from '@angular/forms';
7
- import { AlertService, FormIoModule, WidgetModule, ListModule, DropzoneModule, ModalModule } from '@valtimo/components';
8
- import { combineLatest, BehaviorSubject, Subscription, Subject } from 'rxjs';
9
- import { take, first } from 'rxjs/operators';
10
- import { CommonModule } from '@angular/common';
11
- import { TranslateService, TranslateModule } from '@ngx-translate/core';
12
- import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
13
- import { DocumentService } from '@valtimo/document';
14
-
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 }
64
- ];
65
-
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 mr-1\"></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 mr-1\"></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
- ];
92
- FormManagementComponent.ctorParameters = () => [];
93
-
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\">{{\n 'formManagement.name' | translate\n }}</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\">\n {{ 'formManagement.nameIsRequired' | translate }}\n </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\">{{\n 'formManagement.back' | translate\n }}</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 {{ 'formManagement.reset' | translate }}\n </button>\n <button class=\"btn btn-space btn-primary\" type=\"submit\" [disabled]=\"form.invalid\">\n {{ 'formManagement.submit' | translate }}\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 }
172
- ];
173
-
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=\"icon mdi mdi-download mr-1\"></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 mr-1\"></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=\"icon mdi mdi-delete mr-1\"></i>{{ 'formManagement.delete' | translate }}\n </button>\n <button\n class=\"btn btn-success btn-space\"\n (click)=\"modifyFormDefinition()\"\n [disabled]=\"formDefinition.readOnly\"\n >\n <i class=\"icon mdi mdi-upload mr-1\"></i>{{ 'formManagement.deploy' | translate }}\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\">{{\n 'formManagement.readOnly' | translate\n }}</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 }
315
- ];
316
-
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
- },] }
361
- ];
362
-
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 }
430
- ];
431
-
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 }]
572
- };
573
-
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
- },] }
615
- ];
616
-
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.
674
- */
675
-
676
- /**
677
- * Generated bundle index. Do not edit.
678
- */
679
-
680
- export { FormManagementComponent, FormManagementModule, FormManagementService, compareFormDefinitions, FormManagementCreateComponent as ɵa, FormManagementListComponent as ɵb, FormManagementEditComponent as ɵc, FormManagementUploadComponent as ɵd, FormManagementRoutingModule as ɵe };
681
- //# sourceMappingURL=valtimo-form-management.js.map