-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(core): Modify core module to implement style guidelines. #1202
Conversation
8656e35
to
6f97a0a
Compare
$locationProvider.html5Mode(true).hashPrefix('!'); | ||
|
||
$httpProvider.interceptors.push('authInterceptor'); | ||
} | ||
]); | ||
|
||
angular.module(ApplicationConfiguration.applicationModuleName).run(function ($rootScope, $state, Authentication) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhutchison Left some inline comments. Overall love the PR and is almost spot on with where I was going with it. |
@@ -1,23 +1,29 @@ | |||
'use strict'; | |||
(function (window) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send in angular to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't send in angular anywhere, why here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought since you are now sending window, may as well make it a true IIFE and add angular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, as it's not part of the style guidelines. I can remove window if you wish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use $window instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$window should be used, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it can be, unless angular is injecting it into a controller/service.
@rhutchison , @trainerbill once you guys wrap it up, then @codydaig or @ilanbiala can take a look and comment. |
@rhutchison Based on a fork by @trainerbill I changed the auth-interceptor.service.js responseError function to: function responseError(rejection) {
if (!rejection.config.ignoreAuthModule) {
switch (rejection.status) {
case 401:
var auth = $injector.get('Authentication');
auth.signout();
$injector.get('$state').transitionTo('authentication.signin');
break;
case 403:
$injector.get('$state').transitionTo('forbidden');
break;
}
} |
8360603
to
691aa0b
Compare
@Zeldar that should probably go in a different PR. This is just to conform to the style-guide. I think it is ready to go. |
} | ||
} | ||
})(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
Added a few comments. |
4369199
to
2f9fefb
Compare
@ilanbiala took care of double IIFE - just waiting for successful build. |
Please re-consider having everything use Yes, using However, I do not think it is advisable to have There is an important note in John Papa's guidelines about controllerAs with vm.
|
My preference would be to stick with 'vm'.
I don't know if there is a way around it with HeaderController without implementing nested views. Any ideas?
I believe @mg1075 is saying for searchability in a project. |
@rhutchison I haven't tested this, or given it a thorough review. #1183 |
bootstrapConfig.$inject = ['$locationProvider', '$httpProvider']; | ||
|
||
// Then define the init function for starting up the application | ||
angular.element(document).ready(init); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is angular.element($document).ready(init);
valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but $document.ready also works I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init.js:22 Uncaught ReferenceError: $document is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you inject it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhutchison did you try injecting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried different ways, I don't think it's possible. I have not read or seen any examples that shows otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilanbiala @rhutchison If it's not possible (or easily possible) to use $document
& $window
in this case, then I say it's fine to leave it the way it is.
For the sake of not holding up this PR we can just focus on the style-guide implementation. However, @rhutchison if we're using window
and/or document
anywhere else let's change it to use $window
/$document
if it's an easy change. I haven't thoroughly checked for any other other usages.
@rhutchison left some comments. |
I'd like to use $window and $document everywhere that it can be. Is there any case where we have to use window or document vs. $window and $document? |
4db1e19
to
368bc79
Compare
@ilanbiala @codydaig @mleanos @lirantal this is ready. |
Coverage remained the same at 70.615% when pulling 368bc79e8ecfda2bf8c0c86da0cd8bdb63e7d915 on Gym:core-styleguide into 89d302d on meanjs:master. |
this.socket.on(eventName, function (data) { | ||
function on(eventName, callback) { | ||
if (service.socket) { | ||
service.socket.on(eventName, function (data) { | ||
$timeout(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can just be $timeout(callback(data));
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhutchison did this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not try, but it does not look like it would work.
@rhutchison left some comments, but other than those that you need to fix the only thing I'm thinking of is the $window and $document stuff that @codydaig is also referencing. @rhutchison did you find any sources that say it isn't possible to use them in scenarios like ours? I would imagine Angular probably has a way of using $window or $document everywhere. |
@ilanbiala within the context of angular, I'm sure it's possible, but not sure how it's done in these cases which are bootstrapping angular. Please let me know if you can find a way and I'll gladly update. |
}; | ||
} | ||
// Then init the app | ||
angular.bootstrap(document, [app.applicationModuleName]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inject $document before Angular is even bootstrapped? ;-) Don't think so.
368bc79
to
847ad7a
Compare
Coverage remained the same at 70.615% when pulling 847ad7aea1613016f8fcd36346da59535b8755ee on Gym:core-styleguide into 59e6daa on meanjs:master. |
I was out of town over the weekend, so I apologize for the lack of feedback. I'm planning on pulling this down in the next day or so. |
@rhutchison I just pulled this down, and tested. Overall, it looks pretty good. I think there are a few remaining comments that need to be addressed/finalized. Other than that this looks ready to me. |
@mleanos thanks for reviewing. Please point me to the outstanding items. |
@rhutchison Looking at it closer, I see the aspects where you need to use window vs. $window. I'm cool with the way that it is currently. (I don't think I saw window or document being used inside a controller or service). |
LGTM, only change is the !== -1. Other than that, everything is fine. |
Update the core module to implement the style guidelines. Reduce size of init.js - moved filter logic out to it's own config. Rename Menus to menuService
847ad7a
to
b2462ec
Compare
@ilanbiala done |
@mleanos LGTM. |
LGTM. @mleanos Merge before merge conflicts arise!!!! |
Update the core module to implement the style guidelines.
Reduce size of init.js - moved filter logic out to it's own config.
Rename Menus to menuService
Ref: #657
Ref: #943