mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-08 18:33:22 +02:00
Fixing Articles Issues
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
var mongoose = require('mongoose'),
|
||||
Article = mongoose.model('Article'),
|
||||
_ = require('lodash');
|
||||
|
||||
/**
|
||||
* Get the error message from error object
|
||||
*/
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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'
|
||||
});
|
||||
}
|
||||
]);
|
||||
@@ -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 = '';
|
||||
@@ -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;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -20,6 +20,9 @@
|
||||
<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>
|
||||
@@ -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>
|
||||
@@ -20,6 +20,9 @@
|
||||
<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>
|
||||
@@ -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">
|
||||
<a class="btn btn-primary" href="/#!/articles/{{article._id}}/edit">
|
||||
<i class="glyphicon glyphicon-edit"></i>
|
||||
</a>
|
||||
Reference in New Issue
Block a user