Skip to content

Commit

Permalink
Proper formatting for comment list items, added author and db relatio…
Browse files Browse the repository at this point in the history
…nship in comment model. Moved status messages to include
  • Loading branch information
Adam Crampton committed Mar 4, 2015
1 parent 476310a commit 4eca6e3
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function ajax_add_comment()

// Add author and timestamp of new comment to comment text
$comment_stamp = $insert_comment->updated_at;

$comment_text = $comment_stamp . ' ' . $comment;
$comment_author = User::whereUsers_id($insert_comment->comments_users_fk)->first()->users_username;
$comment_text = 'By <strong>' . $comment_author . '</strong> at ' . $comment_stamp . '<br />' . $comment;

return json_encode(['comment_status' => 'success', 'comment_text' => $comment_text]);
}
Expand Down
6 changes: 6 additions & 0 deletions app/models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
protected $table = 'comments';
protected $primaryKey = 'comments_id';

// DB Relationships
public function master()
{
return $this->belongsTo('Master', 'comments_master_fk', 'master_id');
}

public function users()
{
return $this->belongsTo('User', 'comments_users_fk', 'users_id');
}

}
9 changes: 9 additions & 0 deletions app/views/includes/status_show.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div id="comment_add_success" class="alert alert-success alert-dismissible hide" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Success!</strong> Comment added.
</div>

<div id="comment_add_failed" class="alert alert-danger alert-dismissible hide" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Sorry, there was a problem adding your comment.</strong> Please contact support.
</div>
10 changes: 1 addition & 9 deletions app/views/layouts/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@

<div class="container page">

<div id="comment_add_success" class="alert alert-success alert-dismissible hide" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Success!</strong> Comment added.
</div>

<div id="comment_add_failed" class="alert alert-danger alert-dismissible hide" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>Sorry, there was a problem adding your comment.</strong> Please contact support.
</div>
@include('includes.status_show')

@yield('content')
</div><!-- /.container -->
Expand Down
2 changes: 1 addition & 1 deletion app/views/modals/comment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Add comment to this ticket</h4>
<h4 class="modal-title" id="comment_modal_label">Add comment to this ticket</h4>
</div>
<div class="modal-body">
{{ Form::textarea('comment_add', null, ['id' => 'comment_add', 'class' => 'form-control']) }}
Expand Down
8 changes: 4 additions & 4 deletions app/views/tickets/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
{{ Form::textarea('description', $ticket->master_description, ['id' => 'content_editor', 'class' => 'form-control']) }}
</div>
</div>
<div class="col-md-6">
<div class="col-md-6 comment_box">
<div class="form-group">
{{ Form::label('comments', 'Comments: ') }} {{ Form::button('Add Comment', ['class' => 'btn btn-xs btn-primary pull-right', 'data-toggle' => 'modal', 'data-target' => '#comment_modal']) }}
<ul id="comment_list">
{{ Form::label('comments', 'Comments: ') }} {{ Form::button('Add Comment', ['id' => 'new_comment', 'class' => 'btn btn-xs btn-primary pull-right', 'data-toggle' => 'modal', 'data-target' => '#comment_modal']) }}
<ul id="list-group">
@foreach($comments as $comment)
<li>{{ $comment->updated_at . ': ' . $comment->comments_comment }}</li>
<li class="list-group-item">{{ 'By <strong>' . $comment->users->users_username . '</strong> at ' . $comment->updated_at . '<br />' . $comment->comments_comment }}</li>
@endforeach
</ul>
</div>
Expand Down
17 changes: 15 additions & 2 deletions public/css/main.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
/* LaraDesk Project CSS */
/* LaraDesk CSS */

/*Structural*/
/* Structural */
.page
{
padding-top: 60px;
}

/* Bootstrap Fine Tuning */


/* Ticket Show View */
.comment_box
{
height: 255px;
overflow-y: scroll;
}

.comment_box ul
{
padding-left: 0;
}
13 changes: 12 additions & 1 deletion public/js/utilities.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
// General Scripts
/* _ _ _ _ _ _ _____ _ _
| | | | | (_) (_) | / ____| (_) | |
| | | | |_ _| |_| |_ _ _ | (___ ___ _ __ _ _ __ | |_ ___
| | | | __| | | | __| | | | \___ \ / __| '__| | '_ \| __/ __|
| |__| | |_| | | | |_| |_| | ____) | (__| | | | |_) | |_\__ \
\____/ \__|_|_|_|\__|\__, | |_____/ \___|_| |_| .__/ \__|___/
__/ | | |
|___/ |_|
*/

// Ticket Comments
$(document).ready(function()
{
$('#submit_comment').on('click', function() {
Expand All @@ -7,6 +17,7 @@ $(document).ready(function()

});


// AJAX Functions
function add_comment(event)
{
Expand Down

0 comments on commit 4eca6e3

Please sign in to comment.