Feat: Enhance publications form and edit view with Select2 for authors and organizing institutes
This commit is contained in:
@@ -21,11 +21,13 @@
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="first_author_name" class="block text-sm font-medium text-gray-700">First Author Name</label>
|
||||
<input type="text" name="first_author_name" id="first_author_name" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||
<select id="first_author_name" name="first_author_name[]" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" multiple="multiple"></select>
|
||||
<input type="hidden" id="first_author_name_hidden" name="first_author_name" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="co_authors" class="block text-sm font-medium text-gray-700">Co-Authors (if any)</label>
|
||||
<input type="text" name="co_authors" id="co_authors" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" placeholder="Separate names with commas">
|
||||
<select id="co_authors" name="co_authors[]" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" multiple="multiple"></select>
|
||||
<input type="hidden" id="co_authors_hidden" name="co_authors" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,9 +44,14 @@
|
||||
<input type="text" name="affiliation" id="affiliation" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="organizing_institute" class="block text-sm font-medium text-gray-700">Organizing Institute</label>
|
||||
<input type="text" name="organizing_institute" id="organizing_institute" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||
</div>
|
||||
<label for="organizing_institute" class="block text-sm font-medium text-gray-700">Organising Institute/Company</label>
|
||||
<select name="organizing_institute" id="organizing_institute" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm select2" style="width: 100%;" required>
|
||||
<option value="">Select or type...</option>
|
||||
@foreach($organisingInstitutes as $institute)
|
||||
<option value="{{ $institute }}" {{ old('organizing_institute') == $institute ? 'selected' : '' }}>{{ $institute }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -162,5 +169,64 @@
|
||||
document.getElementById('num_days').value = numDays;
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize Select2 for first_author_name
|
||||
$('#first_author_name').select2({
|
||||
tags: true,
|
||||
tokenSeparators: [','],
|
||||
ajax: {
|
||||
url: '{{ route('api.users.index') }}', // Adjust this route to fetch user names
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
processResults: function(data) {
|
||||
return {
|
||||
results: data.map(user => ({
|
||||
id: user.name,
|
||||
text: user.name
|
||||
}))
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
|
||||
$('#first_author_name').on('change', function() {
|
||||
const selectedValues = $(this).val();
|
||||
document.getElementById('first_author_name_hidden').value = selectedValues.join(', ');
|
||||
});
|
||||
|
||||
// Initialize Select2 for co_authors
|
||||
$('#co_authors').select2({
|
||||
tags: true,
|
||||
tokenSeparators: [','],
|
||||
ajax: {
|
||||
url: '{{ route('api.users.index') }}', // Adjust this route to fetch user names
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
processResults: function(data) {
|
||||
return {
|
||||
results: data.map(user => ({
|
||||
id: user.name,
|
||||
text: user.name
|
||||
}))
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
|
||||
$('#co_authors').on('change', function() {
|
||||
const selectedValues = $(this).val();
|
||||
document.getElementById('co_authors_hidden').value = selectedValues.join(', ');
|
||||
});
|
||||
|
||||
$('#organizing_institute').select2({
|
||||
tags: true,
|
||||
placeholder: "Select or type...",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user