mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Closes #32 : Display comments
This commit is contained in:
parent
c365c6f6e0
commit
82b39586f0
@ -11,6 +11,40 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
||||
$scope.error = response;
|
||||
});
|
||||
|
||||
// Load comments from server
|
||||
Restangular.one('comment', $stateParams.id).get().then(function(data) {
|
||||
$scope.comments = data.comments;
|
||||
}, function(response) {
|
||||
$scope.commentsError = response;
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a comment.
|
||||
*/
|
||||
$scope.comment = '';
|
||||
$scope.addComment = function() {
|
||||
if ($scope.comment.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Restangular.one('comment').put({
|
||||
id: $stateParams.id,
|
||||
content: $scope.comment
|
||||
}).then(function(data) {
|
||||
$scope.comment = '';
|
||||
$scope.comments.push(data);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a comment.
|
||||
*/
|
||||
$scope.deleteComment = function(comment) {
|
||||
Restangular.one('comment', comment.id).remove().then(function() {
|
||||
$scope.comments.splice($scope.comments.indexOf(comment), 1);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a document.
|
||||
*/
|
||||
@ -24,7 +58,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
||||
|
||||
$dialog.messageBox(title, msg, btns, function (result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('document', document.id).remove().then(function () {
|
||||
Restangular.one('document', document.id).remove().then(function() {
|
||||
$scope.loadDocuments();
|
||||
$state.go('document.default');
|
||||
});
|
||||
|
@ -18,7 +18,7 @@
|
||||
<a ng-href="#/document/view/{{ log.message }}/content/file/{{ log.target }}">Open</a>
|
||||
</span>
|
||||
<span ng-switch-when="Comment">
|
||||
<a ng-href="#/document/view/{{ log.message }}/comments">See</a>
|
||||
<a ng-href="#/document/view/{{ log.message }}">See</a>
|
||||
</span>
|
||||
<span ng-switch-when="Acl">
|
||||
{{ log.message }}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<p ng-bind-html="document.description | newline"></p>
|
||||
<p class="well-sm" ng-bind-html="document.description | newline"></p>
|
||||
|
||||
<div ng-file-drop drag-over-class="bg-success" ng-multiple="true" allow-dir="false" ng-model="dropFiles"
|
||||
accept="image/*,application/pdf,application/zip" ng-file-change="fileDropped($files, $event, $rejectedFiles)">
|
||||
|
@ -60,7 +60,35 @@
|
||||
<div ui-view="tab"></div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
Comments
|
||||
<p class="page-header">
|
||||
<span class="glyphicon glyphicon-comment"></span>
|
||||
Comments
|
||||
</p>
|
||||
|
||||
<div ng-show="!comments || comments.length == 0" class="text-center text-muted">
|
||||
<h1 class="glyphicon glyphicon-comment"></h1>
|
||||
<p ng-show="!comments && !commentsError">Loading...</p>
|
||||
<p ng-show="comments.length == 0">No comments on this document yet</p>
|
||||
<p ng-show="!comments && commentsError">Error loading comments</p>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="comment in comments" style="overflow: hidden">
|
||||
<strong>{{ comment.creator }}</strong>
|
||||
<p>
|
||||
{{ comment.content }}<br />
|
||||
<span class="text-muted">{{ comment.create_date | date: 'yyyy-MM-dd' }}</span>
|
||||
<span class="text-muted pull-right btn-link"
|
||||
ng-show="document.writable || userInfo.username == comment.creator"
|
||||
ng-click="deleteComment(comment)">Delete</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form ng-submit="addComment()">
|
||||
<div class="form-group">
|
||||
<label class="sr-only" for="commentInput">Email address</label>
|
||||
<input type="text" class="form-control" id="commentInput" ng-model="comment" placeholder="Add a comment">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user