Skip to content

Commit

Permalink
Merge pull request #115 from rit-sse/khanny17-issue-67
Browse files Browse the repository at this point in the history
Adding a little asterisk if the plan hasn't been saved yet
  • Loading branch information
khanny17 authored Nov 30, 2017
2 parents c3a6fc2 + a6ad403 commit c09e177
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
networks:
- devnetwork
web:
environment:
- TEST=false
build:
context: .
dockerfile: Dockerfile.dev
Expand Down
2 changes: 1 addition & 1 deletion public/js/directives/navbar/navbar-directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<li>
<a href="#" ng-click="savePlan()" ng-switch-when="true">
<i class="fa fa-fw fa-floppy-o"></i>Save
<i class="fa fa-fw fa-floppy-o"></i>Save<i ng-if="!planSaved()">*</i>
</a>
</li>

Expand Down
34 changes: 32 additions & 2 deletions public/js/directives/navbar/navbar-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ angular.module('NavbarDirective',[
'EditColorschemeModal',
'EditProfileModal',
'HelpModal',
'LoginModal'
'LoginModal',
'NotificationService'
])

.directive('navbar', [
Expand All @@ -23,7 +24,8 @@ angular.module('NavbarDirective',[
'authService',
'Notification',
'loginModal',
function($http, planService, openPlanModal, editColorschemeModal, editProfileModal, helpModal, authService, Notification, loginModal) {
'notificationService',
function($http, planService, openPlanModal, editColorschemeModal, editProfileModal, helpModal, authService, Notification, loginModal, notificationService) {
return {
replace: true,
restrict: 'E',
Expand Down Expand Up @@ -92,6 +94,34 @@ angular.module('NavbarDirective',[
};

scope.editProfile = editProfileModal.open;

//Handle an icon indicator of if the plan has been changed
var originalPlan = JSON.parse(JSON.stringify(planService.plan));
scope.planSaved = function() {
//If there's nothing, nothing to save!
if(!originalPlan){
return true;
}

//If it has no id, plan not saved
if(!originalPlan._id){
return false;
}

//If they're not equal, a change was made
if(!angular.equals(originalPlan, planService.plan)){
return false;
}

//If nothing else said no, guess we saved it!
return true;
};

//When the plan is changed - specifically if it is saved, loaded, etc
//update our original plan
notificationService.on('plan-changed', function(){
originalPlan = JSON.parse(JSON.stringify(planService.plan));
});
}
};
}]);
Expand Down
19 changes: 10 additions & 9 deletions public/js/services/plan-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ function($http, $q, notificationService, hotkeys, authService, uploadPlanModal)
colorscheme: {}
};

return authService.getUser()
.then(function(user){
if(user){
self.plan.school = user.school;
notificationService.notify('plan-changed');
}
return self.plan;
});
if(authService.isAuthenticated()){
return authService.getUser()
.then(function(user){
if(user){
self.plan.school = user.school;
notificationService.notify('plan-changed');
}
return self.plan;
});
}
};
self.makeNew(); //Start with a clean plan no matter what

Expand Down Expand Up @@ -171,7 +173,6 @@ function($http, $q, notificationService, hotkeys, authService, uploadPlanModal)
}
});


function errorHandler(response){
if(response.status === -1) {
throw 'No response from server';
Expand Down
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
mongoose.connect(config.db.url)
.then(function(){
console.log('Mongoose Connected');
if(process.env.TEST) {
console.log('Testing?', process.env.TEST);
if(process.env.TEST === true) {
console.log('***********************************************************');
console.log('***************************WARNING*************************');
console.log('***********************************************************');
Expand Down

0 comments on commit c09e177

Please sign in to comment.