Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions resources/js/tasks/components/QuickFillPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,18 @@ 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;

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
Expand All @@ -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);
});
Expand Down
19 changes: 19 additions & 0 deletions resources/views/tasks/preview.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -441,6 +445,7 @@ class="card border-0"
screenFields.forEach((field) => {

const existingValue = _.get(this.formData, field, null);

let quickFillValue;

if (existingValue) {
Expand All @@ -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;
Expand All @@ -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);
});

Expand Down