diff --git a/resources/js/tasks/components/QuickFillPreview.vue b/resources/js/tasks/components/QuickFillPreview.vue index 5cdc27e8a0..efe5bd8938 100644 --- a/resources/js/tasks/components/QuickFillPreview.vue +++ b/resources/js/tasks/components/QuickFillPreview.vue @@ -269,6 +269,10 @@ export default { } this.$emit("close"); }, + validateBase64(field) { + const regex = /^data:image\/\w+;base64,/; + return regex.test(field); + }, buttonThisDataFromFullTask(quickFillData) { // If the task does not have a draft yet, use the task data const dataToUse = this.task.draft?.data ?? this.task.data; @@ -276,6 +280,7 @@ export default { const draftData = {}; this.screenFields.forEach((field) => { const existingValue = _.get(dataToUse, field, null); + let quickFillValue; if (existingValue) { // If the value exists in the task data (or task draft data), don't overwrite it @@ -284,6 +289,11 @@ export default { // use the value from the quick fill quickFillValue = _.get(quickFillData, field, null); } + + if(this.validateBase64(quickFillValue)) { + _.set(draftData, field, existingValue); + return; + } // Set the value. This handles nested values using dot notation in 'field' string _.set(draftData, field, quickFillValue); }); diff --git a/resources/views/tasks/preview.blade.php b/resources/views/tasks/preview.blade.php index 2ecd3141b2..73228e45b1 100644 --- a/resources/views/tasks/preview.blade.php +++ b/resources/views/tasks/preview.blade.php @@ -428,6 +428,10 @@ class="card border-0" this.sendEvent('taskReady', this.task?.id); }); }, + validateBase64(field) { + const regex = /^data:image\/\w+;base64,/; + return regex.test(field); + }, }, mounted() { this.prepareData(); @@ -441,6 +445,7 @@ class="card border-0" screenFields.forEach((field) => { const existingValue = _.get(this.formData, field, null); + let quickFillValue; if (existingValue) { @@ -450,8 +455,14 @@ class="card border-0" // use the value from the quick fill(event.detail) quickFillValue = _.get(event.detail, field, null); } + + if(this.validateBase64(quickFillValue)) { + _.set(newData, field, existingValue); + return; + } // Set the value. This handles nested values using dot notation in 'field' string _.set(newData, field, quickFillValue); + }); this.formData = newData; @@ -461,6 +472,14 @@ class="card border-0" // want to use all data saved in the inbox rule db record, regardless // if the field exists or not. window.addEventListener('fillDataOverwriteExistingFields', event => { + for (let key in event.detail) { + if (event.detail.hasOwnProperty(key)) { + let value = event.detail[key]; + if (this.validateBase64(value)) { + delete event.detail[key]; + } + } + } this.formData = _.merge(_.cloneDeep(this.formData), event.detail); });