Skip to content

Commit

Permalink
add at.js mention in comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Bottelet committed Jul 19, 2017
1 parent 846b796 commit eb9fa89
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 14 deletions.
5 changes: 5 additions & 0 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public function index()
return view('users.index')->withUsers($this->users);
}

public function users()
{
return User::all();
}

public function anyData()
{
$canUpdateUser = auth()->user()->can('update-user');
Expand Down
7 changes: 4 additions & 3 deletions app/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public function mentionedUsers()
return $matches[1];
}

public function setDescriptionAttribute($description)
/* //TODO figure out how to escape the comment, but not the link to the profile, as it just return the full HTML
public function setDescriptionAttribute($description)
{
$this->attributes['description'] = preg_replace(
'/@([\w\-]+)/',
'<a href="/profiles/$1">$0</a>',
'e(<a href="/profiles/$1">$0</a>',
$description
);
}
}*/
}
11 changes: 4 additions & 7 deletions public/css/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/app.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/css/jquery.atwho.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/js/jquery.atwho.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/jquery.caret.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link href="{{ URL::asset('css/font-awesome.min.css') }}" rel="stylesheet" type="text/css">
<link href="{{ URL::asset('css/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css">
<link href="{{ URL::asset('css/dropzone.css') }}" rel="stylesheet" type="text/css">
<link href="{{ URL::asset('css/jquery.atwho.min.css') }}" rel="stylesheet" type="text/css">

<link rel="stylesheet" href="{{ asset(elixir('css/app.css')) }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
Expand Down Expand Up @@ -201,7 +202,8 @@ class="glyphicon sidebar-icon glyphicon-log-out"></i><span id="menu-txt">{{ __('
<script type="text/javascript" src="{{ URL::asset('js/dropzone.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('js/jquery.dataTables.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('js/jasny-bootstrap.min.js') }}"></script>

<script type="text/javascript" src="{{ URL::asset('js/jquery.caret.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('js/jquery.atwho.min.js') }}"></script>
@stack('scripts')
</body>

Expand Down
21 changes: 19 additions & 2 deletions resources/views/partials/comments.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,34 @@
@if($instance == 'task')
{!! Form::open(array('url' => array('/comments/task',$subject->id, ))) !!}
<div class="form-group">
{!! Form::textarea('description', null, ['class' => 'form-control']) !!}
{!! Form::textarea('description', null, ['class' => 'form-control', 'id' => 'comment-field']) !!}

{!! Form::submit( __('Add Comment') , ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
@else
{!! Form::open(array('url' => array('/comments/lead',$lead->id, ))) !!}
<div class="form-group">
{!! Form::textarea('description', null, ['class' => 'form-control']) !!}
{!! Form::textarea('description', null, ['class' => 'form-control', 'id' => 'comment-field']) !!}

{!! Form::submit( __('Add Comment') , ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
@endif

@push('scripts')
<script>
$('#comment-field').atwho({
at: "@",
limit: 5,
delay: 400,
callbacks: {
remoteFilter: function (t, e) {
t.length <= 2 || $.getJSON("/users/users", {q: t}, function (t) {
e(t)
})
}
}
})
</script>
@endpush
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Route::get('/taskdata/{id}', 'UsersController@taskData')->name('users.taskdata');
Route::get('/leaddata/{id}', 'UsersController@leadData')->name('users.leaddata');
Route::get('/clientdata/{id}', 'UsersController@clientData')->name('users.clientdata');
Route::get('/users', 'UsersController@users')->name('users.clientdata');
});
Route::resource('users', 'UsersController');

Expand Down

0 comments on commit eb9fa89

Please sign in to comment.