Skip to content

Commit ea7d923

Browse files
committed
Newest tickets list automatic reload countdown with a specific setting
1 parent 4f5fc8b commit ea7d923

File tree

8 files changed

+93
-4
lines changed

8 files changed

+93
-4
lines changed

src/Controllers/ConfigurationsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function index()
3030
'email.color_button_bg', 'email.account.name', 'email.account.mailbox' ];
3131
$tickets_section = ['default_priority_id', 'default_status_id', 'default_close_status_id', 'default_reopen_status_id',
3232
'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', 'use_default_status_id'];
33+
'attachments_path', 'thumbnails_path', 'oldest_year', 'user_route', 'html_replacements', 'list_text_max_length', 'use_default_status_id', 'newest_list_reload_seconds'];
3434
$perms_section = ['agent_restrict', 'close_ticket_perm', 'reopen_ticket_perm'];
3535
$editor_section = ['editor_enabled', 'editor_html_highlighter', 'codemirror_theme',
3636
'summernote_locale', 'summernote_options_json_file', 'summernote_options_user', 'purifier_config', ];

src/Seeds/SettingsTableSeeder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ public function getDefaults()
266266
*/
267267
'list_text_max_length' => '300',
268268

269+
/*
270+
* Interval in which the Newest tickets list will be reloaded automatically. Set to 0 to disable
271+
*
272+
*/
273+
'newest_list_reload_seconds' => '60',
274+
269275

270276
/*
271277
* Pagination length: For tickets table.

src/Translations/ca/lang.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@
206206
'index-complete-check' => 'Assegureu-vos de revisar els tiquets tancats si no pot trobar el seu tiquet.',
207207
'ticket-notices-title' => 'Avisos',
208208
'ticket-notices-empty' => 'No hi ha cap avís actiu',
209+
/*
210+
// Newest tickets page reload Modal
211+
'page-reload-modal-title' => 'Recàrrega de pàgina',
212+
'page-reload-modal-countdown' => 'Aquesta pàgina es recarregarà en <kbd><span id="counter">:num</span></kbd> segons.',
213+
'page-reload-modal-reloading' => 'Aquesta pàgina està recarregant... si us plau, espera',
214+
'page-reload-modal-button-now' => 'Recarrega ara!',*/
209215

210216
// Ticket forms messages
211217
'update-agent-same' => 'No has canviat l\'agent! Tiquet <a href=":link" title=":title"><u>:name</u></a>',

src/Translations/en/lang.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@
209209
'ticket-notices-title' => 'Notices',
210210
'ticket-notices-empty' => 'There are no active notices',
211211

212+
// Newest tickets page reload Modal
213+
'page-reload-modal-title' => 'Page reload',
214+
'page-reload-modal-countdown' => 'This page will reload in <kbd><span id="counter">:num</span></kbd> seconds.',
215+
'page-reload-modal-reloading' => 'This page is reloading... please wait',
216+
'page-reload-modal-button-now' => 'Reload now!',
217+
212218
// Ticket forms messages
213219
'update-agent-same' => 'Agent was not changed! Ticket <a href=":link" title=":title"><u>:name</u></a>',
214220
'update-agent-ok' => 'Agent was correctly updated. Ticket <a href=":link" title=":title"><u>:name</u></a>: :old_agent -> :new_agent',
@@ -253,7 +259,7 @@
253259
'show-ticket-modal-delete-message' => 'Are you sure you want to delete ticket: :subject?',
254260
'show-ticket-modal-edit-fields' => 'Edit more fields',
255261

