fix(UI): avoid unnecessary updates when cell content not change

This commit is contained in:
Fabio Di Stasio 2021-03-09 18:08:57 +01:00
parent 76c5c0c680
commit e9a26c1bc0
1 changed files with 8 additions and 6 deletions

View File

@ -243,6 +243,7 @@ export default {
editingContent: null, editingContent: null,
editingType: null, editingType: null,
editingField: null, editingField: null,
editingLength: null,
editorMode: 'text', editorMode: 'text',
contentInfo: { contentInfo: {
ext: '', ext: '',
@ -339,23 +340,24 @@ export default {
window.addEventListener('keydown', this.onKey); window.addEventListener('keydown', this.onKey);
const type = this.fields[field].type.toUpperCase(); ; const type = this.fields[field].type.toUpperCase(); ;
this.originalContent = content; this.originalContent = this.$options.filters.typeFormat(content, type, this.fields[field].length);
this.editingType = type; this.editingType = type;
this.editingField = field; this.editingField = field;
this.editingLength = this.fields[field].length;
if (LONG_TEXT.includes(type)) { if (LONG_TEXT.includes(type)) {
this.isTextareaEditor = true; this.isTextareaEditor = true;
this.editingContent = this.$options.filters.typeFormat(this.originalContent, type); this.editingContent = this.$options.filters.typeFormat(content, type);
return; return;
} }
if (BLOB.includes(type)) { if (BLOB.includes(type)) {
this.isBlobEditor = true; this.isBlobEditor = true;
this.editingContent = this.originalContent || ''; this.editingContent = content || '';
this.fileToUpload = null; this.fileToUpload = null;
this.willBeDeleted = false; this.willBeDeleted = false;
if (this.originalContent !== null) { if (content !== null) {
const buff = Buffer.from(this.editingContent); const buff = Buffer.from(this.editingContent);
if (buff.length) { if (buff.length) {
const hex = buff.toString('hex').substring(0, 8).toUpperCase(); const hex = buff.toString('hex').substring(0, 8).toUpperCase();
@ -371,7 +373,7 @@ export default {
} }
// Inline editable fields // Inline editable fields
this.editingContent = this.$options.filters.typeFormat(this.originalContent, type, this.fields[field].length); this.editingContent = this.originalContent;
this.$nextTick(() => { // Focus on input this.$nextTick(() => { // Focus on input
event.target.blur(); event.target.blur();
@ -387,7 +389,7 @@ export default {
this.isInlineEditor[this.editingField] = false; this.isInlineEditor[this.editingField] = false;
let content; let content;
if (!BLOB.includes(this.editingType)) { if (!BLOB.includes(this.editingType)) {
if (this.editingContent === this.$options.filters.typeFormat(this.originalContent, this.editingType)) return;// If not changed if (this.editingContent === this.$options.filters.typeFormat(this.originalContent, this.editingType, this.editingLength)) return;// If not changed
content = this.editingContent; content = this.editingContent;
} }
else { // Handle file upload else { // Handle file upload