Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

feat(core): Modify core module to implement style guidelines. #1202

Merged
merged 1 commit into from
Mar 24, 2016

Conversation

rhutchison
Copy link
Contributor

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

@rhutchison rhutchison force-pushed the core-styleguide branch 2 times, most recently from 8656e35 to 6f97a0a Compare February 11, 2016 06:17
$locationProvider.html5Mode(true).hashPrefix('!');

$httpProvider.interceptors.push('authInterceptor');
}
]);

angular.module(ApplicationConfiguration.applicationModuleName).run(function ($rootScope, $state, Authentication) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trainerbill
Copy link
Contributor

@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) {
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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.

@lirantal
Copy link
Member

@rhutchison , @trainerbill once you guys wrap it up, then @codydaig or @ilanbiala can take a look and comment.

@dprea
Copy link
Contributor

dprea commented Feb 13, 2016

@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;
        }
      }

@rhutchison rhutchison force-pushed the core-styleguide branch 2 times, most recently from 8360603 to 691aa0b Compare February 14, 2016 02:37
@rhutchison
Copy link
Contributor Author

@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.

}
}
})();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

@ilanbiala
Copy link
Member

Added a few comments.

@rhutchison rhutchison force-pushed the core-styleguide branch 2 times, most recently from 4369199 to 2f9fefb Compare February 16, 2016 02:32
@rhutchison
Copy link
Contributor Author

@ilanbiala took care of double IIFE - just waiting for successful build.

@ilanbiala ilanbiala added this to the 0.5.0 milestone Feb 16, 2016
@ilanbiala
Copy link
Member

@codydaig @lirantal 👀?

@mg1075
Copy link

mg1075 commented Feb 16, 2016

Please re-consider having everything use vm in the html views.

Yes, using vm consistently inside the controller function makes sense.
var vm = this;
Awesome.

However, I do not think it is advisable to have vm be the variable inside all the html views.
<div class="container" ng-controller="HeaderController as vm">

There is an important note in John Papa's guidelines about controllerAs with vm.
https://github.com/johnpapa/angular-styleguide#style-y032

Note: When working with larger codebases,using a more descriptive name can help ease cognitive overhead & searchability [emphasis added]. Avoid overly verbose names that are cumbersome to type.

<!-- avoid -->
<input ng-model="customerProductItemVm.text">
<!-- recommended -->
<input ng-model="productVm.id">

@rhutchison
Copy link
Contributor Author

@mg1075 thank you for your feedback. I provided a commit for the community to review. If they are good with it, I will squash the commit.

@ilanbiala @lirantal @codydaig

@rhutchison
Copy link
Contributor Author

My preference would be to stick with 'vm'.

@mleanos

I thought we were trying to get away from using the ng-controller attribute in the views.

I don't know if there is a way around it with HeaderController without implementing nested views. Any ideas?

The John Papa Styleguide examples aren't very clear on using the descriptive vm naming convention. What's the real benefit of doing this? There's only one controller per view, so it seems that vm would never have conflicts with any other vm.

I believe @mg1075 is saying for searchability in a project.

@mleanos
Copy link
Member

mleanos commented Feb 16, 2016

@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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$document

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you inject it?

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@ilanbiala
Copy link
Member

@rhutchison left some comments.

@codydaig
Copy link
Member

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?

@rhutchison
Copy link
Contributor Author

@ilanbiala @codydaig @mleanos @lirantal this is ready.

@coveralls
Copy link

Coverage Status

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 () {
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhutchison did this work?

Copy link
Contributor Author

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.

@ilanbiala
Copy link
Member

@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.

@rhutchison
Copy link
Contributor Author

@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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inject

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.615% when pulling 847ad7aea1613016f8fcd36346da59535b8755ee on Gym:core-styleguide into 59e6daa on meanjs:master.

@lirantal lirantal mentioned this pull request Mar 23, 2016
8 tasks
@mleanos
Copy link
Member

mleanos commented Mar 23, 2016

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.

@mleanos
Copy link
Member

mleanos commented Mar 23, 2016

@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.

@rhutchison
Copy link
Contributor Author

@mleanos thanks for reviewing. Please point me to the outstanding items.

@codydaig
Copy link
Member

@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).

@ilanbiala
Copy link
Member

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
@rhutchison
Copy link
Contributor Author

@ilanbiala done

@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.615% when pulling b2462ec on Gym:core-styleguide into 59e6daa on meanjs:master.

@ilanbiala
Copy link
Member

@mleanos LGTM.

@codydaig
Copy link
Member

LGTM. @mleanos Merge before merge conflicts arise!!!!

@mleanos mleanos merged commit dde9682 into meanjs:master Mar 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.