UNPKG

89.5 kBJavaScriptView Raw
1import { stringTemplate } from '@soushians/shared';
2import { getFormModuleConfig } from '@soushians/config';
3import { BehaviorSubject as BehaviorSubject$1 } from 'rxjs/BehaviorSubject';
4import { BehaviorSubject, Subject } from 'rxjs';
5import { SelectionModel } from '@angular/cdk/collections';
6import { CommonModule } from '@angular/common';
7import { HttpClient, HttpClientModule } from '@angular/common/http';
8import { FlexLayoutModule } from '@angular/flex-layout';
9import { MatTableDataSource, MatExpansionModule, MatSnackBarModule, MatIconModule, MatButtonModule, MatCardModule, MatSelectModule, MatInputModule, MatFormFieldModule, MatTabsModule, MatRadioModule, MatSlideToggleModule, MatDividerModule, MatCheckboxModule, MatTableModule, MatDatepickerModule } from '@angular/material';
10import { FormGroup, FormControl, Validators, FormArray, FormsModule, ReactiveFormsModule } from '@angular/forms';
11import 'rxjs/Observable';
12import { Store, StoreModule } from '@ngrx/store';
13import { __decorate, __metadata } from 'tslib';
14import 'rxjs/add/operator/map';
15import 'rxjs/add/operator/mergeMap';
16import 'rxjs/add/operator/switchMap';
17import { InjectionToken, Inject, Injectable, Component, Input, Output, EventEmitter, NgModule, ViewContainerRef, ComponentFactoryResolver, Compiler, Directive, defineInjectable, inject } from '@angular/core';
18import { ActivatedRoute, Router, RouterModule } from '@angular/router';
19import { Actions, Effect, EffectsModule } from '@ngrx/effects';
20import { of } from 'rxjs/observable/of';
21import { filter, map, take, switchMap, takeUntil, catchError } from 'rxjs/operators';
22
23/**
24 * @fileoverview added by tsickle
25 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
26 */
27var AddFormApiModel;
28(function (AddFormApiModel) {
29 class Request {
30 /**
31 * @param {?=} initValue
32 */
33 constructor(initValue = /** @type {?} */ ({})) {
34 Object.keys(initValue).forEach(key => (this[key] = initValue[key]));
35 }
36 /**
37 * @return {?}
38 */
39 getRequestBody() {
40 return {
41 name: this.name,
42 form: this.form,
43 events: this.events
44 };
45 }
46 /**
47 * @return {?}
48 */
49 static get formGroup() {
50 return new FormGroup({
51 _id: new FormControl("", [Validators.required]),
52 name: new FormControl("", [Validators.required]),
53 title: new FormControl("", [Validators.required]),
54 form: new FormControl({}),
55 events: new FormGroup({
56 accept: new FormGroup({
57 show: new FormControl(false),
58 text: new FormControl("ثبت")
59 }),
60 cancel: new FormGroup({
61 show: new FormControl(false),
62 text: new FormControl("انصراف")
63 })
64 })
65 });
66 }
67 }
68 AddFormApiModel.Request = Request;
69 class Response {
70 constructor() { }
71 }
72 AddFormApiModel.Response = Response;
73})(AddFormApiModel || (AddFormApiModel = {}));
74
75/**
76 * @fileoverview added by tsickle
77 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
78 */
79var EditFormApiModel;
80(function (EditFormApiModel) {
81 class Request {
82 /**
83 * @param {?=} initValue
84 */
85 constructor(initValue = /** @type {?} */ ({})) {
86 Object.keys(initValue).forEach(key => (this[key] = initValue[key]));
87 }
88 /**
89 * @return {?}
90 */
91 getRequestBody() {
92 return {
93 _id: this._id,
94 name: this.name,
95 form: this.form,
96 events: this.events
97 };
98 }
99 /**
100 * @return {?}
101 */
102 static get formGroup() {
103 return new FormGroup({
104 _id: new FormControl("", [Validators.required]),
105 name: new FormControl("", [Validators.required]),
106 form: new FormControl({}),
107 events: new FormGroup({
108 accept: new FormGroup({
109 show: new FormControl(false),
110 text: new FormControl("ثبت")
111 }),
112 cancel: new FormGroup({
113 show: new FormControl(false),
114 text: new FormControl("انصراف")
115 })
116 })
117 });
118 }
119 }
120 EditFormApiModel.Request = Request;
121 class Response {
122 constructor() { }
123 }
124 EditFormApiModel.Response = Response;
125})(EditFormApiModel || (EditFormApiModel = {}));
126
127/**
128 * @fileoverview added by tsickle
129 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
130 */
131var FormListApiModel;
132(function (FormListApiModel) {
133 class Request {
134 /**
135 * @param {?=} initValue
136 */
137 constructor(initValue = /** @type {?} */ ({})) {
138 Object.keys(initValue).forEach((key) => (this[key] = initValue[key]));
139 }
140 /**
141 * @return {?}
142 */
143 getRequestBody() {
144 return {
145 Name: this.Name,
146 Controls: this.Controls
147 };
148 }
149 /**
150 * @return {?}
151 */
152 static get formGroup() {
153 return new FormGroup({
154 Name: new FormControl("", [Validators.required]),
155 Controls: new FormGroup({})
156 });
157 }
158 }
159 FormListApiModel.Request = Request;
160 class Response {
161 constructor() { }
162 }
163 FormListApiModel.Response = Response;
164})(FormListApiModel || (FormListApiModel = {}));
165
166/**
167 * @fileoverview added by tsickle
168 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
169 */
170class Validator {
171 constructor() {
172 this.required = {
173 active: false,
174 message: "این فیلد الزامی است"
175 };
176 this.minlength = {
177 active: false,
178 message: "حداقل تعداد کارکترها",
179 value: 5
180 };
181 this.email = {
182 active: false,
183 message: "لطفا ایمیل صحیح وارد نمایید"
184 };
185 }
186}
187
188/**
189 * @fileoverview added by tsickle
190 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
191 */
192class FieldConfig {
193 /**
194 * @param {?} type
195 */
196 constructor(type) {
197 this.type = type;
198 if (type != "control")
199 this.fields = [];
200 this.width = 3;
201 this.validator = new Validator();
202 }
203}
204
205/**
206 * @fileoverview added by tsickle
207 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
208 */
209class FormSchemaModel {
210 constructor() {
211 this.events = {
212 accept: {
213 show: false,
214 text: "ثبت"
215 },
216 cancel: {
217 show: false,
218 text: "انصراف"
219 }
220 };
221 this.form = new FieldConfig("group");
222 }
223 /**
224 * @return {?}
225 */
226 init() {
227 this._id = (Math.random() * 10).toString();
228 }
229}
230
231/**
232 * @fileoverview added by tsickle
233 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
234 */
235
236/**
237 * @fileoverview added by tsickle
238 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
239 */
240/** @type {?} */
241const MODULE_DEFAULT_CONFIG = {
242 env: {
243 production: false,
244 frontend_server: "frontend/server/did/not/set",
245 server: "server/did/not/set"
246 },
247 endpoints: {
248 addForm: "",
249 editForm: "",
250 getForm: "",
251 getList: "",
252 deleteForm: "",
253 captchaUrl: ""
254 },
255};
256/** @type {?} */
257const MODULE_CONFIG_TOKEN = new InjectionToken("FormModuleConfig");
258
259/**
260 * @fileoverview added by tsickle
261 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
262 */
263class FormConfigurationService {
264 /**
265 * @param {?} configFile
266 * @param {?} store
267 */
268 constructor(configFile, store) {
269 this.store = store;
270 this.config$ = new BehaviorSubject(MODULE_DEFAULT_CONFIG);
271 this._config = Object.assign({}, MODULE_DEFAULT_CONFIG, configFile);
272 this.config$.next(this._config);
273 this.store.select(getFormModuleConfig).subscribe(userConfig => {
274 if (!userConfig)
275 return;
276 this._config = Object.assign({}, this._config, userConfig.Config);
277 this.config$.next(this._config);
278 });
279 }
280 /**
281 * @return {?}
282 */
283 get config() {
284 return this._config;
285 }
286}
287FormConfigurationService.decorators = [
288 { type: Injectable, args: [{
289 providedIn: "root"
290 },] }
291];
292/** @nocollapse */
293FormConfigurationService.ctorParameters = () => [
294 { type: undefined, decorators: [{ type: Inject, args: [MODULE_CONFIG_TOKEN,] }] },
295 { type: Store }
296];
297/** @nocollapse */ FormConfigurationService.ngInjectableDef = defineInjectable({ factory: function FormConfigurationService_Factory() { return new FormConfigurationService(inject(MODULE_CONFIG_TOKEN), inject(Store)); }, token: FormConfigurationService, providedIn: "root" });
298
299/**
300 * @fileoverview added by tsickle
301 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
302 */
303class FormService {
304 /**
305 * @param {?} http
306 * @param {?} store
307 * @param {?} configurationService
308 */
309 constructor(http, store, configurationService) {
310 this.http = http;
311 this.store = store;
312 this.configurationService = configurationService;
313 }
314 /**
315 * @param {?} data
316 * @return {?}
317 */
318 add(data) {
319 /** @type {?} */
320 const model = new AddFormApiModel.Request(data);
321 return this.configurationService.config$
322 .filter((config) => config.endpoints.addForm != "")
323 .take(1)
324 .switchMap((config) => this.http.post(config.env.frontend_server + config.endpoints.addForm, model.getRequestBody()))
325 .map((response) => response.Result);
326 }
327 /**
328 * @param {?} _id
329 * @return {?}
330 */
331 get(_id) {
332 return this.configurationService.config$
333 .filter((config) => config.endpoints.getForm != "")
334 .take(1)
335 .switchMap((config) => this.http.get(stringTemplate(config.env.frontend_server + config.endpoints.getForm, { _id })))
336 .map((response) => response.Result);
337 }
338 /**
339 * @return {?}
340 */
341 getList() {
342 return this.configurationService.config$
343 .filter((config) => config.endpoints.getList != "")
344 .switchMap((config) => this.http.get(config.env.frontend_server + config.endpoints.getList))
345 .map((response) => response.Result);
346 }
347 /**
348 * @param {?} data
349 * @return {?}
350 */
351 update(data) {
352 /** @type {?} */
353 const model = new EditFormApiModel.Request(data);
354 return this.configurationService.config$
355 .filter((config) => config.endpoints.editForm != "")
356 .take(1)
357 .switchMap((config) => this.http.put(config.env.frontend_server + config.endpoints.editForm, model.getRequestBody()))
358 .map((response) => response.Result);
359 }
360 /**
361 * @param {?} _id
362 * @return {?}
363 */
364 delete(_id) {
365 return this.configurationService.config$
366 .filter((config) => config.endpoints.deleteForm != "")
367 .switchMap((config) => this.http.get(config.env.frontend_server + config.endpoints.deleteForm));
368 }
369 /**
370 * @param {?} _id
371 * @return {?}
372 */
373 selectFormById(_id) {
374 /** @type {?} */
375 const subject = new BehaviorSubject$1(undefined);
376 this.store
377 .select((state) => state.form.list.data)
378 .pipe(filter((forms) => forms != null), map((forms) => forms.find((form) => form._id == _id)))
379 .subscribe((formSchemaModel) => subject.next(formSchemaModel));
380 return subject.asObservable();
381 }
382}
383FormService.decorators = [
384 { type: Injectable, args: [{
385 providedIn: "root"
386 },] }
387];
388/** @nocollapse */
389FormService.ctorParameters = () => [
390 { type: HttpClient },
391 { type: Store },
392 { type: FormConfigurationService }
393];
394/** @nocollapse */ FormService.ngInjectableDef = defineInjectable({ factory: function FormService_Factory() { return new FormService(inject(HttpClient), inject(Store), inject(FormConfigurationService)); }, token: FormService, providedIn: "root" });
395
396/**
397 * @fileoverview added by tsickle
398 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
399 */
400class SelectComponent {
401 constructor() { }
402}
403SelectComponent.decorators = [
404 { type: Component, args: [{
405 selector: "ngs-form-control-select",
406 template: "<div [formGroup]=\"group\">\r\n<mat-form-field>\r\n <mat-select [formControlName]=\"config.name\" [placeholder]=\"config.title\">\r\n <mat-option *ngFor=\"let option of config.options\" [value]=\"option.value\">{{option.key}}</mat-option>\r\n </mat-select>\r\n</mat-form-field>\r\n</div>",
407 styles: [":host{display:block}.mat-form-field{width:100%}"]
408 }] }
409];
410/** @nocollapse */
411SelectComponent.ctorParameters = () => [];
412
413/**
414 * @fileoverview added by tsickle
415 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
416 */
417
418/**
419 * @fileoverview added by tsickle
420 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
421 */
422class CheckboxComponent {
423 constructor() { }
424}
425CheckboxComponent.decorators = [
426 { type: Component, args: [{
427 selector: "ngs-form-control-checkbox",
428 template: "<div [formGroup]=\"group\">\r\n <mat-checkbox [formControlName]=\"config.name\">\r\n {{config.title}}\r\n </mat-checkbox>\r\n</div>",
429 styles: [":host{display:block}.mat-form-field{width:100%}"]
430 }] }
431];
432/** @nocollapse */
433CheckboxComponent.ctorParameters = () => [];
434
435/**
436 * @fileoverview added by tsickle
437 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
438 */
439
440/**
441 * @fileoverview added by tsickle
442 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
443 */
444class EmailComponent {
445 constructor() { }
446 /**
447 * @return {?}
448 */
449 ngOnInit() { }
450}
451EmailComponent.decorators = [
452 { type: Component, args: [{
453 selector: "ngs-form-control-email",
454 template: "<div [formGroup]=\"group\">\r\n<mat-form-field fxFlexFill>\r\n <input matInput [type]=\"config.inputType\" [placeholder]=\"config.title\" [formControlName]=\"config.name\">\r\n</mat-form-field>\r\n</div>",
455 styles: [":host{display:block}.mat-form-field{width:100%}"]
456 }] }
457];
458/** @nocollapse */
459EmailComponent.ctorParameters = () => [];
460
461/**
462 * @fileoverview added by tsickle
463 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
464 */
465
466/**
467 * @fileoverview added by tsickle
468 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
469 */
470class ColorComponent {
471 constructor() { }
472 /**
473 * @return {?}
474 */
475 ngOnInit() { }
476}
477ColorComponent.decorators = [
478 { type: Component, args: [{
479 selector: "ngs-form-control-color",
480 template: "<div [formGroup]=\"form\">\r\n<mat-form-field fxFlexFill>\r\n <input matInput [type]=\"schema.inputType\" [placeholder]=\"schema.title\" [formControlName]=\"schema.name\">\r\n</mat-form-field>\r\n</div>",
481 styles: [":host{display:block}.mat-form-field{width:100%}"]
482 }] }
483];
484/** @nocollapse */
485ColorComponent.ctorParameters = () => [];
486ColorComponent.propDecorators = {
487 form: [{ type: Input }],
488 schema: [{ type: Input }]
489};
490
491/**
492 * @fileoverview added by tsickle
493 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
494 */
495
496/**
497 * @fileoverview added by tsickle
498 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
499 */
500class TableComponent {
501 /**
502 * @param {?} http
503 */
504 constructor(http) {
505 this.http = http;
506 this.selection = new SelectionModel(true, []);
507 this.ready = false;
508 }
509 /**
510 * @return {?}
511 */
512 ngOnInit() {
513 this.http.get(this.schema.dataEndpoint).subscribe((data) => {
514 this.ready = true;
515 this.displayedColumns = data.displayedColumns;
516 this.filedDisplayedColumns = data.filedDisplayedColumns;
517 this.dataSource = new MatTableDataSource(data.dataSource);
518 });
519 }
520 /**
521 * Whether the number of selected elements matches the total number of rows.
522 * @return {?}
523 */
524 isAllSelected() {
525 /** @type {?} */
526 const numSelected = this.selection.selected.length;
527 this.form.patchValue({
528 [this.schema.name]: this.selection.selected
529 });
530 /** @type {?} */
531 const numRows = this.dataSource.data.length;
532 return numSelected === numRows;
533 }
534 /**
535 * Selects all rows if they are not all selected; otherwise clear selection.
536 * @return {?}
537 */
538 masterToggle() {
539 this.isAllSelected() ? this.selection.clear() : this.dataSource.data.forEach(row => this.selection.select(row));
540 }
541}
542TableComponent.decorators = [
543 { type: Component, args: [{
544 selector: "ngs-form-control-table",
545 template: "<div class=\"example-container mat-elevation-z8\" *ngIf=\"ready\">\r\n <mat-table #table [dataSource]=\"dataSource\">\r\n \r\n <ng-container matColumnDef=\"select\">\r\n <mat-header-cell *matHeaderCellDef>\r\n <mat-checkbox (change)=\"$event ? masterToggle() : null\"\r\n [checked]=\"selection.hasValue() && isAllSelected()\"\r\n [indeterminate]=\"selection.hasValue() && !isAllSelected()\">\r\n </mat-checkbox>\r\n </mat-header-cell>\r\n <mat-cell *matCellDef=\"let row\">\r\n <mat-checkbox (click)=\"$event.stopPropagation()\"\r\n (change)=\"$event ? selection.toggle(row) : null\"\r\n [checked]=\"selection.isSelected(row)\">\r\n </mat-checkbox>\r\n </mat-cell>\r\n </ng-container>\r\n\r\n <div *ngFor=\"let col of filedDisplayedColumns\">\r\n <ng-container [matColumnDef]=\"col\">\r\n <mat-header-cell *matHeaderCellDef> {{col}} </mat-header-cell>\r\n <mat-cell *matCellDef=\"let element\"> {{element[col]}} </mat-cell>\r\n </ng-container>\r\n </div>\r\n \r\n <ng-container matColumnDef=\"actions\">\r\n <mat-header-cell *matHeaderCellDef></mat-header-cell>\r\n <mat-cell class='left-align' *matCellDef=\"let row\">\r\n <button mat-icon-button>\r\n <mat-icon aria-label=\"\u0627\u0646\u062A\u062E\u0627\u0628\">arrow_back</mat-icon>\r\n </button>\r\n </mat-cell>\r\n </ng-container>\r\n \r\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\r\n <mat-row *matRowDef=\"let row; columns: displayedColumns;\" (click)=\"selection.toggle(row)\"></mat-row>\r\n\r\n </mat-table>\r\n </div>\r\n\r\n\r\n<!-- <mat-form-field fxFlexFill [formGroup]=\"form\">\r\n \r\n <input matInput [id]=\"schema.name\" [type]=\"schema.inputType\" [placeholder]=\"schema.title\" [formControlName]=\"schema.name\">\r\n \r\n <mat-error *ngIf=\"form.get(schema.name).errors?.required\">\r\n {{schema.validator.required.message}}\r\n </mat-error>\r\n <mat-error *ngIf=\"form.get(schema.name).errors?.minlength\">\r\n {{schema.validator.minlength.message}}\r\n </mat-error>\r\n <mat-error *ngIf=\"form.get(schema.name).email?.minlength\">\r\n {{schema.validator.email.message}}\r\n </mat-error>\r\n</mat-form-field> -->\r\n \r\n <!-- <div *ngIf=\"form.get(schema.name).invalid && (form.get(schema.name).dirty || form.get(schema.name).touched)\" class=\"alert alert-danger\">\r\n </div> -->",
546 styles: [":host{display:block}.mat-form-field{width:100%}"]
547 }] }
548];
549/** @nocollapse */
550TableComponent.ctorParameters = () => [
551 { type: HttpClient }
552];
553TableComponent.propDecorators = {
554 form: [{ type: Input }],
555 schema: [{ type: Input }]
556};
557
558/**
559 * @fileoverview added by tsickle
560 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
561 */
562
563/**
564 * @fileoverview added by tsickle
565 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
566 */
567class NumberComponent {
568 constructor() { }
569 /**
570 * @return {?}
571 */
572 ngOnInit() { }
573}
574NumberComponent.decorators = [
575 { type: Component, args: [{
576 selector: "ngs-form-control-number",
577 template: "<div [formGroup]=\"form\">\r\n <mat-form-field fxFlexFill>\r\n <input matInput [type]=\"schema.inputType\" [placeholder]=\"schema.title\" [formControlName]=\"schema.name\">\r\n </mat-form-field>\r\n</div>",
578 styles: [":host{display:block}.mat-form-field{width:100%}"]
579 }] }
580];
581/** @nocollapse */
582NumberComponent.ctorParameters = () => [];
583NumberComponent.propDecorators = {
584 form: [{ type: Input }],
585 schema: [{ type: Input }]
586};
587
588/**
589 * @fileoverview added by tsickle
590 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
591 */
592
593/**
594 * @fileoverview added by tsickle
595 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
596 */
597class TextComponent {
598 constructor() { }
599}
600TextComponent.decorators = [
601 { type: Component, args: [{
602 selector: "ngs-form-control-text",
603 template: "<mat-form-field fxFlexFill [formGroup]=\"group\">\r\n\r\n <input matInput [id]=\"config.name\" [type]=\"config.inputType\" [placeholder]=\"config.title\" [formControlName]=\"config.name\">\r\n\r\n <mat-error *ngIf=\"group.get(config.name).errors?.required\">\r\n {{config.validator.required.message}}\r\n </mat-error>\r\n <mat-error *ngIf=\"group.get(config.name).errors?.minlength\">\r\n {{config.validator.minlength.message}}\r\n </mat-error>\r\n <!-- <mat-error *ngIf=\"group.get(config.name).email?.minlength\">\r\n {{config.validator.email.message}}\r\n </mat-error> -->\r\n\r\n <!-- <div *ngIf=\"form.get(config.name).invalid && (form.get(config.name).dirty || form.get(config.name).touched)\" class=\"alert alert-danger\">\r\n </div> -->\r\n\r\n</mat-form-field>",
604 styles: [":host{display:block}.mat-form-field{width:100%}"]
605 }] }
606];
607/** @nocollapse */
608TextComponent.ctorParameters = () => [];
609
610/**
611 * @fileoverview added by tsickle
612 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
613 */
614
615/**
616 * @fileoverview added by tsickle
617 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
618 */
619
620/**
621 * @fileoverview added by tsickle
622 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
623 */
624/** @enum {string} */
625var FormsListActionTypes = {
626 FORMS_LIST: "[FORM][LIST] FORMS_LIST",
627 FORMS_LIST_START: "[FORM][LIST] FORMS_LIST_START",
628 FORMS_LIST_SUCCEED: "[FORM][LIST] FORMS_LIST_SUCCEED",
629 FORMS_LIST_FAILED: "[FORM][LIST] FORMS_LIST_FAILED",
630 ADD_FORM_SCHEMA: "[FORM][LIST] ADD_FORM_SCHEMA",
631 FORM_SCHEMA_UPDATE: "[FORM][LIST] FORM_SCHEMA_UPDATE",
632 GET_FORM_SCHEMA: "[FORM][LIST] GET_FORM_SCHEMA",
633 FORM_SCHEMA_FETCHED: "[FORM][LIST] FORM_SCHEMA_FETCHED",
634};
635class FormsListAction {
636 constructor() {
637 this.type = FormsListActionTypes.FORMS_LIST;
638 }
639}
640class FormsListStartAction {
641 constructor() {
642 this.type = FormsListActionTypes.FORMS_LIST_START;
643 }
644}
645class FormsListSucceedAction {
646 /**
647 * @param {?} payload
648 */
649 constructor(payload) {
650 this.payload = payload;
651 this.type = FormsListActionTypes.FORMS_LIST_SUCCEED;
652 }
653}
654class FormsListFailedAction {
655 constructor() {
656 this.type = FormsListActionTypes.FORMS_LIST_FAILED;
657 }
658}
659class UpdateFormSchemaAction {
660 /**
661 * @param {?} payload
662 */
663 constructor(payload) {
664 this.payload = payload;
665 this.type = FormsListActionTypes.FORM_SCHEMA_UPDATE;
666 }
667}
668class AddFormSchemaAction {
669 /**
670 * @param {?} payload
671 */
672 constructor(payload) {
673 this.payload = payload;
674 this.type = FormsListActionTypes.ADD_FORM_SCHEMA;
675 }
676}
677class GetFormSchemaAction {
678 /**
679 * @param {?} payload
680 */
681 constructor(payload) {
682 this.payload = payload;
683 this.type = FormsListActionTypes.GET_FORM_SCHEMA;
684 }
685}
686class FormSchemaFechedAction {
687 /**
688 * @param {?} payload
689 */
690 constructor(payload) {
691 this.payload = payload;
692 this.type = FormsListActionTypes.FORM_SCHEMA_FETCHED;
693 }
694}
695
696/**
697 * @fileoverview added by tsickle
698 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
699 */
700class DateFormInputControlComponent {
701 constructor() { }
702}
703DateFormInputControlComponent.decorators = [
704 { type: Component, args: [{
705 selector: "ngs-form-control-date",
706 template: "<mat-form-field fxFlexFill [formGroup]=\"group\">\r\n\r\n <!-- <input matInput [id]=\"config.name\" [type]=\"config.inputType\" [placeholder]=\"config.title\" [formControlName]=\"config.name\"> -->\r\n <input matInput [id]=\"config.name\" [matDatepicker]=\"_datepicker\" [placeholder]=\"config.title\" [formControlName]=\"config.name\">\r\n <mat-datepicker-toggle matSuffix [for]=\"_datepicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #_datepicker></mat-datepicker>\r\n\r\n <mat-error *ngIf=\"group.get(config.name).errors?.required\">\r\n {{config.validator.required.message}}\r\n </mat-error>\r\n <mat-error *ngIf=\"group.get(config.name).errors?.minlength\">\r\n {{config.validator.minlength.message}}\r\n </mat-error>\r\n <!-- <mat-error *ngIf=\"group.get(config.name).email?.minlength\">\r\n {{config.validator.email.message}}\r\n </mat-error> -->\r\n\r\n <!-- <div *ngIf=\"form.get(config.name).invalid && (form.get(config.name).dirty || form.get(config.name).touched)\" class=\"alert alert-danger\">\r\n </div> -->\r\n\r\n</mat-form-field>\r\n\r\n<!-- \r\n\r\n<div [formGroup]=\"formGroup\">\r\n <div class=\"field-wrapper\">\r\n <div [@filedAnimation]=\"mode\">\r\n <mat-form-field class=\"fit\" [(ngClass)]=\"mode\">\r\n <input matInput [matDatepicker]=\"_datepicker\" [placeholder]=\"placeholder\" [formControlName]=\"controlName\">\r\n <mat-datepicker-toggle matSuffix [for]=\"_datepicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #_datepicker></mat-datepicker>\r\n \r\n <mat-icon class=\"tooltip md-18\" *ngIf=\"tooltip\" [matTooltip]=\"tooltip\">help</mat-icon>\r\n </mat-form-field>\r\n <div class=\"value-box\"> \r\n <span class=\"name\">\r\n {{ placeholder }} :\r\n </span>\r\n <span class=\"value\">\r\n {{(DisplayValue$ | async | persianDate)}} \r\n </span>\r\n </div>\r\n </div>\r\n </div>\r\n</div> -->",
707 styles: [":host{display:block}.mat-form-field{width:100%}"]
708 }] }
709];
710/** @nocollapse */
711DateFormInputControlComponent.ctorParameters = () => [];
712
713/**
714 * @fileoverview added by tsickle
715 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
716 */
717class FileFormInputControlComponent {
718 constructor() { }
719}
720FileFormInputControlComponent.decorators = [
721 { type: Component, args: [{
722 selector: "ngs-form-control-file",
723 template: "<div fxFlexFill [formGroup]=\"group\">\r\n\r\n <!-- <input matInput [id]=\"config.name\" [type]=\"config.inputType\" [placeholder]=\"config.title\" [formControlName]=\"config.name\"> -->\r\n <input [id]=\"config.name\" [type]=\"config.inputType\" [placeholder]=\"config.title\" [formControlName]=\"config.name\">\r\n\r\n <mat-error *ngIf=\"group.get(config.name).errors?.required\">\r\n {{config.validator.required.message}}\r\n </mat-error>\r\n <mat-error *ngIf=\"group.get(config.name).errors?.minlength\">\r\n {{config.validator.minlength.message}}\r\n </mat-error>\r\n <!-- <mat-error *ngIf=\"group.get(config.name).email?.minlength\">\r\n {{config.validator.email.message}}\r\n </mat-error> -->\r\n\r\n <!-- <div *ngIf=\"form.get(config.name).invalid && (form.get(config.name).dirty || form.get(config.name).touched)\" class=\"alert alert-danger\">\r\n </div> -->\r\n\r\n</div>\r\n\r\n<!-- \r\n\r\n<div [formGroup]=\"formGroup\">\r\n <div class=\"field-wrapper\">\r\n <div [@filedAnimation]=\"mode\">\r\n <mat-form-field class=\"fit\" [(ngClass)]=\"mode\">\r\n <input matInput [matDatepicker]=\"_datepicker\" [placeholder]=\"placeholder\" [formControlName]=\"controlName\">\r\n <mat-datepicker-toggle matSuffix [for]=\"_datepicker\"></mat-datepicker-toggle>\r\n <mat-datepicker #_datepicker></mat-datepicker>\r\n \r\n <mat-icon class=\"tooltip md-18\" *ngIf=\"tooltip\" [matTooltip]=\"tooltip\">help</mat-icon>\r\n </mat-form-field>\r\n <div class=\"value-box\"> \r\n <span class=\"name\">\r\n {{ placeholder }} :\r\n </span>\r\n <span class=\"value\">\r\n {{(DisplayValue$ | async | persianDate)}} \r\n </span>\r\n </div>\r\n </div>\r\n </div>\r\n</div> -->",
724 styles: [":host{display:block}.mat-form-field{width:100%}"]
725 }] }
726];
727/** @nocollapse */
728FileFormInputControlComponent.ctorParameters = () => [];
729
730/**
731 * @fileoverview added by tsickle
732 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
733 */
734class FormCaptchaService {
735 /**
736 * @param {?} http
737 * @param {?} store
738 * @param {?} configurationService
739 */
740 constructor(http, store, configurationService) {
741 this.http = http;
742 this.store = store;
743 this.configurationService = configurationService;
744 }
745 /**
746 * @return {?}
747 */
748 getCaptcha() {
749 debugger;
750 return this.configurationService.config$.pipe(filter((captcha) => captcha.endpoints.captchaUrl != ""), take(1), switchMap((captcha) => this.http.get(captcha.env.server + captcha.endpoints.captchaUrl)), map((response) => response.Result));
751 }
752 /**
753 * @return {?}
754 */
755 sendCaptcha() {
756 return this.configurationService.config$.pipe(filter((config) => config.endpoints.getList != ""), switchMap((config) => this.http.get(config.env.server + config.endpoints.getList)), map((response) => response.Result));
757 }
758}
759FormCaptchaService.decorators = [
760 { type: Injectable, args: [{
761 providedIn: "root"
762 },] }
763];
764/** @nocollapse */
765FormCaptchaService.ctorParameters = () => [
766 { type: HttpClient },
767 { type: Store },
768 { type: FormConfigurationService }
769];
770/** @nocollapse */ FormCaptchaService.ngInjectableDef = defineInjectable({ factory: function FormCaptchaService_Factory() { return new FormCaptchaService(inject(HttpClient), inject(Store), inject(FormConfigurationService)); }, token: FormCaptchaService, providedIn: "root" });
771
772/**
773 * @fileoverview added by tsickle
774 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
775 */
776class CaptchaModel {
777 /**
778 * @param {?=} __0
779 */
780 constructor({ captchaImg, captchaCode } = {}) {
781 this.captchaImg = `${captchaImg}?${Math.random()}`;
782 this.captchaCode = captchaCode || "";
783 }
784}
785var UpsertCaptchaApiModel;
786(function (UpsertCaptchaApiModel) {
787 class Request {
788 /**
789 * @param {?=} initValue
790 */
791 constructor(initValue = {}) {
792 Object.keys(initValue).forEach(key => (this[key] = initValue[key]));
793 }
794 /**
795 * @return {?}
796 */
797 getRequestBody() {
798 return this.Captcha.captchaCode;
799 }
800 }
801 UpsertCaptchaApiModel.Request = Request;
802 class Response {
803 constructor() { }
804 }
805 UpsertCaptchaApiModel.Response = Response;
806})(UpsertCaptchaApiModel || (UpsertCaptchaApiModel = {}));
807
808/**
809 * @fileoverview added by tsickle
810 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
811 */
812class FormCaptchaComponent {
813 /**
814 * @param {?} service
815 * @param {?} store
816 * @param {?} configurationService
817 */
818 constructor(service, store, configurationService) {
819 // this.captcha = new CaptchaModel({
820 // captchaImg: "http://172.22.34.28:8001/api/authentication/captcha"
821 // });
822 this.service = service;
823 this.store = store;
824 this.configurationService = configurationService;
825 this._captcha_generate();
826 }
827 /**
828 * @return {?}
829 */
830 ngOnInit() {
831 debugger;
832 }
833 /**
834 * @return {?}
835 */
836 refresh() {
837 this.captcha.captchaImg = this._captcha_generate() + `?${Math.random()}`;
838 }
839 /**
840 * @return {?}
841 */
842 _captcha_generate() {
843 this.configurationService.config$.pipe(map(config => config.env.server + config.endpoints.captchaUrl)).subscribe(captcha => {
844 this.captcha = new CaptchaModel({
845 captchaImg: captcha
846 });
847 });
848 }
849}
850FormCaptchaComponent.decorators = [
851 { type: Component, args: [{
852 selector: "lib-form-captcha",
853 template: "<div fxLayout=\"row wrap\" fxLayoutAlign=\"start center\">\r\n <img [src]=\"captcha.captchaImg\" />\r\n\r\n <button mat-icon-button color=\"primary\" (click)=\"refresh()\">\r\n <mat-icon>refresh</mat-icon>\r\n </button>\r\n\r\n <div [formGroup]=\"group\">\r\n <mat-form-field fxFlex>\r\n <input matInput [id]=\"config.name\" [placeholder]=\"config.title\" [formControlName]=\"config.name\" />\r\n </mat-form-field>\r\n </div>\r\n</div>",
854 styles: ["img{border:1px solid #e4e4e4}"]
855 }] }
856];
857/** @nocollapse */
858FormCaptchaComponent.ctorParameters = () => [
859 { type: FormCaptchaService },
860 { type: Store },
861 { type: FormConfigurationService }
862];
863
864/**
865 * @fileoverview added by tsickle
866 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
867 */
868
869/**
870 * @fileoverview added by tsickle
871 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
872 */
873class FormViewComponent {
874 /**
875 * @param {?} service
876 * @param {?} compiler
877 * @param {?} resolver
878 * @param {?} store
879 */
880 constructor(service, compiler, resolver, store) {
881 this.service = service;
882 this.compiler = compiler;
883 this.resolver = resolver;
884 this.store = store;
885 this.unsubscribe = new Subject();
886 this.accept = new EventEmitter();
887 this.cancel = new EventEmitter();
888 this.card = false;
889 this.formGroupCreated = false;
890 this.schema$ = new BehaviorSubject$1(undefined);
891 this.schema$.pipe(takeUntil(this.unsubscribe)).subscribe(schema => {
892 if (!schema)
893 return;
894 this.formGroup = /** @type {?} */ (this.createFrom(schema.form));
895 if (!schema.form.name)
896 return;
897 this.formGroupCreated = true;
898 });
899 }
900 /**
901 * @param {?} id
902 * @return {?}
903 */
904 set id(id) {
905 if (!this.local)
906 this.store.dispatch(new GetFormSchemaAction(id));
907 this.service
908 .selectFormById(id)
909 .pipe(takeUntil(this.unsubscribe))
910 .subscribe(schema => this.schema$.next(schema));
911 }
912 /**
913 * @param {?} schema
914 * @return {?}
915 */
916 set schema(schema) {
917 this.schema$.next(schema);
918 }
919 /**
920 * @return {?}
921 */
922 ngOnDestroy() {
923 this.unsubscribe.next();
924 this.unsubscribe.complete();
925 }
926 /**
927 * @param {?} schema
928 * @return {?}
929 */
930 generate(schema) {
931 this.schema$.next(schema);
932 }
933 /**
934 * @param {?} data
935 * @param {?=} parentPath
936 * @return {?}
937 */
938 createFrom(data, parentPath = "") {
939 if (data.type == "control") {
940 /** @type {?} */
941 let formGroupPath;
942 if (data.parentType == "array") ;
943 else if (data.parentType == "group") {
944 formGroupPath = parentPath;
945 parentPath = `${parentPath}.controls.${((/** @type {?} */ (data))).name}`;
946 }
947 /** @type {?} */
948 const validators = [];
949 if (data.validator.required && data.validator.required.active) {
950 validators.push(Validators.required);
951 }
952 if (data.validator.minlength && data.validator.minlength.active) {
953 validators.push(Validators.minLength(data.validator.minlength.value));
954 }
955 if (data.validator.email && data.validator.email.active) {
956 validators.push(Validators.email);
957 }
958 /** @type {?} */
959 const ctr = new FormControl(data.value, validators);
960 (/** @type {?} */ (ctr)).schema = data;
961 (/** @type {?} */ (ctr)).schema.path = parentPath;
962 (/** @type {?} */ (ctr)).schema.formGroupPath = formGroupPath;
963 return ctr;
964 }
965 else if (data.type == "group") {
966 /** @type {?} */
967 const formGroup = new FormGroup({});
968 if (data.parentType == undefined) {
969 parentPath = (/** @type {?} */ (data)).name;
970 }
971 else if (data.parentType == "array") {
972 parentPath = `${parentPath}.controls[${((/** @type {?} */ (data))).name}]`;
973 }
974 else if (data.parentType == "group") {
975 parentPath = `${parentPath}.controls.${((/** @type {?} */ (data))).name}`;
976 }
977 (/** @type {?} */ (formGroup)).schema = data;
978 (/** @type {?} */ (formGroup)).schema.path = parentPath;
979 data.fields.forEach(item => {
980 item.parentType = "group";
981 formGroup.addControl(item.name, this.createFrom(item, parentPath));
982 });
983 return formGroup;
984 }
985 else {
986 /** @type {?} */
987 const formArray = new FormArray([]);
988 parentPath =
989 parentPath == "" ? (/** @type {?} */ (data)).name : `${parentPath}.controls.${((/** @type {?} */ (data))).name}`;
990 (/** @type {?} */ (formArray)).schema = data;
991 (/** @type {?} */ (formArray)).schema.path = parentPath;
992 data.fields.forEach((item, idx) => {
993 item.parentType = "array";
994 item.name = idx.toString();
995 formArray.controls.push(this.createFrom(item, parentPath));
996 });
997 return formArray;
998 }
999 }
1000 /**
1001 * @return {?}
1002 */
1003 accepted() {
1004 this.accept.emit(this.formGroup);
1005 }
1006 /**
1007 * @return {?}
1008 */
1009 canceled() {
1010 this.cancel.emit(this.formGroup);
1011 }
1012}
1013FormViewComponent.decorators = [
1014 { type: Component, args: [{
1015 selector: "ngs-form-view",
1016 template: "<div fxFlex=\"nogrow\" fxLayoutAlign=\"center center\" class=\"main-container\">\r\n <form *ngIf=\"formGroupCreated && card\" class=\"ngs-dynamic-form\" [formGroup]=\"formGroup\" (ngSubmit)=\"accepted()\">\r\n <mat-card>\r\n <mat-card-title>\r\n {{(schema$ | async)?.name}}\r\n </mat-card-title>\r\n <mat-card-content fxLayout=\"row wrap\" fxLayoutGap=\"25px\">\r\n <div *ngFor=\"let field of (schema$ | async)?.form.fields;\" [fxFlex]=\"field.width * 10\">\r\n <ng-container *ngIf=\"field && field.inputType\" dynamicField [config]=\"field\" [group]=\"formGroup\"></ng-container>\r\n </div>\r\n </mat-card-content>\r\n <mat-card-actions align=\"end\">\r\n <button type=\"button\" *ngIf=\"(schema$ | async)?.events.cancel.show\" (click)=\"cancel.emit()\" mat-button color=\"primary\">{{(schema$\r\n | async)?.events.cancel.text}}</button>\r\n <button type=\"submit\" *ngIf=\"(schema$ | async)?.events.accept.show\" mat-raised-button color=\"primary\">{{(schema$\r\n | async)?.events.accept.text}}</button>\r\n </mat-card-actions>\r\n </mat-card>\r\n </form>\r\n <form *ngIf=\"formGroupCreated && !card\" class=\"ngs-dynamic-form\" [formGroup]=\"formGroup\" (ngSubmit)=\"accepted()\">\r\n <div>\r\n <h3>\r\n {{(schema$ | async)?.name}}\r\n </h3>\r\n <div fxLayout=\"row wrap\" fxLayoutGap=\"5px\">\r\n <div *ngFor=\"let field of (schema$ | async)?.form.fields;\" [fxFlex]=\"field.width * 10\">\r\n <ng-container dynamicField [config]=\"field\" [group]=\"formGroup\"></ng-container>\r\n </div>\r\n </div>\r\n <div>\r\n <button type=\"button\" *ngIf=\"(schema$ | async)?.events.cancel.show\" (click)=\"cancel.emit()\" mat-button color=\"primary\">{{(schema$\r\n | async)?.events.cancel.text}}</button>\r\n <button type=\"submit\" *ngIf=\"(schema$ | async)?.events.accept.show\" mat-raised-button color=\"primary\">{{(schema$\r\n | async)?.events.accept.text}}</button>\r\n </div>\r\n </div>\r\n </form>\r\n\r\n</div>",
1017 styles: [""]
1018 }] }
1019];
1020/** @nocollapse */
1021FormViewComponent.ctorParameters = () => [
1022 { type: FormService },
1023 { type: Compiler },
1024 { type: ComponentFactoryResolver },
1025 { type: Store }
1026];
1027FormViewComponent.propDecorators = {
1028 accept: [{ type: Output }],
1029 cancel: [{ type: Output }],
1030 local: [{ type: Input }],
1031 card: [{ type: Input }],
1032 id: [{ type: Input }],
1033 schema: [{ type: Input }]
1034};
1035/** @type {?} */
1036const components = {
1037 checkbox: CheckboxComponent,
1038 text: TextComponent,
1039 password: TextComponent,
1040 date: DateFormInputControlComponent,
1041 file: FileFormInputControlComponent,
1042 table: TableComponent,
1043 color: ColorComponent,
1044 email: EmailComponent,
1045 captcha: FormCaptchaComponent,
1046 select: SelectComponent
1047};
1048class DynamicFieldDirective {
1049 /**
1050 * @param {?} resolver
1051 * @param {?} container
1052 */
1053 constructor(resolver, container) {
1054 this.resolver = resolver;
1055 this.container = container;
1056 }
1057 /**
1058 * @return {?}
1059 */
1060 ngOnChanges() {
1061 debugger;
1062 if (this.component) {
1063 this.component.instance.config = this.config;
1064 this.component.instance.group = this.group;
1065 }
1066 }
1067 /**
1068 * @return {?}
1069 */
1070 ngOnInit() {
1071 debugger;
1072 if (this.config.inputType == undefined)
1073 return;
1074 if (!components[this.config.inputType]) {
1075 /** @type {?} */
1076 const supportedTypes = Object.keys(components).join(", ");
1077 throw new Error(`Trying to use an unsupported type (${this.config.inputType}).
1078 Supported types: ${supportedTypes}`);
1079 }
1080 /** @type {?} */
1081 const component = this.resolver.resolveComponentFactory(components[this.config.inputType]);
1082 this.component = this.container.createComponent(component);
1083 this.component.instance.config = this.config;
1084 this.component.instance.group = this.group;
1085 }
1086}
1087DynamicFieldDirective.decorators = [
1088 { type: Directive, args: [{
1089 selector: "[dynamicField]"
1090 },] }
1091];
1092/** @nocollapse */
1093DynamicFieldDirective.ctorParameters = () => [
1094 { type: ComponentFactoryResolver },
1095 { type: ViewContainerRef }
1096];
1097DynamicFieldDirective.propDecorators = {
1098 config: [{ type: Input }],
1099 group: [{ type: Input }]
1100};
1101
1102/**
1103 * @fileoverview added by tsickle
1104 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1105 */
1106/** @type {?} */
1107const initialState = {
1108 status: "pristine",
1109 data: []
1110};
1111/**
1112 * @param {?=} state
1113 * @param {?=} action
1114 * @return {?}
1115 */
1116function reducer(state = initialState, action) {
1117 switch (action.type) {
1118 case FormsListActionTypes.FORMS_LIST: {
1119 return Object.assign({}, state, { status: "dirty" });
1120 }
1121 case FormsListActionTypes.FORMS_LIST_START: {
1122 return Object.assign({}, state, { status: "pending" });
1123 }
1124 case FormsListActionTypes.FORMS_LIST_SUCCEED: {
1125 return Object.assign({}, state, { data: action.payload, status: "succeed" });
1126 }
1127 case FormsListActionTypes.FORMS_LIST_FAILED: {
1128 return Object.assign({}, state, { status: "failed" });
1129 }
1130 case FormsListActionTypes.FORM_SCHEMA_UPDATE: {
1131 /** @type {?} */
1132 const data = state.data.concat();
1133 /** @type {?} */
1134 var entityIdx = state.data.findIndex(form => form._id == action.payload._id);
1135 if (entityIdx > -1) {
1136 data[entityIdx] = Object.assign({}, data[entityIdx], action.payload);
1137 }
1138 else {
1139 data.push(action.payload);
1140 }
1141 return Object.assign({}, state, { data: data });
1142 }
1143 case FormsListActionTypes.ADD_FORM_SCHEMA: {
1144 /** @type {?} */
1145 const data = state.data.concat();
1146 /** @type {?} */
1147 var entityIdx = state.data.findIndex(form => form._id == action.payload._id);
1148 if (entityIdx > -1) {
1149 data[entityIdx] = Object.assign({}, data[entityIdx], action.payload);
1150 }
1151 else {
1152 data.push(action.payload);
1153 }
1154 return Object.assign({}, state, { data: data });
1155 }
1156 case FormsListActionTypes.FORM_SCHEMA_FETCHED: {
1157 /** @type {?} */
1158 const data = state.data.concat();
1159 /** @type {?} */
1160 var entityIdx = state.data.findIndex(form => form._id == action.payload._id);
1161 if (entityIdx > -1) {
1162 data[entityIdx] = Object.assign({}, data[entityIdx], action.payload);
1163 }
1164 else {
1165 data.push(action.payload);
1166 }
1167 return Object.assign({}, state, { data: data });
1168 }
1169 default: {
1170 return state;
1171 }
1172 }
1173}
1174
1175/**
1176 * @fileoverview added by tsickle
1177 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1178 */
1179/** @type {?} */
1180const FormReducers = {
1181 list: reducer
1182};
1183
1184/**
1185 * @fileoverview added by tsickle
1186 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1187 */
1188class FormGroupComponent {
1189 constructor() {
1190 this.noHeader = false;
1191 this.changes = new EventEmitter();
1192 this.delete = new EventEmitter();
1193 }
1194 /**
1195 * @return {?}
1196 */
1197 changed() {
1198 this.changes.emit();
1199 }
1200 /**
1201 * @param {?} root
1202 * @return {?}
1203 */
1204 addFormGroup(root) {
1205 /** @type {?} */
1206 const group = new FieldConfig("group");
1207 group.fields = [];
1208 root.fields.push(group);
1209 this.schema.id = this.schema.id + 1;
1210 return group;
1211 }
1212 /**
1213 * @param {?} root
1214 * @return {?}
1215 */
1216 addFormArray(root) {
1217 /** @type {?} */
1218 const array = new FieldConfig("array");
1219 array.fields = [];
1220 root.fields.push(array);
1221 return array;
1222 }
1223 /**
1224 * @param {?} root
1225 * @return {?}
1226 */
1227 addFormControl(root) {
1228 /** @type {?} */
1229 const control = new FieldConfig("control");
1230 root.fields.push(control);
1231 return control;
1232 }
1233 /**
1234 * @param {?} idx
1235 * @return {?}
1236 */
1237 deleteFormGroup(idx) {
1238 this.schema.fields.splice(idx, 1);
1239 }
1240}
1241FormGroupComponent.decorators = [
1242 { type: Component, args: [{
1243 selector: "app-form-group",
1244 template: "<div>\r\n\r\n <mat-form-field *ngIf=\"!noHeader\">\r\n <input matInput [(ngModel)]=\"schema.name\" placeholder=\"Name\">\r\n </mat-form-field>\r\n\r\n <mat-form-field *ngIf=\"!noHeader\">\r\n <input matInput [(ngModel)]=\"schema.title\" placeholder=\"\u0639\u0646\u0648\u0627\u0646\">\r\n </mat-form-field>\r\n\r\n <div class=\"button-row\">\r\n <button mat-button color=\"primary\" (click)=\"addFormGroup(schema)\"> addFormGroup </button>\r\n <button mat-button color=\"primary\" (click)=\"addFormArray(schema)\"> addFormArray </button>\r\n <button mat-button color=\"primary\" (click)=\"addFormControl(schema)\">addFormControl</button>\r\n </div>\r\n\r\n <div *ngFor=\"let field of schema.fields;let i = index\">\r\n <div [ngSwitch]=\"field.type\">\r\n <app-form-group *ngSwitchCase=\"'group'\" [schema]=\"field\" (change)=\"changed()\"></app-form-group>\r\n <!-- <app-form-array *ngSwitchCase=\"'array'\" [schema]=\"field\" (change)=\"changed()\"></app-form-array> -->\r\n <app-form-control *ngSwitchCase=\"'control'\" [schema]=\"field\" (changes)=\"changed()\" (delete)=\"deleteFormGroup(i)\"></app-form-control>\r\n </div>\r\n </div>\r\n</div>"
1245 }] }
1246];
1247/** @nocollapse */
1248FormGroupComponent.ctorParameters = () => [];
1249FormGroupComponent.propDecorators = {
1250 schema: [{ type: Input }],
1251 noHeader: [{ type: Input }],
1252 changes: [{ type: Output }],
1253 delete: [{ type: Output }]
1254};
1255
1256/**
1257 * @fileoverview added by tsickle
1258 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1259 */
1260class FormArrayComponent {
1261 constructor() {
1262 this.changes = new EventEmitter();
1263 }
1264 /**
1265 * @return {?}
1266 */
1267 changed() {
1268 this.changes.emit();
1269 }
1270 /**
1271 * @param {?} root
1272 * @return {?}
1273 */
1274 addFormGroup(root) {
1275 /** @type {?} */
1276 const group = new FieldConfig("group");
1277 group.fields = [];
1278 root.fields.push(group);
1279 return group;
1280 }
1281 /**
1282 * @param {?} root
1283 * @return {?}
1284 */
1285 addFormArray(root) {
1286 /** @type {?} */
1287 const array = new FieldConfig("array");
1288 array.fields = [];
1289 root.fields.push(array);
1290 return array;
1291 }
1292 /**
1293 * @param {?} root
1294 * @return {?}
1295 */
1296 addFormControl(root) {
1297 /** @type {?} */
1298 const control = new FieldConfig("control");
1299 root.fields.push(control);
1300 return control;
1301 }
1302}
1303FormArrayComponent.decorators = [
1304 { type: Component, args: [{
1305 selector: "app-form-array",
1306 template: "<mat-card>\r\n <mat-card-content>\r\n <mat-form-field>\r\n <input matInput [(ngModel)]=\"schema.name\" placeholder=\"Name\">\r\n </mat-form-field>\r\n \r\n <div class=\"button-row\">\r\n <button mat-button color=\"primary\" (click)=\"addFormGroup(schema)\">addFormGroup</button>\r\n <button mat-button color=\"primary\" (click)=\"addFormArray(schema)\">addFormArray</button>\r\n <!-- <button mat-button color=\"primary\" (click)=\"addFormControl(schema)\">addFormControl</button> -->\r\n </div>\r\n \r\n <div *ngFor=\"let field of schema.fields\">\r\n <div [ngSwitch]=\"field.type\">\r\n <app-form-group *ngSwitchCase=\"'group'\" [schema]=\"field\" (changes)=\"changed()\"></app-form-group>\r\n <app-form-array *ngSwitchCase=\"'array'\" [schema]=\"field\" (changes)=\"changed()\"></app-form-array>\r\n <!-- <app-form-control *ngSwitchCase=\"'control'\" [schema]=\"field\" (change)=\"changed($event)\"></app-form-control> -->\r\n </div>\r\n </div>\r\n \r\n </mat-card-content>\r\n</mat-card>"
1307 }] }
1308];
1309/** @nocollapse */
1310FormArrayComponent.ctorParameters = () => [];
1311FormArrayComponent.propDecorators = {
1312 schema: [{ type: Input }],
1313 changes: [{ type: Output }]
1314};
1315
1316/**
1317 * @fileoverview added by tsickle
1318 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1319 */
1320class FormControlComponent {
1321 constructor() {
1322 this.changes = new EventEmitter();
1323 this.delete = new EventEmitter();
1324 this.width = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
1325 this.options = new FormArray([
1326 new FormGroup({
1327 key: new FormControl(),
1328 value: new FormControl()
1329 })
1330 ]);
1331 this.tableOptions = new FormGroup({
1332 dataEndpoint: new FormControl("")
1333 });
1334 }
1335 /**
1336 * @return {?}
1337 */
1338 changed() {
1339 if ([this.schema.name, this.schema.title, this.schema.inputType].some(item => !item))
1340 return true;
1341 if (this.schema.inputType == "table") {
1342 this.schema.options = this.tableOptions.value;
1343 }
1344 else if (this.schema.inputType == "select") {
1345 this.schema.options = this.options.value;
1346 }
1347 this.changes.emit();
1348 }
1349 /**
1350 * @return {?}
1351 */
1352 addOption() {
1353 this.options.push(new FormGroup({
1354 key: new FormControl(),
1355 value: new FormControl()
1356 }));
1357 }
1358 /**
1359 * @param {?} i
1360 * @return {?}
1361 */
1362 removeOption(i) {
1363 this.options.controls.splice(i, 1);
1364 }
1365 /**
1366 * @return {?}
1367 */
1368 insertOptions() {
1369 this.schema.options = this.options.value;
1370 }
1371}
1372FormControlComponent.decorators = [
1373 { type: Component, args: [{
1374 selector: "app-form-control",
1375 template: "<mat-expansion-panel>\r\n <mat-expansion-panel-header>\r\n <mat-panel-title fxLayout=\"row\" fxLayoutAlign=\"start center\">\r\n <button mat-icon-button (click)=\"delete.emit()\">\r\n <mat-icon aria-label=\"icon-button\">delete_forever</mat-icon>\r\n </button>\r\n <span>{{schema.name}}</span>\r\n\r\n </mat-panel-title>\r\n </mat-expansion-panel-header>\r\n <div fxLayout=\"row wrap\" fxLayoutGap=\"10px\">\r\n <mat-form-field fxFlex>\r\n <input matInput [(ngModel)]=\"schema.name\" (change)=\"changed()\" placeholder=\"Name\">\r\n </mat-form-field>\r\n\r\n <mat-form-field fxFlex>\r\n <input matInput [(ngModel)]=\"schema.title\" (change)=\"changed()\" placeholder=\"Placeholder\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field fxFlex>\r\n <mat-select [(ngModel)]=\"schema.inputType\" (change)=\"changed()\" placeholder=\"Input Type\">\r\n <mat-option value=\"table\">table</mat-option>\r\n <mat-option value=\"select\">select</mat-option>\r\n <mat-option value=\"text\">text</mat-option>\r\n <mat-option value=\"number\">number</mat-option>\r\n <mat-option value=\"email\">email</mat-option>\r\n <mat-option value=\"color\">color</mat-option>\r\n <mat-option value=\"radio\">radio</mat-option>\r\n <mat-option value=\"checkbox\">checkbox</mat-option>\r\n <mat-option value=\"checkbox\">captcha</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n <div fxLayout=\"row wrap\" fxLayoutGap=\"10px\">\r\n <mat-form-field fxFlex>\r\n <input matInput [(ngModel)]=\"schema.value\" (change)=\"changed()\" placeholder=\"Value\" />\r\n </mat-form-field>\r\n\r\n <mat-form-field fxFlex>\r\n <mat-select [(ngModel)]=\"schema.width\" (change)=\"changed()\" placeholder=\"width\">\r\n <mat-option *ngFor=\"let item of width\" [value]=\"item\">{{item}}</mat-option>\r\n </mat-select>\r\n </mat-form-field>\r\n </div>\r\n <div fxLayout=\"column\" fxLayoutGap=\"10px\">\r\n <div *ngIf=\"schema.inputType=='table'\" [formGroup]=\"tableOptions\">\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" formControlName=\"dataEndpoint\" placeholder=\"dataEndpoint\" />\r\n </mat-form-field>\r\n </div>\r\n\r\n <div *ngIf=\"schema.inputType=='select'\">\r\n [options]\r\n <button (click)=\"addOption()\">+</button>\r\n <button (click)=\"insertOptions()\">insert</button>\r\n <div *ngFor=\"let option of options.controls;index as i\">\r\n {{i}}\r\n <div [formGroup]=\"options.controls[i]\">\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" formControlName=\"key\" placeholder=\"key\" />\r\n </mat-form-field>\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" formControlName=\"value\" placeholder=\"value\" />\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n </div>\r\n <br />\r\n <mat-card fxLayout=\"column\">\r\n <mat-slide-toggle (change)=\"changed()\" [(ngModel)]=\"schema.validator.required.active\">\u0627\u062C\u0628\u0627\u0631\u06CC</mat-slide-toggle>\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" [(ngModel)]=\"schema.validator.required.message\" placeholder=\"\u067E\u06CC\u063A\u0627\u0645\" />\r\n </mat-form-field>\r\n </mat-card>\r\n <mat-card fxLayout=\"column\">\r\n <mat-slide-toggle (change)=\"changed()\" [(ngModel)]=\"schema.validator.email.active\">\u0627\u06CC\u0645\u06CC\u0644</mat-slide-toggle>\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" [(ngModel)]=\"schema.validator.email.message\" placeholder=\"\u067E\u06CC\u063A\u0627\u0645\" />\r\n </mat-form-field>\r\n </mat-card>\r\n <mat-card fxLayout=\"column\">\r\n <mat-slide-toggle (change)=\"changed()\" [(ngModel)]=\"schema.validator.minlength.active\">\u062D\u062F\u0627\u0642\u0644 \u062A\u0639\u062F\u0627\u062F \u06A9\u0627\u0631\u0627\u06A9\u062A\u0631</mat-slide-toggle>\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" [(ngModel)]=\"schema.validator.minlength.message\" placeholder=\"\u067E\u06CC\u063A\u0627\u0645\" />\r\n </mat-form-field>\r\n <mat-form-field>\r\n <input matInput (change)=\"changed()\" [(ngModel)]=\"schema.validator.minlength.value\" placeholder=\"\u062A\u0639\u062F\u0627\u062F \u062D\u062F\u0627\u0642\u0644 \u06A9\u0627\u0631\u0627\u06A9\u062A\u0631\" />\r\n </mat-form-field>\r\n </mat-card>\r\n </div>\r\n</mat-expansion-panel>"
1376 }] }
1377];
1378/** @nocollapse */
1379FormControlComponent.ctorParameters = () => [];
1380FormControlComponent.propDecorators = {
1381 schema: [{ type: Input }],
1382 changes: [{ type: Output }],
1383 delete: [{ type: Output }]
1384};
1385
1386/**
1387 * @fileoverview added by tsickle
1388 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1389 */
1390/** @enum {string} */
1391var EditFormActionTypes = {
1392 EDIT_FORM: "[FORM][EDIT] EDIT_FORM",
1393 EDIT_FORM_START: "[FORM][EDIT] EDIT_FORM_START",
1394 EDIT_FORM_SUCCEED: "[FORM][EDIT] EDIT_FORM_SUCCEED",
1395 EDIT_FORM_FAILED: "[FORM][EDIT] EDIT_FORM_FAILED",
1396};
1397class EditFormAction {
1398 /**
1399 * @param {?} payload
1400 */
1401 constructor(payload) {
1402 this.payload = payload;
1403 this.type = EditFormActionTypes.EDIT_FORM;
1404 }
1405}
1406class EditFormStartAction {
1407 /**
1408 * @param {?} payload
1409 */
1410 constructor(payload) {
1411 this.payload = payload;
1412 this.type = EditFormActionTypes.EDIT_FORM_START;
1413 }
1414}
1415class EditFormSucceedAction {
1416 /**
1417 * @param {?} payload
1418 */
1419 constructor(payload) {
1420 this.payload = payload;
1421 this.type = EditFormActionTypes.EDIT_FORM_SUCCEED;
1422 }
1423}
1424class EditFormFailedAction {
1425 constructor() {
1426 this.type = EditFormActionTypes.EDIT_FORM_FAILED;
1427 }
1428}
1429
1430/**
1431 * @fileoverview added by tsickle
1432 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1433 */
1434/** @enum {string} */
1435var AddFormActionTypes = {
1436 ADD_FORM: "[FORM][ADD] ADD_FORM_PROFILE",
1437 ADD_FORM_START: "[FORM][ADD] ADD_FORM_START",
1438 ADD_FORM_SUCCEED: "[FORM][ADD] ADD_FORM_SUCCEED",
1439 ADD_FORM_FAILED: "[FORM][ADD] ADD_FORM_FAILED",
1440};
1441class AddFormAction {
1442 /**
1443 * @param {?} payload
1444 */
1445 constructor(payload) {
1446 this.payload = payload;
1447 this.type = AddFormActionTypes.ADD_FORM;
1448 }
1449}
1450class AddFormStartAction {
1451 /**
1452 * @param {?} payload
1453 */
1454 constructor(payload) {
1455 this.payload = payload;
1456 this.type = AddFormActionTypes.ADD_FORM_START;
1457 }
1458}
1459class AddFormSucceedAction {
1460 constructor() {
1461 this.type = AddFormActionTypes.ADD_FORM_SUCCEED;
1462 }
1463}
1464class AddFormFailedAction {
1465 constructor() {
1466 this.type = AddFormActionTypes.ADD_FORM_FAILED;
1467 }
1468}
1469
1470/**
1471 * @fileoverview added by tsickle
1472 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1473 */
1474class AddFormContainerComponent {
1475 /**
1476 * @param {?} store
1477 * @param {?} service
1478 */
1479 constructor(store, service) {
1480 this.store = store;
1481 this.service = service;
1482 }
1483 /**
1484 * @return {?}
1485 */
1486 ngOnInit() {
1487 this.schema = new FormSchemaModel();
1488 this.schema.init();
1489 this.store.dispatch(new AddFormSchemaAction(this.schema));
1490 }
1491 /**
1492 * @param {?} form
1493 * @return {?}
1494 */
1495 add(form) {
1496 this.store.dispatch(new AddFormAction(form));
1497 }
1498 /**
1499 * @param {?} form
1500 * @return {?}
1501 */
1502 update_schema(form) {
1503 this.store.dispatch(new UpdateFormSchemaAction(form));
1504 }
1505}
1506AddFormContainerComponent.decorators = [
1507 { type: Component, args: [{
1508 template: `<ngs-form-add
1509 [schema]="schema"
1510 (changes)="update_schema($event)"
1511 (submited)=add($event)
1512 ></ngs-form-add>`
1513 }] }
1514];
1515/** @nocollapse */
1516AddFormContainerComponent.ctorParameters = () => [
1517 { type: Store },
1518 { type: FormService }
1519];
1520
1521/**
1522 * @fileoverview added by tsickle
1523 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1524 */
1525
1526/**
1527 * @fileoverview added by tsickle
1528 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1529 */
1530class EditFormContainerComponent extends AddFormContainerComponent {
1531 /**
1532 * @param {?} service
1533 * @param {?} route
1534 * @param {?} store
1535 */
1536 constructor(service, route, store) {
1537 super(store, service);
1538 this.service = service;
1539 this.route = route;
1540 this.store = store;
1541 this.formGroup = EditFormApiModel.Request.formGroup;
1542 }
1543 /**
1544 * @return {?}
1545 */
1546 ngOnInit() {
1547 this.route.params
1548 .map((params) => params["_id"])
1549 .subscribe((id) => this.store.dispatch(new GetFormSchemaAction(id)));
1550 this.route.params
1551 .map((params) => params["_id"])
1552 .switchMap((id) => this.service.selectFormById(id))
1553 .filter((data) => data != null)
1554 .take(1)
1555 .subscribe((formSchema) => {
1556 this.schema = formSchema;
1557 this.formGroup.patchValue(formSchema);
1558 });
1559 }
1560 /**
1561 * @param {?} data
1562 * @return {?}
1563 */
1564 update(data) {
1565 this.store.dispatch(new EditFormAction(data));
1566 }
1567}
1568EditFormContainerComponent.decorators = [
1569 { type: Component, args: [{
1570 template: `<edit-form
1571 [formGroup]="formGroup"
1572 [schema]="schema"
1573 (changes)="update_schema($event)"
1574 (submited)="update($event)">
1575 </edit-form>`
1576 }] }
1577];
1578/** @nocollapse */
1579EditFormContainerComponent.ctorParameters = () => [
1580 { type: FormService },
1581 { type: ActivatedRoute },
1582 { type: Store }
1583];
1584
1585/**
1586 * @fileoverview added by tsickle
1587 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1588 */
1589class AddFormComponent {
1590 constructor() {
1591 this.formGroup = AddFormApiModel.Request.formGroup;
1592 this.submited = new EventEmitter();
1593 this.changes = new EventEmitter();
1594 }
1595 /**
1596 * @return {?}
1597 */
1598 emit() {
1599 this.formGroup.patchValue({ form: this.schema.form });
1600 this.submited.emit(this.formGroup.value);
1601 }
1602 /**
1603 * @return {?}
1604 */
1605 changed() {
1606 this.formGroup.patchValue({ form: this.schema.form });
1607 this.changes.emit(this.formGroup.value);
1608 }
1609 /**
1610 * @param {?} $event
1611 * @return {?}
1612 */
1613 changeOrder($event) { }
1614 /**
1615 * @param {?} root
1616 * @return {?}
1617 */
1618 addFormGroup(root) {
1619 /** @type {?} */
1620 const group = new FieldConfig("group");
1621 group.fields = [];
1622 root.fields.push(group);
1623 return group;
1624 }
1625 /**
1626 * @param {?} root
1627 * @return {?}
1628 */
1629 addFormArray(root) {
1630 /** @type {?} */
1631 const array = new FieldConfig("array");
1632 array.fields = [];
1633 root.fields.push(array);
1634 return array;
1635 }
1636 /**
1637 * @param {?} root
1638 * @return {?}
1639 */
1640 addFormControl(root) {
1641 /** @type {?} */
1642 const control = new FieldConfig("control");
1643 root.fields.push(control);
1644 return control;
1645 }
1646}
1647AddFormComponent.decorators = [
1648 { type: Component, args: [{
1649 selector: "ngs-form-add",
1650 template: "<div fxLayout=\"row\" *ngIf=\"schema\">\r\n <div [fxFlex]=\"50\" *ngIf=\"formGroup\">\r\n <form [formGroup]=\"formGroup\">\r\n <mat-card>\r\n <mat-card-title>\u0627\u06CC\u062C\u0627\u062F \u0641\u0631\u0645 \u062C\u062F\u06CC\u062F</mat-card-title>\r\n <mat-card-content>\r\n <mat-form-field>\r\n <input type=\"text\" matInput (change)=\"changed()\" placeholder=\"\u0646\u0627\u0645 \u0641\u0631\u0645\" formControlName=\"name\">\r\n </mat-form-field>\r\n <!-- <div class=\"button-row\">\r\n <button mat-button color=\"primary\" (click)=\"addFormGroup(schema.form)\">Add form group</button>\r\n <button mat-button color=\"primary\" (click)=\"addFormArray(schema.form)\">Add form array</button>\r\n <button mat-button color=\"primary\" (click)=\"addFormControl(schema.form)\">Add form control</button>\r\n </div> -->\r\n </mat-card-content>\r\n </mat-card>\r\n <mat-card>\r\n <mat-card-content>\r\n <div [ngSwitch]=\"schema.form?.type\">\r\n <app-form-group *ngSwitchCase=\"'group'\" [schema]=\"schema.form\" noHeader=\"true\" (changes)=\"changed()\"></app-form-group>\r\n <app-form-array *ngSwitchCase=\"'array'\" [schema]=\"schema.form\" (changes)=\"changed()\"></app-form-array>\r\n </div>\r\n </mat-card-content>\r\n <mat-card-actions>\r\n <!-- <button mat-raised-button color=\"primary\" (click)=\"form.generate(schema)\">\u0627\u06CC\u062C\u0627\u062F \u0641\u0631\u0645</button> -->\r\n <button mat-raised-button color=\"primary\" (click)=\"emit()\" type=\"submit\">\u062B\u0628\u062A</button>\r\n </mat-card-actions>\r\n\r\n <div [formGroup]=\"$any(formGroup.controls.events).controls.accept\">\r\n <mat-slide-toggle (change)=\"changed()\" formControlName=\"show\">\u0646\u0645\u0627\u06CC\u0634 \u062A\u0627\u06CC\u06CC\u062F</mat-slide-toggle>\r\n <mat-form-field>\r\n <input type=\"text\" (change)=\"changed()\" matInput placeholder=\"\u0645\u062A\u0646 \u062A\u0627\u06CC\u06CC\u062F\" formControlName=\"text\">\r\n </mat-form-field>\r\n </div>\r\n <div [formGroup]=\"$any(formGroup.controls.events).controls.cancel\">\r\n <mat-slide-toggle (change)=\"changed()\" formControlName=\"show\">\u0646\u0645\u0627\u06CC\u0634 \u0627\u0646\u0635\u0631\u0627\u0641</mat-slide-toggle>\r\n <mat-form-field>\r\n <input type=\"text\" (change)=\"changed()\" matInput placeholder=\"\u0645\u062A\u0646 \u0627\u0646\u0635\u0631\u0627\u0641\" formControlName=\"text\">\r\n </mat-form-field>\r\n </div>\r\n\r\n </mat-card>\r\n </form>\r\n </div>\r\n <div [fxFlex]=\"50\">\r\n <ngs-form-view [local]='true' [id]=\"schema._id\"></ngs-form-view>\r\n </div>\r\n</div>"
1651 }] }
1652];
1653AddFormComponent.propDecorators = {
1654 schema: [{ type: Input }],
1655 formGroup: [{ type: Input }],
1656 submited: [{ type: Output }],
1657 changes: [{ type: Output }]
1658};
1659
1660/**
1661 * @fileoverview added by tsickle
1662 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1663 */
1664
1665/**
1666 * @fileoverview added by tsickle
1667 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1668 */
1669class EditFormComponent extends AddFormComponent {
1670 /**
1671 * @return {?}
1672 */
1673 emit() {
1674 if (!this.formGroup.valid)
1675 return;
1676 return this.submited.emit(this.formGroup.value);
1677 }
1678}
1679EditFormComponent.decorators = [
1680 { type: Component, args: [{
1681 selector: "edit-form",
1682 template: "<div fxLayout=\"row\" fxLayoutAlign=\"center\" fxLayoutGap=\"25px\" class=\"main-container\">\r\n\r\n <div class=\"content-action\">\r\n <mat-card fxLayout=\"column\" fxLayoutGap=\"10px\" fxLayoutAlign=\"start\" class=\"with-sticky-action\">\r\n <div fxLayout=\"row wrap\" *ngIf=\"schema\" fxFlex=\"100\" fxLayoutAlign=\"start start\" fxLayoutAlign.lt-md=\"center\">\r\n <div fxFlex.gt-md=\"50\" fxFlex.lt-md=\"100\" *ngIf=\"formGroup\">\r\n <form [formGroup]=\"formGroup\">\r\n <mat-card>\r\n <mat-card-title>\u0627\u06CC\u062C\u0627\u062F \u0641\u0631\u0645 \u062C\u062F\u06CC\u062F</mat-card-title>\r\n <mat-card-content>\r\n <mat-form-field>\r\n <input type=\"text\" matInput (change)=\"changed()\" placeholder=\"\u0646\u0627\u0645 \u0641\u0631\u0645\" formControlName=\"name\">\r\n </mat-form-field>\r\n <!-- <div class=\"button-row\">\r\n <button mat-button color=\"primary\" (click)=\"addFormGroup(schema.form)\">Add form group</button>\r\n <button mat-button color=\"primary\" (click)=\"addFormArray(schema.form)\">Add form array</button>\r\n <button mat-button color=\"primary\" (click)=\"addFormControl(schema.form)\">Add form control</button>\r\n </div> -->\r\n <mat-divider></mat-divider>\r\n <div [ngSwitch]=\"schema.form?.type\" class=\"schema-form\">\r\n <app-form-group *ngSwitchCase=\"'group'\" [schema]=\"schema.form\" noHeader=\"true\" (changes)=\"changed()\"></app-form-group>\r\n <app-form-array *ngSwitchCase=\"'array'\" [schema]=\"schema.form\" (changes)=\"changed()\"></app-form-array>\r\n </div>\r\n\r\n <mat-divider></mat-divider>\r\n <div class=\"form-buttons\" fxLayout=\"row wrap\" fxLayoutGap=\"10px\">\r\n\r\n <div fxLayout=\"column\" [formGroup]=\"$any(formGroup.controls.events).controls.accept\">\r\n <mat-slide-toggle (change)=\"changed()\" formControlName=\"show\">\u0646\u0645\u0627\u06CC\u0634 \u062A\u0627\u06CC\u06CC\u062F</mat-slide-toggle>\r\n <mat-form-field>\r\n <input type=\"text\" (change)=\"changed()\" matInput placeholder=\"\u0645\u062A\u0646 \u062A\u0627\u06CC\u06CC\u062F\" formControlName=\"text\">\r\n </mat-form-field>\r\n </div>\r\n <div fxLayout=\"column\" [formGroup]=\"$any(formGroup.controls.events).controls.cancel\">\r\n <mat-slide-toggle (change)=\"changed()\" formControlName=\"show\">\u0646\u0645\u0627\u06CC\u0634 \u0627\u0646\u0635\u0631\u0627\u0641</mat-slide-toggle>\r\n <mat-form-field>\r\n <input type=\"text\" (change)=\"changed()\" matInput placeholder=\"\u0645\u062A\u0646 \u0627\u0646\u0635\u0631\u0627\u0641\" formControlName=\"text\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n\r\n <mat-card-actions>\r\n <!-- <button mat-raised-button color=\"primary\" (click)=\"$any(form).generate(schema)\">\u0627\u06CC\u062C\u0627\u062F \u0641\u0631\u0645</button> -->\r\n <button mat-raised-button color=\"primary\" (click)=\"emit()\" type=\"submit\">\u062B\u0628\u062A</button>\r\n </mat-card-actions>\r\n\r\n </mat-card-content>\r\n </mat-card>\r\n </form>\r\n </div>\r\n <div fxFlex.gt-md=\"50\" fxFlex.lt-md=\"100\" fxLayoutAlign=\"center start\">\r\n <ngs-form-view [local]='true' [id]=\" schema._id\">\r\n </ngs-form-view>\r\n\r\n </div>\r\n </div>\r\n </mat-card>\r\n </div>\r\n</div>",
1683 styles: [".form-buttons,.schema-form{padding:25px 10px}"]
1684 }] }
1685];
1686EditFormComponent.propDecorators = {
1687 schema: [{ type: Input }]
1688};
1689
1690/**
1691 * @fileoverview added by tsickle
1692 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1693 */
1694class FormListContainerComponent {
1695 /**
1696 * @param {?} store
1697 */
1698 constructor(store) {
1699 this.store = store;
1700 this.data$ = this.store.select(state => state.form.list.data);
1701 }
1702 /**
1703 * @return {?}
1704 */
1705 ngOnInit() {
1706 this.store.dispatch(new FormsListAction());
1707 }
1708}
1709FormListContainerComponent.decorators = [
1710 { type: Component, args: [{
1711 template: `<form-list
1712 [data]="data$">
1713 </form-list>`
1714 }] }
1715];
1716/** @nocollapse */
1717FormListContainerComponent.ctorParameters = () => [
1718 { type: Store }
1719];
1720
1721/**
1722 * @fileoverview added by tsickle
1723 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1724 */
1725class FormListComponent {
1726}
1727FormListComponent.decorators = [
1728 { type: Component, args: [{
1729 selector: "form-list",
1730 template: "<div fxLayout=\"row\" fxLayoutAlign=\"center\" fxLayoutGap=\"25px\" class=\"main-container\">\r\n\r\n <div class=\"content-action\">\r\n <mat-card class=\"with-sticky-action\">\r\n <mat-card-header>\r\n <mat-card-title fxLayout=\"row\" fxLayoutGap=\"5px\">\r\n <mat-icon>assignment</mat-icon>\r\n <span>\u0645\u062F\u06CC\u0631\u06CC\u062A \u0641\u0631\u0645 \u0647\u0627</span>\r\n </mat-card-title>\r\n <mat-card-subtitle fxLayout=\"row\" fxLayoutAlign=\"space-between center\">\r\n <span>\r\n \u0634\u0627\u0645\u0644 \u062A\u0645\u0627\u0645\u06CC \u062F\u0631\u062E\u0648\u0627\u0633\u062A\u200C\u0647\u0627 \u0627\u0632 \u0642\u0628\u06CC\u0644 \u062F\u0627\u0626\u0631\u06CC\u060C \u062C\u0645\u0639\u200C\u0622\u0648\u0631\u06CC \u0648 ...\r\n </span>\r\n </mat-card-subtitle>\r\n </mat-card-header>\r\n\r\n <div fxLayout=\"row wrap\" fxLayoutGap=\"10px\" fxLayoutAlign=\"start\">\r\n\r\n <button fxFlex.lt-lg=\"19\" fxFlex.lg=\"24\" fxFlex.md=\"32\" fxFlex.sm=\"49\" fxFlex.xs=\"100\" class='link'\r\n mat-raised-button [routerLink]=\"['edit' , item._id]\" *ngFor=\"let item of (data$ | async)\">\r\n <div fxLayout='column' fxLayoutAlign='center center'>\r\n <mat-icon color='primary'>settings</mat-icon>\r\n <h3 class='title'>{{item.name}}</h3>\r\n </div>\r\n </button>\r\n\r\n </div>\r\n </mat-card>\r\n </div>\r\n</div>",
1731 styles: ["button.link{padding:25px 15px;margin:.5%;box-sizing:border-box}button mat-icon{font-size:34px;width:34px;height:34px}"]
1732 }] }
1733];
1734FormListComponent.propDecorators = {
1735 data$: [{ type: Input, args: ["data",] }]
1736};
1737
1738/**
1739 * @fileoverview added by tsickle
1740 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1741 */
1742class MainContainerComponent {
1743 /**
1744 * @param {?} route
1745 * @param {?} store
1746 */
1747 constructor(route, store) {
1748 this.route = route;
1749 this.store = store;
1750 }
1751}
1752MainContainerComponent.decorators = [
1753 { type: Component, args: [{
1754 template: "<router-outlet></router-outlet>"
1755 }] }
1756];
1757/** @nocollapse */
1758MainContainerComponent.ctorParameters = () => [
1759 { type: ActivatedRoute },
1760 { type: Store }
1761];
1762
1763/**
1764 * @fileoverview added by tsickle
1765 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1766 */
1767class AddFormEffects {
1768 /**
1769 * @param {?} actions$
1770 * @param {?} router
1771 * @param {?} service
1772 */
1773 constructor(actions$, router, service) {
1774 this.actions$ = actions$;
1775 this.router = router;
1776 this.service = service;
1777 this.AddForm$ = this.actions$
1778 .ofType(AddFormActionTypes.ADD_FORM)
1779 .pipe(map(action => action.payload), map(data => new AddFormStartAction(data)));
1780 this.AddFormStart$ = this.actions$
1781 .ofType(AddFormActionTypes.ADD_FORM_START)
1782 .pipe(map(action => action.payload), switchMap((data) => this.service.add(data)), map(res => new AddFormSucceedAction()), catchError(() => of(new AddFormFailedAction())));
1783 }
1784}
1785AddFormEffects.decorators = [
1786 { type: Injectable }
1787];
1788/** @nocollapse */
1789AddFormEffects.ctorParameters = () => [
1790 { type: Actions },
1791 { type: Router },
1792 { type: FormService }
1793];
1794__decorate([
1795 Effect(),
1796 __metadata("design:type", Object)
1797], AddFormEffects.prototype, "AddForm$", void 0);
1798__decorate([
1799 Effect(),
1800 __metadata("design:type", Object)
1801], AddFormEffects.prototype, "AddFormStart$", void 0);
1802
1803/**
1804 * @fileoverview added by tsickle
1805 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1806 */
1807
1808/**
1809 * @fileoverview added by tsickle
1810 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1811 */
1812
1813/**
1814 * @fileoverview added by tsickle
1815 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1816 */
1817class FormsListEffects {
1818 /**
1819 * @param {?} actions$
1820 * @param {?} router
1821 * @param {?} service
1822 */
1823 constructor(actions$, router, service) {
1824 this.actions$ = actions$;
1825 this.router = router;
1826 this.service = service;
1827 this.EditProfileRequest$ = this.actions$.ofType(FormsListActionTypes.FORMS_LIST).map(data => new FormsListStartAction());
1828 this.GetForm$ = this.actions$
1829 .ofType(FormsListActionTypes.GET_FORM_SCHEMA)
1830 .pipe(map(action => action.payload), switchMap(id => this.service.get(id)), map(formSchema => new FormSchemaFechedAction(formSchema)));
1831 this.get_forms_list$ = this.actions$
1832 .ofType(FormsListActionTypes.FORMS_LIST_START)
1833 .pipe(switchMap((data) => this.service.getList()), map(res => new FormsListSucceedAction(res)), catchError(() => of(new FormsListFailedAction())));
1834 }
1835}
1836FormsListEffects.decorators = [
1837 { type: Injectable }
1838];
1839/** @nocollapse */
1840FormsListEffects.ctorParameters = () => [
1841 { type: Actions },
1842 { type: Router },
1843 { type: FormService }
1844];
1845__decorate([
1846 Effect(),
1847 __metadata("design:type", Object)
1848], FormsListEffects.prototype, "EditProfileRequest$", void 0);
1849__decorate([
1850 Effect(),
1851 __metadata("design:type", Object)
1852], FormsListEffects.prototype, "GetForm$", void 0);
1853__decorate([
1854 Effect(),
1855 __metadata("design:type", Object)
1856], FormsListEffects.prototype, "get_forms_list$", void 0);
1857
1858/**
1859 * @fileoverview added by tsickle
1860 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1861 */
1862
1863/**
1864 * @fileoverview added by tsickle
1865 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1866 */
1867class EditFormEffects {
1868 /**
1869 * @param {?} actions$
1870 * @param {?} router
1871 * @param {?} service
1872 */
1873 constructor(actions$, router, service) {
1874 this.actions$ = actions$;
1875 this.router = router;
1876 this.service = service;
1877 this.EditForm$ = this.actions$
1878 .ofType(EditFormActionTypes.EDIT_FORM)
1879 .pipe(map(action => action.payload), map(data => new EditFormStartAction(data)));
1880 this.EditFormStart$ = this.actions$
1881 .ofType(EditFormActionTypes.EDIT_FORM_START)
1882 .pipe(map(action => action.payload), switchMap((data) => this.service.update(data)), map(formSchema => new EditFormSucceedAction(formSchema)), catchError(() => of(new EditFormFailedAction())));
1883 this.UpdateFormsListStart$ = this.actions$
1884 .ofType(EditFormActionTypes.EDIT_FORM_SUCCEED)
1885 .pipe(map(action => action.payload), map(formSchema => new UpdateFormSchemaAction(formSchema)));
1886 }
1887}
1888EditFormEffects.decorators = [
1889 { type: Injectable }
1890];
1891/** @nocollapse */
1892EditFormEffects.ctorParameters = () => [
1893 { type: Actions },
1894 { type: Router },
1895 { type: FormService }
1896];
1897__decorate([
1898 Effect(),
1899 __metadata("design:type", Object)
1900], EditFormEffects.prototype, "EditForm$", void 0);
1901__decorate([
1902 Effect(),
1903 __metadata("design:type", Object)
1904], EditFormEffects.prototype, "EditFormStart$", void 0);
1905__decorate([
1906 Effect(),
1907 __metadata("design:type", Object)
1908], EditFormEffects.prototype, "UpdateFormsListStart$", void 0);
1909
1910/**
1911 * @fileoverview added by tsickle
1912 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1913 */
1914/** @type {?} */
1915const routes = [
1916 {
1917 path: "form",
1918 component: MainContainerComponent,
1919 children: [
1920 {
1921 path: "add",
1922 component: AddFormContainerComponent
1923 },
1924 {
1925 path: "edit/:_id",
1926 component: EditFormContainerComponent
1927 },
1928 {
1929 path: "",
1930 component: FormListContainerComponent
1931 }
1932 ]
1933 }
1934];
1935/** @type {?} */
1936const RoutingModule = RouterModule.forChild(routes);
1937
1938/**
1939 * @fileoverview added by tsickle
1940 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1941 */
1942/** @enum {string} */
1943var CaptchaActionTypes = {
1944 GET_CAPTCHA: "[CAPTCHA][GET] GET_CAPTCHA",
1945 GET_CAPTCHA_START: "[CAPTCHA][GET] GET_CAPTCHA_START",
1946 GET_CAPTCHA_SUCCEED: "[CAPTCHA][GET] GET_CAPTCHA_SUCCEED",
1947 GET_CAPTCHA_FAILED: "[CAPTCHA][GET] GET_CAPTCHA_FAILED",
1948};
1949class GetCaptchaStartAction {
1950 /**
1951 * @param {?} payload
1952 */
1953 constructor(payload) {
1954 this.payload = payload;
1955 this.type = CaptchaActionTypes.GET_CAPTCHA_START;
1956 }
1957}
1958class GetCaptchaSucceedAction {
1959 constructor() {
1960 this.type = CaptchaActionTypes.GET_CAPTCHA_SUCCEED;
1961 }
1962}
1963class GetCaptchaFailedAction {
1964 constructor() {
1965 this.type = CaptchaActionTypes.GET_CAPTCHA_FAILED;
1966 }
1967}
1968
1969/**
1970 * @fileoverview added by tsickle
1971 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1972 */
1973class CaptchaEffects {
1974 /**
1975 * @param {?} actions$
1976 * @param {?} router
1977 * @param {?} service
1978 */
1979 constructor(actions$, router, service) {
1980 this.actions$ = actions$;
1981 this.router = router;
1982 this.service = service;
1983 this.GetCaptcha$ = this.actions$
1984 .ofType(CaptchaActionTypes.GET_CAPTCHA)
1985 .pipe(map(action => action.payload), map(data => new GetCaptchaStartAction(data)));
1986 this.AddFormStart$ = this.actions$
1987 .ofType(CaptchaActionTypes.GET_CAPTCHA_START)
1988 .pipe(map(action => action.payload), switchMap((data) => this.service.getCaptcha()), map(res => new GetCaptchaSucceedAction()), catchError(() => of(new GetCaptchaFailedAction())));
1989 }
1990}
1991CaptchaEffects.decorators = [
1992 { type: Injectable }
1993];
1994/** @nocollapse */
1995CaptchaEffects.ctorParameters = () => [
1996 { type: Actions },
1997 { type: Router },
1998 { type: FormCaptchaService }
1999];
2000__decorate([
2001 Effect(),
2002 __metadata("design:type", Object)
2003], CaptchaEffects.prototype, "GetCaptcha$", void 0);
2004__decorate([
2005 Effect(),
2006 __metadata("design:type", Object)
2007], CaptchaEffects.prototype, "AddFormStart$", void 0);
2008
2009/**
2010 * @fileoverview added by tsickle
2011 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2012 */
2013class NgsFormModule {
2014 /**
2015 * @param {?=} config
2016 * @return {?}
2017 */
2018 static forRoot(config) {
2019 return {
2020 ngModule: RootNgsFormModule,
2021 providers: [{ provide: MODULE_CONFIG_TOKEN, useValue: config }, FormConfigurationService]
2022 };
2023 }
2024}
2025NgsFormModule.decorators = [
2026 { type: NgModule, args: [{
2027 imports: [
2028 HttpClientModule,
2029 FormsModule,
2030 RouterModule,
2031 CommonModule,
2032 MatExpansionModule,
2033 MatSnackBarModule,
2034 MatIconModule,
2035 MatDatepickerModule,
2036 MatButtonModule,
2037 MatCardModule,
2038 MatCheckboxModule,
2039 MatTableModule,
2040 MatSelectModule,
2041 MatInputModule,
2042 MatFormFieldModule,
2043 MatTabsModule,
2044 MatDividerModule,
2045 FlexLayoutModule,
2046 MatRadioModule,
2047 MatSlideToggleModule,
2048 ReactiveFormsModule
2049 ],
2050 declarations: [
2051 EditFormContainerComponent,
2052 EditFormComponent,
2053 FormListContainerComponent,
2054 FormListComponent,
2055 AddFormContainerComponent,
2056 MainContainerComponent,
2057 AddFormComponent,
2058 FormGroupComponent,
2059 FormArrayComponent,
2060 FormControlComponent,
2061 FormViewComponent,
2062 DynamicFieldDirective,
2063 SelectComponent,
2064 CheckboxComponent,
2065 EmailComponent,
2066 ColorComponent,
2067 DateFormInputControlComponent,
2068 FileFormInputControlComponent,
2069 TextComponent,
2070 NumberComponent,
2071 TableComponent,
2072 FormCaptchaComponent
2073 ],
2074 entryComponents: [
2075 SelectComponent,
2076 CheckboxComponent,
2077 EmailComponent,
2078 ColorComponent,
2079 DateFormInputControlComponent,
2080 FileFormInputControlComponent,
2081 TextComponent,
2082 NumberComponent,
2083 TableComponent,
2084 FormCaptchaComponent
2085 ],
2086 exports: [FormViewComponent]
2087 },] }
2088];
2089class RootNgsFormModule {
2090}
2091RootNgsFormModule.decorators = [
2092 { type: NgModule, args: [{
2093 imports: [
2094 NgsFormModule,
2095 StoreModule.forFeature("form", FormReducers),
2096 EffectsModule.forFeature([AddFormEffects, EditFormEffects, FormsListEffects, CaptchaEffects]),
2097 RoutingModule
2098 ],
2099 exports: [NgsFormModule]
2100 },] }
2101];
2102
2103/**
2104 * @fileoverview added by tsickle
2105 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2106 */
2107
2108/**
2109 * @fileoverview added by tsickle
2110 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
2111 */
2112
2113export { FormService, FormViewComponent, DynamicFieldDirective, NgsFormModule, RootNgsFormModule, AddFormComponent as ɵi, AddFormContainerComponent as ɵg, AddFormContainerComponent as ɵl, AddFormEffects as ɵbd, AddFormComponent as ɵn, CaptchaEffects as ɵbg, FormArrayComponent as ɵp, FormControlComponent as ɵq, FormGroupComponent as ɵo, EditFormContainerComponent as ɵf, EditFormEffects as ɵbe, EditFormComponent as ɵh, RoutingModule as ɵbh, MODULE_CONFIG_TOKEN as ɵa, FormListContainerComponent as ɵj, FormListComponent as ɵk, FormsListEffects as ɵbf, reducer as ɵbc, MainContainerComponent as ɵm, FormReducers as ɵb, FormCaptchaService as ɵbb, FormConfigurationService as ɵd, CheckboxComponent as ɵs, ColorComponent as ɵu, DateFormInputControlComponent as ɵv, EmailComponent as ɵt, FileFormInputControlComponent as ɵw, FormCaptchaComponent as ɵba, NumberComponent as ɵy, SelectComponent as ɵr, TableComponent as ɵz, TextComponent as ɵx };
2114
2115//# sourceMappingURL=soushians-form.js.map
\No newline at end of file