Skip to content

Commit

Permalink
Add callback functions (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih authored Jun 30, 2021
1 parent 10f4846 commit 240c2da
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 133 deletions.
2 changes: 1 addition & 1 deletion src/components/ADempiere/Field/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default {
required: true
},
containerManager: {
type: String,
type: Object,
required: true
},
// receives the property that is an object with all the attributes
Expand Down
12 changes: 2 additions & 10 deletions src/components/ADempiere/Field/mixin/mixinField.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
required: true
},
containerManager: {
type: String,
type: Object,
required: true
},
fieldMetadata: {
Expand Down Expand Up @@ -173,8 +173,6 @@ export default {
}
},
actionKeyPerformed(value) {
// TODO: Delete for production
console.info('actionKeyPerformed ', this.containerManager, value)
if (this.metadata.handleActionKeyPerformed) {
this.$store.dispatch('notifyActionKeyPerformed', {
containerUuid: this.metadata.containerUuid,
Expand Down Expand Up @@ -223,15 +221,9 @@ export default {
return
}

if (this.metadata.inTable) {
this.$store.dispatch('notifyCellTableChange', {
parentUuid: this.metadata.parentUuid,
containerUuid: this.metadata.containerUuid,
field: this.metadata
})
}
this.$store.dispatch('notifyFieldChange', {
containerUuid: this.metadata.containerUuid,
containerManager: this.containerManager,
field: this.metadata,
columnName: this.metadata.columnName
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/ADempiere/PanelDefinition/StandardPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default defineComponent({
required: true
},
containerManager: {
type: String,
type: Object,
required: true
},
panelMetadata: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ADempiere/PanelDefinition/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default defineComponent({
required: true
},
containerManager: {
type: String,
type: Object,
required: true
},
panelMetadata: {
Expand Down
17 changes: 10 additions & 7 deletions src/components/ADempiere/TabManager/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default defineComponent({
required: true
},
containerManager: {
type: String,
type: Object,
required: true
},
tabsList: {
Expand Down Expand Up @@ -117,9 +117,7 @@ export default defineComponent({
tabUuid.value = tabuuid
setCurrentTab()
}
if (currentTab.value !== tabindex) {
setTabNumber(tabindex)
}
setTabNumber(tabindex)
}

const setTabNumber = (tabNumber = '0') => {
Expand All @@ -139,9 +137,14 @@ export default defineComponent({
...root.$route.params
}
}, () => {})

// TODO: Delete this to production
console.log('Click tab number ', tabNumber)
const containerManager = props.containerManager
if (containerManager !== undefined) {
console.log(containerManager)
// containerManager.seekTab({
// tabNumber,
// currentTab
// }).then(() => {})
}
return tabNumber
}

Expand Down
110 changes: 2 additions & 108 deletions src/store/modules/ADempiere/panel/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,92 +478,6 @@ const actions = {
}
})

// return new Promise(resolve => {
// if (isEmptyValue(fieldsList)) {
// fieldsList = getters.getFieldsListFromPanel(containerUuid)
// }
// let fieldsShowed = []
// // const promisessList = []
// fieldsList.map(async actionField => {
// if (actionField.isShowedFromUser) {
// fieldsShowed.push(actionField.columnName)
// }
//
// // Evaluate with hasOwnProperty if exits this value
// if (!Object.prototype.hasOwnProperty.call(newValues, actionField.columnName)) {
// if (!isChangedAllValues || withOutColumnNames.includes(actionField.columnName)) {
// // breaks if this value does not exist or ignore with out column names
// return
// }
// // set empty value and continue
// newValues[actionField.columnName] = undefined
// }
//
// if (isChangeFromCallout &&
// actionField.componentPath === 'FieldSelect' &&
// !Object.prototype.hasOwnProperty.call(newValues, actionField.displayColumnName)) {
// let lookup = rootGetters.getLookupItem({
// parentUuid,
// containerUuid,
// directQuery: actionField.reference.directQuery,
// tableName: actionField.reference.tableName,
// value: newValues[actionField.columnName]
// })
//
// if (isEmptyValue(lookup) && !isEmptyValue(newValues[actionField.columnName])) {
// lookup = await dispatch('getLookupItemFromServer', {
// parentUuid,
// containerUuid,
// tableName: actionField.reference.tableName,
// directQuery: actionField.reference.parsedDirectQuery,
// value: newValues[actionField.columnName]
// })
// }
// if (!isEmptyValue(lookup)) {
// newValues[actionField.displayColumnName] = lookup.label
// }
// }
// // Update field
// commit('updateValueOfField', {
// parentUuid,
// containerUuid,
// columnName: actionField.columnName,
// value: newValues[actionField.columnName]
// })
// })
// // show fields in query
// if (isShowedField && !isEmptyValue(newValues)) {
// // join column names without duplicating it
// fieldsShowed = Array.from(new Set([
// ...fieldsShowed,
// ...Object.keys(newValues)
// ]))
//
// dispatch('changeFieldAttributesBoolean', {
// containerUuid,
// attribute: 'isShowedFromUser',
// valueAttribute: true,
// fieldsIncludes: fieldsShowed
// })
// }
// if (panelType === 'window') {
// dispatch('setIsloadContext', {
// containerUuid
// })
// if (isPrivateAccess) {
// const tableName = rootGetters.getTableNameFromTab(parentUuid, containerUuid)
// // TODO: Add current id and new id to comparison
// if (!isEmptyValue(newValues[`${tableName}_ID`])) {
// dispatch('getPrivateAccessFromServer', {
// tableName,
// recordId: newValues[`${tableName}_ID`],
// userUuid: rootGetters['user/getUserUuid']
// })
// }
// }
// }
// })

dispatch('setIsloadContext', {
containerUuid
})
Expand All @@ -577,6 +491,7 @@ const actions = {
*/
notifyFieldChange({ dispatch, getters }, {
containerUuid,
containerManager,
columnName,
field,
newValue
Expand All @@ -598,34 +513,13 @@ const actions = {
} else {
value = newValue
}
// if (!(panelType === 'table' || isAdvancedQuery)) {
// if (!['IN', 'NOT_IN'].includes(field.operator)) {
// value = parsedValueComponent({
// componentPath: field.componentPath,
// columnName: field.columnName,
// displayType: field.displayType,
// value,
// isIdentifier: field.columnName.includes('_ID')
// })
// if (field.isRange) {
// valueTo = parsedValueComponent({
// componentPath: field.componentPath,
// columnName: field.columnName,
// displayType: field.displayType,
// value: valueTo,
// isIdentifier: field.columnName.includes('_ID')
// })
// }
// }
// }
resolve({
tableName: field.tableName,
field,
value
})

// Run specific action
dispatch(field.panelType + 'ActionPerformed', {
containerManager.actionPerformed({
containerUuid: field.containerUuid,
field,
value
Expand Down
19 changes: 18 additions & 1 deletion src/views/ADempiere/Test/MultiTabWindow/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:is="WindowView"
:uuid="uuid"
:metadata="metadata"
:container-manager="containerManager"
/>
</template>

Expand All @@ -37,11 +38,27 @@ export default defineComponent({
// Business Partner
const uuid = 'a520de12-fb40-11e8-a479-7a0060f0aa01'
const metadata = multiTabMetadata.result
const containerManager = {
actionPerformed: function(eventInfo) {
console.log('actionPerformed: ', eventInfo)
return new Promise()
},

seekRecord: function(eventInfo) {
console.log('seekRecord: ', eventInfo)
return new Promise()
},

seekTab: function(eventInfo) {
console.log('seekTab: ', eventInfo)
return new Promise()
}
}
return {
WindowView,
metadata,
uuid
uuid,
containerManager
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/views/ADempiere/WindowView/StandardWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default defineComponent({

props: {
containerManager: {
type: String,
type: Object,
required: true
},
windowMetadata: {
Expand Down
10 changes: 7 additions & 3 deletions src/views/ADempiere/WindowView/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<component
:is="renderWindowComponent"
:container-manager="containerManager"
:container-manager="containerManagerProp"
:window-metadata="windowMetadata"
/>
</el-aside>
Expand Down Expand Up @@ -58,11 +58,15 @@ export default defineComponent({
metadata: {
type: Object,
default: () => {}
},
containerManager: {
type: Object,
required: true
}
},

setup(props, { root }) {
const containerManager = 'window'
const containerManagerProp = props.containerManager

const isLoaded = ref(false)
const windowMetadata = ref({})
Expand Down Expand Up @@ -102,7 +106,7 @@ export default defineComponent({

return {
windowUuid,
containerManager,
containerManagerProp,
windowMetadata,
// computed
renderWindowComponent,
Expand Down

0 comments on commit 240c2da

Please sign in to comment.