256-
'show-ticket-modal-complete-blank-intervention-check' => 'Leave blank intervention',
262+
'show-ticket-modal-complete-blank-intervention-check' => 'Leave blank intervention',
257263
'show-ticket-complete-blank-intervention-alert' => 'To complete the ticket you must confirm that you leave intervention field blank',
258264
'show-ticket-modal-complete-blank-reason-alert' => 'To complete the ticket you must indicate a closing reason',
259265
'show-ticket-complete-bad-status' => 'Ticket not completed: The specified status is not valid',

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,55 @@
11
<script>
22
$(function(){
3-
// Ticket List: Change ticket agent
3+
4+
5+
// Ticket List: Change ticket agent
46
$('#tickets-table').on('draw.dt', function(e){
7+
@if ($ticketList == 'newest' && $setting->grab('newest_list_reload_seconds'))
8+
9+
var modal_countdown = ({{ $setting->grab('newest_list_reload_seconds') }} - 5)*1000;
10+
11+
setTimeout(function(){ $('#modal-page-reload').modal('show'); }, modal_countdown);
12+
var reload_secs = 6;
13+
var page_reload = "";
14+
15+
$('#modal-page-reload').on('show.bs.modal', function () {
16+
17+
$('#modal-page-reload #text_countdown').show();
18+
$('#modal-page-reload #text_reloading').hide();
19+
20+
$('#modal-page-reload #counter').text(reload_secs-1);
21+
22+
// Update the count down every 1 second
23+
page_reload = setInterval(function() {
24+
reload_secs = reload_secs - 1;
25+
26+
// Output the result in an element with id="demo"
27+
$('#modal-page-reload #counter').text(reload_secs);
28+
29+
// If the count down is over, write some text
30+
if (reload_secs == 0) {
31+
$('#modal-page-reload #text_countdown').hide();
32+
$('#modal-page-reload #text_reloading').show();
33+
clearInterval(page_reload);
34+
window.location.reload(false);
35+
}
36+
}, 1000);
37+
});
38+
39+
$('#modal-page-reload').on('hidden.bs.modal', function () {
40+
clearInterval(page_reload);
41+
42+
setTimeout(function(){ $('#modal-page-reload').modal('show'); }, modal_countdown);
43+
page_reload = "";
44+
reload_secs = 6;
45+
});
46+
47+
$('#modal-page-reload #confirm').click(function(e){
48+
$('#modal-page-reload #text_countdown').hide();
49+
$('#modal-page-reload #text_reloading').show();
50+
window.location.reload(false);
51+
});
52+
@endif
553
654
// Plus / less buttons for text fields
755
$('.jquery_ticket_text_toggle').click(function(e){
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Modal Dialog -->
2+
<div class="modal fade" id="modal-page-reload" role="dialog" tabindex="-1">
3+
<div class="modal-dialog">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<h4 class="modal-title">{{ trans('panichd::lang.page-reload-modal-title') }}</h4>
7+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">{{ trans('panichd::lang.flash-x') }}</button>
8+
</div>
9+
<div class="modal-body">
10+
<p id="text_countdown">{!! trans('panichd::lang.page-reload-modal-countdown', ['num' => '5']) !!}</p>
11+
<p id="text_reloading" style="display: none">{!! trans('panichd::lang.page-reload-modal-reloading') !!}</p>
12+
</div>
13+
<div class="modal-footer">
14+
<button type="button" class="btn btn-light mr-auto" data-dismiss="modal">{{ trans('panichd::lang.btn-cancel') }}</button>
15+
<button type="button" class="btn btn-light" id="confirm">{{ trans('panichd::lang.page-reload-modal-button-now') }}</button>
16+
</div>
17+
</div>
18+
</div>
19+
</div>

src/Views/tickets/index.blade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
</div>
2828
@include('panichd::tickets.partials.modal_agent')
2929
@include('panichd::tickets.partials.priority_popover_form')
30+
31+
@if($ticketList == 'newest')
32+
@include('panichd::tickets.datatable.modal_page_reload')
33+
@endif
3034
@stop
3135

3236
@section('footer')

src/Views/tickets/show.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{!! $comments->render() !!}
2727
@include('panichd::tickets.show.modal_comment_new')
2828
@if ($setting->grab('ticket_attachments_feature'))
29-
@include('panichd::shared.attach_files_script')
29+
@include('panichd::shared.attach_files_script')
3030
@endif
3131
@endsection
3232

0 commit comments

Comments
 (0)