Skip to content

Commit 1713357

Browse files
committed
Ticket list: Plus / minus to show or hide full content
1 parent a9404b7 commit 1713357

4 files changed

Lines changed: 50 additions & 6 deletions

File tree

src/Controllers/ConfigurationsController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public function index()
2828
'email.google_plus_link', 'email.facebook_link', 'email.twitter_link', 'email.footer', 'email.footer_link',
2929
'email.color_body_bg', 'email.color_header_bg', 'email.color_content_bg', 'email.color_footer_bg',
3030
'email.color_button_bg', 'email.account.name', 'email.account.mailbox' ];
31-
$tickets_section = ['default_priority_id', 'default_status_id', 'default_close_status_id', 'default_reopen_status_id', 'subject_content_column', 'paginate_items', 'attachments_ticket_max_size', 'attachments_ticket_max_files_num', 'attachments_mimes', 'attachments_path', 'thumbnails_path', 'oldest_year', 'user_route', 'html_replacements'];
31+
$tickets_section = ['default_priority_id', 'default_status_id', 'default_close_status_id', 'default_reopen_status_id',
32+
'subject_content_column', 'paginate_items', 'attachments_ticket_max_size', 'attachments_ticket_max_files_num', 'attachments_mimes',
33+
'attachments_path', 'thumbnails_path', 'oldest_year', 'user_route', 'html_replacements', 'list_text_max_length'];
3234
$perms_section = ['agent_restrict', 'close_ticket_perm', 'reopen_ticket_perm'];
3335
$editor_section = ['editor_enabled', 'editor_html_highlighter', 'codemirror_theme',
3436
'summernote_locale', 'summernote_options_json_file', 'summernote_options_user', 'purifier_config', ];

src/Controllers/TicketsController.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,34 @@ public function renderTicketTable($collection)
200200
if (Setting::grab('subject_content_column') == 'no'){
201201
return $field;
202202
}else{
203-
$field = '<div style="margin: 0em 0em 1em 0em;">'.$field.'</div>' . $ticket->content;
204-
if ($ticket->all_attachments_count>0) $field.= "<br />" . $ticket->all_attachments_count . ' <span class="fa fa-paperclip tooltip-info attachment" title="'.trans('panichd::lang.table-info-attachments-total', ['num' => $ticket->all_attachments_count]).'"></span>';
203+
$field = '<div style="margin: 0em 0em 1em 0em;">'.$field.'</div>';
204+
205+
if (Setting::grab('list_text_max_length') != 0 and strlen($ticket->content) > (Setting::grab('list_text_max_length')+30)){
206+
$field.= '<div class="jquery_ticket_' . $ticket->id . '_text"><span class="text_minus">' . mb_substr($ticket->content, 0, Setting::grab('list_text_max_length')) . '...</span>'
207+
.'<span class="text_plus" style="display: none">' . $ticket->content . '</span>'
208+
.' <button class="btn btn-light btn-xs jquery_ticket_text_toggle" data-action="plus" data-height-plus="" data-height-minus="" data-id="' . $ticket->id . '" data-plus-icon="fa fa-minus" data-minus-icon="fa fa-plus"><span class="fa fa-plus"></span></button></div>';
209+
210+
}else{
211+
$field.= $ticket->content;
212+
}
205213

214+
if ($ticket->all_attachments_count>0){
215+
$field.= "<br />" . $ticket->all_attachments_count . ' <span class="fa fa-paperclip tooltip-info attachment" title="'.trans('panichd::lang.table-info-attachments-total', ['num' => $ticket->all_attachments_count]).'"></span>';
216+
}
206217
return $field;
207218
}
208219
});
209220

210221
if (Setting::grab('subject_content_column') == 'no'){
211222
$collection->editColumn('content', function ($ticket) {
212-
$field = $ticket->content;
223+
if (Setting::grab('list_text_max_length') != 0 and strlen($ticket->content) > (Setting::grab('list_text_max_length')+30)){
224+
$field = '<div class="jquery_ticket_' . $ticket->id . '_text"><span class="text_minus">' . mb_substr($ticket->content, 0, Setting::grab('list_text_max_length')) . '...</span>'
225+
.'<span class="text_plus" style="display: none">' . $ticket->content . '</span>'
226+
.' <button class="btn btn-light btn-xs jquery_ticket_text_toggle" data-action="plus" data-height-plus="" data-height-minus="" data-id="' . $ticket->id . '" data-plus-icon="fa fa-minus" data-minus-icon="fa fa-plus"><span class="fa fa-plus"></span></button></div>';
227+
228+
}else{
229+
$field = $ticket->content;
230+
}
213231
if ($ticket->all_attachments_count>0) $field.= "<br />" . $ticket->all_attachments_count . ' <span class="fa fa-paperclip tooltip-info attachment" title="'.trans('panichd::lang.table-info-attachments-total', ['num' => $ticket->all_attachments_count]).'"></span>';
214232

215233
return $field;

src/Seeds/SettingsTableSeeder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ public function getDefaults()
197197
* Default: false
198198
*/
199199
'default_reopen_status_id' => false,
200+
200201
/*
201202
* [Deprecated] User ids who are members of admin role
202203
* Default: 1
@@ -256,7 +257,11 @@ public function getDefaults()
256257
'<br>' => ' '
257258
],
258259

259-
260+
/*
261+
* If set to a number, limit texts in ticket list to specified character length and show plus / minus icons
262+
*/
263+
'list_text_max_length' => '300',
264+
260265

261266
/*
262267
* Pagination length: For tickets table.

src/Views/tickets/datatable/events.blade.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@
22
$(function(){
33
// Ticket List: Change ticket agent
44
$('#tickets-table').on('draw.dt', function(e){
5-
5+
6+
// Plus / less buttons for text fields
7+
$('.jquery_ticket_text_toggle').click(function(e){
8+
9+
if($(this).find('span.fa').hasClass("fa-plus")){
10+
$(this).prop('data-height-minus', $('.jquery_ticket_' + $(this).data('id') + '_text').height());
11+
$(this).find('span.fa').removeClass('fa-plus').addClass('fa-minus');
12+
$('.jquery_ticket_' + $(this).data('id') + '_text').find('.text_minus').hide();
13+
$('.jquery_ticket_' + $(this).data('id') + '_text').find('.text_plus').css('display', 'inline');
14+
15+
$(this).prop('data-height-plus', $('.jquery_ticket_' + $(this).data('id') + '_text').height());
16+
$('.jquery_ticket_' + $(this).data('id') + '_text').css('height', $(this).prop('data-height-minus')).animate({height: $(this).prop('data-height-plus')}, 500);
17+
}else{
18+
$(this).find('span.fa').removeClass('fa-minus').addClass('fa-plus');
19+
$('.jquery_ticket_' + $(this).data('id') + '_text').find('.text_minus').show();
20+
$('.jquery_ticket_' + $(this).data('id') + '_text').find('.text_plus').hide();
21+
$('.jquery_ticket_' + $(this).data('id') + '_text').css('height', '');
22+
}
23+
});
24+
625
// Agent change: Modal for > 4 agents
726
$('.jquery_agent_change_modal').click(function(e){
827
e.preventDefault();

0 commit comments

Comments
 (0)