Peter Muturi 2 anni fa
parent
commit
d7a6f1a249

+ 180 - 27
resources/views/app/patient/modules/sleep_study_intake/edit.blade.php

@@ -90,6 +90,9 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
 	</div>
 </div>
 <script>
+
+
+
 	(function() {
 		function init() {
 
@@ -102,16 +105,166 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
 				data: {
 					form: $('#edit-sleep_study_intake-container').closest('form'),
 					data: <?= json_encode($contentData) ?>,
-					defaultDropdownOptions: {}
+					defaultDropdownOptions: {
+						Dozing: [{
+								label: 'Never Chance of Doze',
+								value: 'Never Chance of Doze'
+							},
+							{
+								label: 'Slight Chance of Dozing',
+								value: 'Slight Chance of Dozing'
+							},
+							{
+								label: 'Moderate Chance of Dozing',
+								value: 'Moderate Chance of Dozing'
+							},
+							{
+								label: 'High Chance of Dozing',
+								value: 'High Chance of Dozing'
+							},
+						],
+						Sitting: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						Watching: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						Sitting_Inactive: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						Passenger_Car: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						Sitting_Quietly: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						LyingDown: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						SittingandTalking: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						],
+						Traffic: [{
+								label: 0,
+								value: 0
+							},
+							{
+								label: 1,
+								value: 1
+							},
+							{
+								label: 2,
+								value: 2
+							},
+							{
+								label: 3,
+								value: 3
+							},
+						]
+					}
 				},
 				watch: {
 					$data: {
 						handler: function(val, oldVal) {
-							let parent = $('#edit-sleep_study_intake-container').closest('form');
-							parent.find('[name="data"]').val(JSON.stringify(this.data));
-
-							// autosave on change
-							autoSaveSegment(parent.find('[submit]').first());
+							this.autoSaveForm();
 						},
 						deep: true
 					}
@@ -150,6 +303,26 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
 						});
 						return false;
 					},
+					onInputChange: function(evt){
+	          var self = this;
+	          var input = evt.target;
+	          var name = input.name || $(input).data('name');
+	          value = input.value;
+	          if($(input).is(':radio')){
+	            if(!input.checked){
+	              value = null;
+	            }
+	          }
+	          self.data[name] = value;
+	          self.autoSaveForm();
+	        },
+					initSelect2: function(){
+	          $('[select2]').select2({
+	            tags: true,
+	            allowClear: true,
+	            placeholder: 'Press "Enter" to create a new selection',
+	          });
+	        },
 					calculateScore: function() {
                         var self = this;
                         var fields = self.form.find('[score-input]');
@@ -170,33 +343,13 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
                             self.calculateScore();
                         });
                     },
-					onInputChange: function(evt){
-						var self = this;
-						var input = evt.target;
-						var name = input.name || $(input).data('name');
-						value = input.value;
-						if($(input).is(':radio')){
-							if(!input.checked){
-								value = null;
-							}
-						}
-						self.data[name] = value;
-						self.autoSaveForm();
-					},
-          initSelect2: function(){
-            $('[select2]').select2({
-              tags: true,
-              allowClear: true,
-              placeholder: 'Press "Enter" to create a new selection',
-            });
-          },
 				},
 				mounted: function() {
 					if (!this.data.dropdownOptions) {
 						this.data.dropdownOptions = this.defaultDropdownOptions;
 						this.$forceUpdate();
 					}
-          this.initSelect2();
+					this.initSelect2();
 					this.initOnSelectChange();
 					console.log('1: DATA: ', this.data);
 				}