Skip to content

Commit

Permalink
Support Zoom Fields (PanJiaChen#2289)
Browse files Browse the repository at this point in the history
* Initial commit

* Minimal changes
  • Loading branch information
elsiosanchez authored May 30, 2024
1 parent e57f04b commit bd7bbb6
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 81 deletions.
16 changes: 14 additions & 2 deletions src/api/ADempiere/zoom.js → src/api/ADempiere/field/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,23 @@ export function listZoomWindowsRequest({
case !isEmptyValue(column_id):
url = `/field/zooms/column/${column_id}`
break
default:
break
}
return request({
url: url,
method: 'get'
})
}

export function getZoomParentRecord({
window_id,
tab_id,
value
}) {
return request({
url: `/field/zooms/record/${window_id}/${tab_id}`,
method: 'get',
params: {
value
}
})
}
37 changes: 19 additions & 18 deletions src/components/ADempiere/DataTable/Components/ChangeRecord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@
<script>
import { defineComponent, computed } from '@vue/composition-api'

import router from '@/router'
import store from '@/store'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { isEmptyValue, setRecordPath } from '@/utils/ADempiere/valueUtils'

export default defineComponent({
name: 'ChangeRecord',
Expand Down Expand Up @@ -127,19 +126,6 @@ export default defineComponent({
return []
})

function setRecordPath(recordId) {
router.push({
query: {
...root.$route.query,
recordId
},
params: {
...root.$route.params,
recordId
}
}, () => {})
}

/**
* changePreviousRecord
*/
Expand Down Expand Up @@ -167,7 +153,15 @@ export default defineComponent({
containerUuid: props.containerUuid,
row: previosRecord
})
setRecordPath(recordId)
if (tabAttributes.value.isParentTab) {
setRecordPath({
recordId: recordId
})
return
}
setRecordPath({
recordChildId: recordId
})
}

/**
Expand Down Expand Up @@ -198,8 +192,15 @@ export default defineComponent({
containerUuid: props.containerUuid,
row: nextRecord
})

setRecordPath(recordId)
if (tabAttributes.value.isParentTab) {
setRecordPath({
recordId: recordId
})
return
}
setRecordPath({
recordChildId: recordId
})
}

function hangleChangeRecord(action) {
Expand Down
16 changes: 13 additions & 3 deletions src/components/ADempiere/DataTable/Windows/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,19 @@ export default defineComponent({
})
const { table_name } = props.panelMetadata
if (!isEmptyValue(table_name) && !isEmptyValue(row[table_name + '_ID'])) {
setRecordPath({
recordId: row[table_name + '_ID']
})
const currentTab = store.getters.getStoredTab(
props.parentUuid,
props.containerUuid
)
if (currentTab.isParentTab) {
setRecordPath({
recordId: row[table_name + '_ID']
})
} else {
setRecordPath({
recordChildId: row[table_name + '_ID']
})
}
}

// if (isMobile.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const zoomInOptionItem = {
componentRender: () => import('@/components/ADempiere/FieldDefinition/FieldOptions/EmptyOption'),
executeMethod: ({ containerManager, window, fieldAttributes, value, zoom }) => {
const { parentUuid, containerUuid, reference } = fieldAttributes
let children
let zoom_windows = reference.zoom_windows
if (isEmptyValue(zoom_windows)) {
zoom_windows = zoom.zoom_windows
Expand All @@ -67,7 +68,7 @@ export const zoomInOptionItem = {
})
windowToZoom = zoom_windows.find(zoomWindow => {
// Is Sales Transaction Window or Is Purchase Transaction Window
return zoomWindow.isSalesTransaction === isSOTrx
return zoomWindow.is_sales_transaction === isSOTrx
})
if (isEmptyValue(windowToZoom)) {
windowToZoom = zoom_windows.at(0)
Expand Down Expand Up @@ -102,14 +103,21 @@ export const zoomInOptionItem = {
currentValue = reference.id
}

if (!isEmptyValue(windowToZoom) && !windowToZoom.is_parent_tab) {
columnName = zoom.parentTab.key_column
currentValue = zoom.parentTab.record_id
children = windowToZoom
}

zoomIn({
attributeValue: `window_${windowToZoom.id}`,
attributeName: 'containerKey',
query: {
[columnName]: currentValue
},
params: {
[columnName]: currentValue
[columnName]: currentValue,
children
}
})
}
Expand Down
25 changes: 17 additions & 8 deletions src/components/ADempiere/FieldDefinition/FieldOptions/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,6 @@ export default defineComponent({
}
if (isSupportLookup(field.display_type)) {
menuOptions.push(refreshLookup)
if (field.reference && !isEmptyValue(field.id)) {
searchZoom(field)
menuOptions.push(zoomInOptionItem)
}
// if (field.reference && !isEmptyValue(field.reference.zoom_windows)) {
// menuOptions.push(zoomInOptionItem)
// }
}

if (field.componentPath === 'FieldButton') {
Expand Down Expand Up @@ -321,14 +314,29 @@ export default defineComponent({
process_parameter_id: field.process_id,
field_id: field.id,
column_name: field.columnName,
table_name: field.tabTableName
table_name: field.tabTableName,
valueField: valueField.value
}).then(response => {
zoom.value = response
}).finally(() => {
return false
})
}

function addOptionsZoom(field) {
const {
id,
reference,
display_type
} = field
if (isSupportLookup(display_type)) {
if (reference && !isEmptyValue(id)) {
searchZoom(field)
optionsList.value.unshift(zoomInOptionItem)
}
}
}

const openOptionField = computed({
get() {
const option = optionsList.value.find(option => {
Expand Down Expand Up @@ -377,6 +385,7 @@ export default defineComponent({
}

const handleOpen = (key, keyPath) => {
addOptionsZoom(props.metadata)
triggerMenu.value = 'hover'
}
const handleClose = (key, keyPath) => {
Expand Down
38 changes: 20 additions & 18 deletions src/components/ADempiere/TabManager/TabPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ import PanelDefinition from '@/components/ADempiere/PanelDefinition/index.vue'
import TabOptions from './TabOptions.vue'

// Utils and Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import { isEmptyValue, setRecordPath } from '@/utils/ADempiere/valueUtils'

export default defineComponent({
name: 'TabPanel',
Expand Down Expand Up @@ -387,7 +387,15 @@ export default defineComponent({
containerUuid: props.currentTabUuid,
row: previosRecord
})
setRecordPath(recordId)
if (currentTab.value.isParentTab) {
setRecordPath({
recordId: recordId
})
return
}
setRecordPath({
recordChildId: recordId
})
}

/**
Expand Down Expand Up @@ -418,20 +426,15 @@ export default defineComponent({
row: nextRecord
})

setRecordPath(recordId)
}

function setRecordPath(recordId) {
router.push({
query: {
...root.$route.query,
recordId
},
params: {
...root.$route.params,
recordId
}
}, () => {})
if (currentTab.value.isParentTab) {
setRecordPath({
recordId: recordId
})
return
}
setRecordPath({
recordChildId: recordId
})
}

return {
Expand All @@ -458,8 +461,7 @@ export default defineComponent({
handleChangePage,
handleChangeSizePage,
changePreviousRecord,
changeNextRecord,
setRecordPath
changeNextRecord
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/components/ADempiere/TabManager/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ import { requestListResources } from '@/api/ADempiere/file-management/resource-r
import { requestExistsIssues } from '@/api/ADempiere/logs/tabInfo/windowIssues.ts'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { isEmptyValue, setRecordPath } from '@/utils/ADempiere/valueUtils.js'
// import { showMessage } from '@/utils/ADempiere/notification'

export default defineComponent({
Expand Down Expand Up @@ -473,6 +473,10 @@ export default defineComponent({
})
}
}

setRecordPath({
tab: tabindex
})
}

const setTabNumber = (tabNumber = '0') => {
Expand All @@ -482,9 +486,11 @@ export default defineComponent({
if (tabNumber !== currentTab.value) {
currentTab.value = tabNumber
}

setValuesPath({
query: {
...currentRoute.query,
tab: currentTab.value,
[queryProperty]: currentTab.value
},
params: {
Expand Down
25 changes: 24 additions & 1 deletion src/components/ADempiere/TabManager/tabChild.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ import TabOptions from './TabOptions.vue'
import { UUID } from '@/utils/ADempiere/constants/systemColumns.js'

// utils and helper methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { isEmptyValue, setRecordPath } from '@/utils/ADempiere/valueUtils.js'
import { isDisplayedTab } from '@/utils/ADempiere/dictionary/window'
import { getContextAttributes, generateContextKey } from '@/utils/ADempiere/contextUtils/contextAttributes'

Expand Down Expand Up @@ -174,6 +174,7 @@ export default defineComponent({

setup(props, { root }) {
const queryProperty = 'tabChild'
const currentRoute = router.app._route

// if tabParent is present in path set this
const tabNo = root.$route.query[queryProperty] || '0'
Expand Down Expand Up @@ -269,6 +270,9 @@ export default defineComponent({
}

function changeTab({ uuid, index }) {
setRecordPath({
tabChild: index
})
setTabNumber(index)

// set metadata tab
Expand Down Expand Up @@ -482,6 +486,25 @@ export default defineComponent({
getData()
}

setTimeout(() => {
if (
!isEmptyValue(currentRoute.params) &&
!isEmptyValue(currentRoute.params.children) &&
!isEmptyValue(currentRoute.params.children.tab_id)
) {
const children = currentRoute.params.children
const indexTab = showedTabsList.value.findIndex(items => {
if (items.id === children.tab_id) {
return items
}
})
changeTab({
uuid: children.tab_uuid,
index: indexTab
})
}
}, 2000)

watch(showedTabsList, (newValue, oldValue) => {
if (newValue) {
const currentIndexDisplayed = newValue.some(newTab => {
Expand Down
9 changes: 0 additions & 9 deletions src/store/modules/ADempiere/field/accountingCombination.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ const AccountCombinations = {
isBooleanToString: true
})
}
console.log({
id,
uuid,
attributes,
accountId,
organizationId,
accountingSchemaId,
contextAttributesList
})

return requestSaveAccountingCombination({
id,
Expand Down
Loading

0 comments on commit bd7bbb6

Please sign in to comment.