Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a little asterisk if the plan hasn't been saved yet #115

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file modified entrypoint.sh
100644 → 100755
Empty file.
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