Skip to content

Commit 3b09851

Browse files
committed
Ticket create / edit: Radio for ticket list. Make it affect status_id if last was the default for list
1 parent ad9debf commit 3b09851

1 file changed

Lines changed: 61 additions & 16 deletions

File tree

src/Views/tickets/createedit.blade.php

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,56 @@
7272
@if ($u->currentLevel() > 1)
7373
<div class="jquery_level2_show">
7474
<div class="form-group row">
75-
<label class="col-lg-3 col-form-label tooltip-info" title="{{ trans('panichd::lang.create-ticket-visible-help') }}">{{ trans('panichd::lang.create-ticket-visible') . trans('panichd::lang.colon') }} <span class="fa fa-question-circle" style="color: #bbb"></span></label>
75+
<label class="col-lg-3 tooltip-info" title="{{ trans('panichd::lang.create-ticket-visible-help') }}">{{ trans('panichd::lang.create-ticket-visible') . trans('panichd::lang.colon') }} <span class="fa fa-question-circle" style="color: #bbb"></span></label>
7676

77-
<div class="col-lg-9" style="padding-top: 7px;">
77+
<div class="col-lg-9" style="xpadding-top: 7px;">
7878
<label><input type="radio" name="hidden" value="false" {{ (!isset($ticket) || (isset($ticket) && !$ticket->hidden)) ? 'checked' : '' }}> {{ trans('panichd::lang.yes') }}</label><label style="margin: 0em 0em 0em 1em;"><input type="radio" name="hidden" value="true" {{ (isset($ticket) && $ticket->hidden) ? 'checked' : ''}}> {{ trans('panichd::lang.no') }}</label>
7979
</div>
8080

8181
</div>
8282

8383
<div class="form-group row" style="margin-bottom: 3em"><!-- TICKET LIST -->
84-
{!! CollectiveForm::label('status_id', trans('panichd::lang.list') . trans('panichd::lang.colon'), [
85-
'class' => 'col-lg-3 col-form-label'
84+
{!! CollectiveForm::label('complete', trans('panichd::lang.list') . trans('panichd::lang.colon'), [
85+
'class' => 'col-lg-3',
86+
'title' => trans('panichd::lang.create-ticket-change-list'),
87+
'id' => 'last_list',
88+
'data-last_list_default_status_id' => $a_current['status_id']
8689
]) !!}
8790
<div class="col-lg-9">
88-
<button type="button" id="complete_no" class="btn btn-light btn-default text-warning" data-value="no" data-click-status="{{$setting->grab('default_close_status_id')}}" title="{{ trans('panichd::lang.create-ticket-change-list') }}" {!! $a_current['complete'] == "yes" ? 'style="display:none"' : ''!!}><span class="fa fa-file"></span> {{ trans('panichd::lang.active-tickets-adjective') }}</button>
89-
<button type="button" id="complete_yes" class="btn btn-light btn-default text-success" data-value="yes" data-click-status="{{$setting->grab('default_reopen_status_id')}}" title="{{ trans('panichd::lang.create-ticket-change-list') }}" {!! $a_current['complete'] == "yes" ? '' : 'style="display:none"'!!}><span class="fa fa-check-circle"></span> {{ trans('panichd::lang.complete-tickets-adjective') }}</button>
91+
<?php
92+
$a_lists = [
93+
'newest' => [
94+
'complete' => 'no',
95+
'default_status_id' => $setting->grab('default_status_id')
96+
],
97+
'active' => [
98+
'complete' => 'no',
99+
'default_status_id' => $setting->grab('default_reopen_status_id')
100+
],
101+
'complete' => [
102+
'complete' => 'yes',
103+
'default_status_id' => $setting->grab('default_close_status_id')
104+
]
105+
];
106+
107+
if ($a_current['complete'] == "yes"){
108+
$checked_list = 'complete';
109+
}elseif($a_current['status_id'] == $setting->grab('default_status_id')){
110+
$checked_list = 'newest';
111+
}else{
112+
$checked_list = 'active';
113+
}
114+
?>
115+
116+
@foreach ($a_lists as $list => $a_list)
117+
<div class="form-check form-check-inline">
118+
<label class="form-check-label">
119+
<input type="radio" class="jquery_ticket_list form-check-input" name="complete" value="{{ $a_list['complete'] }}" @if($list == $checked_list) {!! 'checked="checked"' !!}@endif data-list="{{ $list }}" data-default_status_id="{{ $a_list['default_status_id'] }}">{{ trans('panichd::lang.' . $list . '-tickets-adjective') }}
120+
</label>
121+
</div>
122+
@endforeach
123+
90124
</div>
91-
{!! CollectiveForm::hidden('complete', isset($ticket) ? ($ticket->completed_at == '' ? 'no' : 'yes') : 'no',['id' => 'value_complete']) !!}
92125
</div>
93126

94127
<div class="form-group row"><!-- STATUS -->
@@ -269,7 +302,27 @@
269302
var category_id=<?=$a_current['cat_id'];?>;
270303
271304
$(function(){
272-
// Category select with $u->maxLevel() > 1 only
305+
// Change in List affects current status
306+
$('.jquery_ticket_list').click(function(){
307+
var new_status = "";
308+
309+
if ($(this).data('default_status_id') != ""){
310+
if ($(this).data('list') == 'newest'){
311+
new_status = $(this).data('default_status_id');
312+
}else if($('#last_list').data('last_list_default_status_id') == $('#select_status').val()){
313+
new_status = $(this).data('default_status_id');
314+
}
315+
316+
if (new_status != ""){
317+
$('#select_status').val(new_status).effect('highlight');
318+
}
319+
320+
$('#last_list').data('last_list_default_status_id', $(this).data('default_status_id'));
321+
}
322+
});
323+
324+
325+
// Category select with $u->maxLevel() > 1 only
273326
$('#category_change').change(function(){
274327
// Update agent list
275328
$('#agent_id').prop('disabled',true);
@@ -308,14 +361,6 @@
308361
$('#jquery_tag_category_'+$(this).val()).next().show();
309362
});
310363
311-
$('#complete_no, #complete_yes').click(function(){
312-
$(this).hide();
313-
var other = $(this).attr('data-value') == 'yes' ? 'no' : 'yes';
314-
$('#value_complete').val(other);
315-
$('#complete_'+other).show();
316-
$('#select_status').val($(this).attr('data-click-status'));
317-
});
318-
319364
$('#start_date input[name="start_date"]').val('');
320365
$('#start_date').datetimepicker({
321366
locale: '{{App::getLocale()}}',

0 commit comments

Comments
 (0)