-
Notifications
You must be signed in to change notification settings - Fork 2k
Conversation
}) | ||
.state('articles.create', { | ||
url: '/create', | ||
templateUrl: 'modules/articles/client/views/create-article.client.view.html', | ||
controller: 'ArticlesController', |
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.
Shouldn't this be 'ArticlesCreateController' or something similar since we are doing that above?
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.
Well previously I had them all separate controllers but that got shot down. I can see the need for a create controller if we don't want to pass in a blank article to resolve. Then the ArticlesController would handle edit/view since it needs an article to resolve? @rhutchison
@rhutchison Angular Stylized I will fix the tests once we finalize the code. Do the tests need to follow any sort of guidelines? |
I'm not a fan of the IIFEs. Is anyone of the belief that what we have inside is actually being initialized as a global variable and should definitely not be there. It seems unnecessary to me. |
@ilanbiala I think the point is to have a style guide and stick to it everywhere, whether or not it is functionally necessary. |
I would second the IIDEs. Other than that, I've been following th John Papa style guide in my most recent project and love it. |
f3e4445
to
989a4fd
Compare
@codydaig what benefit does the IIFE offer? I don't see us creating many global variables. |
@rhutchison @ilanbiala @lirantal @codydaig Can I get a code review here? I fixed the tests and everything is looking pretty good to me. thx As for the IIFEs, I think it is best practice and it is in line with our style guide, regardless if it is needed functionally. |
Other projects might, as it's a boilerplate. It's a good practise to pass on for others, especially for less experienced developers. Although for articles.client.module.js it indeed looks a bit silly. :-) |
@simison the other thing is that I'm pretty sure these IIFes are set up incorrectly. The whole point is that there are 0 global variables. In articles.client.module.js, |
@simison With the architecture of this boilerplate, I don't see the need for IIFE's. As long as users of this project keep their project's architecture inline with this implementation, then there shouldn't be a need for us to introduce this particular best practice. I would even say it would be confusing to less experienced developers; whereas how it's setup now, it's pretty easy to understand & read the code. If someone deviates from the current implementation, and finds that they need to implement this best practice, then they could do so. But it would be a conscious effort on their part, and they'd have a specific reason for doing so. |
@ilanbiala @mleanos All valid points and good food for thought! |
@ilanbiala You are correct on the articles.client.module.js and I will change that. If you find any others let me know. I don't think we should deviate from a style guide that we chose to use... I think we need to stick to it otherwise how is a dev gonna know what to do and what not to do? |
Would we be ok with angular being global? Or are we passing that into the IIFE as well? |
@ilanbiala I meant I agree with you. I don't like IIFEs at all. I dislike how your code starts indented vefore you even write your first line. As long as you concat before you minify and uglify, it doesn't make a difference. |
Sounds like its been decided to not use IIFEs. @trainerbill go ahead and remove them. I'll be able to do a more through review later day as well. |
@codydaig I don't know why we would decide that. If we are going to have a style guide we should really stick to it. Picking and choosing leaves gray areas. Where was the discussion and decision made? I know of 3 people that support them. |
@trainerbill we are picking a style guide and we are doing what makes sense for the framework. A style guide is exactly that, a guide for what you should do. It isn't a rulebook that says do everything exactly as I say. IIFEs aren't necessary because of the way our app is set up, therefore why add the complication and extra code that does nothing. |
@ilanbiala fair enough. Someone should make a MEAN.js styleguide then. It makes it easier as a contributor to know up front what I need to do, rather than go through 50 code reviews for style issues. |
if (!isValid) { | ||
$scope.$broadcast('show-errors-check-validity', 'articleForm'); | ||
function ArticlesController($scope, $state, Authentication, articleResolve) { | ||
var vm = this; |
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.
What is vm?
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.
view model. It's supposed to replace $scope.
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.
The only issue is we can't just change it in one place. Maybe we do that as migration to 1.5?
@mleanos - I think there would be overhead if If One advantage of using
Imagine I have an app where there is an angular Controller that is a parent controller, sort of like a shell controller for an app. And then, of course, I have a controller nested inside. Using |
@mg1075 I'm advocating to use IMO, most users of this framework don't modify the core, or users module. They take our example CRUD (Articles) and use it as a guide for developing their own custom modules. This is another reason why it makes more sense to implement the style-guide into the Article module to start. |
@mg1075 I'm on Gitter right now, if you'd like to discuss this there. To avoid cluttering this issue. |
@mleanos @mg1075 @lirantal @ilanbiala I'd much rather see it broken up by module rather than one large PR. Because that PR is going to be a nightmare for anyone doing it if any changes are made along the way. All modules need to be switched over before 0.5 is released though to avoid overhead. The master branch is considered development, so anyone using it in production runs the risk of some type of overhead as not all proposed changes will have been made yet. |
@codydaig do you want to oversee that then? It's fine if people submit PRs too, but if not then would you be able to refactor that code? I'll gladly review it as well to help out. Also, one thing that I'd want to see if we're doing it now is avoiding $scope as much as possible. https://toddmotto.com/no-scope-soup-bind-to-controller-angularjs/ http://blog.ninja-squad.com/2015/07/21/what-is-new-angularjs-1.4/ have suggestions on how to do that, but they require Angular 1.4. |
@ilanbiala I can oversee that. I've worked with the John Papa style guide. (Actually more familiar with that then using $scope.) I agree, $scope shouldn't have to be used anywhere with the ControllerAs syntax. I will try upgrading Angular and see if it breaks anything. These next 2 weeks are crazy for me, but come January I should be able to crank these out. |
@codydaig - recall @rhutchison comments in gitter about using controllerAs:
...and...
|
I'd like to undertake the refactoring of the Users Admin feature. I have a good amount of experience with John Papa's styleguide as well. As for the use of |
@trainerbill @rhutchison what's the plan here? |
Update the articles module to implement the style guidelines. Much of this work is from @trainerbill Closes meanjs#874 Closes meanjs#339
tested and looking good @trainerbill clean up the commit message and squash the commits - LGTM |
@@ -19,7 +19,7 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(function ($ro | |||
if (toState.data && toState.data.roles && toState.data.roles.length > 0) { | |||
var allowed = false; | |||
toState.data.roles.forEach(function (role) { | |||
if (Authentication.user.roles !== undefined && Authentication.user.roles.indexOf(role) !== -1) { | |||
if ((role === 'guest') || (Authentication.user && Authentication.user.roles !== undefined && Authentication.user.roles.indexOf(role) !== -1)) { |
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 Why is this included? It's already in master.
We should be using rebase, not merges right?
99c8cb0
to
bd3ace1
Compare
|
||
newArticle.$inject = ['Article']; | ||
|
||
function newArticle(Article) { |
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.
Why do this? Why not just do it in the controller
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 It makes the controller smaller and allows the use of UI-Router nested views to share the resolve between the views and other controllers.
@trainerbill There's a reference to a merge conflict still in the code.. I commented on the line that has Also, there are some older line comments that haven't been addressed. |
Update the articles module to implement the style guidelines. Much of this work is from @trainerbill Closes meanjs#874 Closes meanjs#339
Superceeds #800
@ilanbiala @rhutchison