Peter Muturi 3 éve
szülő
commit
eed6aadfbd

+ 17 - 11
resources/views/app/patient/create-patient/create-patient-script-templates.blade.php

@@ -24,25 +24,31 @@
 		function init() {
 			(function($) {
 				var createPatientTemplateScript = {
+					defaultTemplate: "dialmd-covid-kit",
 					initScriptTemplateChange: function(){
-						var templateContainer = $('#scriptTemplateContent');
+						var self = this;
 						$('select[name=script_type]').change(function(evt){
 							var input = evt.target;
 							var value = input.value;
-							templateContainer.html('<i class="fas fa-circle-notch fa-spin text-primary"></i> Loading template...');
-							$.get('{{ route("admin.getCreateNewPatientScriptTemplate") }}', {template:value}, function(response){
-								if(response.success){
-									var templateHtml = response.data;
-									templateContainer.html(templateHtml);
-								}else{
-									toastr.error(response.message);
-									templateContainer.html('');
-								}
-							}, 'json');
+							self.onTemplateChange(value);
 						});
 					},
+					onTemplateChange: function(value) {
+						var templateContainer = $('#scriptTemplateContent');
+						templateContainer.html('<i class="fas fa-circle-notch fa-spin text-primary"></i> Loading template...');
+						$.get('{{ route("admin.getCreateNewPatientScriptTemplate") }}', {template:value}, function(response){
+							if(response.success){
+								var templateHtml = response.data;
+								templateContainer.html(templateHtml);
+							}else{
+								toastr.error(response.message);
+								templateContainer.html('');
+							}
+						}, 'json');
+					},
 					init: function() {
 						this.initScriptTemplateChange();
+						this.onTemplateChange(this.defaultTemplate);
 					}
 				};
 				createPatientTemplateScript.init();