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

Commit

Permalink
Fixing Articles Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed Apr 23, 2014
1 parent 430e66b commit f132e10
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/controllers/articles.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var mongoose = require('mongoose'),
Article = mongoose.model('Article'),
_ = require('lodash');

/**
* Get the error message from error object
*/
Expand All @@ -16,7 +17,7 @@ var getErrorMessage = function(err) {
switch (err.code) {
case 11000:
case 11001:
message = 'Unique already exists';
message = 'Article already exists';
break;
default:
message = 'Something went wrong';
Expand Down
2 changes: 1 addition & 1 deletion app/routes/articles.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var users = require('../../app/controllers/users.server.controller'),
articles = require('../../app/controllers/articles.server.controller');

module.exports = function(app) {
// Article Routes, using express 4.x syntax
// Article Routes
app.route('/articles')
.get(articles.list)
.post(users.requiresLogin, articles.create);
Expand Down
8 changes: 4 additions & 4 deletions public/modules/articles/config/articles.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ angular.module('articles').config(['$stateProvider',
$stateProvider.
state('listArticles', {
url: '/articles',
templateUrl: 'modules/articles/views/list.client.view.html'
templateUrl: 'modules/articles/views/list.articles.client.view.html'
}).
state('createArticle', {
url: '/articles/create',
templateUrl: 'modules/articles/views/create.client.view.html'
templateUrl: 'modules/articles/views/create.article.client.view.html'
}).
state('viewArticle', {
url: '/articles/:articleId',
templateUrl: 'modules/articles/views/view.client.view.html'
templateUrl: 'modules/articles/views/view.article.client.view.html'
}).
state('editArticle', {
url: '/articles/:articleId/edit',
templateUrl: 'modules/articles/views/edit.client.view.html'
templateUrl: 'modules/articles/views/edit.article.client.view.html'
});
}
]);
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ angular.module('articles').controller('ArticlesController', ['$scope', '$statePa
});
article.$save(function(response) {
$location.path('articles/' + response._id);
}, function(errorResponse) {
$scope.error = errorResponse.data.message;
});

this.title = '';
Expand Down Expand Up @@ -42,6 +44,8 @@ angular.module('articles').controller('ArticlesController', ['$scope', '$statePa

article.$update(function() {
$location.path('articles/' + article._id);
}, function(errorResponse) {
$scope.error = errorResponse.data.message;
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1>New Article</h1>
</div>
<div class="col-md-12">
<form class="form-horizontal" data-ng-submit="create()">
<form class="form-horizontal" data-ng-submit="create()" novalidate>
<fieldset>
<div class="form-group">
<label class="control-label" for="title">Title</label>
Expand All @@ -20,6 +20,9 @@ <h1>New Article</h1>
<div class="form-group">
<input type="submit" class="btn btn-default">
</div>
<div data-ng-show="error" class="text-danger">
<strong>{{error}}</strong>
</div>
</fieldset>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1>Edit Article</h1>
</div>
<div class="col-md-12">
<form class="form-horizontal" data-ng-submit="update()">
<form class="form-horizontal" data-ng-submit="update()" novalidate>
<fieldset>
<div class="form-group">
<label class="control-label" for="title">Title</label>
Expand All @@ -20,6 +20,9 @@ <h1>Edit Article</h1>
<div class="form-group">
<input type="submit" value="Update" class="btn btn-default">
</div>
<div data-ng-show="error" class="text-danger">
<strong>{{error}}</strong>
</div>
</fieldset>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1>{{article.title}}</h1>
</div>

<div class="pull-right" data-ng-show="authentication.user._id == article.user._id">
<div class="pull-right" data-ng-show="authentication.user._id == article.user._id || true">

This comment has been minimized.

Copy link
@ryanlatham

ryanlatham Apr 25, 2014

Why did you "or" with "true"? Is this just a temporary measure? Currently it means that statement will always be true. Unless I am missing something?

<a class="btn btn-primary" href="/#!/articles/{{article._id}}/edit">
<i class="glyphicon glyphicon-edit"></i>
</a>
Expand Down

0 comments on commit f132e10

Please sign in to comment.