angular-formio-proyectoscolfuturo
Version:
Form.io Angular JSON Form Renderer ========================== This library serves as a Dynamic JSON Powered Form rendering library for [Angular](https://angular.io). This works by providing a JSON schema to a ```<formio>``` Angular component, where tha
1,064 lines (1,053 loc) • 124 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('lodash'), require('formiojs-proyectoscolfuturo'), require('@angular/common'), require('@angular/router'), require('rxjs')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'lodash', 'formiojs-proyectoscolfuturo', '@angular/common', '@angular/router', 'rxjs'], factory) :
(global = global || self, factory(global['formio-auth'] = {}, global.core, global.lodash, global.formiojsProyectoscolfuturo, global.common, global.router, global.rxjs));
}(this, function (exports, core, lodash, formiojsProyectoscolfuturo, common, router, rxjs) { 'use strict';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAuthConfig = /** @class */ (function () {
function FormioAuthConfig() {
}
FormioAuthConfig.decorators = [
{ type: core.Injectable },
];
return FormioAuthConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAppConfig = /** @class */ (function () {
function FormioAppConfig() {
this.appUrl = '';
this.apiUrl = '';
}
FormioAppConfig.decorators = [
{ type: core.Injectable },
];
return FormioAppConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAuthService = /** @class */ (function () {
function FormioAuthService(appConfig, config) {
var _this = this;
this.appConfig = appConfig;
this.config = config;
this.authenticated = false;
this.formAccess = {};
this.submissionAccess = {};
this.is = {};
this.user = null;
if (this.appConfig && this.appConfig.appUrl) {
formiojsProyectoscolfuturo.Formio.setBaseUrl(this.appConfig.apiUrl);
formiojsProyectoscolfuturo.Formio.setProjectUrl(this.appConfig.appUrl);
formiojsProyectoscolfuturo.Formio.formOnly = !!this.appConfig.formOnly;
}
else {
console.error('You must provide an AppConfig within your application!');
}
this.loginForm =
this.appConfig.appUrl +
'/' +
lodash.get(this.config, 'login.form', 'user/login');
this.registerForm =
this.appConfig.appUrl +
'/' +
lodash.get(this.config, 'register.form', 'user/login');
this.onLogin = new core.EventEmitter();
this.onLogout = new core.EventEmitter();
this.onRegister = new core.EventEmitter();
this.onUser = new core.EventEmitter();
this.onError = new core.EventEmitter();
this.ready = new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
_this.readyResolve = resolve;
_this.readyReject = reject;
}));
// Register for the core events.
formiojsProyectoscolfuturo.Formio.events.on('formio.badToken', (/**
* @return {?}
*/
function () { return _this.logoutError(); }));
formiojsProyectoscolfuturo.Formio.events.on('formio.sessionExpired', (/**
* @return {?}
*/
function () { return _this.logoutError(); }));
this.init();
}
/**
* @param {?} submission
* @return {?}
*/
FormioAuthService.prototype.onLoginSubmit = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
this.setUser(submission);
this.onLogin.emit(submission);
};
/**
* @param {?} submission
* @return {?}
*/
FormioAuthService.prototype.onRegisterSubmit = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
this.setUser(submission);
this.onRegister.emit(submission);
};
/**
* @return {?}
*/
FormioAuthService.prototype.init = /**
* @return {?}
*/
function () {
var _this = this;
this.projectReady = formiojsProyectoscolfuturo.Formio.makeStaticRequest(this.appConfig.appUrl).then((/**
* @param {?} project
* @return {?}
*/
function (project) {
lodash.each(project.access, (/**
* @param {?} access
* @return {?}
*/
function (access) {
_this.formAccess[access.type] = access.roles;
}));
}), (/**
* @return {?}
*/
function () {
_this.formAccess = {};
return null;
}));
// Get the access for this project.
this.accessReady = formiojsProyectoscolfuturo.Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((/**
* @param {?} access
* @return {?}
*/
function (access) {
lodash.each(access.forms, (/**
* @param {?} form
* @return {?}
*/
function (form) {
_this.submissionAccess[form.name] = {};
form.submissionAccess.forEach((/**
* @param {?} subAccess
* @return {?}
*/
function (subAccess) {
_this.submissionAccess[form.name][subAccess.type] = subAccess.roles;
}));
}));
_this.roles = access.roles;
return access;
}), (/**
* @return {?}
*/
function () {
_this.roles = {};
return null;
}));
this.userReady = formiojsProyectoscolfuturo.Formio.currentUser().then((/**
* @param {?} user
* @return {?}
*/
function (user) {
_this.setUser(user);
return user;
}));
// Trigger we are redy when all promises have resolved.
if (this.accessReady) {
this.accessReady
.then((/**
* @return {?}
*/
function () { return _this.projectReady; }))
.then((/**
* @return {?}
*/
function () { return _this.userReady; }))
.then((/**
* @return {?}
*/
function () { return _this.readyResolve(true); }))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.readyReject(err); }));
}
};
/**
* @param {?} user
* @return {?}
*/
FormioAuthService.prototype.setUser = /**
* @param {?} user
* @return {?}
*/
function (user) {
if (user) {
this.user = user;
localStorage.setItem('formioAppUser', JSON.stringify(user));
this.setUserRoles();
}
else {
this.user = null;
this.is = {};
localStorage.removeItem('formioAppUser');
formiojsProyectoscolfuturo.Formio.clearCache();
formiojsProyectoscolfuturo.Formio.setUser(null);
}
this.authenticated = !!formiojsProyectoscolfuturo.Formio.getToken();
this.onUser.emit(this.user);
};
/**
* @return {?}
*/
FormioAuthService.prototype.setUserRoles = /**
* @return {?}
*/
function () {
var _this = this;
if (this.accessReady) {
this.accessReady.then((/**
* @return {?}
*/
function () {
lodash.each(_this.roles, (/**
* @param {?} role
* @param {?} roleName
* @return {?}
*/
function (role, roleName) {
if (_this.user.roles.indexOf(role._id) !== -1) {
_this.is[roleName] = true;
}
}));
}));
}
};
/**
* @return {?}
*/
FormioAuthService.prototype.logoutError = /**
* @return {?}
*/
function () {
this.setUser(null);
localStorage.removeItem('formioToken');
this.onError.emit();
};
/**
* @return {?}
*/
FormioAuthService.prototype.logout = /**
* @return {?}
*/
function () {
var _this = this;
this.setUser(null);
localStorage.removeItem('formioToken');
formiojsProyectoscolfuturo.Formio.logout()
.then((/**
* @return {?}
*/
function () { return _this.onLogout.emit(); }))
.catch((/**
* @return {?}
*/
function () { return _this.logoutError(); }));
};
FormioAuthService.decorators = [
{ type: core.Injectable },
];
/** @nocollapse */
FormioAuthService.ctorParameters = function () { return [
{ type: FormioAppConfig },
{ type: FormioAuthConfig }
]; };
return FormioAuthService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAuthComponent = /** @class */ (function () {
function FormioAuthComponent() {
}
FormioAuthComponent.decorators = [
{ type: core.Component, args: [{
template: "<div class=\"card card-primary panel panel-default\"> <div class=\"card-header panel-heading\"> <ul class=\"nav nav-tabs card-header-tabs\"> <li class=\"nav-item\" role=\"presentation\" routerLinkActive=\"active\"><a class=\"nav-link\" routerLink=\"login\" routerLinkActive=\"active\">Login</a></li> <li class=\"nav-item\" role=\"presentation\" routerLinkActive=\"active\"><a class=\"nav-link\" routerLink=\"register\" routerLinkActive=\"active\">Register</a></li> </ul> </div> <div class=\"card-body panel-body\"> <router-outlet></router-outlet> </div> </div> "
},] },
];
return FormioAuthComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAuthLoginComponent = /** @class */ (function () {
function FormioAuthLoginComponent(service) {
this.service = service;
}
FormioAuthLoginComponent.decorators = [
{ type: core.Component, args: [{
template: "<formio [src]=\"service.loginForm\" (submit)=\"service.onLoginSubmit($event)\"></formio> "
},] },
];
/** @nocollapse */
FormioAuthLoginComponent.ctorParameters = function () { return [
{ type: FormioAuthService }
]; };
return FormioAuthLoginComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAuthRegisterComponent = /** @class */ (function () {
function FormioAuthRegisterComponent(service) {
this.service = service;
}
FormioAuthRegisterComponent.decorators = [
{ type: core.Component, args: [{
template: "<formio [src]=\"service.registerForm\" (submit)=\"service.onRegisterSubmit($event)\"></formio> "
},] },
];
/** @nocollapse */
FormioAuthRegisterComponent.ctorParameters = function () { return [
{ type: FormioAuthService }
]; };
return FormioAuthRegisterComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?=} config
* @return {?}
*/
function FormioAuthRoutes(config) {
return [
{
path: '',
component: config && config.auth ? config.auth : FormioAuthComponent,
children: [
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: 'login',
component: config && config.login ? config.login : FormioAuthLoginComponent
},
{
path: 'register',
component: config && config.register ? config.register : FormioAuthRegisterComponent
}
]
}
];
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioService = /** @class */ (function () {
function FormioService(url, options) {
this.url = url;
this.options = options;
this.formio = new formiojsProyectoscolfuturo.Formio(this.url, this.options);
}
/**
* @param {?} fn
* @return {?}
*/
FormioService.prototype.requestWrapper = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
/** @type {?} */
var record;
/** @type {?} */
var called = false;
return rxjs.Observable.create((/**
* @param {?} observer
* @return {?}
*/
function (observer) {
try {
if (!called) {
called = true;
fn()
.then((/**
* @param {?} _record
* @return {?}
*/
function (_record) {
record = _record;
observer.next(record);
observer.complete();
}))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return observer.error(err); }));
}
else if (record) {
observer.next(record);
observer.complete();
}
}
catch (err) {
observer.error(err);
}
}));
};
/**
* @param {?} form
* @return {?}
*/
FormioService.prototype.saveForm = /**
* @param {?} form
* @return {?}
*/
function (form) {
var _this = this;
return this.requestWrapper((/**
* @return {?}
*/
function () { return _this.formio.saveForm(form); }));
};
/**
* @param {?=} options
* @return {?}
*/
FormioService.prototype.loadForm = /**
* @param {?=} options
* @return {?}
*/
function (options) {
var _this = this;
return this.requestWrapper((/**
* @return {?}
*/
function () { return _this.formio.loadForm(options); }));
};
/**
* @return {?}
*/
FormioService.prototype.loadSubmission = /**
* @return {?}
*/
function () {
var _this = this;
return this.requestWrapper((/**
* @return {?}
*/
function () { return _this.formio.loadSubmission(); }));
};
/**
* @param {?} submission
* @return {?}
*/
FormioService.prototype.saveSubmission = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
var _this = this;
return this.requestWrapper((/**
* @return {?}
*/
function () { return _this.formio.saveSubmission(submission); }));
};
/**
* @return {?}
*/
FormioService.prototype.loadSubmissions = /**
* @return {?}
*/
function () {
var _this = this;
return this.requestWrapper((/**
* @return {?}
*/
function () { return _this.formio.loadSubmissions(); }));
};
return FormioService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioLoader = /** @class */ (function () {
function FormioLoader() {
this.loading = true;
}
FormioLoader.decorators = [
{ type: core.Injectable },
];
return FormioLoader;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioAlerts = /** @class */ (function () {
function FormioAlerts() {
this.alerts = [];
}
/**
* @param {?} alert
* @return {?}
*/
FormioAlerts.prototype.setAlert = /**
* @param {?} alert
* @return {?}
*/
function (alert) {
this.alerts = [alert];
};
/**
* @param {?} alert
* @return {?}
*/
FormioAlerts.prototype.addAlert = /**
* @param {?} alert
* @return {?}
*/
function (alert) {
this.alerts.push(alert);
};
/**
* @param {?} alerts
* @return {?}
*/
FormioAlerts.prototype.setAlerts = /**
* @param {?} alerts
* @return {?}
*/
function (alerts) {
this.alerts = alerts;
};
return FormioAlerts;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/* tslint:disable */
var FormioComponent = /** @class */ (function () {
function FormioComponent(loader, config) {
var _this = this;
this.loader = loader;
this.config = config;
this.submission = {};
this.readOnly = false;
this.frontOffice = false;
this.viewOnly = false;
this.hooks = {};
this.render = new core.EventEmitter();
this.customEvent = new core.EventEmitter();
this.submit = new core.EventEmitter();
this.prevPage = new core.EventEmitter();
this.nextPage = new core.EventEmitter();
this.beforeSubmit = new core.EventEmitter();
this.change = new core.EventEmitter();
this.invalid = new core.EventEmitter();
this.errorChange = new core.EventEmitter();
this.formLoad = new core.EventEmitter();
this.ready = new core.EventEmitter();
this.initialized = false;
this.alerts = new FormioAlerts();
this.submitting = false;
if (this.config) {
formiojsProyectoscolfuturo.Formio.setBaseUrl(this.config.apiUrl);
formiojsProyectoscolfuturo.Formio.setProjectUrl(this.config.appUrl);
}
else {
console.warn('You must provide an AppConfig within your application!');
}
this.formioReady = new Promise((/**
* @param {?} ready
* @return {?}
*/
function (ready) {
_this.formioReadyResolve = ready;
}));
}
/**
* @param {?} form
* @return {?}
*/
FormioComponent.prototype.setForm = /**
* @param {?} form
* @return {?}
*/
function (form) {
var _this = this;
this.form = form;
if (this.formio) {
this.formio.destroy();
}
/** @type {?} */
var Renderer = this.renderer || formiojsProyectoscolfuturo.Form;
this.formio = (new Renderer(this.formioElement ? this.formioElement.nativeElement : null, this.form, lodash.assign({}, {
icons: lodash.get(this.config, 'icons', 'fontawesome'),
noAlerts: lodash.get(this.options, 'noAlerts', true),
readOnly: this.readOnly,
frontOffice: this.frontOffice,
viewAsHtml: this.viewOnly,
i18n: lodash.get(this.options, 'i18n', null),
fileService: lodash.get(this.options, 'fileService', null),
hooks: this.hooks
}, this.renderOptions || {}))).create();
if (this.url) {
this.formio.setUrl(this.url, this.formioOptions || {});
}
if (this.src) {
this.formio.setUrl(this.src, this.formioOptions || {});
}
this.formio.nosubmit = true;
this.formio.on('prevPage', (/**
* @param {?} data
* @return {?}
*/
function (data) { return _this.onPrevPage(data); }));
this.formio.on('nextPage', (/**
* @param {?} data
* @return {?}
*/
function (data) { return _this.onNextPage(data); }));
this.formio.on('change', (/**
* @param {?} value
* @return {?}
*/
function (value) { return _this.change.emit(value); }));
this.formio.on('customEvent', (/**
* @param {?} event
* @return {?}
*/
function (event) {
return _this.customEvent.emit(event);
}));
this.formio.on('submit', (/**
* @param {?} submission
* @return {?}
*/
function (submission) {
return _this.submitForm(submission);
}));
this.formio.on('error', (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
this.formio.on('render', (/**
* @return {?}
*/
function () { return _this.render.emit(); }));
this.formio.on('formLoad', (/**
* @param {?} loadedForm
* @return {?}
*/
function (loadedForm) {
return _this.formLoad.emit(loadedForm);
}));
this.formio.form = this.form;
return this.formio.ready.then((/**
* @return {?}
*/
function () {
_this.loader.loading = false;
_this.ready.emit(_this);
_this.formioReadyResolve(_this.formio);
return _this.formio;
}));
};
/**
* @return {?}
*/
FormioComponent.prototype.initialize = /**
* @return {?}
*/
function () {
if (this.initialized) {
return;
}
this.options = Object.assign({
errors: {
message: 'Please fix the following errors before submitting.'
},
alerts: {
submitMessage: 'Submission Complete.'
},
disableAlerts: false,
hooks: {
beforeSubmit: null
}
}, this.options);
this.initialized = true;
};
/**
* @return {?}
*/
FormioComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.initialize();
if (this.language) {
this.language.subscribe((/**
* @param {?} lang
* @return {?}
*/
function (lang) {
_this.formio.language = lang;
}));
}
if (this.refresh) {
this.refresh.subscribe((/**
* @param {?} refresh
* @return {?}
*/
function (refresh) {
return _this.onRefresh(refresh);
}));
}
if (this.error) {
this.error.subscribe((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
}
if (this.success) {
this.success.subscribe((/**
* @param {?} message
* @return {?}
*/
function (message) {
_this.alerts.setAlert({
type: 'success',
message: message || lodash.get(_this.options, 'alerts.submitMessage')
});
}));
}
if (this.src) {
if (!this.service) {
this.service = new FormioService(this.src);
}
this.loader.loading = true;
this.service.loadForm({ params: { live: 1 } }).subscribe((/**
* @param {?} form
* @return {?}
*/
function (form) {
if (form && form.components) {
_this.setForm(form);
}
// if a submission is also provided.
if (lodash.isEmpty(_this.submission) &&
_this.service &&
_this.service.formio.submissionId) {
_this.service.loadSubmission().subscribe((/**
* @param {?} submission
* @return {?}
*/
function (submission) {
if (_this.readOnly) {
_this.formio.options.readOnly = true;
}
_this.submission = _this.formio.submission = submission;
}), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
}
}), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
}
if (this.url && !this.service) {
this.service = new FormioService(this.url);
}
};
/**
* @param {?} refresh
* @return {?}
*/
FormioComponent.prototype.onRefresh = /**
* @param {?} refresh
* @return {?}
*/
function (refresh) {
var _this = this;
this.formioReady.then((/**
* @return {?}
*/
function () {
if (refresh.form) {
_this.formio.setForm(refresh.form).then((/**
* @return {?}
*/
function () {
if (refresh.submission) {
_this.formio.setSubmission(refresh.submission);
}
}));
}
else if (refresh.submission) {
_this.formio.setSubmission(refresh.submission);
}
else {
switch (refresh.property) {
case 'submission':
_this.formio.submission = refresh.value;
break;
case 'form':
_this.formio.form = refresh.value;
break;
}
}
}));
};
/**
* @param {?} changes
* @return {?}
*/
FormioComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
this.initialize();
if (changes.form && changes.form.currentValue) {
this.setForm(changes.form.currentValue);
}
this.formioReady.then((/**
* @return {?}
*/
function () {
if (changes.submission && changes.submission.currentValue) {
_this.formio.submission = changes.submission.currentValue;
}
if (changes.hideComponents) {
_this.formio.hideComponents(changes.hideComponents.currentValue);
}
}));
};
/**
* @param {?} data
* @return {?}
*/
FormioComponent.prototype.onPrevPage = /**
* @param {?} data
* @return {?}
*/
function (data) {
this.alerts.setAlerts([]);
this.prevPage.emit(data);
};
/**
* @param {?} data
* @return {?}
*/
FormioComponent.prototype.onNextPage = /**
* @param {?} data
* @return {?}
*/
function (data) {
this.alerts.setAlerts([]);
this.nextPage.emit(data);
};
/**
* @param {?} submission
* @param {?} saved
* @return {?}
*/
FormioComponent.prototype.onSubmit = /**
* @param {?} submission
* @param {?} saved
* @return {?}
*/
function (submission, saved) {
this.submitting = false;
if (saved) {
this.formio.emit('submitDone', submission);
}
this.submit.emit(submission);
if (!this.success) {
this.alerts.setAlert({
type: 'success',
message: lodash.get(this.options, 'alerts.submitMessage')
});
}
};
/**
* @param {?} err
* @return {?}
*/
FormioComponent.prototype.onError = /**
* @param {?} err
* @return {?}
*/
function (err) {
var _this = this;
this.loader.loading = false;
this.alerts.setAlerts([]);
this.submitting = false;
if (!err) {
return;
}
// Make sure it is an array.
/** @type {?} */
var errors = Array.isArray(err) ? err : [err];
// Emit these errors again.
this.errorChange.emit(errors);
// Iterate through each one and set the alerts array.
errors.forEach((/**
* @param {?} error
* @return {?}
*/
function (error) {
var _a = error
? error.details
? {
message: error.details.map((/**
* @param {?} detail
* @return {?}
*/
function (detail) { return detail.message; })).join(' '),
paths: error.details.map((/**
* @param {?} detail
* @return {?}
*/
function (detail) { return detail.path; })),
}
: {
message: error.message || error.toString(),
paths: error.path ? [error.path] : [],
}
: {
message: '',
paths: [],
}, message = _a.message, paths = _a.paths;
_this.alerts.addAlert({
type: 'danger',
message: message,
});
paths.forEach((/**
* @param {?} path
* @return {?}
*/
function (path) {
/** @type {?} */
var component = _this.formio.getComponent(path);
/** @type {?} */
var components = Array.isArray(component) ? component : [component];
components.forEach((/**
* @param {?} comp
* @return {?}
*/
function (comp) { return comp.setCustomValidity(message, true); }));
}));
}));
};
/**
* @param {?} submission
* @return {?}
*/
FormioComponent.prototype.submitExecute = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
var _this = this;
if (this.service && !this.url) {
this.service
.saveSubmission(submission)
.subscribe((/**
* @param {?} sub
* @return {?}
*/
function (sub) { return _this.onSubmit(sub, true); }), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
}
else {
this.onSubmit(submission, false);
}
};
/**
* @param {?} submission
* @return {?}
*/
FormioComponent.prototype.submitForm = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
var _this = this;
// Keep double submits from occurring...
if (this.submitting) {
return;
}
this.submitting = true;
this.beforeSubmit.emit(submission);
// if they provide a beforeSubmit hook, then allow them to alter the submission asynchronously
// or even provide a custom Error method.
/** @type {?} */
var beforeSubmit = lodash.get(this.options, 'hooks.beforeSubmit');
if (beforeSubmit) {
beforeSubmit(submission, (/**
* @param {?} err
* @param {?} sub
* @return {?}
*/
function (err, sub) {
if (err) {
_this.onError(err);
return;
}
_this.submitExecute(sub);
}));
}
else {
this.submitExecute(submission);
}
};
FormioComponent.decorators = [
{ type: core.Component, args: [{
selector: 'formio',
template: "<div> <div *ngIf=\"loader.loading\" style=\"position:relative;height:200px\"> <formio-loader></formio-loader> </div> <formio-alerts *ngIf=\"!this.options.disableAlerts\" [alerts]=\"alerts\"></formio-alerts> <div #formio></div> </div> ",
styles: [".flatpickr-calendar{background:0 0;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,.08)}.flatpickr-calendar.inline,.flatpickr-calendar.open{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown .3s cubic-bezier(.23,1,.32,1);animation:fpFadeInDown .3s cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none!important;box-shadow:none!important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasTime .dayContainer,.flatpickr-calendar .hasWeeks .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:after,.flatpickr-calendar:before{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.arrowRight:after,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.rightMost:before{left:auto;right:22px}.flatpickr-calendar.arrowCenter:after,.flatpickr-calendar.arrowCenter:before{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:after,.flatpickr-calendar.arrowTop:before{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:after,.flatpickr-calendar.arrowBottom:before{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:0 0;color:rgba(0,0,0,.9);fill:rgba(0,0,0,.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-next-month,.flatpickr-months .flatpickr-prev-month{text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,.9);fill:rgba(0,0,0,.9)}.flatpickr-months .flatpickr-next-month.flatpickr-disabled,.flatpickr-months .flatpickr-prev-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-next-month i,.flatpickr-months .flatpickr-prev-month i{position:relative}.flatpickr-months .flatpickr-next-month.flatpickr-prev-month,.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month{left:0}.flatpickr-months .flatpickr-next-month.flatpickr-next-month,.flatpickr-months .flatpickr-prev-month.flatpickr-next-month{right:0}.flatpickr-months .flatpickr-next-month:hover,.flatpickr-months .flatpickr-prev-month:hover{color:#959ea9}.flatpickr-months .flatpickr-next-month:hover svg,.flatpickr-months .flatpickr-prev-month:hover svg{fill:#f64747}.flatpickr-months .flatpickr-next-month svg,.flatpickr-months .flatpickr-prev-month svg{width:14px;height:14px}.flatpickr-months .flatpickr-next-month svg path,.flatpickr-months .flatpickr-prev-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-inner-spin-button,.numInputWrapper input::-webkit-outer-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57,57,57,.15);-webkit-box-sizing:border-box;box-sizing:border-box}.numInputWrapper span:hover{background:rgba(0,0,0,.1)}.numInputWrapper span:active{background:rgba(0,0,0,.2)}.numInputWrapper span:after{display:block;content:\"\";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57,57,57,.6);top:26%}.numInputWrapper span.arrowDown{top:50%}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57,57,57,.6);top:40%}.numInputWrapper span svg{width:inherit;height:auto}.numInputWrapper span svg path{fill:rgba(0,0,0,.5)}.numInputWrapper:hover{background:rgba(0,0,0,.05)}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0}.flatpickr-current-month span.cur-month:hover{background:rgba(0,0,0,.05)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\0;display:inline-block}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0,0,0,.9)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0,0,0,.9)}.flatpickr-current-month input.cur-year{background:0 0;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0,0,0,.5);background:0 0;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:0 0;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:0;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto}.flatpickr-current-month .flatpickr-monthDropdown-months:active,.flatpickr-current-month .flatpickr-monthDropdown-months:focus{outline:0}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0,0,0,.05)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:0;padding:0}.flatpickr-weekdays{background:0 0;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:0 0;color:rgba(0,0,0,.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px}.flatpickr-days:focus{outline:0}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}.dayContainer+.dayContainer{-webkit-box-shadow:-1px 0 0 #e6e6e6;box-shadow:-1px 0 0 #e6e6e6}.flatpickr-day{background:0 0;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center}.flatpickr-day.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day.nextMonthDay:focus,.flatpickr-day.nextMonthDay:hover,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.today.inRange,.flatpickr-day:focus,.flatpickr-day:hover{cursor:pointer;outline:0;background:#e6e6e6;border-color:#e6e6e6}.flatpickr-day.today{border-color:#959ea9}.flatpickr-day.today:focus,.flatpickr-day.today:hover{border-color:#959ea9;background:#959ea9;color:#fff}.flatpickr-day.endRange,.flatpickr-day.endRange.inRange,.flatpickr-day.endRange.nextMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.endRange:focus,.flatpickr-day.endRange:hover,.flatpickr-day.selected,.flatpickr-day.selected.inRange,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.selected:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange,.flatpickr-day.startRange.inRange,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.startRange:focus,.flatpickr-day.startRange:hover{background:#569ff7;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#569ff7}.flatpickr-day.endRange.startRange,.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange{border-radius:50px 0 0 50px}.flatpickr-day.endRange.endRange,.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange{bord