Skip to content

Instantly share code, notes, and snippets.

View travist's full-sized avatar

Travis Tidwell travist

View GitHub Profile
@travist
travist / addproject.js
Created July 18, 2019 19:11
Script to add project ID's to submissions
'use strict';
/**
* Adds project IDs to all submissions.
*
* Run this using
* npm install
* node addproject.js --NODE_CONFIG='{"mongo": "mongodb://localhost:27017/formio"}'
*
* @param db
@travist
travist / custom-builder.js
Created June 20, 2019 15:49
Override Validation Components
import BaseEditValidationForm from 'formiojs/components/base/editForm/Base.edit.validation.form';
import _ from 'lodash';
const customValidation = _.cloneDeep(BaseEditValidationForm[4]);
customValidation.components.splice(3, 1);
Formio.builder(document.getElementById('builder'), {}, {
editForm: {
textfield: [
{
key: 'validation',
@travist
travist / README.md
Created June 14, 2019 04:45
Form.io Enterprise Docker Compose

This is an example of how to deploy the Form.io Enterprise solution locally. To get this to work, please step through the following instructions.

  1. Install Docker to your local machine.
  2. Download this Gist to your local computer, and navigate to the folder within your machines terminal.
  3. Get a temporary LICENSE by contacting [email protected]
  4. Once you receive your license, paste this as the value for the LICENSE: environment variable within the docker-compose.yml file.
  5. Type docker-compose up within your terminal.
  6. This will install all dependencies locally and run the server @ http://localhost:3000 on your machine.
  7. Login using the credentials [email protected] and CHANGEME as the password.
  8. You should see a project called "Portal Base", open this project and then navigate to Settings > Stage Versions > Import Template
@travist
travist / docker-compose.yml
Created June 4, 2019 15:38
Example Form.io Enterprise Docker Compose
version: '3.7'
services:
mongo:
image: mongo:4.1
restart: always
volumes:
- mdb-data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME:
MONGO_INITDB_ROOT_PASSWORD:
@travist
travist / checkmatrix.js
Last active May 7, 2019 16:09
ES5 Custom Component
/**
* Get the base component class by referencing Formio.Components.components map.
*/
var BaseComponent = Formio.Components.components.base;
/**
* Create a new CheckMatrixComponent "class" using ES5 class inheritance notation.
* https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Inheritance
*
* Here we will derive from the base component which all Form.io form components derive from.
@travist
travist / deploy.sh
Created September 25, 2018 16:02
On-Premise Deployment Single Server w/ External Mongo
docker network create formio && \
docker run -itd \
--name formio-redis \
--network formio \
--restart unless-stopped \
redis && \
docker run -itd \
-e "FORMIO_FILES_SERVER=http://formio-files:4005" \
-e "PORTAL_SECRET=CHANGEME" \
-e "JWT_SECRET=CHANGEME" \
@travist
travist / undelete.js
Last active October 19, 2018 00:54
Undelete Project
var PROJECT = '';
db.projects.find({_id: ObjectId(PROJECT)}).forEach(function(project) {
var TIMESTAMP = (project.deleted > 0) ? (project.deleted - 1000) : 0;
print('Undeleting project ' + project._id.toString());
db.projects.update({_id: ObjectId(PROJECT)}, {$set: {deleted: null}});
print('Undeleting forms within ' + project._id.toString());
db.forms.update({project: project._id, deleted: {$gt: TIMESTAMP}}, {$set: {deleted: null}}, {multi: true});
print('Undeleting roles within ' + project._id.toString());
db.roles.update({project: project._id, deleted: {$gt: TIMESTAMP}}, {$set: {deleted: null}}, {multi: true});
db.forms.find({project: project._id, deleted: {$gt: TIMESTAMP}}).forEach(function(form) {
@travist
travist / timezones.json
Created August 18, 2018 04:15
Timezones for moment-timezone
[
{
"name": "Africa/Abidjan",
"label": "Africa/Abidjan"
},
{
"name": "Africa/Accra",
"label": "Africa/Accra"
},
{
@travist
travist / component.ts
Created June 29, 2018 19:29
Angular Form Builder
export default class MyComponent {
this.builderForm = {components: []};
this.builderReady = false;
this.builderOptions = {
builder: {
resource: {}
}
};
constructor() {