Team2 (Lung Care Programme) Remove Index
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m31s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m31s
Details
This commit is contained in:
parent
c3308b2885
commit
ba46a82103
|
|
@ -327,6 +327,8 @@
|
|||
const tmHierarchies = @json(isset($form->users) ? collect($form->users)->pluck('hierarchy_id')->filter()->unique()->values() : []);
|
||||
|
||||
let doctor_count = 0;
|
||||
let allDoctorsList = [];
|
||||
|
||||
|
||||
function initializeSelect2(element) {
|
||||
const $element = $(element);
|
||||
|
|
@ -559,6 +561,8 @@
|
|||
return String(a.display || '').localeCompare(String(b.display || ''), 'en', { sensitivity: 'base' });
|
||||
});
|
||||
|
||||
allDoctorsList = allDoctors;
|
||||
|
||||
const $doctorSelect = $('#field-contact_id');
|
||||
|
||||
const preselectedDoctorId = String($doctorSelect.attr('data-preselected') || '');
|
||||
|
|
@ -606,7 +610,7 @@
|
|||
loadAllTmDoctors();
|
||||
|
||||
// Add another doctor wrapper. The first wrapper is already present in the form.
|
||||
$('#adddoctor-btn').on('click', function () {
|
||||
/* $('#adddoctor-btn').on('click', function () {
|
||||
if ($('.doctor-wrapper').length >= 5) return;
|
||||
|
||||
const doctorOptions = $('#field-contact_id').html();
|
||||
|
|
@ -679,11 +683,103 @@
|
|||
initializeExecutionSelects();
|
||||
preventDuplicateDoctors();
|
||||
|
||||
if ($('.doctor-wrapper').length >= 5) {
|
||||
$('#adddoctor-btn').hide();
|
||||
}
|
||||
}); */
|
||||
|
||||
$('#adddoctor-btn').on('click', function () {
|
||||
if ($('.doctor-wrapper').length >= 5) return;
|
||||
|
||||
doctor_count++;
|
||||
|
||||
|
||||
let doctorOptionsHtml = '<option value=""> -- Select Doctor -- </option>';
|
||||
allDoctorsList.forEach(function (doctor) {
|
||||
const contact = doctor.contact || {};
|
||||
const msl = contact.msl_code || contact.legacy_code || '';
|
||||
const spec = contact.speciality || '';
|
||||
doctorOptionsHtml += `<option value="${doctor.value}" msl_code="${msl}" speciality="${spec}">${doctor.display || ''}</option>`;
|
||||
});
|
||||
|
||||
const empty_doctor = `
|
||||
<div class="doctor-wrapper">
|
||||
<button type="button" class="btn btn-danger btn-remove float-end" style="margin-top:-25px; margin-right:-25px">
|
||||
<i class="mdi mdi-close"></i>
|
||||
</button>
|
||||
@foreach($questions as $question)
|
||||
@if(in_array($question->code, ["record_date", "select_rxber_type"]))
|
||||
@continue;
|
||||
@endif
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-{{$question->code}}-${doctor_count}" class="form-label">
|
||||
{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!}
|
||||
</label>
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="hidden" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('file')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':''}} value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('number')
|
||||
<input type="number" min="0" max="9999999999" step="1" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" class="form-control" {{$question->required == 'yes'?'required':''}} value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{$question->code}}-${doctor_count}" name="{{$question->code}}[${doctor_count}]" {{$question->required == 'yes'?'required':''}}>
|
||||
@if($question->code == 'contact_id')
|
||||
${doctorOptionsHtml}
|
||||
@else
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}">{{$option->display}}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-${doctor_count}-{{$option->value}}" name="{{$question->code}}[${doctor_count}]" value="{{$option->value}}">
|
||||
<label class="form-check-label" for="field-{{$question->code}}-${doctor_count}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
</div>`;
|
||||
|
||||
$('#doctor-group-wrapper').append(empty_doctor);
|
||||
|
||||
const $newDoctorSelect = $('#field-contact_id-' + doctor_count);
|
||||
initializeSelect2($newDoctorSelect);
|
||||
$('#field-msl_code-' + doctor_count + ', #field-speciality-' + doctor_count).attr('readonly', true);
|
||||
initializeExecutionSelects();
|
||||
preventDuplicateDoctors();
|
||||
|
||||
if ($('.doctor-wrapper').length >= 5) {
|
||||
$('#adddoctor-btn').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
function reindexDoctorWrappers() {
|
||||
$('.doctor-wrapper').each(function (index) {
|
||||
$(this).find('[name]').each(function () {
|
||||
const currentName = $(this).attr('name');
|
||||
|
||||
const updatedName = currentName.replace(/\[\d+\]/, '[' + index + ']');
|
||||
$(this).attr('name', updatedName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Remove a dynamically added doctor wrapper without reusing its element IDs.
|
||||
$(document).on('click', '.btn-remove', function () {
|
||||
doctor_count--;
|
||||
|
|
@ -692,6 +788,7 @@
|
|||
if ($(this).hasClass('select2-hidden-accessible')) $(this).select2('destroy');
|
||||
});
|
||||
$wrapper.remove();
|
||||
reindexDoctorWrappers();
|
||||
preventDuplicateDoctors();
|
||||
if ($('.doctor-wrapper').length < 5) $('#adddoctor-btn').show();
|
||||
});
|
||||
|
|
@ -730,7 +827,7 @@
|
|||
alert('You must select exactly 5 doctors. Currently selected: ' + selectedDoctorCount);
|
||||
return;
|
||||
}
|
||||
|
||||
reindexDoctorWrappers();
|
||||
$('#pageloader').fadeIn();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
|
|
|||
Loading…
Reference in New Issue