From 49e82232f92c1c26eefdbe2e51b682d0a369690c Mon Sep 17 00:00:00 2001 From: Yamel Senih Date: Thu, 30 Apr 2020 00:44:03 -0400 Subject: [PATCH] Add support to conditional for event handler (#474) --- src/components/ADempiere/Field/FieldMixin.js | 64 +++++++++++--------- src/utils/ADempiere/lookupFactory.js | 5 ++ 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/components/ADempiere/Field/FieldMixin.js b/src/components/ADempiere/Field/FieldMixin.js index 260a7242..6a76ff06 100644 --- a/src/components/ADempiere/Field/FieldMixin.js +++ b/src/components/ADempiere/Field/FieldMixin.js @@ -49,34 +49,42 @@ export const fieldMixin = { this.handleChange(value) }, focusGained(value) { - this.$store.dispatch('notifyFocusGained', { - containerUuid: this.metadata.containerUuid, - columnName: this.metadata.columnName, - value: this.value - }) + if (this.metadata.handleFocusGained) { + this.$store.dispatch('notifyFocusGained', { + containerUuid: this.metadata.containerUuid, + columnName: this.metadata.columnName, + value: this.value + }) + } }, focusLost(value) { - this.$store.dispatch('notifyFocusLost', { - containerUuid: this.metadata.containerUuid, - columnName: this.metadata.columnName, - value: this.value - }) + if (this.metadata.handleFocusLost) { + this.$store.dispatch('notifyFocusLost', { + containerUuid: this.metadata.containerUuid, + columnName: this.metadata.columnName, + value: this.value + }) + } }, keyPressed(value) { - this.$store.dispatch('notifyKeyPressed', { - containerUuid: this.metadata.containerUuid, - columnName: this.metadata.columnName, - value: value.key, - keyCode: value.keyCode - }) + if (this.metadata.handleKeyPressed) { + this.$store.dispatch('notifyKeyPressed', { + containerUuid: this.metadata.containerUuid, + columnName: this.metadata.columnName, + value: value.key, + keyCode: value.keyCode + }) + } }, keyReleased(value) { - this.$store.dispatch('notifyKeyReleased', { - containerUuid: this.metadata.containerUuid, - columnName: this.metadata.columnName, - value: value.key, - keyCode: value.keyCode - }) + if (this.metadata.handleKeyReleased) { + this.$store.dispatch('notifyKeyReleased', { + containerUuid: this.metadata.containerUuid, + columnName: this.metadata.columnName, + value: value.key, + keyCode: value.keyCode + }) + } }, /** * @param {mixed} value, main value in component @@ -115,11 +123,13 @@ export const fieldMixin = { isChangedOldValue } // Global Action performed - this.$store.dispatch('notifyActionPerformed', { - containerUuid: this.metadata.containerUuid, - columnName: this.metadata.columnName, - value: newValue - }) + if (this.metadata.handleActionPerformed) { + this.$store.dispatch('notifyActionPerformed', { + containerUuid: this.metadata.containerUuid, + columnName: this.metadata.columnName, + value: newValue + }) + } if (this.metadata.inTable) { this.$store.dispatch('notifyCellTableChange', { ...sendParameters, diff --git a/src/utils/ADempiere/lookupFactory.js b/src/utils/ADempiere/lookupFactory.js index adbf0d02..b60951e8 100644 --- a/src/utils/ADempiere/lookupFactory.js +++ b/src/utils/ADempiere/lookupFactory.js @@ -309,6 +309,11 @@ export function getFieldTemplate(overwriteDefinition) { mandatoryLogic: undefined, readOnlyLogic: undefined, parentFieldsList: undefined, + handleFocusGained: false, + handleFocusLost: false, + handleKeyPressed: false, + handleKeyReleased: false, + handleActionPerformed: true, dependentFieldsList: [], reference: { tableName: '',