Skip to content

Conversation

@klawton1
Copy link

No description provided.

ivannash23
ivannash23 approved these changes Feb 27, 2017
}).then(function Success(response){
vm.book = response.data;
})
vm.makeCopy = function(book){

Choose a reason for hiding this comment

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

unsure why this was needed, but it doesn't break anything.

Copy link

Choose a reason for hiding this comment

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

I can see why this was necessary, but would give it a different name; something like "selectBookToEdit" or "makeEditable"

Copy link

Choose a reason for hiding this comment

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

It even looks like you're trying to call this from your frontend as makeEdit rather than makeCopy :(

}
.title{
width: 550px;
}

Choose a reason for hiding this comment

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

look up https://bestmotherfucking.website/ for styling tips, but great job styling

<option ng-model="bc.filter">author</option>
<option ng-model="bc.filter">title</option>
</select>
<div class="book" ng-repeat="book in bc.books | orderBy: bc.filter" >

Choose a reason for hiding this comment

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

filter feature?!?! Way to go above and beyond the call of duty, soldier.

display: inline;
}
.title{
width: 550px;

Choose a reason for hiding this comment

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

watch out for hard coded px! This will break on smaller screens

Copy link

@ivannash23 ivannash23 left a comment

Choose a reason for hiding this comment

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

WHITESPACE IS GOOD FOR YOU!

<script src="/public/scripts/app.js"></script>
<script src="/public/scripts/controllers/booksController.js"></script>
<script src="/public/scripts/controllers/oneBookController.js"></script>
</head>

Choose a reason for hiding this comment

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

add a whitespace line for better reading, brosky

templateUrl: '/templates/onebook.html',
controller: 'OneBookController',
controllerAs: 'obc'
})

Choose a reason for hiding this comment

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

semi-colon player!

url: "https://super-crud.herokuapp.com/books",
}).then(function Success(json){
vm.books = json.data.books;
})

Choose a reason for hiding this comment

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

where's the semi-colons, dude?

<h5>{{book.author}}</h5>
<h5>{{book.releaseDate}}</h5>
</div>
<hr>

Choose a reason for hiding this comment

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

add a whitespace for god's sake!

<button class="btn btn-default" ng-show="edit" ng-click="edit=false; obc.makeEdit(obc.book)">Cancel</button>
<button class="btn btn-default" ng-click="obc.makeCopy(obc.book); edit=true" ng-hide="edit" >Edit</button>
<hr>
<button class="btn btn-default" ng-click="obc.delete()">Delete</button>

Choose a reason for hiding this comment

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

try to read this and only breathe in only on whitespaces, you can't can you? CAN YOU?!

vm.book = res.data;
$location.path('/');
})
}

Choose a reason for hiding this comment

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

CAN I PLEASE HAVE A WHITESPACE?!

Copy link

@mnfmnfm mnfmnfm left a comment

Choose a reason for hiding this comment

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

Overall looks good! I'm guessing you have a bug where editing isn't quite working as you'd hoped, because you call the function two different things in two different places. But your angular is generally well-written.

}
$http({
method: "GET",
url: "https://super-crud.herokuapp.com/books/" + $routeParams.id,
Copy link

Choose a reason for hiding this comment

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

Should use template string rather than concatenation

$http({
method: "GET",
url: "https://super-crud.herokuapp.com/books/" + $routeParams.id,
}).then(function Success(response){
Copy link

Choose a reason for hiding this comment

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

Why does this function get an uppercase name? Those names are usually reserved for constructor functions. should be success(response)

})
vm.makeCopy = function(book){
for(key in vm.editBook){
vm.editBook[key] = book[key]
Copy link

Choose a reason for hiding this comment

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

missing semicolon

}).then(function Success(response){
vm.book = response.data;
})
vm.makeCopy = function(book){
Copy link

Choose a reason for hiding this comment

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

I can see why this was necessary, but would give it a different name; something like "selectBookToEdit" or "makeEditable"

vm.submit = function(book){
$http({
method: "PUT",
url: "https://super-crud.herokuapp.com/books/" + book._id,
Copy link

Choose a reason for hiding this comment

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

concat vs. template

<img class="book-cover" ng-src="{{obc.book.image}}">
</div>
<form class="editing" ng-submit="obc.submit(obc.book)">
<h3 class="title"><span ng-hide="edit">{{obc.book.title}}</span><input type="text" name="title" ng-show="edit" ng-model="obc.editBook.title"></h3>
Copy link

Choose a reason for hiding this comment

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

These are each a lot of things on one line. I try never to have more than one tag in a line; I'd break this up into like 4 lines.

<h5><span ng-hide="edit">{{obc.book.releaseDate}}</span> <input type="text" name="releaseDate" ng-model="obc.editBook.releaseDate" ng-show="edit"></h5>
<button class="btn btn-default" ng-show="edit" ng-click="edit=false" type="submit">Save</button>
</form>
<button class="btn btn-default" ng-show="edit" ng-click="edit=false; obc.makeEdit(obc.book)">Cancel</button>
Copy link

Choose a reason for hiding this comment

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

Where you do 2 things in these ng-click callbacks, it makes more sense to include that line in the function you're calling (i.e., just say obc.makeEdit(obc.book), make all your ng-show listen to obc.edit, and then in your definition of makeEdit set this.edit = false; similar in other places).

}).then(function Success(response){
vm.book = response.data;
})
vm.makeCopy = function(book){
Copy link

Choose a reason for hiding this comment

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

It even looks like you're trying to call this from your frontend as makeEdit rather than makeCopy :(

"dependencies": {
"angular-route": "^1.6.2",
"bower": "^1.8.0",
"mongoose": "^4.8.4"
Copy link

Choose a reason for hiding this comment

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

I don't think you actually use these dependencies, and you should've been using budo rather than node. Why do you have a package.json file?

.controller("BooksController", BooksController);

BooksController.$inject = ['$http', '$routeParams'];
function BooksController( $http, $routeParams) {
Copy link

Choose a reason for hiding this comment

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

This file is using single-space indentation; most of the rest of your files use two-space indentation. Consistency would be nice, and a single space is not enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants