|
@@ -44,6 +44,8 @@
|
|
|
|
|
|
form: <?= json_encode(json_decode($survey->survey_data ?? '{}')) ?>,
|
|
|
socketIo: null,
|
|
|
+ submitting: false,
|
|
|
+ loading: false,
|
|
|
},
|
|
|
methods: {
|
|
|
onFormFieldChange: function(){
|
|
@@ -60,17 +62,14 @@
|
|
|
return;
|
|
|
});
|
|
|
|
|
|
- form.find('input[type=text], textarea').off('keyup');
|
|
|
- form.find('input[type=text], textarea').on('keyup', function(){
|
|
|
- self.autosaveChanges();
|
|
|
- return;
|
|
|
- });
|
|
|
-
|
|
|
},
|
|
|
autosaveChanges: function(){
|
|
|
var self = this;
|
|
|
+ if(self.submitting) return;
|
|
|
+ self.submitting = true;
|
|
|
var url = "{{ @$survey->access_key ? route('view-survey-form-auto-submit', @$survey->access_key) : '' }}";
|
|
|
$.post(url, { dataJson: JSON.stringify(self.form) }, function(response){
|
|
|
+ self.submitting = false;
|
|
|
if(response.success){
|
|
|
self.socketIo.emit('SURVEY_DATA_CHANGED_BY_SESSION', {socketSessionID: self.socketSessionID, surveyAccessKey: self.surveyAccessKey});
|
|
|
}else{
|
|
@@ -88,8 +87,11 @@
|
|
|
},
|
|
|
updateUi: function(){
|
|
|
var self = this;
|
|
|
+ if(self.loading) return;
|
|
|
+ self.loading = true;
|
|
|
var url = "{{ @$survey->access_key ? route('view-survey-form-get-data', @$survey->access_key) : '' }}";
|
|
|
$.get(url, {}, function(response){
|
|
|
+ self.loading = false;
|
|
|
if(response.success){
|
|
|
const data = JSON.parse(response.data.survey_data);
|
|
|
self.form = data;
|