fixed client tests

This commit is contained in:
David Baldwynn 2015-11-23 11:19:02 -08:00
parent 463bdbc96c
commit 3af0468f4d
40 changed files with 905 additions and 491 deletions

View file

@ -3,8 +3,8 @@ TellForm
Current stable release: v1.2.1
[![Build Status](https://travis-ci.org/whitef0x0/nodeforms.svg?branch=master)](https://travis-ci.org/whitef0x0/nodeforms)
[![Dependencies Status](https://david-dm.org/whitef0x0/NodeForms.svg)](https://david-dm.org/whitef0x0/nodeforms)
[![Build Status](https://travis-ci.org/whitef0x0/tellform.svg?branch=master)](https://travis-ci.org/whitef0x0/tellform)
[![Dependencies Status](https://david-dm.org/whitef0x0/tellform.svg)](https://david-dm.org/whitef0x0/tellform)
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
@ -45,6 +45,11 @@ $ npm install
$ bower install
```
Setup environment.
```bash
$ grunt build
```
To run development version:
```bash
$ grunt default
@ -81,6 +86,11 @@ $ grunt test:client
Currently the live example uses heroku github deployments. The Docker file is out of date and does not work. If someone wishes to get it working feel free to submit a pull request.
To calculate your code coverage with Istanbul, run the coverage task
```bash
$ grunt coverage
```
## Running in a secure environment
To run your application in a secure manner you'll need to use OpenSSL and generate a set of self-signed certificates. Unix-based users can use the following command:
```bash

View file

@ -1,7 +1,7 @@
{
"name": "TellForm",
"description": "Beautiful, opensource web forms",
"repository": "https://github.com/whitef0x0/nodeforms",
"repository": "https://github.com/whitef0x0/tellform",
"logo": "https://node-js-sample.herokuapp.com/node.svg",
"keywords": ["node", "express", "static", "mean"]
}

View file

@ -41,7 +41,7 @@ describe('User CRUD tests', function() {
password: 'password'
};
Create a new user
//Create a new user
_User = {
firstName: 'Full',
lastName: 'Name',

View file

@ -68,9 +68,7 @@
</div>
<header data-ng-include="'/modules/core/views/header.client.view.html'"></header>
<section class="content">
<!-- <section class="container"> -->
{% block content %}{% endblock %}
<!-- </section> -->
</section>
<script src="lib/file-saver.js/FileSaver.js" type="text/javascript"></script>

View file

@ -2,7 +2,7 @@
"name": "TellForm",
"description": "Opensource alternative to TypeForm",
"version": "1.2.1",
"homepage": "https://github.com/whitef0x0/NodeForms",
"homepage": "https://github.com/whitef0x0/tellform",
"authors": [
"David Baldwynn <polydaic@gmail.com> (http://baldwynn.me)"
],
@ -11,17 +11,16 @@
"appPath": "public/modules",
"dependencies": {
"bootstrap": "~3",
"angular": "~1.3.20",
"angular-resource": "~1.4.4",
"angular-animate": "~1.3.20",
"angular-mocks": "~1.3.20",
"angular": "~1.4.7",
"angular-resource": "~1.4.7",
"angular-animate": "~1.4.7",
"angular-mocks": "~1.4.7",
"angular-bootstrap": "~0.12.0",
"angular-ui-utils": "~0.1.1",
"angular-ui-router": "~0.2.11",
"angular-strap": "~2.3.1",
"restangular": "~1.5.1",
"fontawesome": "~4.3.0",
"ng-file-upload": "~9.1.2",
"ng-file-upload": "~10.0.2",
"angular-raven": "~0.5.11",
"angular-ui-date": "~0.0.8",
"lodash": "~3.10.0",
@ -35,7 +34,8 @@
"angular-ui-router-tabs": "~1.7.0"
},
"resolutions": {
"angular": "~1.3.20",
"angular-bootstrap": "^0.14.0"
"angular-bootstrap": "^0.14.0",
"angular": "~1.4.7",
"angular-animate": "~1.4.7"
}
}

24
config/env/all.js vendored
View file

@ -3,8 +3,8 @@
module.exports = {
app: {
title: 'TellForm',
description: 'Generate Forms from PDFs',
keywords: 'typeform, pdfs, forms, generator, form generator',
description: 'Opensource form builder alternative to TypeForm',
keywords: 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs',
},
port: process.env.PORT || 3000,
templateEngine: 'swig',
@ -39,7 +39,7 @@ module.exports = {
maxAge: null,
// To set the cookie in a specific domain uncomment the following
// setting:
// domain: 'forms.polydaic.com'
// domain: 'tellform.com'
},
/*
@ -64,29 +64,13 @@ module.exports = {
}
},
assets: {
// lib: {
// css: [
// 'public/lib/bootstrap/dist/css/bootstrap.css',
// 'public/lib/bootstrap/dist/css/bootstrap-theme.css',
// ],
// js: [
// 'public/lib/angular/angular.js',
// 'public/lib/angular-permission/dist/angular-permission.js',
// 'public/lib/angular-resource/angular-resource.js',
// 'public/lib/angular-animate/angular-animate.js',
// 'public/lib/angular-ui-router/release/angular-ui-router.js',
// 'public/lib/angular-ui-utils/ui-utils.js',
// 'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
// 'public/lib/ng-file-upload/ng-file-upload-all.js',
// 'public/lib/angular-cookies/angular-cookies.js',
// ]
// },
css: [
'public/modules/**/css/*.css'
],
js: [
'public/config.js',
'public/application.js',
'public/populate_template_cache.js',
'public/modules/*/*.js',
'public/modules/*/*[!tests]*/*.js'
],

View file

@ -22,20 +22,6 @@ module.exports = {
domain: 'dev.tellform.com'
},
assets: {
// lib: {
// css: [
// 'public/lib/bootstrap/dist/css/bootstrap.min.css',
// 'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
// ],
// js: [
// 'public/lib/angular/angular.min.js',
// 'public/lib/angular-resource/angular-resource.min.js',
// 'public/lib/angular-animate/angular-animate.min.js',
// 'public/lib/angular-ui-router/release/angular-ui-router.min.js',
// 'public/lib/angular-ui-utils/ui-utils.min.js',
// 'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js'
// ]
// },
css: 'public/dist/application.min.css',
js: 'public/dist/application.min.js'
},
@ -65,7 +51,7 @@ module.exports = {
callbackURL: '/auth/github/callback'
},
mailer: {
from: process.env.MAILER_FROM || 'no-reply@kioskform-dev.herokuapp.com',
from: process.env.MAILER_FROM || 'no-reply@dev.tellform.com',
options: {
service: process.env.MAILER_SERVICE_PROVIDER || '',
auth: {

View file

@ -22,20 +22,6 @@ module.exports = {
domain: 'tellform.com'
},
assets: {
// lib: {
// css: [
// 'public/lib/bootstrap/dist/css/bootstrap.min.css',
// 'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
// ],
// js: [
// 'public/lib/angular/angular.min.js',
// 'public/lib/angular-resource/angular-resource.min.js',
// 'public/lib/angular-animate/angular-animate.min.js',
// 'public/lib/angular-ui-router/release/angular-ui-router.min.js',
// 'public/lib/angular-ui-utils/ui-utils.min.js',
// 'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js'
// ]
// },
css: 'public/dist/application.min.css',
js: 'public/dist/application.min.js'
},

14
config/env/secure.js vendored
View file

@ -36,20 +36,6 @@ module.exports = {
domain: 'forms.polydaic.com'
},
assets: {
// lib: {
// css: [
// 'public/lib/bootstrap/dist/css/bootstrap.min.css',
// 'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
// ],
// js: [
// 'public/lib/angular/angular.min.js',
// 'public/lib/angular-resource/angular-resource.min.js',
// 'public/lib/angular-animate/angular-animate.min.js',
// 'public/lib/angular-ui-router/release/angular-ui-router.min.js',
// 'public/lib/angular-ui-utils/ui-utils.min.js',
// 'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js'
// ]
// },
css: 'public/dist/application.min.css',
js: 'public/dist/application.min.js'
},

View file

@ -8,7 +8,9 @@ module.exports = function(grunt) {
clientViews: ['public/modules/**/views/**/*.html'],
clientJS: ['public/js/*.js', 'public/modules/**/*.js'],
clientCSS: ['public/modules/**/*.css'],
mochaTests: ['app/tests/**/*.js']
serverTests: ['app/tests/**/*.js'],
clientTests: ['public/modules/**/tests/*.js'],
allTests: ['public/modules/**/tests/*.js', 'app/tests/**/*.js'],
};
// Project Configuration
@ -32,6 +34,7 @@ module.exports = function(grunt) {
},
clientViews: {
files: watchFiles.clientViews,
tasks: ['html2js:main'],
options: {
livereload: true,
spawn: false
@ -54,7 +57,7 @@ module.exports = function(grunt) {
}
},
mochaTests: {
files: watchFiles.mochaTests,
files: watchFiles.serverTests,
tasks: ['test:server'],
}
},
@ -166,6 +169,80 @@ module.exports = function(grunt) {
}
}
},
mocha_istanbul: {
coverage: {
src: watchFiles.allTests, // a folder works nicely
options: {
mask: '*.test.js'
}
},
coverageClient: {
src: watchFiles.clientTests, // specifying file patterns works as well
options: {
coverageFolder: 'coverageClient',
mask: '*.test.js',
}
},
coverageServer: {
src: watchFiles.serverTests,
options: {
coverageFolder: 'coverageServer',
mask: '*.test.js',
}
},
coveralls: {
src: watchFiles.allTests, // multiple folders also works
options: {
coverage:true, // this will make the grunt.event.on('coverage') event listener to be triggered
check: {
lines: 75,
statements: 75
},
root: './lib', // define where the cover task should consider the root of libraries that are covered by tests
reportFormats: ['cobertura','lcovonly']
}
}
},
istanbul_check_coverage: {
default: {
options: {
coverageFolder: 'coverage*', // will check both coverage folders and merge the coverage results
check: {
lines: 80,
statements: 80
}
}
}
},
html2js: {
options: {
base: 'NodeForm',
module: 'NodeForm.templates',
singleModule: true,
useStrict: true,
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
}
},
main: {
src: ['public/modules/**/views/**.html', 'public/modules/**/views/**/*.html'],
dest: 'public/populate_template_cache.js'
}
}
});
grunt.event.on('coverage', function(lcov, done){
require('coveralls').handleInput(lcov, function(err){
if (err) {
return done(err);
}
done();
});
});
// Load NPM tasks
@ -182,26 +259,33 @@ module.exports = function(grunt) {
grunt.config.set('applicationJavaScriptFiles', config.assets.js);
grunt.config.set('applicationCSSFiles', config.assets.css);
});
grunt.loadNpmTasks('grunt-html2js');
grunt.loadNpmTasks('grunt-html2js');
grunt.loadNpmTasks('grunt-mocha-istanbul');
// Code coverage tasks.
grunt.registerTask('coveralls', ['mocha_istanbul:coveralls']);
grunt.registerTask('coverage', ['mocha_istanbul:coverage']);
grunt.registerTask('coverage:client', ['mocha_istanbul:coverageClient']);
grunt.registerTask('coverage:server', ['mocha_istanbul:coverageServer']);
// Default task(s).
grunt.registerTask('default', ['lint', 'concurrent:default']);
grunt.registerTask('default', ['lint', 'html2js:main', 'concurrent:default']);
// Debug task.
grunt.registerTask('debug', ['lint', 'concurrent:debug']);
grunt.registerTask('debug', ['lint', 'html2js:main', 'concurrent:debug']);
// Secure task(s).
grunt.registerTask('secure', ['env:secure', 'lint', 'concurrent:default']);
grunt.registerTask('secure', ['env:secure', 'lint', 'html2js:main', 'concurrent:default']);
// Lint task(s).
grunt.registerTask('lint', ['newer:jshint', 'newer:csslint']);
// Build task(s).
grunt.registerTask('build', ['lint', 'loadConfig', 'uglify', 'cssmin', 'ngAnnotate' ]);
grunt.registerTask('build', ['lint', 'loadConfig', 'uglify', 'cssmin', 'ngAnnotate', 'html2js:main']);
// Test task.
grunt.registerTask('test', ['test:server', 'test:client']);
grunt.registerTask('test:server', ['env:test', 'mochaTest']);
grunt.registerTask('test:client', ['env:test', 'karma:unit']);
grunt.registerTask('test:server', ['html2js:main', 'env:test', 'mochaTest']);
grunt.registerTask('test:client', ['html2js:main', 'env:test', 'karma:unit']);
};

View file

@ -21,11 +21,12 @@ module.exports = function(config) {
// Possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['mocha', 'html', 'progress'],
preprocessors: {
'public/modules/*/views/**/*.html': ['ng-html2js'],
'public/modules/*/views/**/**.html': ['ng-html2js'],
'public/modules/*/views/*.html': ['ng-html2js'],
'public/modules/*/*.js': ['coverage'],
'public/modules/*/*[!tests]*/*.js': ['coverage'],
//'public/modules/*/*.js': ['coverage'],
//'public/modules/*/*[!tests]*/*.js': ['coverage'],
},
ngHtml2JsPreprocessor: {
@ -43,10 +44,10 @@ module.exports = function(config) {
//Make sure we capture console.log output
client: {
captureConsole: true,
mocha: {
bail: true
}
captureConsole: true,
mocha: {
bail: true
}
},
// Level of logging
@ -67,7 +68,7 @@ module.exports = function(config) {
browsers: ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
captureTimeout: 3000,
// Continuous Integration mode
// If true, it capture browsers, run tests and exit

View file

@ -2,7 +2,7 @@
"name": "TellForm",
"description": "Opensource alternative to TypeForm",
"version": "1.2.1",
"homepage": "https://github.com/whitef0x0/NodeForms",
"homepage": "https://github.com/whitef0x0/tellform",
"authors": [
"David Baldwynn <polydaic@gmail.com> (http://baldwynn.me)"
],
@ -50,7 +50,6 @@
"grunt-contrib-watch": "~0.6.1",
"grunt-env": "~0.4.1",
"grunt-karma": "~0.12.1",
"grunt-mocha-test": "~0.12.1",
"grunt-newer": "~1.1.1",
"grunt-ng-annotate": "~1.0.1",
"grunt-node-inspector": "~0.4.1",
@ -62,7 +61,6 @@
"main-bower-files": "~2.9.0",
"math": "0.0.3",
"method-override": "~2.3.0",
"mocha": ">=1.20.0",
"mongoose": "~3.8.8",
"mongoose-utilities": "~0.1.1",
"morgan": "~1.6.1",
@ -90,19 +88,23 @@
"express-device": "~0.4.2"
},
"devDependencies": {
"node-mandrill": "^1.0.1",
"grunt-mocha-istanbul": "^3.0.1",
"grunt-mocha-test": "~0.12.1",
"istanbul": "^0.4.0",
"karma": "~0.13.14",
"karma-chrome-launcher": "~0.2.1",
"karma-jasmine-html-reporter": "^0.1.8",
"karma-mocha-reporter": "^1.1.1",
"karma-ng-html2js-preprocessor": "^0.2.0",
"karma-coverage": "~0.2.0",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "^0.2.3",
"karma-jasmine-html-reporter": "^0.1.8",
"karma-mocha-reporter": "^1.1.1",
"karma-ng-html2js-preprocessor": "^0.2.0",
"karma-phantomjs-launcher": "~0.1.2",
"mailosaur": "^1.0.1",
"mocha": ">=1.20.0",
"node-mandrill": "^1.0.1",
"should": "~7.1.1",
"supertest": "~1.1.0",
"supertest-session": "^1.0.0",
"mailosaur": "^1.0.1",
"karma": "~0.13.14"
"supertest-session": "^1.0.0"
}
}

View file

@ -4,7 +4,7 @@
var ApplicationConfiguration = (function() {
// Init module configuration options
var applicationModuleName = 'NodeForm';
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ngRaven', 'cgBusy'];
var applicationModuleVendorDependencies = ['ngResource', 'NodeForm.templates', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ngRaven', 'cgBusy'];
// Add a new vertical module
var registerModule = function(moduleName, dependencies) {

View file

@ -1,28 +1,5 @@
'use strict';
// Init the application configuration module for AngularJS application
var ApplicationConfiguration = (function() {
// Init module configuration options
var applicationModuleName = 'NodeForm';
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ngRaven', 'cgBusy'];
// Add a new vertical module
var registerModule = function(moduleName, dependencies) {
// Create angular module
angular.module(moduleName, dependencies || []);
// Add the module to the AngularJS configuration file
angular.module(applicationModuleName).requires.push(moduleName);
};
return {
applicationModuleName: applicationModuleName,
applicationModuleVendorDependencies: applicationModuleVendorDependencies,
registerModule: registerModule
};
})();
'use strict';
//Start by defining the main module and adding the module dependencies
angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfiguration.applicationModuleVendorDependencies);
@ -110,6 +87,63 @@ angular.element(document).ready(function() {
});
'use strict';
// Init the application configuration module for AngularJS application
var ApplicationConfiguration = (function() {
// Init module configuration options
var applicationModuleName = 'TellForm';
var applicationModuleVendorDependencies = ['ngResource', 'TellForm.templates', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ngRaven', 'cgBusy'];
// Add a new vertical module
var registerModule = function(moduleName, dependencies) {
// Create angular module
angular.module(moduleName, dependencies || []);
// Add the module to the AngularJS configuration file
angular.module(applicationModuleName).requires.push(moduleName);
};
return {
applicationModuleName: applicationModuleName,
applicationModuleVendorDependencies: applicationModuleVendorDependencies,
registerModule: registerModule
};
})();
angular.module('TellForm.templates', []).run(['$templateCache', function($templateCache) {
"use strict";
$templateCache.put("../public/modules/core/views/header.client.view.html",
"<section class=\"navbar navbar-fixed-top navbar-inverse\" data-ng-controller=HeaderController ng-hide=hideNav><div class=container><div class=navbar-header><button class=navbar-toggle type=button data-ng-click=toggleCollapsibleMenu()><span class=sr-only>Toggle navigation</span> <span class=icon-bar></span> <span class=icon-bar></span> <span class=icon-bar></span></button> <a href=\"/#!/\" class=navbar-brand><i class=\"fa fa-archive\" style=\"padding-right: 0.3em\"></i>Tell<span>Forms</span></a></div><nav class=\"collapse navbar-collapse\" collapse=!isCollapsed role=navigation><ul class=\"nav navbar-nav\" data-ng-if=authentication.isAuthenticated()><li data-ng-repeat=\"item in menu.items | orderBy: 'position'\" data-ng-if=item.shouldRender(authentication.isAuthenticated()); ng-switch=item.menuItemType ui-route={{item.uiRoute}} class={{item.menuItemClass}} ng-class=\"{active: ($uiRoute)}\" dropdown=\"item.menuItemType === 'dropdown'\"><a ng-switch-when=dropdown class=dropdown-toggle dropdown-toggle><span data-ng-bind=item.title></span> <b class=caret></b></a><ul ng-switch-when=dropdown class=dropdown-menu><li data-ng-repeat=\"subitem in item.items | orderBy: 'position'\" data-ng-if=subitem.shouldRender(authentication.isAuthenticated()); ui-route={{subitem.uiRoute}} ng-class=\"{active: $uiRoute}\"><a href=/#!/{{subitem.link}} data-ng-bind=subitem.title></a></li></ul><a ng-switch-default href=/#!/{{item.link}} data-ng-bind=item.title></a></li></ul><ul class=\"nav navbar-nav navbar-right\" data-ng-hide=authentication.isAuthenticated()><li ui-route=/signup ng-class=\"{active: $uiRoute}\"><a href=/#!/signup>Sign Up</a></li><li class=divider-vertical></li><li ui-route=/signin ng-class=\"{active: $uiRoute}\"><a href=/#!/signin>Sign In</a></li></ul><ul class=\"nav navbar-nav navbar-right\" data-ng-show=authentication.isAuthenticated()><li class=dropdown uib-dropdown><a href=# class=dropdown-toggle data-toggle=dropdown dropdown-toggle><span>My Settings</span> <b class=caret></b></a><ul class=dropdown-menu><li><a href=/#!/settings/profile>Edit Profile</a></li><li class=divider></li><li><a href=/#!/settings/password>Change Password</a></li><li data-ng-show=\"authentication.isAuthenticated().provider === 'local'\"><a href=/#!/settings/password>Change Password</a></li></ul></li><li ng-click=signout()><a>Signout</a></li></ul></nav></div></section>");
$templateCache.put("../public/modules/core/views/home.client.view.html",
"<section data-ng-controller=HomeController class=hero-section style=overflow:hidden><div class=opacity-background></div><div class=image-background></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=\"row text-center logo\" style=\"border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 30px\"><h3 class=col-xs-12 style=\"color: #FA787E; margin-bottom:0px\"><i class=\"fa fa-archive fa-3x\"></i></h3><h2 class=col-xs-12 style=margin-top:0px><span>Tell<span style=\"text-decoration: underline; color: #FA787E\">Form</span></span></h2></div><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Craft beautiful forms in seconds.</h1><h2 class=\"lead col-sm-12 text-center hidden-md hidden-lg\" style=font-size:2.8em>Craft beautiful forms.</h2><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div></div></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Create your next ______.</h1><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:2.5em>Tell a story with a form.</h1><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div><div class=row style=margin-top:7%><a class=\"col-xs-4 col-xs-offset-4 btn btn-info signup-btn\" href=/#!/signup style=\"background-color:#FA787E; border: none; font-size: 2em; padding: 0.3em 0.9em; color: white\">sign me up!</a></div></div></div></section>");
$templateCache.put("../public/modules/forms/views/admin-form.client.view.html",
"<div class=container cg-busy=\"{promise:updatePromise,templateUrl:'modules/forms/views/directiveViews/cgBusy/update-form-message-TypeB.html',message:'Updating form...', backdrop:false, wrapperClass:'.busy-updating-wrapper'}\"></div><section class=\"container admin-form\"><script type=text/ng-template id=myModalContent.html><div class=\"modal-header\">\n" +
" <h2 class=\"modal-title hidden-md hidden-lg\">Are you ABSOLUTELY sure?</h2>\n" +
" <h3 class=\"modal-title hidden-xs hidden-sm\">Are you ABSOLUTELY sure?</h3>\n" +
" </div>\n" +
" <div class=\"modal-body\">\n" +
" <div class=\"modal-body-alert\">\n" +
" Unexpected bad things will happen if you dont read this!\n" +
" </div>\n" +
" <p class=\"hidden-xs hidden-sm\">\n" +
" This action <strong>CANNOT</strong> be undone.This will permanently delete the <strong>{{myform.title}}</strong> form, form submissions and remove all associated pdfs.\n" +
" </p>\n" +
" <p>Please type in the name of the form to confirm.</p>\n" +
" </div>\n" +
" <div class=\"modal-footer\">\n" +
" <p>\n" +
" <input type=\"text\" data-ng-model=\"deleteConfirm\" class=\"input-block\" autofocus required aria-label=\"Type in the name of the form to confirm that you want to delete this form.\">\n" +
" </p>\n" +
" <button type=\"submit\" ng-click=\"removeCurrentForm()\" class=\"btn btn-block btn-danger\" ng-disabled=\"myform.title != deleteConfirm\">\n" +
" I understand the consequences, delete this form\n" +
" </button>\n" +
" </div></script><div class=\"page-header row\" style=\"padding-bottom: 0px\"><div class=\"col-xs-10 col-sm-8\"><h1 class=\"hidden-sm hidden-xs\" data-ng-bind=myform.title style=\"margin-bottom: 0px\"></h1><h2 class=\"hidden-md hidden-lg\" data-ng-bind=myform.title style=\"margin-bottom: 0px\"></h2></div><div class=\"col-xs-1 col-sm-2\"><small class=pull-right><button class=\"btn btn-danger\" ng-click=openDeleteModal()><i class=\"fa fa-trash-o\"></i> <span class=hidden-xs>Delete</span> <span class=\"hidden-xs hidden-sm\">Form</span></button></small></div><div class=\"col-xs-1 col-sm-2\"><small class=pull-right><a class=\"btn btn-default view-form-btn\" href=/#!/forms/{{myform._id}}><span class=\"hidden-xs hidden-sm\">View <span ng-show=myform.isLive>Live</span> <span ng-hide=myform.isLive>Preview</span> Form</span> <span class=\"hidden-xs hidden-md hidden-lg\">View <span ng-if=myform.isLive>Live</span> <span ng-if=!myform.isLive>Preview</span></span> <i class=\"status-light status-light-on fa fa-dot-circle-o\" ng-if=myform.isLive></i> <i class=\"status-light status-light-off fa fa-dot-circle-o\" ng-if=!myform.isLive></i></a></small></div></div><div class=row><div class=col-xs-12><tabs data=tabData></tabs></div><div class=col-xs-12><ui-view></ui-view></div></div></section>");
$templateCache.put("../public/modules/forms/views/list-forms.client.view.html",
"<section class=overlay ng-if=showCreateModal ng-click=closeCreateModal()></section><section data-ng-controller=\"ListFormsController as ctrl\" data-ng-init=findAll() class=container><br><div class=row><div ng-click=openCreateModal() class=\"col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new\"><div class=\"title-row col-xs-12\"><h4 class=\"fa fa-plus fa-6\"></h4></div><div class=\"col-xs-12 details-row\"><small class=list-group-item-text>Create a new form</small></div></div><form name=forms.createForm class=\"col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new new-form\" ng-if=showCreateModal><div class=\"title-row row\"><div class=\"col-xs-5 field-title text-left\">Name</div><div class=\"col-xs-12 field-input\"><input name=title required ng-model=formTitle ng-pattern=\"/^[a-zA-Z0-9 \\-.]*$/\" ng-minlength=\"4\"></div></div><div class=\"details-row row\"><div class=\"col-xs-5 field-title text-left\">Language</div><div class=\"col-xs-12 field-input\"><div class=\"button custom-select\"><select style=color:black name=language required ng-model=formLanguage ng-init=\"formLanguage = user.language\"><option ng-repeat=\"language in languages\" value={{language}}>{{language}}</option></select></div></div></div><div class=\"details-row submit row\"><div class=\"col-xs-12 field-title text-center\"><button class=\"btn btn-primary\" ng-disabled=forms.createForm.$invalid ng-click=createNewForm()>Create Form</button></div></div></form><div data-ng-repeat=\"form in myforms\" class=\"col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item container\"><div class=row><span class=pull-right><i style=cursor:pointer class=\"fa fa-trash-o\" ng-click=removeForm($index)></i> <i style=cursor:pointer class=\"fa fa-files-o\" ng-click=duplicateForm($index)></i></span></div><div class=row><a data-ng-href=#!/forms/{{form._id}}/admin/create class=\"title-row col-xs-12\"><h4 class=list-group-item-heading data-ng-bind=form.title></h4></a></div><div class=\"row footer\"><div class=\"col-xs-12 details-row\"><small class=list-group-item-text>Created on <span data-ng-bind=\"form.created | date:'shortDate'\"></span></small></div></div></div></div></section>");
$templateCache.put("../public/modules/forms/views/submit-form.client.view.html",
"<section class=public-form ng-style=\"{ 'background-color': myform.design.colors.backgroundColor }\"><submit-form-directive myform=myform></submit-form-directive></section>");
}]);
'use strict';
// Use Application configuration module to register a new module
ApplicationConfiguration.registerModule('core', ['users']);
@ -441,7 +475,6 @@ angular.module('forms').config(['$stateProvider',
resolve: {
Forms: 'Forms',
myForm: ["Forms", "$stateParams", function (Forms, $stateParams) {
console.log('getting form');
return Forms.get({formId: $stateParams.formId}).$promise;
}],
},
@ -471,6 +504,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
$scope.animationsEnabled = true;
$scope.myform = myForm;
$rootScope.saveInProgress = false;
CurrentForm.setForm($scope.myform);
$scope.tabData = [
@ -491,20 +525,6 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
route: 'viewForm.analyze',
}
];
// Find a specific Form
$scope.findOne = function(){
Forms.get({
formId: $stateParams.formId
}, function(form){
CurrentForm.setForm(form);
$scope.myform = form;
$scope.myform._id = $stateParams.formId;
}, function(err){
console.error('Could not fetch form');
console.error(err);
});
};
$scope.setForm = function(form){
$scope.myform = form;
@ -520,19 +540,19 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
*/
$scope.openDeleteModal = function(){
$scope.deleteModal = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'AdminFormController',
resolve: {
myForm: function () {
return $scope.myform;
}
}
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'AdminFormController',
resolve: {
myForm: function(){
return $scope.myform;
}
}
});
$scope.deleteModal.result.then(function (selectedItem) {
$scope.selected = selectedItem;
$scope.selected = selectedItem;
}, function () {
console.log('Modal dismissed at: ' + new Date());
console.log('Modal dismissed at: ' + new Date());
});
};
@ -540,12 +560,6 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
$scope.cancelDeleteModal = function(){
if($scope.deleteModal){
$scope.deleteModal.dismiss('cancel');
$scope.deleteModal.result(function(selectedItem){
this.selected = selectedItem;
}, function(type){
this.canceled = true;
});
}
};
@ -697,10 +711,10 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
]);
'use strict';
// Forms controller
angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$state', 'myForm',
function($scope, $rootScope, $state, myForm) {
$scope.authentication = $rootScope.authentication;
// SubmitForm controller
angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$state', 'myForm', 'Auth',
function($scope, $rootScope, $state, myForm, Auth) {
$scope.authentication = Auth;
$scope.myform = myForm;
if(!$scope.myform.isLive){
@ -791,7 +805,6 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
console.log('Form saving started');
debounceSave();
console.log('introParagraphStartPage.$dirty AFTER: '+$scope.editForm.introParagraphStartPage.$dirty);
}
});
@ -805,8 +818,13 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
oldValue.form_fields = _.removeDateFields(oldValue.form_fields);
var changedFields = !_.isEqual(oldValue.form_fields,newValue.form_fields) || !_.isEqual(oldValue.startPage, newValue.startPage);
var changedFieldMap = false;
var changedFieldMap = !!oldValue.plugins.oscarhost.settings.fieldMap && !_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap);
if(oldValue.hasOwnProperty('plugins.oscarhost.settings.fieldMap')){
changedFieldMap = !!oldValue.plugins.oscarhost.settings.fieldMap && !_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap);
}
//If our form is undefined, don't save form
if( (!newValue && !oldValue) || !oldValue ){
return;
}
@ -824,7 +842,7 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
// console.log(newValue.form_fields);
if(oldValue.form_fields.length === 0) {
$rootScope.finishedRender = true
$rootScope.finishedRender = true;
}
//Save form ONLY IF rendering is finished, form_fields have been changed AND currently not save in progress
@ -1069,24 +1087,23 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
** startPage Button Methods
*/
// add new Button to the startPage/EndPage
// add new Button to the startPage
$scope.addButton = function(){
var newButton = {};
newButton.bgColor = '#ddd';
newButton.color = '#ffffff';
newButton.text = 'Button';
newButton._id = _.uniqueId();
newButton._id = Math.floor(100000*Math.random());
$scope.myform.startPage.buttons.push(newButton);
};
// delete particular Button
// delete particular Button from startPage
$scope.deleteButton = function(button){
// var hashKey = _.chain(button.$$hashKey).words().last().parseInt().value();
var currID;
for(var i = 0; i < $scope.myform.startPage.buttons.length; i++){
// var currHashKey = _.chain($scope.myform.startPage.buttons[i].$$hashKey).words().last().parseInt().value();
currID = $scope.myform.startPage.buttons[i]._id;
console.log(currID);
@ -1103,33 +1120,44 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
*/
// add new option to the field
$scope.addOption = function (field){
if(!field.fieldOptions) field.fieldOptions = [];
$scope.addOption = function(field_index){
var currField = $scope.myform.form_fields[field_index];
var lastOptionID = 0;
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
if(!currField.fieldOptions) currField.fieldOptions = [];
if(field.fieldOptions[field.fieldOptions.length-1]){
lastOptionID = field.fieldOptions[field.fieldOptions.length-1].option_id;
var lastOptionID = 0;
if(currField.fieldOptions[currField.fieldOptions.length-1]){
lastOptionID = currField.fieldOptions[currField.fieldOptions.length-1].option_id;
}
// new option's id
var option_id = lastOptionID + 1;
var newOption = {
'option_id' : Math.floor(100000*Math.random()),
"option_title" : 'Option '+lastOptionID,
'option_value' : 'Option ' +lastOptionID,
};
// put new option into fieldOptions array
$scope.myform.form_fields[field_index].fieldOptions.push(newOption);
}
// new option's id
var option_id = lastOptionID + 1;
var newOption = {
'option_id' : option_id,
'option_value' : 'Option ' + option_id,
};
// put new option into fieldOptions array
field.fieldOptions.push(newOption);
};
// delete particular option
$scope.deleteOption = function (field, option){
for(var i = 0; i < field.fieldOptions.length; i++){
if(field.fieldOptions[i].option_id === option.option_id){
field.fieldOptions.splice(i, 1);
break;
$scope.deleteOption = function (field_index, option){
var currField = $scope.myform.form_fields[field_index];
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
for(var i = 0; i < currField.fieldOptions.length; i++){
if(currField.fieldOptions[i].option_id === option.option_id){
$scope.myform.form_fields[field_index].fieldOptions.splice(i, 1);
break;
}
}
}
};
@ -1427,7 +1455,6 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
TimeCounter.startClock();
/*
** Field Controls
*/
@ -1493,8 +1520,6 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
form.percentageComplete = $filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100;
delete form.visible_form_fields;
$scope.authentication = Auth;
$scope.submitPromise = $http.post('/forms/'+$scope.myform._id, form)
.success(function(data, status, headers){
console.log('form submitted successfully');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,7 +10,7 @@
<i class="fa fa-archive fa-3x"></i>
</h3>
<h2 class="col-xs-12" style="margin-top:0px">
<span style="color: #FA787E">Tell<span style="text-decoration: underline;">Forms</span></span>
<span>Tell<span style="text-decoration: underline; color: #FA787E;">Form</span></span>
</h2>
</div>
<div class="row" style="margin-top:0px">
@ -32,6 +32,29 @@
</div>
</div>
</div>
<div class="jumbotron text-center">
<div class="container" data-ng-if="!authentication.isAuthenticated()">
<div class="row" style="margin-top:0px">
<h1 class="lead col-md-10 col-md-offset-1 hidden-xs hidden-sm" style="font-size:3.8em;">
Create your next ______.
</h1>
<h1 class="lead col-md-10 col-md-offset-1 hidden-xs hidden-sm" style="font-size:2.5em;">
Tell a story with a form.
</h1>
<p class="lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2" style="font-size:1.5em; color:rgba(255,255,255,.75)">
<i>TellForm is an opensource <b>alternative to TypeForm </b> that can create stunning forms from PDFs or from scratch</i>
</p>
<p class="lead col-xs-12 hidden-md hidden-lg" style="font-size:1.5em; color:rgba(255,255,255,.75)">
<i>TellForm is an opensource <b>alternative to TypeForm </b> that can create stunning forms from PDFs or from scratch</i>
</h1>
</div>
<div class="row" style="margin-top:7%;">
<a class="col-xs-4 col-xs-offset-4 btn btn-info signup-btn" href="/#!/signup" style="background-color:#FA787E; border: none; font-size: 2em; padding: 0.3em 0.9em; color: white;">
sign me up!
@ -40,3 +63,5 @@
</div>
</div>
</section>

View file

@ -35,7 +35,6 @@ angular.module('forms').config(['$stateProvider',
resolve: {
Forms: 'Forms',
myForm: function (Forms, $stateParams) {
console.log('getting form');
return Forms.get({formId: $stateParams.formId}).$promise;
},
},

View file

@ -8,6 +8,7 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
$scope.animationsEnabled = true;
$scope.myform = myForm;
$rootScope.saveInProgress = false;
CurrentForm.setForm($scope.myform);
$scope.tabData = [
@ -28,20 +29,6 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
route: 'viewForm.analyze',
}
];
// Find a specific Form
$scope.findOne = function(){
Forms.get({
formId: $stateParams.formId
}, function(form){
CurrentForm.setForm(form);
$scope.myform = form;
$scope.myform._id = $stateParams.formId;
}, function(err){
console.error('Could not fetch form');
console.error(err);
});
};
$scope.setForm = function(form){
$scope.myform = form;
@ -57,19 +44,19 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
*/
$scope.openDeleteModal = function(){
$scope.deleteModal = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'AdminFormController',
resolve: {
myForm: function () {
return $scope.myform;
}
}
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller: 'AdminFormController',
resolve: {
myForm: function(){
return $scope.myform;
}
}
});
$scope.deleteModal.result.then(function (selectedItem) {
$scope.selected = selectedItem;
$scope.selected = selectedItem;
}, function () {
console.log('Modal dismissed at: ' + new Date());
console.log('Modal dismissed at: ' + new Date());
});
};
@ -77,12 +64,6 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
$scope.cancelDeleteModal = function(){
if($scope.deleteModal){
$scope.deleteModal.dismiss('cancel');
$scope.deleteModal.result(function(selectedItem){
this.selected = selectedItem;
}, function(type){
this.canceled = true;
});
}
};

View file

@ -1,9 +1,9 @@
'use strict';
// Forms controller
angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$state', 'myForm',
function($scope, $rootScope, $state, myForm) {
$scope.authentication = $rootScope.authentication;
// SubmitForm controller
angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$state', 'myForm', 'Auth',
function($scope, $rootScope, $state, myForm, Auth) {
$scope.authentication = Auth;
$scope.myform = myForm;
if(!$scope.myform.isLive){

View file

@ -420,9 +420,12 @@ section > section.public-form {
display: inline-block;
background-color: transparent;
border-radius: 7px;
width:100%;
width: 100%;
border: 25px transparent solid;
}
.activeField input {
background-color: transparent;
}
.form-item:hover, .form-item.create-new:hover {
@ -452,8 +455,6 @@ section > section.public-form {
.form-item.create-new .title-row{
padding: 0;
/*margin-top:1em; */
}
.form-item.create-new .title-row h4 {
font-size: 7em;

View file

@ -70,7 +70,6 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
console.log('Form saving started');
debounceSave();
console.log('introParagraphStartPage.$dirty AFTER: '+$scope.editForm.introParagraphStartPage.$dirty);
}
});
@ -84,8 +83,13 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
oldValue.form_fields = _.removeDateFields(oldValue.form_fields);
var changedFields = !_.isEqual(oldValue.form_fields,newValue.form_fields) || !_.isEqual(oldValue.startPage, newValue.startPage);
var changedFieldMap = false;
var changedFieldMap = !!oldValue.plugins.oscarhost.settings.fieldMap && !_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap);
if(oldValue.hasOwnProperty('plugins.oscarhost.settings.fieldMap')){
changedFieldMap = !!oldValue.plugins.oscarhost.settings.fieldMap && !_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap);
}
//If our form is undefined, don't save form
if( (!newValue && !oldValue) || !oldValue ){
return;
}
@ -103,7 +107,7 @@ angular.module('forms').directive('autoSaveForm', ['$rootScope', '$timeout', fun
// console.log(newValue.form_fields);
if(oldValue.form_fields.length === 0) {
$rootScope.finishedRender = true
$rootScope.finishedRender = true;
}
//Save form ONLY IF rendering is finished, form_fields have been changed AND currently not save in progress

View file

@ -103,7 +103,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
//Delete field from field map
var currFieldId = $scope.myform.form_fields[field_index]._id
if($scope.myform.plugins.oscarhost.baseUrl) delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId];
if($scope.myform.hasOwnProperty('plugins.oscarhost.baseUrl')) delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId];
//Delete field
$scope.myform.form_fields.splice(field_index, 1);
@ -122,24 +122,23 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
** startPage Button Methods
*/
// add new Button to the startPage/EndPage
// add new Button to the startPage
$scope.addButton = function(){
var newButton = {};
newButton.bgColor = '#ddd';
newButton.color = '#ffffff';
newButton.text = 'Button';
newButton._id = _.uniqueId();
newButton._id = Math.floor(100000*Math.random());
$scope.myform.startPage.buttons.push(newButton);
};
// delete particular Button
// delete particular Button from startPage
$scope.deleteButton = function(button){
// var hashKey = _.chain(button.$$hashKey).words().last().parseInt().value();
var currID;
for(var i = 0; i < $scope.myform.startPage.buttons.length; i++){
// var currHashKey = _.chain($scope.myform.startPage.buttons[i].$$hashKey).words().last().parseInt().value();
currID = $scope.myform.startPage.buttons[i]._id;
console.log(currID);
@ -156,33 +155,44 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
*/
// add new option to the field
$scope.addOption = function (field){
if(!field.fieldOptions) field.fieldOptions = [];
$scope.addOption = function(field_index){
var currField = $scope.myform.form_fields[field_index];
var lastOptionID = 0;
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
if(!currField.fieldOptions) $scope.myform.form_fields[field_index].fieldOptions = [];
if(field.fieldOptions[field.fieldOptions.length-1]){
lastOptionID = field.fieldOptions[field.fieldOptions.length-1].option_id;
var lastOptionID = 0;
if(currField.fieldOptions[currField.fieldOptions.length-1]){
lastOptionID = currField.fieldOptions[currField.fieldOptions.length-1].option_id;
}
// new option's id
var option_id = lastOptionID + 1;
var newOption = {
'option_id' : Math.floor(100000*Math.random()),
'option_title' : 'Option '+lastOptionID,
'option_value' : 'Option ' +lastOptionID,
};
// put new option into fieldOptions array
$scope.myform.form_fields[field_index].fieldOptions.push(newOption);
}
// new option's id
var option_id = lastOptionID + 1;
var newOption = {
'option_id' : option_id,
'option_value' : 'Option ' + option_id,
};
// put new option into fieldOptions array
field.fieldOptions.push(newOption);
};
// delete particular option
$scope.deleteOption = function (field, option){
for(var i = 0; i < field.fieldOptions.length; i++){
if(field.fieldOptions[i].option_id === option.option_id){
field.fieldOptions.splice(i, 1);
break;
$scope.deleteOption = function (field_index, option){
var currField = $scope.myform.form_fields[field_index];
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
for(var i = 0; i < currField.fieldOptions.length; i++){
if(currField.fieldOptions[i].option_id === option.option_id){
$scope.myform.form_fields[field_index].fieldOptions.splice(i, 1);
break;
}
}
}
};

View file

@ -8,8 +8,8 @@ var __indexOf = [].indexOf || function(item) {
return -1;
};
angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$rootScope',
function($http, $compile, $rootScope) {
angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache',
function($http, $compile, $rootScope, $templateCache) {
var getTemplateUrl = function(field) {
@ -36,7 +36,9 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
if (__indexOf.call(supported_fields, type) >= 0) {
templateUrl = templateUrl+type+'.html';
}
return templateUrl;
return $templateCache.get('../public/'+templateUrl);
//return templateUrl;
};
return {
@ -63,11 +65,11 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
}
// GET template content from path
var templateUrl = getTemplateUrl(scope.field);
$http.get(templateUrl).success(function(data) {
element.html(data).show();
var template = getTemplateUrl(scope.field);
//$http.get(templateUrl).success(function(data) {
element.html(template).show();
$compile(element.contents())(scope);
});
//});
},
};
}]);

View file

@ -10,8 +10,14 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
},
controller: function($scope){
$scope.authentication = $rootScope.authentication;
angular.element(document).ready(function() {
$scope.reloadForm = function(){
//Reset Form
$scope.myform.submitted = false;
$scope.myform.form_fields = _.chain($scope.myform.form_fields).map(function(field){
field.fieldValue = '';
return field;
}).value();
$scope.error = '';
$scope.selected = {
@ -19,101 +25,88 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
index: null,
};
$scope.submitted = false;
//Reset Timer
TimeCounter.restartClock();
};
TimeCounter.startClock();
/*
** Field Controls
*/
$rootScope.setActiveField = function(field_id, field_index) {
if($scope.selected === null){
$scope.selected = {
_id: '',
index: 0,
};
}
console.log('field_id: '+field_id);
console.log('field_index: '+field_index);
console.log($scope.selected);
$scope.selected._id = field_id;
$scope.selected.index = field_index;
setTimeout(function() {
$('html, body').animate({
scrollTop: $('.activeField').offset().top
},200);
}, 10);
};
$scope.nextField = function(){
if($scope.selected.index < $scope.myform.form_fields.length-1){
$scope.selected.index++;
$scope.selected._id = $scope.myform.form_fields[$scope.selected.index]._id;
$rootScope.setActiveField($scope.selected._id, $scope.selected.index);
}
};
$scope.prevField = function(){
if($scope.selected.index > 0){
$scope.selected.index = $scope.selected.index - 1;
$scope.selected._id = $scope.myform.form_fields[$scope.selected.index]._id;
$rootScope.setActiveField($scope.selected._id, $scope.selected.index);
}
};
$scope.hideOverlay = function(){
/*
** Field Controls
*/
$rootScope.setActiveField = function(field_id, field_index) {
if($scope.selected === null){
$scope.selected = {
_id: '',
index: null,
index: 0,
};
}
console.log('field_id: '+field_id);
console.log('field_index: '+field_index);
console.log($scope.selected);
$scope.selected._id = field_id;
$scope.selected.index = field_index;
setTimeout(function() {
$('html, body').animate({
scrollTop: $('.activeField').offset().top
},200);
}, 10);
};
$scope.nextField = function(){
if($scope.selected.index < $scope.myform.form_fields.length-1){
$scope.selected.index++;
$scope.selected._id = $scope.myform.form_fields[$scope.selected.index]._id;
$rootScope.setActiveField($scope.selected._id, $scope.selected.index);
}
};
$scope.prevField = function(){
if($scope.selected.index > 0){
$scope.selected.index = $scope.selected.index - 1;
$scope.selected._id = $scope.myform.form_fields[$scope.selected.index]._id;
$rootScope.setActiveField($scope.selected._id, $scope.selected.index);
}
};
$scope.hideOverlay = function(){
$scope.selected = {
_id: '',
index: null,
};
};
/*
** Form Display Functions
*/
$scope.exitStartPage = function(){
$scope.myform.startPage.showStart = false;
if($scope.myform.form_fields.length > 0){
$scope.selected._id = $scope.myform.form_fields[0]._id;
}
};
/*
** Form Display Functions
*/
$scope.exitStartPage = function(){
$scope.myform.startPage.showStart = false;
if($scope.myform.form_fields.length > 0){
$scope.selected._id = $scope.myform.form_fields[0]._id;
}
};
$scope.submitForm = function(){
var _timeElapsed = TimeCounter.stopClock();
$scope.submitForm = function(){
var _timeElapsed = TimeCounter.stopClock();
var form = _.cloneDeep($scope.myform);
form.timeElapsed = _timeElapsed;
var form = _.cloneDeep($scope.myform);
form.timeElapsed = _timeElapsed;
// console.log('percentageComplete: '+$filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100+'%');
form.percentageComplete = $filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100;
delete form.visible_form_fields;
form.percentageComplete = $filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100;
delete form.visible_form_fields;
$scope.authentication = Auth;
$scope.submitPromise = $http.post('/forms/'+$scope.myform._id, form)
.success(function(data, status, headers){
console.log('form submitted successfully');
$scope.myform.submitted = true;
})
.error(function(error){
console.log(error);
$scope.error = error.message;
});
};
$scope.submitPromise = $http.post('/forms/'+$scope.myform._id, form)
.success(function(data, status, headers){
console.log('form submitted successfully');
$scope.myform.submitted = true;
})
.error(function(error){
console.log(error);
$scope.error = error.message;
});
};
$scope.reloadForm = function(){
//Reset Timer
TimeCounter.stopClock();
TimeCounter.startClock();
//Reset Form
$scope.myform.submitted = false;
$scope.myform.form_fields = _.chain($scope.myform.form_fields).map(function(field){
field.fieldValue = '';
return field;
}).value();
};
//Load our form when the page is ready
angular.element(document).ready(function() {
$scope.reloadForm();
});
}

View file

@ -6,17 +6,26 @@ angular.module('forms').service('TimeCounter', [
this.timeSpent = 0;
this.startClock = function(){
this.restartClock = function(){
_startTime = Date.now();
_endTime = _startTime;
// console.log('Clock Started');
};
this.stopClock = function(){
_endTime = Date.now();
that.timeSpent = Math.abs(_endTime.valueOf() - _startTime.valueOf())/1000;
// console.log('Clock Ended');
return that.timeSpent;
if(_startTime){
_endTime = Date.now();
that.timeSpent = Math.abs(_endTime.valueOf() - _startTime.valueOf())/1000;
// console.log('Clock Ended');
return that.timeSpent;
}else{
return new Error('Clock has not been started');
}
};
this.clockStarted = function(){
return !!this._startTime;
}
}
]);

View file

@ -52,26 +52,30 @@
_id: '525a8422f6d0f87f0e407a33'
};
var fakeModal = function(){
this.opened = true;
this.result = function(confirmCallback, cancelCallback) {
//Store the callbacks for later when the user clicks on the OK or Cancel button of the dialog
this.confirmCallBack = confirmCallback;
this.cancelCallback = cancelCallback;
};
this.close = function( item ) {
//The user clicked OK on the modal dialog, call the stored confirm callback with the selected item
this.opened = false;
this.confirmCallBack( item );
};
this.dismiss = function( type ) {
//The user clicked cancel on the modal dialog, call the stored cancel callback
this.opened = false;
this.cancelCallback( type );
};
var newFakeModal = function(){
var result = {
opened: true,
result: {
then: function(confirmCallback, cancelCallback) {
//Store the callbacks for later when the user clicks on the OK or Cancel button of the dialog
this.confirmCallBack = confirmCallback;
this.cancelCallback = cancelCallback;
}
},
close: function( item ) {
//The user clicked OK on the modal dialog, call the stored confirm callback with the selected item
this.opened = false;
this.result.confirmCallBack( item );
},
dismiss: function( type ) {
//The user clicked cancel on the modal dialog, call the stored cancel callback
this.opened = false;
this.result.cancelCallback( type );
}
};
return result;
};
//Mock Users Service
beforeEach(module(function($provide) {
$provide.service('myForm', function($q) {
@ -99,7 +103,6 @@
});
});
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
@ -160,8 +163,12 @@
});
}));
//Mock $uibModal
beforeEach(inject(function($uibModal) {
spyOn($uibModal, 'open').and.returnValue(new fakeModal());
var modal = newFakeModal();
spyOn($uibModal, 'open').and.returnValue(modal);
//spyOn($uibModal, 'close').and.callFake(modal.close());
}));
// The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
@ -197,27 +204,6 @@
expect(scope.myform).toEqualData(sampleForm);
});
it('$scope.findOne() should fetch current Form', inject(function(Forms) {
// Define a sample article object
var expectedFormObj = new Forms(expectedForm);
var controller = createAdminFormController();
// Set the URL parameter
$stateParams.formId = expectedForm._id;
// Set GET response
$httpBackend.expectGET(/^(\/forms\/)([0-9a-fA-F]{24})$/).respond(200, sampleForm);
// Run controller functionality
scope.findOne();
$httpBackend.flush();
// Test scope value
expect( scope.myform.toJSON() ).toEqualData(expectedFormObj);
}));
it('$scope.removeCurrentForm() with valid form data should send a DELETE request with the id of form', function() {
var controller = createAdminFormController();
@ -229,13 +215,6 @@
//Run controller functionality
scope.openDeleteModal();
scope.deleteModal.result(function(selectedItem){
this.selected = selectedItem;
}, function(type){
this.canceled = true;
});
scope.removeCurrentForm();
$httpBackend.flush();
@ -259,7 +238,8 @@
//Run controller functionality
scope.openDeleteModal();
expect( scope.deleteModal.opened ).toEqual(true);
console.log(scope.deleteModal);
expect(scope.deleteModal.opened).toEqual(true);
});
it('$scope.cancelDeleteModal() should close $scope.deleteModal', inject(function($uibModal) {
@ -267,13 +247,10 @@
//Run controller functionality
scope.openDeleteModal();
console.log(scope.deleteModal.opened);
//Run controller functionality
scope.cancelDeleteModal();
expect( scope.deleteModal.opened ).toEqual(false);
expect( scope.deleteModal.canceled ).toEqual(true);
}));
});
}());

View file

@ -130,7 +130,7 @@
expect( scope.myforms ).toEqualData(sampleFormList);
}));
it('$scope.duplicate() should duplicate a Form', inject(function(Forms) {
it('$scope.duplicateForm() should duplicate a Form', inject(function(Forms) {
var dupSampleForm = sampleFormList[2],
dupSampleForm_index = 3,
@ -149,7 +149,7 @@
// Set GET response
$httpBackend.expect('POST', '/forms').respond(200, dupSampleForm);
// Run controller functionality
scope.duplicate(2);
scope.duplicateForm(2);
$httpBackend.flush();
// Test scope value
@ -191,7 +191,7 @@
expect( scope.myforms[0] ).not.toEqualData(delSampleForm);
}));
it('$scope.createNew() should create a new Form', inject(function(Forms) {
it('$scope.createNewForm() should create a new Form', inject(function(Forms) {
var newForm = _.clone(sampleForm);
newForm.name = 'Test Form5';
@ -207,18 +207,14 @@
$dirty: true,
$valid: true,
};
// scope.forms.createForm.language.$modelValue = 'english';
// scope.forms.createForm.name.$modelValue = 'Test Form5';
// scope.forms.createForm.$dirty = true;
// scope.forms.createForm.$invalid = false;
//Set $state transition
$state.expectTransitionTo('viewForm');
$state.expectTransitionTo('viewForm.create');
// Set GET response
$httpBackend.expect('POST', '/forms').respond(200, newForm);
scope.createNew();
scope.createNewForm();
$httpBackend.flush();
$state.ensureAllTransitionsHappened();

View file

@ -148,7 +148,7 @@
});
}));
//Mock Users Service
//Mock Users Service
beforeEach(module(function($provide) {
$provide.service('User', function($q) {
return {

View file

@ -34,10 +34,10 @@
admin: 'ed873933b1f1dea0ce12fab9',
language: 'english',
form_fields: [
{fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
{fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
{fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
],
{fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
{fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
{fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
],
pdf: {},
pdfFieldMap: {},
startPage: {
@ -71,9 +71,9 @@
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
beforeEach(module('stateMock'));
beforeEach(module('module-templates'));
beforeEach(module('stateMock'));
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
//Instantiate directive.
var tmp_scope = $rootScope.$new();

View file

@ -35,9 +35,9 @@
admin: 'ed873933b1f1dea0ce12fab9',
language: 'english',
form_fields: [
{fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
{fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
{fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
{fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
{fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
{fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
],
pdf: {},
pdfFieldMap: {},
@ -114,8 +114,8 @@
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
beforeEach(module('module-templates'));
beforeEach(module('stateMock'));
beforeEach(module('module-templates'));
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {

View file

@ -35,9 +35,9 @@
admin: 'ed873933b1f1dea0ce12fab9',
language: 'english',
form_fields: [
{fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false},
{fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false},
{fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false}
{fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
{fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
{fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
],
pdf: {},
pdfFieldMap: {},
@ -73,8 +73,8 @@
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
beforeEach(module('stateMock'));
beforeEach(module('module-templates'));
beforeEach(module('stateMock'));
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
//Instantiate directive.
@ -89,7 +89,7 @@
// Point global variables to injected services
$httpBackend = _$httpBackend_;
$httpBackend.whenGET(/.+\.html$/).respond('');
//$httpBackend.whenGET(/.+\.html$/).respond('');
$httpBackend.whenGET('/users/me/').respond('');
//Grab controller instance
@ -101,7 +101,7 @@
}));
describe('Form Field Tests',function(){
describe('> Form Field >',function(){
beforeEach(function(){
scope.myform = _.cloneDeep(sampleForm);
@ -142,13 +142,20 @@
//Run controller methods
scope.duplicateField(0);
var originalField = _.cloneDeep(scope.myform.form_fields[0]);
originalField.title += ' copy';
delete originalField._id;
var copyField = _.cloneDeep(scope.myform.form_fields[1]);
delete copyField._id;
expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length+1);
expect(scope.myform.form_fields[0]).toEqualData(scope.myform.form_fields[1]);
expect(originalField).toEqualData(copyField);
});
});
describe('Form Field Button Tests',function(){
describe('> Form Field Button >',function(){
it('$scope.addButton() should ADD a button to $scope.myform.startPage.buttons', function() {
@ -170,30 +177,27 @@
it('$scope.deleteButton() should DELETE a button from $scope.myform.startPage.buttons', function() {
//Run controller methods
scope.deleteButton(scope.myform.startPage.buttons[0]);
expect(scope.myform.startPage.buttons.length).toEqual(0);
});
});
describe('Form Field Option Tests',function(){
describe('> Form Field Option >',function(){
it('$scope.addOption() should ADD a new option to a field.fieldOptions', function() {
var originalOptionLen = scope.myform.form_fields[1].fieldOptions.length;
//Run controller methods
scope.addOption(scope.myform.form_fields[0]);
scope.addOption(1);
var expectedFieldOption = {
option_id : 1,
option_title : 'Option 1',
option_value : 1
};
expect(scope.myform.form_fields[0].fieldOptions.length).toEqual(sampleForm.form_fields[0].fieldOptions.length+1);
expect(scope.myform.form_fields[0].fieldOptions[0]).toEqualData(expectedFieldOption);
expect(originalOptionLen+1).toEqual(scope.myform.form_fields[1].fieldOptions.length);
expect(scope.myform.form_fields[1].fieldOptions[0].option_title).toEqualData('Option 0');
expect(scope.myform.form_fields[1].fieldOptions[0].option_value).toEqualData('Option 0');
});
it('$scope.deleteOption() should DELETE remove option from field.fieldOptions', function() {
//Run controller methods
scope.deleteOption(1, scope.myform.form_fields[1].fieldOptions[0]);
//Run controller methods
expect(scope.myform.form_fields[0].fieldOptions.length).toEqual(0);
expect(scope.myform.form_fields[0].fieldOptions[0]).not.toBeDefined();
});

View file

@ -53,7 +53,6 @@
// // Load the main application module
// beforeEach(module(ApplicationConfiguration.applicationModuleName));
// beforeEach(module('module-templates'));
// beforeEach(inject(function($rootScope, _$compile_, _$httpBackend_) {
// scope = $rootScope.$new();

View file

@ -19,7 +19,6 @@
it('should emit Custom "Finished" and "Started" events on ng-repeat', inject(function($compile, $rootScope) {
// console.log(FormFields.types);
scope.myfields = FormFields.types;
var e = $compile('<div><div ng-repeat="item in myfields" on-finish-render="editFormFields">{{item.name}}</div></div>')(scope);

View file

@ -4,7 +4,7 @@
// Forms Controller Spec
describe('SubmitForm Directive-Controller Tests', function() {
// Initialize global variables
var el, scope, controller, $httpBackend;
var scope, controller, $httpBackend;
var sampleUser = {
firstName: 'Full',
@ -35,15 +35,13 @@
admin: 'ed873933b1f1dea0ce12fab9',
language: 'english',
form_fields: [
{fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
{fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
{fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
],
{fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
{fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
{fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'} ],
visible_form_fields: [
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': '', 'deletePreserved': false},
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': '', 'deletePreserved': false},
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': '', 'deletePreserved': false}
],
{fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
{fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
{fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'} ],
pdf: {},
pdfFieldMap: {},
startPage: {
@ -58,9 +56,9 @@
var sampleSubmission = {
form_fields: [
{fieldType:'textfield', title:'First Name', fieldValue: 'John Smith', deletePreserved: false},
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: true, deletePreserved: false},
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: false, deletePreserved: false}
{fieldType:'textfield', title:'First Name', fieldValue: 'John Smith', deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: true, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
],
admin: sampleUser,
form: sampleForm,
@ -70,8 +68,8 @@
var sampleSubmissions = [{
form_fields: [
{fieldType:'textfield', title:'First Name', fieldValue: 'The Terminator', deletePreserved: false},
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
{fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
{fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
],
admin: sampleUser,
form: sampleForm,
@ -119,14 +117,13 @@
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
beforeEach(module('stateMock'));
beforeEach(module('module-templates'));
beforeEach(module('stateMock'));
beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
// Point global variables to injected services
$httpBackend = _$httpBackend_;
$httpBackend.whenGET('/users/me/').respond('');
//Instantiate directive.
@ -134,8 +131,9 @@
tmp_scope.myform = sampleForm;
//gotacha: Controller and link functions will execute.
el = angular.element('<submit-form-directive myform="myform"></submit-form-directive>');
var el = angular.element('<submit-form-directive myform="myform"></submit-form-directive>');
$compile(el)(tmp_scope);
tmp_scope.$digest();
$rootScope.$digest();
//Grab controller instance
@ -144,6 +142,8 @@
//Grab scope. Depends on type of scope.
//See angular.element documentation.
scope = el.isolateScope() || el.scope();
console.log(scope);
}));
var Validator = (function() {
@ -158,7 +158,7 @@
})();
it('$scope.submit() should submit valid form', function(){
it('$scope.submitForm() should submit valid form', function(){
//Initialize variables
scope.myform.form_fields = sampleSubmissions[0].form_fields;
@ -175,15 +175,11 @@
return Validator.isNewForm(form) && _.isEqual(compareForm, expectedForm);
};
// console.log('!_.isEmpty(expectedForm.timeElapsed): '+!_.isEmpty(expectedForm.timeElapsed));
console.log('data:'+data(expectedForm));
// //Set expected HTTP requests
//Set expected HTTP requests
$httpBackend.expect('POST',/^(\/forms\/)([0-9a-fA-F]{24})$/, data).respond(200);
// //Run Controller Logic to Test
scope.submit();
//Run Controller Logic to Test
scope.submitForm();
$httpBackend.flush();
expect(scope.myform.submitted).toBe(true);
@ -191,10 +187,10 @@
});
it('$scope.reloadForm() should reset and reload form', function(){
scope.submit();
scope.submitForm();
scope.reloadForm();
expect(scope.submitted).toBe(false);
expect(scope.myform.submitted).toBe(false);
for(var i=0; i<scope.myform.form_fields.length; i++){
expect(scope.myform.form_fields[i].fieldValue).toEqual('');
}

View file

@ -16,7 +16,7 @@
it('should be able to time 1 second interval as 1 second', function() {
var timeSpent = 0;
TimeCounter.startClock();
TimeCounter.restartClock();
setTimeout(function(){
timeSpent = TimeCounter.stopClock();

View file

@ -155,7 +155,7 @@
<div class="col-sm-12 col-md-8 dropzoneContainer">
<accordion close-others="accordion.oneAtATime" ui-sortable="dropzone" ng-model="myform.form_fields" class="dropzone">
<accordion-group data-ng-repeat="field in myform.form_fields track by field._id" is-open="accordion[$index].isOpen" on-finish-render="editFormFields" ng-if="!field.deletePreserved">
<accordion-group data-ng-repeat="field in myform.form_fields track by field._id" is-open="accordion[$index].isOpen" on-finish-render="editFormFields" ng-if="!field.deletePreserved">
<accordion-heading>

View file

@ -0,0 +1,33 @@
angular.module('TellForm.templates', []).run(['$templateCache', function($templateCache) {
"use strict";
$templateCache.put("../public/modules/core/views/header.client.view.html",
"<section class=\"navbar navbar-fixed-top navbar-inverse\" data-ng-controller=HeaderController ng-hide=hideNav><div class=container><div class=navbar-header><button class=navbar-toggle type=button data-ng-click=toggleCollapsibleMenu()><span class=sr-only>Toggle navigation</span> <span class=icon-bar></span> <span class=icon-bar></span> <span class=icon-bar></span></button> <a href=\"/#!/\" class=navbar-brand><i class=\"fa fa-archive\" style=\"padding-right: 0.3em\"></i>Tell<span>Forms</span></a></div><nav class=\"collapse navbar-collapse\" collapse=!isCollapsed role=navigation><ul class=\"nav navbar-nav\" data-ng-if=authentication.isAuthenticated()><li data-ng-repeat=\"item in menu.items | orderBy: 'position'\" data-ng-if=item.shouldRender(authentication.isAuthenticated()); ng-switch=item.menuItemType ui-route={{item.uiRoute}} class={{item.menuItemClass}} ng-class=\"{active: ($uiRoute)}\" dropdown=\"item.menuItemType === 'dropdown'\"><a ng-switch-when=dropdown class=dropdown-toggle dropdown-toggle><span data-ng-bind=item.title></span> <b class=caret></b></a><ul ng-switch-when=dropdown class=dropdown-menu><li data-ng-repeat=\"subitem in item.items | orderBy: 'position'\" data-ng-if=subitem.shouldRender(authentication.isAuthenticated()); ui-route={{subitem.uiRoute}} ng-class=\"{active: $uiRoute}\"><a href=/#!/{{subitem.link}} data-ng-bind=subitem.title></a></li></ul><a ng-switch-default href=/#!/{{item.link}} data-ng-bind=item.title></a></li></ul><ul class=\"nav navbar-nav navbar-right\" data-ng-hide=authentication.isAuthenticated()><li ui-route=/signup ng-class=\"{active: $uiRoute}\"><a href=/#!/signup>Sign Up</a></li><li class=divider-vertical></li><li ui-route=/signin ng-class=\"{active: $uiRoute}\"><a href=/#!/signin>Sign In</a></li></ul><ul class=\"nav navbar-nav navbar-right\" data-ng-show=authentication.isAuthenticated()><li class=dropdown uib-dropdown><a href=# class=dropdown-toggle data-toggle=dropdown dropdown-toggle><span>My Settings</span> <b class=caret></b></a><ul class=dropdown-menu><li><a href=/#!/settings/profile>Edit Profile</a></li><li class=divider></li><li><a href=/#!/settings/password>Change Password</a></li><li data-ng-show=\"authentication.isAuthenticated().provider === 'local'\"><a href=/#!/settings/password>Change Password</a></li></ul></li><li ng-click=signout()><a>Signout</a></li></ul></nav></div></section>");
$templateCache.put("../public/modules/core/views/home.client.view.html",
"<section data-ng-controller=HomeController class=hero-section style=overflow:hidden><div class=opacity-background></div><div class=image-background></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=\"row text-center logo\" style=\"border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 30px\"><h3 class=col-xs-12 style=\"color: #FA787E; margin-bottom:0px\"><i class=\"fa fa-archive fa-3x\"></i></h3><h2 class=col-xs-12 style=margin-top:0px><span>Tell<span style=\"text-decoration: underline; color: #FA787E\">Forms</span></span></h2></div><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Craft beautiful forms in seconds.</h1><h2 class=\"lead col-sm-12 text-center hidden-md hidden-lg\" style=font-size:2.8em>Craft beautiful forms.</h2><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div></div></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Create your next ______.</h1><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:2.5em>Tell a story with a form.</h1><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div><div class=row style=margin-top:7%><a class=\"col-xs-4 col-xs-offset-4 btn btn-info signup-btn\" href=/#!/signup style=\"background-color:#FA787E; border: none; font-size: 2em; padding: 0.3em 0.9em; color: white\">sign me up!</a></div></div></div></section>");
$templateCache.put("../public/modules/forms/views/admin-form.client.view.html",
"<div class=container cg-busy=\"{promise:updatePromise,templateUrl:'modules/forms/views/directiveViews/cgBusy/update-form-message-TypeB.html',message:'Updating form...', backdrop:false, wrapperClass:'.busy-updating-wrapper'}\"></div><section class=\"container admin-form\"><script type=text/ng-template id=myModalContent.html><div class=\"modal-header\">\n" +
" <h2 class=\"modal-title hidden-md hidden-lg\">Are you ABSOLUTELY sure?</h2>\n" +
" <h3 class=\"modal-title hidden-xs hidden-sm\">Are you ABSOLUTELY sure?</h3>\n" +
" </div>\n" +
" <div class=\"modal-body\">\n" +
" <div class=\"modal-body-alert\">\n" +
" Unexpected bad things will happen if you dont read this!\n" +
" </div>\n" +
" <p class=\"hidden-xs hidden-sm\">\n" +
" This action <strong>CANNOT</strong> be undone.This will permanently delete the <strong>{{myform.title}}</strong> form, form submissions and remove all associated pdfs.\n" +
" </p>\n" +
" <p>Please type in the name of the form to confirm.</p>\n" +
" </div>\n" +
" <div class=\"modal-footer\">\n" +
" <p>\n" +
" <input type=\"text\" data-ng-model=\"deleteConfirm\" class=\"input-block\" autofocus required aria-label=\"Type in the name of the form to confirm that you want to delete this form.\">\n" +
" </p>\n" +
" <button type=\"submit\" ng-click=\"removeCurrentForm()\" class=\"btn btn-block btn-danger\" ng-disabled=\"myform.title != deleteConfirm\">\n" +
" I understand the consequences, delete this form\n" +
" </button>\n" +
" </div></script><div class=\"page-header row\" style=\"padding-bottom: 0px\"><div class=\"col-xs-10 col-sm-8\"><h1 class=\"hidden-sm hidden-xs\" data-ng-bind=myform.title style=\"margin-bottom: 0px\"></h1><h2 class=\"hidden-md hidden-lg\" data-ng-bind=myform.title style=\"margin-bottom: 0px\"></h2></div><div class=\"col-xs-1 col-sm-2\"><small class=pull-right><button class=\"btn btn-danger\" ng-click=openDeleteModal()><i class=\"fa fa-trash-o\"></i> <span class=hidden-xs>Delete</span> <span class=\"hidden-xs hidden-sm\">Form</span></button></small></div><div class=\"col-xs-1 col-sm-2\"><small class=pull-right><a class=\"btn btn-default view-form-btn\" href=/#!/forms/{{myform._id}}><span class=\"hidden-xs hidden-sm\">View <span ng-show=myform.isLive>Live</span> <span ng-hide=myform.isLive>Preview</span> Form</span> <span class=\"hidden-xs hidden-md hidden-lg\">View <span ng-if=myform.isLive>Live</span> <span ng-if=!myform.isLive>Preview</span></span> <i class=\"status-light status-light-on fa fa-dot-circle-o\" ng-if=myform.isLive></i> <i class=\"status-light status-light-off fa fa-dot-circle-o\" ng-if=!myform.isLive></i></a></small></div></div><div class=row><div class=col-xs-12><tabs data=tabData></tabs></div><div class=col-xs-12><ui-view></ui-view></div></div></section>");
$templateCache.put("../public/modules/forms/views/list-forms.client.view.html",
"<section class=overlay ng-if=showCreateModal ng-click=closeCreateModal()></section><section data-ng-controller=\"ListFormsController as ctrl\" data-ng-init=findAll() class=container><br><div class=row><div ng-click=openCreateModal() class=\"col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new\"><div class=\"title-row col-xs-12\"><h4 class=\"fa fa-plus fa-6\"></h4></div><div class=\"col-xs-12 details-row\"><small class=list-group-item-text>Create a new form</small></div></div><form name=forms.createForm class=\"col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new new-form\" ng-if=showCreateModal><div class=\"title-row row\"><div class=\"col-xs-5 field-title text-left\">Name</div><div class=\"col-xs-12 field-input\"><input name=title required ng-model=formTitle ng-pattern=\"/^[a-zA-Z0-9 \\-.]*$/\" ng-minlength=\"4\"></div></div><div class=\"details-row row\"><div class=\"col-xs-5 field-title text-left\">Language</div><div class=\"col-xs-12 field-input\"><div class=\"button custom-select\"><select style=color:black name=language required ng-model=formLanguage ng-init=\"formLanguage = user.language\"><option ng-repeat=\"language in languages\" value={{language}}>{{language}}</option></select></div></div></div><div class=\"details-row submit row\"><div class=\"col-xs-12 field-title text-center\"><button class=\"btn btn-primary\" ng-disabled=forms.createForm.$invalid ng-click=createNewForm()>Create Form</button></div></div></form><div data-ng-repeat=\"form in myforms\" class=\"col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item container\"><div class=row><span class=pull-right><i style=cursor:pointer class=\"fa fa-trash-o\" ng-click=removeForm($index)></i> <i style=cursor:pointer class=\"fa fa-files-o\" ng-click=duplicateForm($index)></i></span></div><div class=row><a data-ng-href=#!/forms/{{form._id}}/admin/create class=\"title-row col-xs-12\"><h4 class=list-group-item-heading data-ng-bind=form.title></h4></a></div><div class=\"row footer\"><div class=\"col-xs-12 details-row\"><small class=list-group-item-text>Created on <span data-ng-bind=\"form.created | date:'shortDate'\"></span></small></div></div></div></div></section>");
$templateCache.put("../public/modules/forms/views/submit-form.client.view.html",
"<section class=public-form ng-style=\"{ 'background-color': myform.design.colors.backgroundColor }\"><submit-form-directive myform=myform></submit-form-directive></section>");
}]);

View file

@ -126,7 +126,7 @@
$httpBackend.expect('GET', '/auth/verify/'+sampleVerifyToken).respond(200);
//Run Service Logic to Test
expect(function(){ User.validateVerifyToken(sampleVerifyToken) }).not.toThrow();
expect(function(){ User.validateVerifyToken(sampleVerifyToken); }).not.toThrow();
$httpBackend.flush();
});

File diff suppressed because one or more lines are too long