parent
1875c9682e
commit
e15b004a1e
@ -120,7 +120,7 @@ $app->post('/items/:itemId/comment', function($itemId) use ($app, $jsonResponse)
|
|||||||
$item->ownComment[] = $comment;
|
$item->ownComment[] = $comment;
|
||||||
R::store($item);
|
R::store($item);
|
||||||
|
|
||||||
logAction($user->username . ' added a comment to item ' . $item->title, null, $comment, $itemId);
|
logAction($user->username . ' added a comment to item ' . $item->title, null, $comment->export(), $itemId);
|
||||||
$jsonResponse->addAlert('success', 'Comment added to item ' . $item->title . '.');
|
$jsonResponse->addAlert('success', 'Comment added to item ' . $item->title . '.');
|
||||||
$jsonResponse->addBeans(R::load('item', $itemId));
|
$jsonResponse->addBeans(R::load('item', $itemId));
|
||||||
}
|
}
|
||||||
@ -128,6 +128,28 @@ $app->post('/items/:itemId/comment', function($itemId) use ($app, $jsonResponse)
|
|||||||
$app->response->setBody($jsonResponse->asJson());
|
$app->response->setBody($jsonResponse->asJson());
|
||||||
})->conditions(['itemId' => '\d+']);
|
})->conditions(['itemId' => '\d+']);
|
||||||
|
|
||||||
|
// Update an existing comment
|
||||||
|
$app->post('/comments/:commentId', function($commentId) use ($app, $jsonResponse) {
|
||||||
|
$data = json_decode($app->environment['slim.input']);
|
||||||
|
|
||||||
|
if(validateToken()) {
|
||||||
|
$user = getUser();
|
||||||
|
$comment = R::load('comment', $commentId);
|
||||||
|
$before = $comment->export();
|
||||||
|
|
||||||
|
$comment->text = $data->text;
|
||||||
|
$comment->userId = $user->id;
|
||||||
|
$comment->timestamp = time();
|
||||||
|
$comment->isEdited = true;
|
||||||
|
R::store($comment);
|
||||||
|
|
||||||
|
logAction($user->username . ' edited comment ' . $comment->id, $before, $comment->export(), $comment->id);
|
||||||
|
$jsonResponse->addAlert('success', 'Comment edited.');
|
||||||
|
$jsonResponse->addBeans(R::load('item', $comment->item_id));
|
||||||
|
}
|
||||||
|
$app->response->setBody($jsonResponse->asJson());
|
||||||
|
})->conditions(['commentId' => '\d+']);
|
||||||
|
|
||||||
// Remove a comment from an item.
|
// Remove a comment from an item.
|
||||||
$app->post('/items/:itemId/comment/remove', function($itemId) use ($app, $jsonResponse) {
|
$app->post('/items/:itemId/comment/remove', function($itemId) use ($app, $jsonResponse) {
|
||||||
$data = json_decode($app->environment['slim.input']);
|
$data = json_decode($app->environment['slim.input']);
|
||||||
|
@ -369,6 +369,13 @@ span.fa {
|
|||||||
.view-item-comment-form {
|
.view-item-comment-form {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.edit-item-comment-form {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.edit-item-comment-form button {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
.detail {
|
.detail {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
@ -384,6 +391,19 @@ p.detail {
|
|||||||
.links a {
|
.links a {
|
||||||
margin-left: 3px;
|
margin-left: 3px;
|
||||||
}
|
}
|
||||||
|
.commentText {
|
||||||
|
display: inline-block;
|
||||||
|
width: 95%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.commentActions {
|
||||||
|
position: absolute;
|
||||||
|
top: .8em;
|
||||||
|
right: .4em;
|
||||||
|
}
|
||||||
|
.commentActions a {
|
||||||
|
margin-left: 3px;
|
||||||
|
}
|
||||||
#add-comment {
|
#add-comment {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ taskBoardControllers.controller('ItemViewBoardCtrl',
|
|||||||
['$scope', '$window', 'BoardService',
|
['$scope', '$window', 'BoardService',
|
||||||
function ($scope, $window, BoardService) {
|
function ($scope, $window, BoardService) {
|
||||||
$scope.viewItem = {};
|
$scope.viewItem = {};
|
||||||
|
$scope.comment = {};
|
||||||
$scope.toggle = {
|
$scope.toggle = {
|
||||||
sidebar: false
|
sidebar: false
|
||||||
};
|
};
|
||||||
@ -38,6 +39,9 @@ function ($scope, $window, BoardService) {
|
|||||||
updateItem = function(item) {
|
updateItem = function(item) {
|
||||||
$scope.viewItem = item;
|
$scope.viewItem = item;
|
||||||
$scope.viewItem.laneName = $scope.laneNames[item.lane_id];
|
$scope.viewItem.laneName = $scope.laneNames[item.lane_id];
|
||||||
|
convertDates($scope.viewItem.ownComment);
|
||||||
|
convertDates($scope.viewItem.ownAttachment);
|
||||||
|
convertDates($scope.viewItem.ownActivity);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.openItem = function(item, openModal) {
|
$scope.openItem = function(item, openModal) {
|
||||||
@ -54,9 +58,6 @@ function ($scope, $window, BoardService) {
|
|||||||
$scope.viewItem.ownAttachment = [];
|
$scope.viewItem.ownAttachment = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
convertDates($scope.viewItem.ownComment);
|
|
||||||
convertDates($scope.viewItem.ownAttachment);
|
|
||||||
convertDates($scope.viewItem.ownActivity);
|
|
||||||
$scope.fileReset = true;
|
$scope.fileReset = true;
|
||||||
|
|
||||||
if (openModal) {
|
if (openModal) {
|
||||||
@ -179,7 +180,7 @@ function ($scope, $window, BoardService) {
|
|||||||
|
|
||||||
$scope.addItemComment = function(comment) {
|
$scope.addItemComment = function(comment) {
|
||||||
if (comment === "" || undefined === comment) {
|
if (comment === "" || undefined === comment) {
|
||||||
$scope.alerts.showAlert({ type: 'error', text:'Comment cannot be empty.' });
|
$scope.alerts.showAlert({ type: 'error', text: 'Comment cannot be empty.' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +195,28 @@ function ($scope, $window, BoardService) {
|
|||||||
$scope.comment.text = "";
|
$scope.comment.text = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.beginEditComment = function(commentId, comment) {
|
||||||
|
$scope.comment.isEdit = true;
|
||||||
|
$scope.comment.editText = comment;
|
||||||
|
$scope.comment.id = commentId;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.editComment = function(commentId, comment) {
|
||||||
|
$scope.comment.isEdit = false;
|
||||||
|
if (comment === '' || undefined === comment) {
|
||||||
|
$scope.alerts.showAlert({ type: 'error', text: 'Comment cannot be empty.' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.viewItem.disabled = true;
|
||||||
|
BoardService.updateItemComment(commentId, comment)
|
||||||
|
.success(function(data) {
|
||||||
|
updateItem(data.data[0]);
|
||||||
|
$scope.loadBoards();
|
||||||
|
$scope.viewItem.disabled = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.addItemAttachment = function() {
|
$scope.addItemAttachment = function() {
|
||||||
if ($scope.itemUpload === undefined || $scope.itemUpload.name === '') {
|
if ($scope.itemUpload === undefined || $scope.itemUpload.name === '') {
|
||||||
$scope.alerts.showAlert({ type: 'error', text: 'Select a file before uploading.' });
|
$scope.alerts.showAlert({ type: 'error', text: 'Select a file before uploading.' });
|
||||||
|
@ -102,6 +102,12 @@ function($http) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateItemComment: function(commentId, comment) {
|
||||||
|
return $http.post('api/comments/' + commentId, {
|
||||||
|
text: comment
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
removeItemComment: function(itemId, commentId) {
|
removeItemComment: function(itemId, commentId) {
|
||||||
return $http.post('api/items/' + itemId + '/comment/remove', {
|
return $http.post('api/items/' + itemId + '/comment/remove', {
|
||||||
id: commentId
|
id: commentId
|
||||||
|
@ -86,21 +86,41 @@
|
|||||||
<div class="list-group-item"
|
<div class="list-group-item"
|
||||||
data-ng-repeat="comment in viewItem.ownComment | orderBy:'timestamp':comments.sorting"
|
data-ng-repeat="comment in viewItem.ownComment | orderBy:'timestamp':comments.sorting"
|
||||||
data-ng-class-even="'alternate'">
|
data-ng-class-even="'alternate'">
|
||||||
<p class="comment">
|
<div class="comment">
|
||||||
<span data-ng-bind-html="markedComment(comment.text)"></span>
|
<span class="commentText" data-ng-bind-html="markedComment(comment.text)"></span>
|
||||||
<a class="fa fa-trash-o pull-right"
|
<span class="commentActions">
|
||||||
data-ng-if="currentUser.userId == comment.user_id || currentUser.isAdmin == 1"
|
<a class="fa fa-edit"
|
||||||
data-ng-click="deleteComment(comment.id)"></a>
|
data-ng-if="currentUser.userId == comment.user_id || currentUser.isAdmin == 1"
|
||||||
|
data-ng-click="beginEditComment(comment.id, comment.text)"></a>
|
||||||
|
<a class="fa fa-trash-o"
|
||||||
|
data-ng-if="currentUser.userId == comment.user_id || currentUser.isAdmin == 1"
|
||||||
|
data-ng-click="deleteComment(comment.id)"></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="detail">
|
||||||
|
<span data-ng-if="!comment.is_edited == 1">Posted</span>
|
||||||
|
<span data-ng-if="comment.is_edited == 1">Edited</span>
|
||||||
|
by {{ userNames[comment.user_id] }} on {{ comment.date }}
|
||||||
</p>
|
</p>
|
||||||
<p class="detail">Posted by {{ userNames[comment.user_id] }} on {{ comment.date }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="edit-item-comment-form" data-ng-if="comment.isEdit">
|
||||||
|
<h4>Edit Comment</h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<textarea id="editComment" class="form-control" rows="4" data-ng-model="comment.editText"></textarea>
|
||||||
|
<button id="edit-comment" class="btn btn-info pull-right"
|
||||||
|
data-ng-class="{ 'disabled': viewItem.disabled }"
|
||||||
|
data-ng-click="editComment(comment.id, comment.editText)"><span class="fa fa-comment-o"></span> Edit Comment</button>
|
||||||
|
<button id="cancel-edit-comment" class="btn btn-default pull-right"
|
||||||
|
data-ng-click="comment.isEdit = false"><span class="fa fa-times"></span> Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="view-item-comment-form">
|
<div class="view-item-comment-form">
|
||||||
<h4>Add Comment</h4>
|
<h4>Add Comment</h4>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea id="itemComment" class="form-control" rows="4" data-ng-model="comment.text"></textarea>
|
<textarea id="itemComment" class="form-control" rows="4" data-ng-model="comment.text"></textarea>
|
||||||
<button type="submit" id="add-comment" class="btn btn-info pull-right"
|
<button id="add-comment" class="btn btn-info pull-right"
|
||||||
data-ng-class="{ 'disabled': viewItem.disabled }"
|
data-ng-class="{ 'disabled': viewItem.disabled }"
|
||||||
data-ng-click="addItemComment(comment.text)"><span class="fa fa-comment-o"></span> Submit Comment</button>
|
data-ng-click="addItemComment(comment.text)"><span class="fa fa-comment-o"></span> Submit Comment</button>
|
||||||
</div>
|
</div>
|
||||||
|
12
readme.md
12
readme.md
@ -97,12 +97,12 @@ Count was done from parent directory of TaskBoard as `./cloc-1.62.pl TaskBoard -
|
|||||||
|
|
||||||
Language | Files | Blank Lines | Comments | Code
|
Language | Files | Blank Lines | Comments | Code
|
||||||
-------------------|-------:|-------------:|---------:|---------:
|
-------------------|-------:|-------------:|---------:|---------:
|
||||||
Javascript | 23 | 190 | 34 | 1886
|
Javascript | 23 | 194 | 34 | 1914
|
||||||
HTML | 17 | 10 | 10 | 991
|
HTML | 17 | 10 | 10 | 1011
|
||||||
PHP | 6 | 152 | 57 | 855
|
PHP | 6 | 156 | 58 | 872
|
||||||
CSS | 1 | 11 | 33 | 616
|
CSS | 1 | 11 | 33 | 636
|
||||||
Bourne Again Shell | 4 | 10 | 0 | 53
|
Bourne Again Shell | 4 | 10 | 0 | 53
|
||||||
XML | 1 | 0 | 0 | 12
|
XML | 1 | 0 | 0 | 12
|
||||||
__SUM:__ | __52__ | __373__ | __134__ | __4413__
|
__SUM:__ | __52__ | __381__ | __135__ | __4498__
|
||||||
|
|
||||||
Counts Last Updated: Oct. 31, 2014
|
Counts Last Updated: Nov. 2, 2014
|
||||||
|
Reference in New Issue
Block a user