Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'formiojs' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
Object.keys(given).forEach(machineName => {
let tempForm = given[machineName];
// Convert all resources to point to the resource name;
formioUtils.eachComponent(tempForm.components, (component) => {
hook.alter('exportComponent', component);
if (component.hasOwnProperty('resource') && project.resources && project.resources.hasOwnProperty(component.resource)) {
component.resource = project.resources[component.resource].name;
}
}, true);
given[machineName] = tempForm;
});
init() {
if (this.initialized) {
return;
}
this.initialized = true;
if (this.appConfig && this.appConfig.appUrl) {
Formio.setBaseUrl(this.appConfig.apiUrl);
Formio.setProjectUrl(this.appConfig.appUrl);
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;
}
init() {
if (this.initialized) {
return;
}
this.initialized = true;
if (this.appConfig && this.appConfig.appUrl) {
Formio.setBaseUrl(this.appConfig.apiUrl);
Formio.setProjectUrl(this.appConfig.appUrl);
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();
console.error('You must provide an AppConfig within your application!');
}
this.loginForm = this.appConfig.appUrl + '/' + this.config.login.form;
this.registerForm = this.appConfig.appUrl + '/' + this.config.register.form;
this.onLogin = new core_1.EventEmitter();
this.onLogout = new core_1.EventEmitter();
this.onRegister = new core_1.EventEmitter();
this.onUser = new core_1.EventEmitter();
this.onError = new core_1.EventEmitter();
this.ready = new Promise(function (resolve, reject) {
_this.readyResolve = resolve;
_this.readyReject = reject;
});
// Register for the core events.
Formio.events.on('formio.badToken', function () { return _this.logoutError(); });
Formio.events.on('formio.sessionExpired', function () { return _this.logoutError(); });
this.init();
}
FormioAuthService.prototype.onLoginSubmit = function (submission) {
else {
console.error('You must provide an AppConfig within your application!');
}
this.loginForm = this.appConfig.appUrl + '/' + this.config.login.form;
this.registerForm = this.appConfig.appUrl + '/' + this.config.register.form;
this.onLogin = new core_1.EventEmitter();
this.onLogout = new core_1.EventEmitter();
this.onRegister = new core_1.EventEmitter();
this.onUser = new core_1.EventEmitter();
this.onError = new core_1.EventEmitter();
this.ready = new Promise(function (resolve, reject) {
_this.readyResolve = resolve;
_this.readyReject = reject;
});
// Register for the core events.
Formio.events.on('formio.badToken', function () { return _this.logoutError(); });
Formio.events.on('formio.sessionExpired', function () { return _this.logoutError(); });
this.init();
}
FormioAuthService.prototype.onLoginSubmit = function (submission) {
}
catch (error) {
console.warn('Error calculating select components in ' + this.props.component.key, error);
this.setState({
selectItems: []
});
}
};
this.refreshItems();
break;
case 'resource':
case 'url':
if (this.props.component.dataSrc === 'url') {
this.url = this.props.component.data.url;
if (this.url.substr(0, 1) === '/') {
this.url = formiojs.getBaseUrl() + this.props.component.data.url;
}
// Disable auth for outgoing requests.
if (!this.props.component.authenticate && this.url.indexOf(formiojs.getBaseUrl()) === -1) {
this.options = {
disableJWT: true,
headers: {
Authorization: undefined,
Pragma: undefined,
'Cache-Control': undefined
}
};
}
}
else {
this.url = formiojs.getBaseUrl();
init() {
this.projectReady = Formio.makeStaticRequest(this.appConfig.appUrl).then((project: any) => {
_each(project.access, (access: any) => {
this.formAccess[access.type] = access.roles;
});
}, (err: any): any => {
this.formAccess = {};
return null;
});
// Get the access for this project.
this.accessReady = Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((access: any) => {
_each(access.forms, (form: any) => {
this.submissionAccess[form.name] = {};
form.submissionAccess.forEach((access: any) => {
this.submissionAccess[form.name][access.type] = access.roles;
});
});
this.roles = access.roles;
return access;
}, (err: any): any => {
this.roles = {};
return null;
});
this.userReady = Formio.currentUser().then((user: any) => {
this.setUser(user);
return user;
init() {
this.projectReady = Formio.makeStaticRequest(this.appConfig.appUrl).then((project: any) => {
_each(project.access, (access: any) => {
this.formAccess[access.type] = access.roles;
});
}, (err: any): any => {
this.formAccess = {};
return null;
});
// Get the access for this project.
this.accessReady = Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((access: any) => {
_each(access.forms, (form: any) => {
this.submissionAccess[form.name] = {};
form.submissionAccess.forEach((access: any) => {
this.submissionAccess[form.name][access.type] = access.roles;
});
return;
}
this.setState({
alerts: [],
isSubmitting: true
});
var sub = this.state.submission;
sub.data = clone(this.data);
var request;
var method;
// Do the submit here.
if (this.state.form.action) {
method = this.state.submission._id ? 'put' : 'post';
request = Formiojs.request(this.state.form.action, method, sub);
}
else if (this.formio) {
request = this.formio.saveSubmission(sub);
}
if (request) {
request.then(function (submission) {
if (typeof this.props.onFormSubmit === 'function') {
this.props.onFormSubmit(submission);
}
this.setState({
isSubmitting: false,
alerts: [{
type: 'success',
message: 'Submission was ' + ((method === 'put') ? 'updated' : 'created')
}]
});
init() {
this.projectReady = Formio.makeStaticRequest(this.appConfig.appUrl).then(
(project: any) => {
each(project.access, (access: any) => {
this.formAccess[access.type] = access.roles;
});
},
(): any => {
this.formAccess = {};
return null;
}
);
// Get the access for this project.
this.accessReady = Formio.makeStaticRequest(
this.appConfig.appUrl + '/access'
).then(
(access: any) => {
each(access.forms, (form: any) => {
this.submissionAccess[form.name] = {};
form.submissionAccess.forEach((subAccess: any) => {
this.submissionAccess[form.name][subAccess.type] = subAccess.roles;
});
});
this.roles = access.roles;
return access;
},
(): any => {
this.roles = {};
return null;
}