removed all circular dependency problems

This commit is contained in:
David Baldwynn 2015-06-30 09:30:56 -07:00
parent 410d999727
commit a923b2d30e
2 changed files with 76 additions and 66 deletions

View file

@ -1,31 +1,38 @@
<section data-ng-controller="ViewFormController" data-ng-init="findOne()"> <section data-ng-controller="ViewSubmissionsController" data-ng-init="findAll()">
<div class="page-header">
<h1 data-ng-bind="form.title"> Form Submissions</h1>
</div>
<div class="pull-right" data-ng-show="authentication.user._id == form.user._id">
<a class="btn btn-primary" href="/#!/forms/{{form._id}}/edit">
<i class="glyphicon glyphicon-edit"></i>
</a>
<a class="btn btn-primary" data-ng-click="remove();">
<i class="glyphicon glyphicon-trash"></i>
</a>
<a class="btn btn-primary" href="/#!/forms/{{form._id}}">
View Public Form
</a>
<a class="btn btn-primary" href="/#!/forms/{{form._id}}/submissions">
View Form Submissions
</a>
</div>
<div class="row"> <div class="row">
<span class="col-md-5" data-ng-bind="form"></span> <div class="page-header col-xs-10 col-xs-offset-1">
<h1>{{submissions[0].form.title}} submissions</h1>
</div>
</div>
<div class="row container">
<a data-ng-href="#!/forms/create" class="col-xs-2 col-xs-offset-1 form-item row container 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>
</a>
<a data-ng-repeat="form in forms" data-ng-href="#!/forms/{{form._id}}/admin" class="col-xs-2 col-xs-offset-1 form-item row">
<div class="title-row col-xs-12">
<h4 class="list-group-item-heading" data-ng-bind="form.title"></h4>
</div>
<div class="col-xs-12 details-row">
<small class="list-group-item-text">
Created on
<span data-ng-bind="form.created | date:'mediumDate'"></span>
by
<span data-ng-bind="form.user.displayName"></span>
</small>
</div>
</a>
</div> </div>
<small>
<em class="text-muted">
Created on
<span data-ng-bind="form.created | date:'mediumDate'"></span>
by
<span data-ng-bind="form.admin.displayName"></span>
</em>
</small>
<!-- <p class="lead" data-ng-bind="form.content"></p> -->
</section> </section>

View file

@ -3,50 +3,53 @@
angular.module('users').controller('PasswordController', ['$scope', '$stateParams', '$state', 'Principal', angular.module('users').controller('PasswordController', ['$scope', '$stateParams', '$state', 'Principal',
function($scope, $stateParams, $state, Principal) { function($scope, $stateParams, $state, Principal) {
$scope.authentication = Principal; $scope.authentication = Principal;
$scope.authentication.user = Principal.user();
//If user is signed in then redirect back home //If user is signed in then redirect back home
if ($scope.authentication.user) $state.go('home'); if ($scope.authentication.isAuthenticated()) $state.go('home');
// Submit forgotten password account id Principal.identity().then(function(response){
$scope.askForPasswordReset = function() { $scope.authentication.user = response;
Principal.askForPasswordReset($scope.credentials).then(
function(response){
$scope.success = response.message
$scope.credentials = null;
},
function(error){
$scope.error = error;
$scope.credentials = null;
}
);
};
// Change user password // Submit forgotten password account id
$scope.resetUserPassword = function() { $scope.askForPasswordReset = function() {
Principal.askForPasswordReset($scope.credentials).then( Principal.askForPasswordReset($scope.credentials).then(
function(response){ function(response){
$scope.credentials = null; $scope.success = response.message
}, $scope.credentials = null;
function(error){ },
$scope.error = error; function(error){
$scope.credentials = null; $scope.error = error;
} $scope.credentials = null;
); }
// $scope.success = $scope.error = null; );
};
// $http.post('/auth/reset/' + $stateParams.token, $scope.passwordDetails).success(function(response) { // Change user password
// // If successful show success message and clear form $scope.resetUserPassword = function() {
// $scope.passwordDetails = null; Principal.askForPasswordReset($scope.credentials).then(
function(response){
$scope.credentials = null;
},
function(error){
$scope.error = error;
$scope.credentials = null;
}
);
// $scope.success = $scope.error = null;
// // Attach user profile // $http.post('/auth/reset/' + $stateParams.token, $scope.passwordDetails).success(function(response) {
// // Principal.user() = response; // // If successful show success message and clear form
// $scope.passwordDetails = null;
// // And redirect to the index page // // Attach user profile
// $state.go('reset-success'); // // Principal.user() = response;
// }).error(function(response) {
// $scope.error = response.message; // // And redirect to the index page
// }); // $state.go('reset-success');
}; // }).error(function(response) {
// $scope.error = response.message;
// });
};
});
} }
]); ]);