Skip to content

Instantly share code, notes, and snippets.

View travist's full-sized avatar

Travis Tidwell travist

View GitHub Profile
@travist
travist / report.js
Last active September 26, 2017 18:40
Report API Example
var pipeline = [];
pipeline.push({
'$match': {
'form': {$in: ['23234234234234423', '234234234234234234']}
}
});
pipeline.push({
'$match': {
'$or': [
{'data.firstName': 'Travis'},
@travist
travist / app.js
Created September 26, 2017 02:29
Extend Angular Form Builder
var fbScope = angular.element('#form-builder').scope();
fbScope.formComponentGroups.existing = {
title: 'Existing Fields',
panelClass: 'subgroup-accordion-container',
subgroups: {}
};
fbScope.formComponentsByGroup.existing = {
'firstName': {
type: 'textfield',
key: 'firstName',
@travist
travist / deploy.sh
Created September 4, 2017 16:40
Form.io Docker Files Deployment
docker network create formio;
docker run -itd \
--name minio \
--network formio \
-p 9000:9000 \
minio/minio server /data;
docker run -itd \
-e "FORMIO_PROJECT=[FORM.IO PROJECT ID]" \
-e "FORMIO_PROJECT_TOKEN=[FORM.IO PROJECT TOKEN]" \
-e "FORMIO_PDF_PROJECT=[FORM.IO PDF PROJECT URL]" \
@travist
travist / form.js
Created August 22, 2017 01:21
Send form submission to custom API
import { Component } from '@angular/core';
import { FormioService } from 'ng2-formio';
@Component({
template: '<formio *ngIf="form" form="[form]" (submit)="onSubmit($event)"></formio>'
})
export class FormioFormExample {
public form: object;
public service: FormioService;
constructor() {
@travist
travist / generate.js
Created August 3, 2017 13:35
Form.io External JWT Token Generation
/**
* This code does require our Docker deployment where the "JWT_SECRET" would be the
* same secret of the environment variable when the docker is spun up.
*/
var jwt = require('jsonwebtoken');
var token = jwt.sign({
external: true,
form: {
_id: '59795d259be16e3ee58fddaa',
project: '59795d259be16e3ee58fdda6'
{
"title": "Person",
"display": "form",
"type": "form",
"name": "person",
"path": "person",
"components": [
{
"type": "textfield",
"input": true,
[
{"name": "Afghanistan", "code": "AF", "flagged": true},
{"name": "land Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "AndorrA", "code": "AD"},
{"name": "Angola", "code": "AO"},
{"name": "Anguilla", "code": "AI"},
{"name": "Antarctica", "code": "AQ"},
@travist
travist / jsonpretty
Last active July 20, 2017 15:47
Pretty print JSON
<pre><code id="json"></code></pre>
@travist
travist / custom.js
Last active May 10, 2019 09:48
Custom Component
import { BaseComponent } from './Base';
import { Formio } from 'formiojs/full';
export class CustomComponent extends BaseComponent {
constructor(component, options, data) {
super(component, options, data);
}
}
Formio.registerComponent('custom', CustomComponent);
@travist
travist / workflow.js
Last active October 26, 2021 05:34
Form.io - Multi-page form workflows
var workflow = new FormioWizard(document.getElementById('workflow'));
workflow.form = {
components: [
{
type: 'hidden',
key: 'score',
input: true,
defaultValue: 0,
calculateValue: {
"+": [