diff --git a/app/models/form.server.model.js b/app/models/form.server.model.js index e8cdbcff..7fe05f13 100644 --- a/app/models/form.server.model.js +++ b/app/models/form.server.model.js @@ -23,11 +23,6 @@ var FormSchema = new Schema({ type: Date, default: Date.now }, - // type: { - // type: String, - // default: 'template', - // enum: ['submission', 'template'] - // }, title: { type: String, default: '', @@ -39,7 +34,7 @@ var FormSchema = new Schema({ type: String, default: '', }, - form_fields: [Schema.Types.Mixed], + form_fields: [FieldSchema], submissions: [{ type: Schema.Types.ObjectId, @@ -57,6 +52,10 @@ var FormSchema = new Schema({ pdfFieldMap: { type: Schema.Types.Mixed }, + hideFooter: { + type: Boolean, + default: true, + }, isGenerated: { type: Boolean, default: false, @@ -113,7 +112,7 @@ FormSchema.pre('save', function (next) { //Autogenerate FORM from PDF if 'isGenerated' flag is 'true' FormSchema.pre('save', function (next) { - var field; + var field, _form_fields; if(this.isGenerated && this.pdf){ @@ -137,13 +136,22 @@ FormSchema.pre('save', function (next) { field.fieldType = _typeConvMap[ field.fieldType+'' ]; } - field.created = Date.now(); + // field.created = Date.now(); field.fieldValue = ''; - field.required = true; - field.disabled = false; + // field.required = true; + //field.disabled = false; // field = new Field(field); - // field.save() + // field.save(function(err) { + // if (err) { + // console.error(err.message); + // throw new Error(err.message); + // }); + // } else { + // _form_fields[i] = this; + // } + // }); + _form_fields[i] = field; } console.log('NEW FORM_FIELDS: '); diff --git a/app/models/form_field.server.model.js b/app/models/form_field.server.model.js index d3725aa6..ed58cc9f 100644 --- a/app/models/form_field.server.model.js +++ b/app/models/form_field.server.model.js @@ -49,7 +49,7 @@ var FormFieldSchema = new Schema({ }, required: { type: Boolean, - default: false, + default: true, }, disabled: { type: Boolean, diff --git a/bower.json b/bower.json index f5c986ee..22af2af4 100755 --- a/bower.json +++ b/bower.json @@ -11,7 +11,8 @@ "angular-bootstrap": "~0.12.0", "angular-ui-utils": "~0.1.1", "angular-ui-router": "~0.2.11", - "angular-strap": "~2.2.1" + "angular-strap": "~2.2.1", + "angular-permission": "~0.3.0" }, "resolutions": { "angular": "^1.2.21", diff --git a/public/config.js b/public/config.js index 109385a5..920f8981 100755 --- a/public/config.js +++ b/public/config.js @@ -4,7 +4,7 @@ var ApplicationConfiguration = (function() { // Init module configuration options var applicationModuleName = 'medform'; - var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils']; + var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils', 'permission']; // Add a new vertical module var registerModule = function(moduleName, dependencies) { diff --git a/public/modules/core/config/core.client.routes.js b/public/modules/core/config/core.client.routes.js index 5752a1aa..730618f9 100755 --- a/public/modules/core/config/core.client.routes.js +++ b/public/modules/core/config/core.client.routes.js @@ -11,16 +11,12 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider', state('home', { url: '/', templateUrl: 'modules/core/views/home.client.view.html' - }). - state('restricted', { - 'abstract': true, - resolve: { - authorize: ['Authorization', - function(Authorization) { - return Authorization.authorize(); - } - ] - } }); + + $urlRouterProvider.otherwise( function($injector) { + var $state = $injector.get("$state"); + $state.go('home'); + }); + } ]); \ No newline at end of file diff --git a/public/modules/forms/views/create-form.client.view.html b/public/modules/forms/views/create-form.client.view.html index 7eb80bf9..51ba2228 100644 --- a/public/modules/forms/views/create-form.client.view.html +++ b/public/modules/forms/views/create-form.client.view.html @@ -190,12 +190,14 @@

-
+
-
- - +
+ +
+
+
diff --git a/public/modules/forms/views/list-forms.client.view.html b/public/modules/forms/views/list-forms.client.view.html index 4ce1a2f6..d5db734f 100644 --- a/public/modules/forms/views/list-forms.client.view.html +++ b/public/modules/forms/views/list-forms.client.view.html @@ -1,13 +1,15 @@ -
-
diff --git a/public/modules/users/config/users.client.config.js b/public/modules/users/config/users.client.config.js index d4756c5b..225007ce 100755 --- a/public/modules/users/config/users.client.config.js +++ b/public/modules/users/config/users.client.config.js @@ -1,30 +1,53 @@ // 'use strict'; -// // Config HTTP Error Handling -// angular.module('users').config(['$httpProvider', -// function($httpProvider) { -// // Set the httpProvider "not authorized" interceptor -// $httpProvider.interceptors.push(['$q', '$location', 'Principal', -// function($q, $location, Principal) { -// return { -// responseError: function(rejection) { -// switch (rejection.status) { -// case 401: -// // Deauthenticate the global user -// Principal.authenticate(null); +// Config HTTP Error Handling +angular.module('users').config(['$httpProvider','$q', '$location', 'Principal', + function($httpProvider, $q, $location, Principal) { + // Set the httpProvider "not authorized" interceptor + $httpProvider.interceptors.push(['$q', '$location', 'Principal', + function($q, $location, Principal) { + return { + responseError: function(rejection) { + switch (rejection.status) { + case 401: + // Deauthenticate the global user + -// // Redirect to signin page -// $location.path('signin'); -// break; -// case 403: -// // Add unauthorized behaviour -// break; -// } + // Redirect to signin page + $location.path('signin'); + break; + case 403: + // Add unauthorized behaviour + break; + } -// return $q.reject(rejection); -// } -// }; -// } -// ]); -// } -// ]); \ No newline at end of file + return $q.reject(rejection); + } + }; + } + ]); + } +]).config(['Permission', 'Principal', + function($Permission, Principal) { + var User = Principal.identity(); + Permission.defineRole('anonymous', function (stateParams) { + // If the returned value is *truthy* then the user has the role, otherwise they don't + if ( !User || !Principal.isInAnyRole() ) { + return true; // Is anonymous + } + return false; + }).defineRole('admin', function (stateParams) { + // If the returned value is *truthy* then the user has the role, otherwise they don't + if (Principal.isInRole('admin')) { + return true; // Is anonymous + } + return false; + }).defineRole('admin', function (stateParams) { + // If the returned value is *truthy* then the user has the role, otherwise they don't + if (Principal.isInRole('user') && !Principal.isInRole('admin') ) { + return true; // Is anonymous + } + return false; + }); + } +]); \ No newline at end of file