Skip to content

Instantly share code, notes, and snippets.

View travist's full-sized avatar

Travis Tidwell travist

View GitHub Profile
@travist
travist / force.js
Last active October 30, 2016 23:37
Force Field Validation Errors in Form.io
var forceFieldError = function(key, error) {
var formioFormScope = angular.element('[name="formioForm"]').scope();
var formioScope = formioFormScope.$parent;
var formioForm = formioFormScope.formioForm;
var component = FormioUtils.getComponent(formioScope.form.components, key);
component.customError = error;
formioForm.$pristine = false;
formioForm.$valid = false;
formioForm[key].$setValidity('custom', false);
formioForm[key].$pristine = false;
@travist
travist / debounce.js
Last active October 2, 2021 11:28
How to debounce a $scope.$watch for Angular.js.
['$scope', function($scope) {
var debounce = function(cb) {
var timeout = null;
return function(data) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
cb(data);
}, 200);
@travist
travist / state.json
Last active October 1, 2016 21:13
U.S. States GeoCode API Results
{
"Alabama": {
"address_components": [{
"long_name": "Alabama",
"short_name": "AL",
"types": ["administrative_area_level_1", "political"]
}, {
"long_name": "United States",
"short_name": "US",
"types": ["country", "political"]
@travist
travist / formio-submission-index-search.js
Created September 7, 2016 04:17
Form.io Submission Index Requests
/**
* This will request all submissions where they provided "Smith" in the Last Name field.
*
* GET - https://yourproject.form.io/yourform/submission?data.lastName=Smith
*/
var request = require("request");
var options = {
method: 'GET',
url: 'https://yourproject.form.io/yourform/submission',
qs: {'data.lastName': 'Smith'},
if ($scope.action) {
var method = submissionData._id ? 'put' : 'post';
$http[method]($scope.action, submissionData, {
disableJWT: true,
headers: {
Authorization: undefined,
Pragma: undefined,
'Cache-Control': undefined
}
}).success(function(submission) {
@travist
travist / ajax.js
Created August 31, 2016 21:30
Submitting Form.io Form using jQuery ajax
var submission = {
data: {
firstName: 'Test',
lastName: 'Person',
email: '[email protected]',
phoneNumber: '123123123123'
}
};
var settings = {
"async": true,
@travist
travist / report.js
Created August 22, 2016 18:26
Form.io Reporting API
var request = require("request");
var options = {
method: 'POST',
url: 'https://myproject.form.io/report',
headers: {
'content-type': 'application/json',
'x-jwt-token': '..... TOKEN GOES HERE .....'
},
body: [
{
@travist
travist / index.route.js
Last active July 12, 2018 02:34
Auto-populate a field with data
FormioResourceProvider.register('todo', AppConfig.forms.todoForm, {
defaultValue: {data: {status: 'notstarted'}},
templates: {
view: 'views/todo/view.html'
},
controllers: {
create: ['$scope', '$rootScope', function($scope, $rootScope) {
$rootScope.whenReady.then(function() {
$scope.submission = {data: {
email: $rootScope.user.data.email
@travist
travist / email.html
Last active November 10, 2022 17:37
An example email template for Form.io email messages
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Actionable emails e.g. reset password</title>
<style type="text/css">
img {
@travist
travist / README.md
Last active July 3, 2022 23:25
Installing Form.io on Ubuntu Server

Installing Form.io Enterprise on Ubuntu Sever

This is a complete installation script of a standalone Form.io server within Ubuntu Server. You must upgrade one of your Form.io projects to Enterprise to get this working.