fixed small ux bugs
This commit is contained in:
parent
758eb5a786
commit
f3638a1d42
@ -44,7 +44,7 @@ block content
|
||||
|
||||
script(type='text/javascript', src='https://cdnjs.cloudflare.com/ajax/libs/angular-strap/2.3.8/angular-strap.min.js')
|
||||
|
||||
//script(src='http://textangular.com/dist/textAngular.min.js')
|
||||
script(src='https://cdnjs.cloudflare.com/ajax/libs/ng-quill/3.5.1/ng-quill.min.js')
|
||||
|
||||
//Application JavaScript Files
|
||||
each jsFile in jsFiles
|
||||
|
||||
12
bower.json
12
bower.json
@ -16,13 +16,11 @@
|
||||
"angular-mocks": "~1.4.7",
|
||||
"angular-bootstrap": "~0.14.3",
|
||||
"angular-ui-utils": "~3.0.0",
|
||||
"angular-ui-router": "~0.2.11",
|
||||
"ng-file-upload": "^12.0.4",
|
||||
"angular-raven": "~0.5.11",
|
||||
"angular-ui-date": "~0.0.11",
|
||||
"lodash": "~3.10.0",
|
||||
"angular-ui-sortable": "~0.13.4",
|
||||
"angular-permission": "~1.1.1",
|
||||
"file-saver.js": "~1.20150507.2",
|
||||
"angular-bootstrap-colorpicker": "~3.0.19",
|
||||
"angular-scroll": "^1.0.0",
|
||||
@ -45,18 +43,20 @@
|
||||
"angular-ui-select": "^0.19.8",
|
||||
"angular-bootstrap-switch": "^0.5.2",
|
||||
"jquery": "^3.2.1",
|
||||
"ng-quill": "https://github.com/KillerCodeMonkey/ng-quill"
|
||||
"ng-quill": "https://github.com/KillerCodeMonkey/ng-quill",
|
||||
"angular-ui-router": "^1.0.11",
|
||||
"angular-permission": "^5.3.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"angular-bootstrap": "^0.14.0",
|
||||
"angular": "1.4.14",
|
||||
"jspdf": "~1.0.178",
|
||||
"angular-sanitize": "1.4.14",
|
||||
"angular-ui-sortable": "^0.17.1",
|
||||
"angular-ui-date": "~0.0.11",
|
||||
"angular-input-stars-directive": "master",
|
||||
"angular-ui-select": "^0.19.8",
|
||||
"jquery": "^3.2.1"
|
||||
"jquery": "^3.2.1",
|
||||
"angular-ui-router": "^1.0.11",
|
||||
"angular-permission": "^5.3.2"
|
||||
},
|
||||
"overrides": {
|
||||
"BOWER-PACKAGE": {
|
||||
|
||||
@ -320,12 +320,11 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
|
||||
|
||||
setTimeout(function () {
|
||||
$scope.submitPromise = $http.post('/forms/' + $scope.myform._id, form)
|
||||
.success(function (data, status) {
|
||||
.then(function (data, status) {
|
||||
$scope.myform.submitted = true;
|
||||
$scope.loading = false;
|
||||
SendVisitorData.send(form, getActiveField(), _timeElapsed);
|
||||
})
|
||||
.error(function (error) {
|
||||
}, function (error) {
|
||||
$scope.loading = false;
|
||||
console.error(error);
|
||||
$scope.error = error.message;
|
||||
|
||||
@ -8,6 +8,9 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider',
|
||||
}
|
||||
]);
|
||||
|
||||
var statesWithoutAuth = ['signin', 'resendVerifyEmail', 'verify', 'signup', 'signup-success', 'forgot', 'reset-invalid', 'reset', 'reset-success'];
|
||||
var statesToIgnore = statesWithoutAuth.concat(['', 'home']);
|
||||
|
||||
angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope', 'Auth', '$state', '$stateParams',
|
||||
function($rootScope, Auth, $state, $stateParams) {
|
||||
|
||||
@ -21,10 +24,8 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
|
||||
params: fromParams
|
||||
}
|
||||
|
||||
var statesToIgnore = ['', 'home', 'signin', 'resendVerifyEmail', 'verify', 'signup', 'signup-success', 'forgot', 'reset-invalid', 'reset', 'reset-success'];
|
||||
|
||||
//Redirect to listForms if user is authenticated
|
||||
if(statesToIgnore.indexOf(toState.name) > 0){
|
||||
if(statesToIgnore.indexOf(toState.name) > -1){
|
||||
if(Auth.isAuthenticated()){
|
||||
event.preventDefault(); // stop current execution
|
||||
$state.go('listForms'); // go to listForms page
|
||||
@ -43,23 +44,28 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
|
||||
//Page access/authorization logic
|
||||
angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope', 'Auth', 'User', 'Authorizer', '$state', '$stateParams',
|
||||
function($rootScope, Auth, User, Authorizer, $state, $stateParams) {
|
||||
$rootScope.$on('$stateChangeStart', function(event, next) {
|
||||
console.log('$stateChangeStart');
|
||||
var authenticator, permissions, user;
|
||||
permissions = next && next.data && next.data.permissions ? next.data.permissions : null;
|
||||
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
|
||||
if(statesWithoutAuth.indexOf(toState.name) === -1){
|
||||
Auth.ensureHasCurrentUser(User).then(
|
||||
function onSuccess(currentUser){
|
||||
if(currentUser){
|
||||
var authenticator = new Authorizer(user);
|
||||
var permissions = toState && toState.data && toState.data.permissions ? toState.data.permissions : null;
|
||||
|
||||
Auth.ensureHasCurrentUser(User);
|
||||
user = Auth.currentUser;
|
||||
|
||||
if(user){
|
||||
authenticator = new Authorizer(user);
|
||||
|
||||
if( (permissions !== null) ){
|
||||
if( !authenticator.canAccess(permissions) ){
|
||||
if( permissions !== null && !authenticator.canAccess(permissions) ){
|
||||
event.preventDefault();
|
||||
$state.go('access_denied');
|
||||
}
|
||||
}
|
||||
},
|
||||
function onError(error){
|
||||
event.preventDefault();
|
||||
$state.go('access_denied');
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
event.preventDefault();
|
||||
$state.go('access_denied');
|
||||
}
|
||||
});
|
||||
}]);
|
||||
}]);
|
||||
@ -6,11 +6,8 @@ angular.module('core').controller('HeaderController', ['$rootScope', '$scope', '
|
||||
$rootScope.signupDisabled = $window.signupDisabled;
|
||||
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
|
||||
$scope.authentication = $rootScope.authentication = Auth;
|
||||
|
||||
$rootScope.languages = $scope.languages = ['en', 'fr', 'es', 'it', 'de'];
|
||||
|
||||
//Set global app language
|
||||
$rootScope.language = $scope.user.language;
|
||||
$translate.use($scope.user.language);
|
||||
|
||||
@ -74,9 +74,9 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
|
||||
delete form._id;
|
||||
|
||||
$http.post('/forms', {form: form})
|
||||
.success(function(data, status, headers){
|
||||
.then(function(data, status, headers){
|
||||
$scope.myforms.splice(form_index+1, 0, data);
|
||||
}).error(function(errorResponse){
|
||||
}, function(errorResponse){
|
||||
console.error(errorResponse);
|
||||
if(errorResponse === null){
|
||||
$scope.error = errorResponse.data.message;
|
||||
@ -93,10 +93,10 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
|
||||
|
||||
if($scope.forms.createForm.$valid && $scope.forms.createForm.$dirty){
|
||||
$http.post('/forms', {form: form})
|
||||
.success(function(data, status, headers){
|
||||
.then(function(data, status, headers){
|
||||
// Redirect after save
|
||||
$scope.goToWithId('viewForm.create', data._id+'');
|
||||
}).error(function(errorResponse){
|
||||
}, function(errorResponse){
|
||||
console.error(errorResponse);
|
||||
$scope.error = errorResponse.data.message;
|
||||
});
|
||||
@ -109,10 +109,10 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
|
||||
}
|
||||
|
||||
$http.delete('/forms/'+$scope.myforms[form_index]._id)
|
||||
.success(function(data, status, headers){
|
||||
.then(function(data, status, headers){
|
||||
$scope.myforms.splice(form_index, 1);
|
||||
$scope.cancelDeleteModal();
|
||||
}).error(function(error){
|
||||
}, function(error){
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
@ -172,14 +172,13 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||
method: 'DELETE',
|
||||
data: {deleted_submissions: delete_ids},
|
||||
headers: {'Content-Type': 'application/json;charset=utf-8'}
|
||||
}).success(function(data, status){
|
||||
}).then(function(data, status){
|
||||
$scope.deletionInProgress = true;
|
||||
//Remove deleted ids from table
|
||||
$scope.table.rows = $scope.table.rows.filter(function(field){
|
||||
return !field.selected;
|
||||
});
|
||||
})
|
||||
.error(function(err){
|
||||
}, function(err){
|
||||
$scope.deletionInProgress = true;
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
angular.module('forms').service('FormFields', [ '$rootScope', '$translate', 'Auth',
|
||||
function($rootScope, $translate, Auth) {
|
||||
|
||||
var language = Auth.ensureHasCurrentUser().language;
|
||||
var language = $rootScope.language;
|
||||
$translate.use(language);
|
||||
|
||||
this.types = [
|
||||
|
||||
@ -74,11 +74,23 @@
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 field-input">
|
||||
<!--
|
||||
<text-angular ng-model="myform.respondentNotifications.htmlTemplate"
|
||||
ta-toolbar="[['bold','italics', 'insertField']]"
|
||||
ta-unsafe-sanitizer="true"
|
||||
ta-default-wrap='p'>
|
||||
</text-angular>
|
||||
-->
|
||||
<ng-quill-editor ng-model="myform.respondentNotifications.htmlTemplate">
|
||||
<ng-quill-toolbar>
|
||||
<div>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-bold"></button>
|
||||
<button class="ql-italic"></button>
|
||||
</span>
|
||||
</div>
|
||||
</ng-quill-toolbar>
|
||||
</ng-quill-editor>
|
||||
<div ng-bind="myform.respondentNotifications.htmlTemplate"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -4,5 +4,5 @@
|
||||
ApplicationConfiguration.registerModule('forms', [
|
||||
'ngFileUpload', 'ui.date', 'ui.sortable',
|
||||
'angular-input-stars', 'users', 'ngclipboard', 'textAngular',
|
||||
'frapontillo.bootstrap-switch'
|
||||
'frapontillo.bootstrap-switch', 'ngQuill'
|
||||
]);//, 'colorpicker.module' @TODO reactivate this module
|
||||
|
||||
@ -4,26 +4,26 @@
|
||||
angular.module('users').config(['$stateProvider',
|
||||
function($stateProvider) {
|
||||
|
||||
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
if (Auth.currentUser && Auth.currentUser.email) {
|
||||
$timeout(deferred.resolve);
|
||||
}
|
||||
else {
|
||||
Auth.currentUser = User.getCurrent(
|
||||
function() {
|
||||
Auth.login();
|
||||
$timeout(deferred.resolve());
|
||||
},
|
||||
function() {
|
||||
Auth.logout();
|
||||
$timeout(deferred.reject());
|
||||
$state.go('signin', {reload: true});
|
||||
});
|
||||
}
|
||||
var checkCurrentUser = function($q, $state, User, Auth) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
if (Auth.currentUser && Auth.currentUser.email) {
|
||||
deferred.resolve(Auth.currentUser);
|
||||
} else {
|
||||
User.getCurrent().then(
|
||||
function(user) {
|
||||
console.log(user);
|
||||
Auth.login();
|
||||
deferred.resolve(user);
|
||||
},
|
||||
function() {
|
||||
Auth.logout();
|
||||
deferred.reject();
|
||||
$state.go('signin', {reload: true});
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var checkSignupDisabled = function($window, $timeout, $q) {
|
||||
@ -40,22 +40,24 @@ angular.module('users').config(['$stateProvider',
|
||||
$stateProvider.
|
||||
state('profile', {
|
||||
resolve: {
|
||||
loggedin: checkLoggedin
|
||||
currentUser: ['$q', '$state', 'User', 'Auth', checkCurrentUser]
|
||||
},
|
||||
url: '/settings/profile',
|
||||
templateUrl: 'modules/users/views/settings/edit-profile.client.view.html'
|
||||
templateUrl: 'modules/users/views/settings/edit-profile.client.view.html',
|
||||
controller: 'SettingsController'
|
||||
}).
|
||||
state('password', {
|
||||
resolve: {
|
||||
loggedin: checkLoggedin
|
||||
},
|
||||
currentUser: ['$q', '$state', 'User', 'Auth', checkCurrentUser]
|
||||
},
|
||||
url: '/settings/password',
|
||||
templateUrl: 'modules/users/views/settings/change-password.client.view.html'
|
||||
templateUrl: 'modules/users/views/settings/change-password.client.view.html',
|
||||
controller: 'SettingsController'
|
||||
}).
|
||||
state('accounts', {
|
||||
resolve: {
|
||||
loggedin: checkLoggedin
|
||||
},
|
||||
currentUser: ['$q', '$state', 'User', 'Auth', checkCurrentUser]
|
||||
},
|
||||
url: '/settings/accounts',
|
||||
templateUrl: 'modules/users/views/settings/social-accounts.client.view.html'
|
||||
}).
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('users').controller('SettingsController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth',
|
||||
function($scope, $rootScope, $http, $state, Users, Auth) {
|
||||
angular.module('users').controller('SettingsController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth', 'currentUser',
|
||||
function($scope, $rootScope, $http, $state, Users, Auth, currentUser) {
|
||||
|
||||
$scope.user = Auth.currentUser;
|
||||
$scope.user = currentUser;
|
||||
|
||||
// Check if there are additional accounts
|
||||
$scope.hasConnectedAdditionalSocialAccounts = function(provider) {
|
||||
@ -30,12 +30,12 @@ angular.module('users').controller('SettingsController', ['$scope', '$rootScope'
|
||||
params: {
|
||||
provider: provider
|
||||
}
|
||||
}).success(function(response) {
|
||||
}).then(function(response) {
|
||||
// If successful show success message and clear form
|
||||
$scope.success = true;
|
||||
$scope.error = null;
|
||||
$scope.user = response;
|
||||
}).error(function(response) {
|
||||
}, function(response) {
|
||||
$scope.success = null;
|
||||
$scope.error = response.message;
|
||||
});
|
||||
@ -64,12 +64,12 @@ angular.module('users').controller('SettingsController', ['$scope', '$rootScope'
|
||||
$scope.changeUserPassword = function() {
|
||||
$scope.success = $scope.error = null;
|
||||
|
||||
$http.post('/users/password', $scope.passwordDetails).success(function(response) {
|
||||
$http.post('/users/password', $scope.passwordDetails).then(function(response) {
|
||||
// If successful show success message and clear form
|
||||
$scope.success = true;
|
||||
$scope.error = null;
|
||||
$scope.passwordDetails = null;
|
||||
}).error(function(response) {
|
||||
}, function(response) {
|
||||
$scope.success = null;
|
||||
$scope.error = response.message;
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('users').factory('Auth', ['$window',
|
||||
function($window) {
|
||||
angular.module('users').factory('Auth', ['$window', '$q',
|
||||
function($window, $q) {
|
||||
|
||||
var userState = {
|
||||
isLoggedIn: false
|
||||
@ -17,26 +17,30 @@ angular.module('users').factory('Auth', ['$window',
|
||||
// because that would create a circular dependency
|
||||
// Auth <- $http <- $resource <- LoopBackResource <- User <- Auth
|
||||
ensureHasCurrentUser: function(User) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
if (service._currentUser && service._currentUser.username) {
|
||||
return service._currentUser;
|
||||
deferred.resolve(service._currentUser);
|
||||
} else if ($window.user){
|
||||
service._currentUser = $window.user;
|
||||
return service._currentUser;
|
||||
deferred.resolve(service._currentUser)
|
||||
} else {
|
||||
User.getCurrent().then(function(user) {
|
||||
// success
|
||||
service._currentUser = user;
|
||||
userState.isLoggedIn = true;
|
||||
$window.user = service._currentUser;
|
||||
return service._currentUser;
|
||||
deferred.resolve(service._currentUser);
|
||||
},
|
||||
function(response) {
|
||||
userState.isLoggedIn = false;
|
||||
service._currentUser = null;
|
||||
$window.user = null;
|
||||
return null;
|
||||
deferred.reject('User data could not be fetched from server');
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
isAuthenticated: function() {
|
||||
|
||||
@ -6,19 +6,16 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
var userService = {
|
||||
getCurrent: function() {
|
||||
var deferred = $q.defer();
|
||||
|
||||
$http.get('/users/me')
|
||||
.success(function(response) {
|
||||
deferred.resolve(response);
|
||||
})
|
||||
.error(function() {
|
||||
.then(function(response) {
|
||||
deferred.resolve(response.data);
|
||||
}, function() {
|
||||
deferred.reject('User\'s session has expired');
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
login: function(credentials) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.post('/auth/signin', credentials).then(function(response) {
|
||||
deferred.resolve(response.data);
|
||||
@ -29,7 +26,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
return deferred.promise;
|
||||
},
|
||||
logout: function() {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.get('/auth/signout').then(function(response) {
|
||||
deferred.resolve(null);
|
||||
@ -40,7 +36,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
return deferred.promise;
|
||||
},
|
||||
signup: function(credentials) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.post('/auth/signup', credentials).then(function(response) {
|
||||
// If successful we assign the response to the global user model
|
||||
@ -53,7 +48,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
},
|
||||
|
||||
resendVerifyEmail: function(_email) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.post('/auth/verify', {email: _email}).then(function(response) {
|
||||
deferred.resolve(response.data);
|
||||
@ -65,7 +59,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
},
|
||||
|
||||
validateVerifyToken: function(token) {
|
||||
|
||||
//DAVID: TODO: The valid length of a token should somehow be linked to server config values
|
||||
//DAVID: TODO: SEMI-URGENT: Should we even be doing this?
|
||||
var validTokenRe = /^([A-Za-z0-9]{48})$/g;
|
||||
@ -82,7 +75,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
},
|
||||
|
||||
resetPassword: function(passwordDetails, token) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.post('/auth/reset/'+token, passwordDetails).then(function(response) {
|
||||
deferred.resolve(response);
|
||||
@ -95,7 +87,6 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
||||
|
||||
// Submit forgotten password account id
|
||||
askForPasswordReset: function(credentials) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.post('/auth/forgot', credentials).then(function(response) {
|
||||
// Show user success message and clear form
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<header data-ng-include="'/static/modules/core/views/header.client.view.html'"></header>
|
||||
|
||||
<section class="row" data-ng-controller="SettingsController">
|
||||
<section class="row">
|
||||
<h3 class="col-md-12 text-center">{{ 'CHANGE_PASSWORD' | translate }}</h3>
|
||||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6">
|
||||
<form data-ng-submit="changeUserPassword()" class="signin form-horizontal" autocomplete="off">
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<header data-ng-include="'/static/modules/core/views/header.client.view.html'"></header>
|
||||
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css'>
|
||||
|
||||
<section class="row" data-ng-controller="SettingsController">
|
||||
<section class="row">
|
||||
<h2 class="col-xs-offset-1 col-xs-10 text-center">{{ 'EDIT_PROFILE' | translate }}</h2>
|
||||
<div class="col-xs-offset-3 col-xs-6">
|
||||
<form name="userForm" data-ng-submit="updateUserProfile(userForm.$valid)" class="signin form-horizontal" autocomplete="off">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user