angular-formio
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 that f
1,366 lines (1,346 loc) • 221 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('lodash'), require('formiojs'), require('rxjs'), require('native-promise-only'), require('@angular/router'), require('@angular/common'), require('formiojs/utils/Evaluator'), require('@angular/forms'), require('ngx-bootstrap/pagination')) :
typeof define === 'function' && define.amd ? define('index', ['exports', '@angular/core', 'lodash', 'formiojs', 'rxjs', 'native-promise-only', '@angular/router', '@angular/common', 'formiojs/utils/Evaluator', '@angular/forms', 'ngx-bootstrap/pagination'], factory) :
(global = global || self, factory(global['formio-resource'] = {}, global.core, global._, global.formiojs, global.rxjs, global.Promise$1, global.router, global.common, global.Evaluator, global.forms, global.pagination));
}(this, (function (exports, core, _, formiojs, rxjs, Promise$1, router, common, Evaluator, forms, pagination) { 'use strict';
var ___default = 'default' in _ ? _['default'] : _;
Promise$1 = Promise$1 && Promise$1.hasOwnProperty('default') ? Promise$1['default'] : Promise$1;
Evaluator = Evaluator && Evaluator.hasOwnProperty('default') ? Evaluator['default'] : Evaluator;
/**
* @fileoverview added by tsickle
* Generated from: resource/resource.config.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceConfig = /** @class */ (function () {
function FormioResourceConfig() {
this.name = '';
this.form = '';
this.parents = [];
}
FormioResourceConfig.decorators = [
{ type: core.Injectable },
];
return FormioResourceConfig;
}());
/**
* @fileoverview added by tsickle
* Generated from: auth/auth.config.ts
* @suppress {checkTypes,constantProperty,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
* Generated from: formio.config.ts
* @suppress {checkTypes,constantProperty,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
* Generated from: auth/auth.service.ts
* @suppress {checkTypes,constantProperty,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) {
formiojs.Formio.setBaseUrl(this.appConfig.apiUrl);
formiojs.Formio.setProjectUrl(this.appConfig.appUrl);
formiojs.Formio.formOnly = !!this.appConfig.formOnly;
}
else {
console.error('You must provide an AppConfig within your application!');
}
this.loginForm =
this.appConfig.appUrl +
'/' +
_.get(this.config, 'login.form', 'user/login');
this.registerForm =
this.appConfig.appUrl +
'/' +
_.get(this.config, 'register.form', 'user/register');
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.
formiojs.Formio.events.on('formio.badToken', (/**
* @return {?}
*/
function () { return _this.logoutError(); }));
formiojs.Formio.events.on('formio.sessionExpired', (/**
* @return {?}
*/
function () { return _this.logoutError(); }));
if (!this.config.delayAuth) {
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 = formiojs.Formio.makeStaticRequest(this.appConfig.appUrl).then((/**
* @param {?} project
* @return {?}
*/
function (project) {
_.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 = formiojs.Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((/**
* @param {?} access
* @return {?}
*/
function (access) {
_.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;
}));
/** @type {?} */
var currentUserPromise;
if (this.config.oauth) {
// Make a fix to the hash to remove starting "/" that angular might put there.
if (window.location.hash && window.location.hash.match(/^#\/access_token/)) {
history.pushState(null, null, window.location.hash.replace(/^#\/access_token/, '#access_token'));
}
// Initiate the SSO if they provide oauth settings.
currentUserPromise = formiojs.Formio.ssoInit(this.config.oauth.type, this.config.oauth.options);
}
else {
currentUserPromise = formiojs.Formio.currentUser();
}
this.userReady = currentUserPromise.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) {
/** @type {?} */
var namespace = formiojs.Formio.namespace || 'formio';
if (user) {
this.user = user;
localStorage.setItem(namespace + "AppUser", JSON.stringify(user));
this.setUserRoles();
}
else {
this.user = null;
this.is = {};
localStorage.removeItem(namespace + "AppUser");
formiojs.Formio.clearCache();
formiojs.Formio.setUser(null);
}
this.authenticated = !!formiojs.Formio.getToken();
this.onUser.emit(this.user);
};
/**
* @return {?}
*/
FormioAuthService.prototype.setUserRoles = /**
* @return {?}
*/
function () {
var _this = this;
if (this.accessReady) {
this.accessReady.then((/**
* @return {?}
*/
function () {
_.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');
formiojs.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
* Generated from: resource/resources.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResources = /** @class */ (function () {
function FormioResources(auth) {
this.auth = auth;
this.resources = {};
this.error = new core.EventEmitter();
this.onError = this.error;
this.resources = {
currentUser: {
resourceLoaded: this.auth.userReady
}
};
}
FormioResources.decorators = [
{ type: core.Injectable },
];
/** @nocollapse */
FormioResources.ctorParameters = function () { return [
{ type: FormioAuthService }
]; };
return FormioResources;
}());
/**
* @fileoverview added by tsickle
* Generated from: components/alerts/formio.alerts.ts
* @suppress {checkTypes,constantProperty,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
* Generated from: components/loader/formio.loader.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioLoader = /** @class */ (function () {
function FormioLoader() {
this.loading$ = new rxjs.BehaviorSubject(true);
this.loading = true;
}
/**
* @param {?} loading
* @return {?}
*/
FormioLoader.prototype.setLoading = /**
* @param {?} loading
* @return {?}
*/
function (loading) {
this.loading = loading;
this.loading$.next(loading);
};
FormioLoader.decorators = [
{ type: core.Injectable },
];
return FormioLoader;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/resource.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceService = /** @class */ (function () {
function FormioResourceService(appConfig, config, loader, resourcesService) {
var _this = this;
this.appConfig = appConfig;
this.config = config;
this.loader = loader;
this.resourcesService = resourcesService;
this.initialized = false;
this.alerts = new FormioAlerts();
this.refresh = new core.EventEmitter();
this.formLoaded = new Promise$1((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
_this.formResolve = resolve;
_this.formReject = reject;
}));
this.init();
}
/**
* @return {?}
*/
FormioResourceService.prototype.initialize = /**
* @return {?}
*/
function () {
console.warn('FormioResourceService.initialize() has been deprecated.');
};
/**
* @return {?}
*/
FormioResourceService.prototype.init = /**
* @return {?}
*/
function () {
if (this.initialized) {
return;
}
this.initialized = true;
if (this.appConfig && this.appConfig.appUrl) {
formiojs.Formio.setBaseUrl(this.appConfig.apiUrl);
formiojs.Formio.setProjectUrl(this.appConfig.appUrl);
formiojs.Formio.formOnly = this.appConfig.formOnly;
}
else {
console.error('You must provide an AppConfig within your application!');
}
// Create the form url and load the resources.
this.formUrl = this.appConfig.appUrl + '/' + this.config.form;
this.resource = { data: {} };
// Add this resource service to the list of all resources in context.
if (this.resourcesService) {
this.resources = this.resourcesService.resources;
this.resources[this.config.name] = this;
}
return this.loadForm();
};
/**
* @param {?} error
* @return {?}
*/
FormioResourceService.prototype.onError = /**
* @param {?} error
* @return {?}
*/
function (error) {
this.alerts.setAlert({
type: 'danger',
message: error.message || error
});
if (this.resourcesService) {
this.resourcesService.error.emit(error);
}
throw error;
};
/**
* @param {?} err
* @return {?}
*/
FormioResourceService.prototype.onFormError = /**
* @param {?} err
* @return {?}
*/
function (err) {
this.formReject(err);
this.onError(err);
};
/**
* @param {?} route
* @return {?}
*/
FormioResourceService.prototype.setContext = /**
* @param {?} route
* @return {?}
*/
function (route) {
this.resourceId = route.snapshot.params['id'];
this.resource = { data: {} };
this.resourceUrl = this.appConfig.appUrl + '/' + this.config.form;
if (this.resourceId) {
this.resourceUrl += '/submission/' + this.resourceId;
}
this.formio = new formiojs.Formio(this.resourceUrl);
if (this.resourcesService) {
this.resources[this.config.name] = this;
}
this.loadParents();
};
/**
* @return {?}
*/
FormioResourceService.prototype.loadForm = /**
* @return {?}
*/
function () {
var _this = this;
this.formFormio = new formiojs.Formio(this.formUrl);
this.loader.setLoading(true);
this.formLoading = this.formFormio
.loadForm()
.then((/**
* @param {?} form
* @return {?}
*/
function (form) {
_this.form = form;
_this.formResolve(form);
_this.loader.setLoading(false);
_this.loadParents();
return form;
}), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onFormError(err); }))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onFormError(err); }));
return this.formLoading;
};
/**
* @return {?}
*/
FormioResourceService.prototype.loadParents = /**
* @return {?}
*/
function () {
var _this = this;
if (!this.config.parents || !this.config.parents.length) {
return Promise$1.resolve([]);
}
if (!this.resourcesService) {
console.warn('You must provide the FormioResources within your application to use nested resources.');
return Promise$1.resolve([]);
}
return this.formLoading.then((/**
* @param {?} form
* @return {?}
*/
function (form) {
// Iterate through the list of parents.
/** @type {?} */
var _parentsLoaded = [];
_this.config.parents.forEach((/**
* @param {?} parent
* @return {?}
*/
function (parent) {
/** @type {?} */
var resourceName = parent.resource || parent;
/** @type {?} */
var resourceField = parent.field || parent;
/** @type {?} */
var filterResource = parent.hasOwnProperty('filter') ? parent.filter : true;
if (_this.resources.hasOwnProperty(resourceName) && _this.resources[resourceName].resourceLoaded) {
_parentsLoaded.push(_this.resources[resourceName].resourceLoaded.then((/**
* @param {?} resource
* @return {?}
*/
function (resource) {
/** @type {?} */
var parentPath = '';
formiojs.Utils.eachComponent(form.components, (/**
* @param {?} component
* @param {?} path
* @return {?}
*/
function (component, path) {
if (component.key === resourceField) {
component.hidden = true;
component.clearOnHide = false;
___default.set(_this.resource.data, path, resource);
parentPath = path;
return true;
}
}));
return {
name: parentPath,
filter: filterResource,
resource: resource
};
})));
}
}));
// When all the parents have loaded, emit that to the onParents emitter.
return Promise$1.all(_parentsLoaded).then((/**
* @param {?} parents
* @return {?}
*/
function (parents) {
_this.refresh.emit({
form: form,
submission: _this.resource
});
return parents;
}));
}));
};
/**
* @param {?} err
* @return {?}
*/
FormioResourceService.prototype.onSubmissionError = /**
* @param {?} err
* @return {?}
*/
function (err) {
this.onError(err);
};
/**
* @param {?} route
* @return {?}
*/
FormioResourceService.prototype.loadResource = /**
* @param {?} route
* @return {?}
*/
function (route) {
var _this = this;
this.setContext(route);
this.loader.setLoading(true);
this.resourceLoading = this.resourceLoaded = this.formio
.loadSubmission(null, { ignoreCache: true })
.then((/**
* @param {?} resource
* @return {?}
*/
function (resource) {
_this.resource = resource;
_this.loader.setLoading(false);
_this.refresh.emit({
property: 'submission',
value: _this.resource
});
return resource;
}), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onSubmissionError(err); }))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onSubmissionError(err); }));
return this.resourceLoading;
};
/**
* @param {?} resource
* @return {?}
*/
FormioResourceService.prototype.save = /**
* @param {?} resource
* @return {?}
*/
function (resource) {
var _this = this;
/** @type {?} */
var formio = resource._id ? this.formio : this.formFormio;
return formio
.saveSubmission(resource)
.then((/**
* @param {?} saved
* @return {?}
*/
function (saved) {
_this.resource = saved;
return saved;
}), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
};
/**
* @return {?}
*/
FormioResourceService.prototype.remove = /**
* @return {?}
*/
function () {
var _this = this;
return this.formio
.deleteSubmission()
.then((/**
* @return {?}
*/
function () {
_this.resource = null;
}), (/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError(err); }));
};
FormioResourceService.decorators = [
{ type: core.Injectable },
];
/** @nocollapse */
FormioResourceService.ctorParameters = function () { return [
{ type: FormioAppConfig },
{ type: FormioResourceConfig },
{ type: FormioLoader },
{ type: FormioResources, decorators: [{ type: core.Optional }] }
]; };
return FormioResourceService;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/resource.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceComponent = /** @class */ (function () {
function FormioResourceComponent(service, route, auth, changeDetectorRef) {
this.service = service;
this.route = route;
this.auth = auth;
this.changeDetectorRef = changeDetectorRef;
this.perms = { delete: false, edit: false };
}
/**
* @return {?}
*/
FormioResourceComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.service.loadResource(this.route);
this.service.formLoaded.then((/**
* @param {?} form
* @return {?}
*/
function (form) {
_this.auth.ready.then((/**
* @return {?}
*/
function () {
_this.service.resourceLoaded.then((/**
* @param {?} resource
* @return {?}
*/
function (resource) {
_this.service.formFormio.userPermissions(_this.auth.user, form, resource).then((/**
* @param {?} perms
* @return {?}
*/
function (perms) {
_this.perms.delete = perms.delete;
_this.perms.edit = perms.edit;
_this.changeDetectorRef.detectChanges();
}));
}));
}));
}));
};
FormioResourceComponent.decorators = [
{ type: core.Component, args: [{
template: "<ul class=\"nav nav-tabs\" style=\"margin-bottom: 10px\"> <li class=\"nav-item\"><a class=\"nav-link\" routerLink=\"../\"><i class=\"fa fa-chevron-left glyphicon glyphicon-chevron-left\"></i></a></li> <li class=\"nav-item\" routerLinkActive=\"active\"><a class=\"nav-link\" routerLink=\"view\" routerLinkActive=\"active\">View</a></li> <li class=\"nav-item\" routerLinkActive=\"active\" *ngIf=\"perms.edit\"><a class=\"nav-link\" routerLink=\"edit\" routerLinkActive=\"active\">Edit</a></li> <li class=\"nav-item\" routerLinkActive=\"active\" *ngIf=\"perms.delete\"><a class=\"nav-link\" routerLink=\"delete\" routerLinkActive=\"active\"><span class=\"fa fa-trash glyphicon glyphicon-trash\"></span></a></li> </ul> <router-outlet></router-outlet> "
},] },
];
/** @nocollapse */
FormioResourceComponent.ctorParameters = function () { return [
{ type: FormioResourceService },
{ type: router.ActivatedRoute },
{ type: FormioAuthService },
{ type: core.ChangeDetectorRef }
]; };
return FormioResourceComponent;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/view/view.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceViewComponent = /** @class */ (function () {
function FormioResourceViewComponent(service, config) {
this.service = service;
this.config = config;
}
FormioResourceViewComponent.decorators = [
{ type: core.Component, args: [{
template: "<formio [form]=\"service.form\" [submission]=\"service.resource\" [refresh]=\"service.refresh\" [hideComponents]=\"config.parents\" [readOnly]=\"true\" ></formio> "
},] },
];
/** @nocollapse */
FormioResourceViewComponent.ctorParameters = function () { return [
{ type: FormioResourceService },
{ type: FormioResourceConfig }
]; };
return FormioResourceViewComponent;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/edit/edit.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceEditComponent = /** @class */ (function () {
function FormioResourceEditComponent(service, route, router, config) {
this.service = service;
this.route = route;
this.router = router;
this.config = config;
this.triggerError = new core.EventEmitter();
}
/**
* @param {?} submission
* @return {?}
*/
FormioResourceEditComponent.prototype.onSubmit = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
var _this = this;
/** @type {?} */
var edit = this.service.resource;
edit.data = submission.data;
this.service.save(edit)
.then((/**
* @return {?}
*/
function () {
_this.router.navigate(['../', 'view'], { relativeTo: _this.route });
}))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.triggerError.emit(err); }));
};
FormioResourceEditComponent.decorators = [
{ type: core.Component, args: [{
template: "<formio [form]=\"service.form\" [submission]=\"service.resource\" [error]=\"triggerError\" [refresh]=\"service.refresh\" (submit)=\"onSubmit($event)\" ></formio> "
},] },
];
/** @nocollapse */
FormioResourceEditComponent.ctorParameters = function () { return [
{ type: FormioResourceService },
{ type: router.ActivatedRoute },
{ type: router.Router },
{ type: FormioResourceConfig }
]; };
return FormioResourceEditComponent;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/delete/delete.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceDeleteComponent = /** @class */ (function () {
function FormioResourceDeleteComponent(service, route, router) {
this.service = service;
this.route = route;
this.router = router;
}
/**
* @return {?}
*/
FormioResourceDeleteComponent.prototype.onDelete = /**
* @return {?}
*/
function () {
var _this = this;
this.service.remove().then((/**
* @return {?}
*/
function () {
_this.router.navigate(['../../'], { relativeTo: _this.route });
}));
};
/**
* @return {?}
*/
FormioResourceDeleteComponent.prototype.onCancel = /**
* @return {?}
*/
function () {
this.router.navigate(['../', 'view'], { relativeTo: this.route });
};
FormioResourceDeleteComponent.decorators = [
{ type: core.Component, args: [{
template: "<h3>Are you sure you wish to delete this record?</h3> <div class=\"btn-toolbar\"> <button type=\"button\" (click)=\"onDelete()\" class=\"btn btn-danger\" style=\"margin-right: 10px;\">Yes</button> <button type=\"button\" (click)=\"onCancel()\" class=\"btn btn-danger\">No</button> </div> "
},] },
];
/** @nocollapse */
FormioResourceDeleteComponent.ctorParameters = function () { return [
{ type: FormioResourceService },
{ type: router.ActivatedRoute },
{ type: router.Router }
]; };
return FormioResourceDeleteComponent;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/create/create.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceCreateComponent = /** @class */ (function () {
function FormioResourceCreateComponent(service, route, router, config) {
this.service = service;
this.route = route;
this.router = router;
this.config = config;
this.onError = new core.EventEmitter();
this.onSuccess = new core.EventEmitter();
}
/**
* @return {?}
*/
FormioResourceCreateComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.service.setContext(this.route);
};
/**
* @param {?} submission
* @return {?}
*/
FormioResourceCreateComponent.prototype.onSubmit = /**
* @param {?} submission
* @return {?}
*/
function (submission) {
var _this = this;
this.service
.save(submission)
.then((/**
* @return {?}
*/
function () {
_this.router.navigate(['../', _this.service.resource._id, 'view'], {
relativeTo: _this.route
});
}))
.catch((/**
* @param {?} err
* @return {?}
*/
function (err) { return _this.onError.emit(err); }));
};
FormioResourceCreateComponent.decorators = [
{ type: core.Component, args: [{
styles: [".back-button { font-size: 0.8em; } "],
template: "<h3 *ngIf=\"service.form\" style=\"margin-top:0;\"> <a routerLink=\"../\" class=\"back-button\"> <i class=\"fa fa-chevron-left glyphicon glyphicon-chevron-left\"></i> </a> | New {{ service.form.title }} </h3> <formio [form]=\"service.form\" [submission]=\"service.resource\" [refresh]=\"service.refresh\" [error]=\"onError\" [success]=\"onSuccess\" (submit)=\"onSubmit($event)\" ></formio> "
},] },
];
/** @nocollapse */
FormioResourceCreateComponent.ctorParameters = function () { return [
{ type: FormioResourceService },
{ type: router.ActivatedRoute },
{ type: router.Router },
{ type: FormioResourceConfig }
]; };
return FormioResourceCreateComponent;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/index/index.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioResourceIndexComponent = /** @class */ (function () {
function FormioResourceIndexComponent(service, route, router, config) {
this.service = service;
this.route = route;
this.router = router;
this.config = config;
}
/**
* @return {?}
*/
FormioResourceIndexComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.gridQuery = {};
this.service.setContext(this.route);
this.service.formLoaded.then((/**
* @return {?}
*/
function () {
if (_this.service &&
_this.config.parents &&
_this.config.parents.length) {
_this.service.loadParents().then((/**
* @param {?} parents
* @return {?}
*/
function (parents) {
_.each(parents, (/**
* @param {?} parent
* @return {?}
*/
function (parent) {
if (parent && parent.filter) {
_this.gridQuery['data.' + parent.name + '._id'] =
parent.resource._id;
}
}));
// Set the source to load the grid.
_this.gridSrc = _this.service.formUrl;
_this.createText = "New " + _this.service.form.title;
}));
}
else if (_this.service.formUrl) {
_this.gridSrc = _this.service.formUrl;
_this.createText = "New " + _this.service.form.title;
}
}));
};
/**
* @param {?} row
* @return {?}
*/
FormioResourceIndexComponent.prototype.onSelect = /**
* @param {?} row
* @return {?}
*/
function (row) {
this.router.navigate([row._id, 'view'], { relativeTo: this.route });
};
/**
* @return {?}
*/
FormioResourceIndexComponent.prototype.onCreateItem = /**
* @return {?}
*/
function () {
this.router.navigate(['new'], { relativeTo: this.route });
};
FormioResourceIndexComponent.decorators = [
{ type: core.Component, args: [{
template: "<formio-alerts [alerts]=\"service.alerts\"></formio-alerts> <formio-grid [src]=\"gridSrc\" [query]=\"gridQuery\" [onForm]=\"service.formLoaded\" (rowSelect)=\"onSelect($event)\" (error)=\"service.onError($event)\" (createItem)=\"onCreateItem()\" [createText]=\"createText\" ></formio-grid> "
},] },
];
/** @nocollapse */
FormioResourceIndexComponent.ctorParameters = function () { return [
{ type: FormioResourceService },
{ type: router.ActivatedRoute },
{ type: router.Router },
{ type: FormioResourceConfig }
]; };
return FormioResourceIndexComponent;
}());
/**
* @fileoverview added by tsickle
* Generated from: resource/resource.routes.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?=} config
* @return {?}
*/
function FormioResourceRoutes(config) {
return [
{
path: '',
component: config && config.index ? config.index : FormioResourceIndexComponent
},
{
path: 'new',
component: config && config.create ? config.create : FormioResourceCreateComponent
},
{
path: ':id',
component: config && config.resource ? config.resource : FormioResourceComponent,
children: [
{
path: '',
redirectTo: 'view',
pathMatch: 'full'
},
{
path: 'view',
component: config && config.view ? config.view : FormioResourceViewComponent
},
{
path: 'edit',
component: config && config.edit ? config.edit : FormioResourceEditComponent
},
{
path: 'delete',
component: config && config.delete ? config.delete : FormioResourceDeleteComponent
}
]
}
];
}
/**
* @fileoverview added by tsickle
* Generated from: formio.service.ts
* @suppress {checkTypes,constantProperty,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 formiojs.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
* Generated from: custom-component/custom-tags.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var CustomTagsService = /** @class */ (function () {
function CustomTagsService() {
this.tags = [];
}
/**
* @param {?} tag
* @return {?}
*/
CustomTagsService.prototype.addCustomTag = /**
* @param {?} tag
* @return {?}
*/
function (tag) {
this.tags.push(tag);
};
CustomTagsService.decorators = [
{ type: core.Injectable },
];
return CustomTagsService;
}());
/**
* @fileoverview added by tsickle
* Generated from: FormioBaseComponent.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FormioBaseComponent = /** @class */ (function () {
function FormioBaseComponent(ngZone, loader, config, customTags) {
var _this = this;
this.ngZone = ngZone;
this.loader = loader;
this.config = config;
this.customTags = customTags;
this.submission = {};
this.noeval = false;
this.readOnly = 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.submissionLoad = new core.EventEmitter();
this.ready = new core.EventEmitter();
this.initialized = false;
this.alerts = new FormioAlerts();
this.submitting = false;
this.formioReady = new Promise((/**
* @param {?} ready
* @return {?}
*/
function (ready) {
_this.formioReadyResolve = ready;