Team 4 (Mother Forum)
Specific Folder FTP Upload / ftp-deploy (push) Successful in 36s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 36s
Details
This commit is contained in:
parent
5302263349
commit
dee26ee664
|
|
@ -77,7 +77,7 @@
|
|||
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<select class="form-control" id="field-{{ $question->code }}" name="{{ $question->code }}" data-initial-value="{{ isset($question->value) ? $question->value : '' }}" {{ $question->required == 'yes' ? 'required' : '' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach ($question->options as $option)
|
||||
@if($question->code == 'contact_id' && isset($option->contact->type) && $option->contact->type == 'doctor' )
|
||||
|
|
@ -220,7 +220,6 @@
|
|||
function applySelect2ToDoctorDropdowns() {
|
||||
$("[id^='field-contact_id']").each(function () {
|
||||
var select = $(this);
|
||||
// Avoid re-initializing select2
|
||||
if (select.data("select2")) return;
|
||||
select.select2({
|
||||
width: "100%",
|
||||
|
|
@ -246,7 +245,6 @@
|
|||
|
||||
currentSelect.find("option").prop("disabled", false);
|
||||
|
||||
// Disable values selected in OTHER selects (keep current selection enabled)
|
||||
selectedValues.forEach(function (v) {
|
||||
if (v && v !== currentVal) {
|
||||
currentSelect
|
||||
|
|
@ -255,84 +253,80 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Refresh select2 UI if present
|
||||
if (currentSelect.data("select2")) {
|
||||
currentSelect.trigger("change.select2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$("[id^='field-contact_id']").each(function() {
|
||||
var select = $(this);
|
||||
// Clear previous options
|
||||
var existingVal = select.val();
|
||||
select.html('');
|
||||
// Add a default 'Select' option
|
||||
select.append(
|
||||
$("<option></option>")
|
||||
.attr("value", '')
|
||||
.text('-- Select --')
|
||||
);
|
||||
// Append options from contacts
|
||||
contacts.forEach(function(itm) {
|
||||
var option = $("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display);
|
||||
// If doctor options have extra attributes
|
||||
if (itm.contact && itm.contact.msl_code) {
|
||||
option.attr("msl_code", itm.contact.msl_code);
|
||||
}
|
||||
if (itm.contact && itm.contact.speciality) {
|
||||
option.attr("speciality", itm.contact.speciality);
|
||||
}
|
||||
select.append(option);
|
||||
});
|
||||
var select = $(this);
|
||||
|
||||
// For each select element, add a change event handler to populate `msl_code` and `speciality`
|
||||
// We assume dropdowns and targets follow the pattern:
|
||||
// - select: field-contact_id_1, field-contact_id_2, ..., field-contact_id
|
||||
// - result: field-msl_code_1, field-speciality_1, etc.
|
||||
|
||||
var existingVal = select.attr('data-initial-value') || select.val();
|
||||
|
||||
// Remove any old event handlers first to prevent duplicate bindings
|
||||
|
||||
select.empty();
|
||||
|
||||
if (existingVal) {
|
||||
select.val(existingVal);
|
||||
}
|
||||
// Default option
|
||||
select.append($("<option></option>").attr("value", '').text('-- Select --'));
|
||||
|
||||
select.off('change').on('change', function () {
|
||||
var selected = $(this).find(':selected');
|
||||
|
||||
var selectId = $(this).attr('id'); // e.g., field-contact_id_1
|
||||
// Extract the suffix (e.g., _1 or empty)
|
||||
var match = selectId.match(/^field-contact_id(_\d+)?$/);
|
||||
var suffix = match && match[1] ? match[1] : '';
|
||||
|
||||
contacts.forEach(function(itm) {
|
||||
var option = $("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display);
|
||||
|
||||
// Build the target msl_code and speciality field ids
|
||||
var mslCodeField = $('#field-msl_code' + suffix);
|
||||
var specialityField = $('#field-speciality' + suffix);
|
||||
if (itm.contact && itm.contact.msl_code) {
|
||||
option.attr("msl_code", itm.contact.msl_code);
|
||||
}
|
||||
if (itm.contact && itm.contact.speciality) {
|
||||
option.attr("speciality", itm.contact.speciality);
|
||||
}
|
||||
select.append(option);
|
||||
});
|
||||
|
||||
if (mslCodeField.length) {
|
||||
mslCodeField.val(selected.attr('msl_code') || '');
|
||||
}
|
||||
if (specialityField.length) {
|
||||
specialityField.val(selected.attr('speciality') || '');
|
||||
}
|
||||
|
||||
if (existingVal) {
|
||||
select.val(String(existingVal));
|
||||
}
|
||||
|
||||
// Prevent selecting the same doctor across multiple dropdowns
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
|
||||
select.off('change').on('change', function () {
|
||||
var selected = $(this).find(':selected');
|
||||
var selectId = $(this).attr('id');
|
||||
var match = selectId.match(/^field-contact_id(_\d+)?$/);
|
||||
var suffix = match && match[1] ? match[1] : '';
|
||||
|
||||
if (existingVal) {
|
||||
select.trigger('change');
|
||||
}
|
||||
var mslCodeField = $('#field-msl_code' + suffix);
|
||||
var specialityField = $('#field-speciality' + suffix);
|
||||
|
||||
// Ensure unique selection is enforced after initial render
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
if (mslCodeField.length) {
|
||||
mslCodeField.val(selected.attr('msl_code') || '');
|
||||
}
|
||||
if (specialityField.length) {
|
||||
specialityField.val(selected.attr('speciality') || '');
|
||||
}
|
||||
|
||||
// Enable search on doctor dropdowns
|
||||
applySelect2ToDoctorDropdowns();
|
||||
$("#pageloader").fadeOut();
|
||||
enforceUniqueDoctorSelections();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
applySelect2ToDoctorDropdowns();
|
||||
|
||||
|
||||
$("[id^='field-contact_id']").each(function() {
|
||||
var select = $(this);
|
||||
var existingVal = select.attr('data-initial-value');
|
||||
if (existingVal) {
|
||||
select.val(String(existingVal)).trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$("#pageloader").fadeOut();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue