diff --git a/README.md b/README.md index e1f4b909..131afa12 100755 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ MEDFORMS -------- -[![Build Status](https://travis-ci.org/meanjs/mean.svg?branch=master)](https://travis-ci.org/meanjs/mean) +[![Build Status](https://travis-ci.org/whitef0x0/medforms.svg?branch=master)](https://travis-ci.org/whitef0x0/medforms) [![Dependencies Status](https://david-dm.org/meanjs/mean.svg)](https://david-dm.org/meanjs/mean) -[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/meanjs/mean?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Medforms is an opensource *form builder* that can create stunning forms from PDFs or from scratch diff --git a/app/views/layout.server.view.html b/app/views/layout.server.view.html index a6853f6e..98cc4cab 100755 --- a/app/views/layout.server.view.html +++ b/app/views/layout.server.view.html @@ -54,7 +54,7 @@ - +
diff --git a/public/modules/forms/tests/view-from.client.controller.test.js b/public/modules/forms/tests/view-from.client.controller.test.js index 2bef78a4..1369a227 100644 --- a/public/modules/forms/tests/view-from.client.controller.test.js +++ b/public/modules/forms/tests/view-from.client.controller.test.js @@ -1,170 +1,170 @@ -'use strict'; +// 'use strict'; -(function() { - // Forms Controller Spec - describe('ViewForm Controller Tests', function() { - // Initialize global variables - var ViewFormController, - scope, - $httpBackend, - $stateParams, - $location; +// (function() { +// // Forms Controller Spec +// describe('ViewForm Controller Tests', function() { +// // Initialize global variables +// var ViewFormController, +// scope, +// $httpBackend, +// $stateParams, +// $location; - // The $resource service augments the response object with methods for updating and deleting the resource. - // If we were to use the standard toEqual matcher, our tests would fail because the test values would not match - // the responses exactly. To solve the problem, we define a new toEqualData Jasmine matcher. - // When the toEqualData matcher compares two objects, it takes only object properties into - // account and ignores methods. - beforeEach(function() { - jasmine.addMatchers({ - toEqualData: function(util, customEqualityTesters) { - return { - compare: function(actual, expected) { - return { - pass: angular.equals(actual, expected) - }; - } - }; - } - }); - }); +// // The $resource service augments the response object with methods for updating and deleting the resource. +// // If we were to use the standard toEqual matcher, our tests would fail because the test values would not match +// // the responses exactly. To solve the problem, we define a new toEqualData Jasmine matcher. +// // When the toEqualData matcher compares two objects, it takes only object properties into +// // account and ignores methods. +// beforeEach(function() { +// jasmine.addMatchers({ +// toEqualData: function(util, customEqualityTesters) { +// return { +// compare: function(actual, expected) { +// return { +// pass: angular.equals(actual, expected) +// }; +// } +// }; +// } +// }); +// }); - // Then we can start by loading the main application module - beforeEach(module(ApplicationConfiguration.applicationModuleName)); +// // Then we can start by loading the main application module +// beforeEach(module(ApplicationConfiguration.applicationModuleName)); - // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). - // This allows us to inject a service but then attach it to a variable - // with the same name as the service. - beforeEach(inject(function($controller, $rootScope, _$location_, _$stateParams_, _$httpBackend_) { - // Set a new global scope - scope = $rootScope.$new(); +// // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_). +// // This allows us to inject a service but then attach it to a variable +// // with the same name as the service. +// beforeEach(inject(function($controller, $rootScope, _$location_, _$stateParams_, _$httpBackend_) { +// // Set a new global scope +// scope = $rootScope.$new(); - // Point global variables to injected services - $stateParams = _$stateParams_; - $httpBackend = _$httpBackend_; - $location = _$location_; +// // Point global variables to injected services +// $stateParams = _$stateParams_; +// $httpBackend = _$httpBackend_; +// $location = _$location_; - // Initialize the Forms controller. - FormsController = $controller('FormsController', { - $scope: scope - }); - })); +// // Initialize the Forms controller. +// FormsController = $controller('FormsController', { +// $scope: scope +// }); +// })); - it('$scope.find() should create an array with at least one article object fetched from XHR', inject(function(Forms) { - // Create sample article using the Forms service - var sampleArticle = new Forms({ - title: 'An Article about MEAN', - content: 'MEAN rocks!' - }); +// it('$scope.find() should create an array with at least one article object fetched from XHR', inject(function(Forms) { +// // Create sample article using the Forms service +// var sampleArticle = new Forms({ +// title: 'An Article about MEAN', +// content: 'MEAN rocks!' +// }); - // Create a sample Forms array that includes the new article - var sampleForms = [sampleForm]; +// // Create a sample Forms array that includes the new article +// var sampleForms = [sampleForm]; - // Set GET response - $httpBackend.expectGET('Forms').respond(sampleForms); +// // Set GET response +// $httpBackend.expectGET('Forms').respond(sampleForms); - // Run controller functionality - scope.find(); - $httpBackend.flush(); +// // Run controller functionality +// scope.find(); +// $httpBackend.flush(); - // Test scope value - expect(scope.Forms).toEqualData(sampleForms); - })); +// // Test scope value +// expect(scope.Forms).toEqualData(sampleForms); +// })); - it('$scope.findOne() should create an array with one article object fetched from XHR using a articleId URL parameter', inject(function(Forms) { - // Define a sample article object - var sampleArticle = new Forms({ - title: 'An Article about MEAN', - content: 'MEAN rocks!' - }); +// it('$scope.findOne() should create an array with one article object fetched from XHR using a articleId URL parameter', inject(function(Forms) { +// // Define a sample article object +// var sampleArticle = new Forms({ +// title: 'An Article about MEAN', +// content: 'MEAN rocks!' +// }); - // Set the URL parameter - $stateParams.articleId = '525a8422f6d0f87f0e407a33'; +// // Set the URL parameter +// $stateParams.articleId = '525a8422f6d0f87f0e407a33'; - // Set GET response - $httpBackend.expectGET(/Forms\/([0-9a-fA-F]{24})$/).respond(sampleArticle); +// // Set GET response +// $httpBackend.expectGET(/Forms\/([0-9a-fA-F]{24})$/).respond(sampleArticle); - // Run controller functionality - scope.findOne(); - $httpBackend.flush(); +// // Run controller functionality +// scope.findOne(); +// $httpBackend.flush(); - // Test scope value - expect(scope.article).toEqualData(sampleArticle); - })); +// // Test scope value +// expect(scope.article).toEqualData(sampleArticle); +// })); - it('$scope.create() with valid form data should send a POST request with the form input values and then locate to new object URL', inject(function(Forms) { - // Create a sample article object - var sampleArticlePostData = new Forms({ - title: 'An Article about MEAN', - content: 'MEAN rocks!' - }); +// it('$scope.create() with valid form data should send a POST request with the form input values and then locate to new object URL', inject(function(Forms) { +// // Create a sample article object +// var sampleArticlePostData = new Forms({ +// title: 'An Article about MEAN', +// content: 'MEAN rocks!' +// }); - // Create a sample article response - var sampleArticleResponse = new Forms({ - _id: '525cf20451979dea2c000001', - title: 'An Article about MEAN', - content: 'MEAN rocks!' - }); +// // Create a sample article response +// var sampleArticleResponse = new Forms({ +// _id: '525cf20451979dea2c000001', +// title: 'An Article about MEAN', +// content: 'MEAN rocks!' +// }); - // Fixture mock form input values - scope.title = 'An Article about MEAN'; - scope.content = 'MEAN rocks!'; +// // Fixture mock form input values +// scope.title = 'An Article about MEAN'; +// scope.content = 'MEAN rocks!'; - // Set POST response - $httpBackend.expectPOST('Forms', sampleArticlePostData).respond(sampleArticleResponse); +// // Set POST response +// $httpBackend.expectPOST('Forms', sampleArticlePostData).respond(sampleArticleResponse); - // Run controller functionality - scope.create(); - $httpBackend.flush(); +// // Run controller functionality +// scope.create(); +// $httpBackend.flush(); - // Test form inputs are reset - expect(scope.title).toEqual(''); - expect(scope.content).toEqual(''); +// // Test form inputs are reset +// expect(scope.title).toEqual(''); +// expect(scope.content).toEqual(''); - // Test URL redirection after the article was created - expect($location.path()).toBe('/Forms/' + sampleArticleResponse._id); - })); +// // Test URL redirection after the article was created +// expect($location.path()).toBe('/Forms/' + sampleArticleResponse._id); +// })); - it('$scope.update() should update a valid article', inject(function(Forms) { - // Define a sample article put data - var sampleArticlePutData = new Forms({ - _id: '525cf20451979dea2c000001', - title: 'An Article about MEAN', - content: 'MEAN Rocks!' - }); +// it('$scope.update() should update a valid article', inject(function(Forms) { +// // Define a sample article put data +// var sampleArticlePutData = new Forms({ +// _id: '525cf20451979dea2c000001', +// title: 'An Article about MEAN', +// content: 'MEAN Rocks!' +// }); - // Mock article in scope - scope.article = sampleArticlePutData; +// // Mock article in scope +// scope.article = sampleArticlePutData; - // Set PUT response - $httpBackend.expectPUT(/Forms\/([0-9a-fA-F]{24})$/).respond(); +// // Set PUT response +// $httpBackend.expectPUT(/Forms\/([0-9a-fA-F]{24})$/).respond(); - // Run controller functionality - scope.update(); - $httpBackend.flush(); +// // Run controller functionality +// scope.update(); +// $httpBackend.flush(); - // Test URL location to new object - expect($location.path()).toBe('/Forms/' + sampleArticlePutData._id); - })); +// // Test URL location to new object +// expect($location.path()).toBe('/Forms/' + sampleArticlePutData._id); +// })); - it('$scope.remove() should send a DELETE request with a valid articleId and remove the article from the scope', inject(function(Forms) { - // Create new article object - var sampleArticle = new Forms({ - _id: '525a8422f6d0f87f0e407a33' - }); +// it('$scope.remove() should send a DELETE request with a valid articleId and remove the article from the scope', inject(function(Forms) { +// // Create new article object +// var sampleArticle = new Forms({ +// _id: '525a8422f6d0f87f0e407a33' +// }); - // Create new Forms array and include the article - scope.Forms = [sampleArticle]; +// // Create new Forms array and include the article +// scope.Forms = [sampleArticle]; - // Set expected DELETE response - $httpBackend.expectDELETE(/Forms\/([0-9a-fA-F]{24})$/).respond(204); +// // Set expected DELETE response +// $httpBackend.expectDELETE(/Forms\/([0-9a-fA-F]{24})$/).respond(204); - // Run controller functionality - scope.remove(sampleArticle); - $httpBackend.flush(); +// // Run controller functionality +// scope.remove(sampleArticle); +// $httpBackend.flush(); - // Test array after successful delete - expect(scope.Forms.length).toBe(0); - })); - }); -}()); \ No newline at end of file +// // Test array after successful delete +// expect(scope.Forms.length).toBe(0); +// })); +// }); +// }()); \ No newline at end of file diff --git a/public/modules/users/services/auth.js b/public/modules/users/services/auth.js index 581909b2..0b657cb1 100644 --- a/public/modules/users/services/auth.js +++ b/public/modules/users/services/auth.js @@ -1,7 +1,6 @@ 'use strict'; -angular.module('users') - .factory('Auth', function($window) { +angular.module('users').factory('Auth', function($window) { var userState = { isLoggedIn: false diff --git a/public/modules/users/services/principal.client.service.js b/public/modules/users/services/principal.client.service.js deleted file mode 100755 index 670d703f..00000000 --- a/public/modules/users/services/principal.client.service.js +++ /dev/null @@ -1,202 +0,0 @@ -// 'use strict'; - -// angular.module('users').factory('AuthenticationService', function($http, $timeout, $q) { -// var error; -// var service = { -// // Information about the current user -// currentUser: null, - -// login: function(credentials) { -// var login = $http.post('/auth/signin', credentials); -// login.success(function(data) { -// service.currentUser = data.user; -// // $flash.clear(); -// }).error(function(error) { -// error = error.error ? error.error : error; -// console.error(error.message || error); -// }); -// return login; -// }, - -// logout: function() { -// var logout = $http.get('/auth/logout'); -// logout.success(function() { -// service.currentUser = null; -// console.log("You've successfully logged out"); -// }); -// return logout; -// }, - -// signup: function(credentials) { -// var signup = $http.post('/auth/signup', credentials) -// signup.success(function(response) { -// console.log("You've successfully created an account"); -// }).error(function(response) { -// error = error.error ? error.error : error; -// console.error(error.message || error); -// }); - -// return signup; -// }, - -// // Ask the backend to see if a user is already authenticated - -// // this may be from a previous session. -// identity: function() { -// if (service.isAuthenticated()) { -// return $q.when(service.currentUser); -// } else { -// return $http.get('/user/me').then(function(response) { -// service.currentUser = response.data.user; -// return service.currentUser; -// }); -// } -// }, - -// // Is the current user authenticated? -// isAuthenticated: function() { -// return !!service.currentUser; -// }, - -// isInRole: function(role) { -// return service.isAuthenticated() (service.currentUser.roles.indexOf(role) !== -1); -// }, - -// isInAnyRole: function(roles) { -// if ( !service.isAuthenticated() || !service.currentUser.roles) return false; -// var roles = service.currentUser.roles; - -// for (var i = 0; i < roles.length; i++) { -// if (this.isInRole(roles[i])) return true; -// } - -// return false; -// }, - -// }; -// return service; -// }); - -// // .factory('Principal', ['$window', '$http', '$q', '$timeout', '$state', -// // function($window, $http, $q, $timeout, $state) { -// // var _identity, -// // _authenticated = false; - -// // return { -// // isIdentityResolved: function() { -// // return angular.isDefined(_identity); -// // }, -// // isAuthenticated: function() { -// // return _authenticated; -// // }, -// // isInRole: function(role) { -// // if (!_authenticated || !_identity.roles) return false; - -// // return _identity.roles.indexOf(role) !== -1; -// // }, -// // isInAnyRole: function(roles) { -// // if (!_authenticated || !_identity.roles) return false; - -// // for (var i = 0; i < roles.length; i++) { -// // if (this.isInRole(roles[i])) return true; -// // } - -// // return false; -// // }, -// // authenticate: function(user) { -// // _identity = user; -// // _authenticated = (user !== null); - -// // // for this demo, we'll store the identity in localStorage. For you, it could be a cookie, sessionStorage, whatever -// // if (user) $window.user = user; -// // else $window.user = null; -// // }, -// // signin: function(credentials) { - -// // var deferred = $q.defer(); -// // var self = this; -// // $http.post('/auth/signin', credentials).success(function(response) { -// // // If successful we assign the response to the global user model -// // self.authenticate(response); -// // deferred.resolve(response); -// // }).error(function(response) { -// // _authenticated = false; -// // deferred.reject({ error: response.message }); -// // }); -// // return deferred.promise; -// // }, -// // signup: function(credentials) { - -// // var deferred = $q.defer(); - -// // $http.post('/auth/signup', credentials).success(function(response) { -// // // If successful we assign the response to the global user model -// // deferred.resolve(response); -// // }).error(function(response) { - -// // deferred.reject({ error: response.message }); -// // }); - -// // return deferred.promise; -// // }, -// // signout: function() { -// // var deferred = $q.defer(); -// // $http.get('/auth/signout').success(function(response) { -// // // If successful we assign the response to the global user model -// // deferred.resolve({}); -// // }).error(function(response) { -// // deferred.reject({ error: response.message }); -// // }); - -// // _authenticated = false; -// // _identity = undefined; - -// // return deferred.promise; -// // }, -// // identity: function() { -// // var self = this; - -// // var deferred = $q.defer(); - -// // // check and see if we have retrieved the user data from the server. if we have, reuse it by immediately resolving -// // if (angular.isDefined(_identity)) { - -// // deferred.resolve(_identity); -// // return deferred.promise; -// // }else if($window.user){ -// // // console.log($window.user); -// // // self.authenticate($window.user); -// // // var user = $window.user; -// // _identity = $window.user; -// // self.authenticate(_identity); -// // deferred.resolve(_identity); - -// // return deferred.promise; -// // }else { - -// // // otherwise, retrieve the user data from the server, update the user object, and then resolve. -// // $http.get('/users/me', { ignoreErrors: true }) -// // .success(function(response) { -// // self.authenticate(response); -// // $window.user = response; -// // deferred.resolve(_identity); -// // }) -// // .error(function() { -// // _identity = null; -// // _authenticated = false; -// // $window.user = null; -// // $state.path('signin'); -// // deferred.resolve(_identity); -// // }); - -// // return deferred.promise; -// // } -// // }, -// // getUser: function(){ -// // this.identity(false).then( function(user){ -// // return user; -// // }); -// // } -// // }; - -// // } -// // ]);