Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Load records in tab child. #1403

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
8 changes: 1 addition & 7 deletions src/components/ADempiere/DefaultTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ import ColumnsDisplayOption from './ColumnsDisplayOption'
import CustomPagination from './CustomPagination.vue'

// utils and helper methods
import { fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
import { isLookup } from '@/utils/ADempiere/references'
import { tableColumnDataType } from '@/utils/ADempiere/valueUtils'

Expand Down Expand Up @@ -210,12 +209,7 @@ export default defineComponent({
*/
function isDisplayed(field) {
// validate with container manager
if (!root.isEmptyValue(props.containerManager) &&
props.containerManager.isDisplayedColumn) {
return props.containerManager.isDisplayedColumn(field)
}

return fieldIsDisplayed(field, true)
return props.containerManager.isDisplayedColumn(field)
}

/**
Expand Down
158 changes: 0 additions & 158 deletions src/components/ADempiere/PanelDefinition/panelUtils.js

This file was deleted.

29 changes: 8 additions & 21 deletions src/components/ADempiere/RecordNavigation/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<default-table
:parent-uuid="parentUuid"
:container-uuid="containerUuid"
:container-manager="recordNavigationManager"
:container-manager="containerManager"
:panel-metadata="panelMetadata"
:header="tableheaders"
:data-table="recordsList"
Expand Down Expand Up @@ -99,28 +99,19 @@ export default defineComponent({
return []
})

// namespace to vuex store module
const vuexStore = props.containerManager.vuexStore()
const tabData = computed(() => {
return root.$store.getters.getTabData({
containerUuid: props.containerUuid
})
})

// get records list
const recordsList = computed(() => {
const data = root.$store.getters[vuexStore + '/getContainerData']({
containerUuid: props.containerUuid
})
if (data && data.recordsList) {
return data.recordsList
}
return []
return tabData.value.recordsList
})

const recordCount = computed(() => {
const data = root.$store.getters[vuexStore + '/getContainerData']({
containerUuid: props.containerUuid
})
if (data && data.recordCount) {
return data.recordCount
}
return 0
return tabData.value.recordCount
})

const actionAdvancedQuery = () => {
Expand All @@ -131,15 +122,11 @@ export default defineComponent({
activeName.value = activeNames
}

// set and/or overwrite methods
const recordNavigationManager = props.containerManager

return {
activeName,
// computeds
recordsList,
recordCount,
recordNavigationManager,
isLoadedPanel,
panelMetadata,
tableheaders,
Expand Down
72 changes: 37 additions & 35 deletions src/components/ADempiere/TabManager/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<record-navigation
:parent-uuid="parentUuid"
:container-uuid="tabUuid"
:container-manager="containerManagerTab"
:container-manager="containerManager"
:current-tab="tabsList[currentTab]"
/>
</auxiliary-panel>
Expand Down Expand Up @@ -63,7 +63,7 @@
key="default-table"
:parent-uuid="parentUuid"
:container-uuid="tabAttributes.uuid"
:container-manager="containerManagerTab"
:container-manager="containerManager"
:header="tableHeaders"
:data-table="recordsList"
:panel-metadata="tabAttributes"
Expand All @@ -88,7 +88,7 @@
</template>

<script>
import { defineComponent, computed, ref } from '@vue/composition-api'
import { defineComponent, computed, watch, ref } from '@vue/composition-api'

// components and mixins
import AuxiliaryPanel from '@/components/ADempiere/AuxiliaryPanel/index.vue'
Expand Down Expand Up @@ -187,14 +187,6 @@ export default defineComponent({
})
}

const containerManagerTab = computed(() => {
return {
...props.containerManager,

vuexStore: () => 'dataManager'
}
})

// create the table header
const tableHeaders = computed(() => {
const panel = props.tabsList[tabNo]
Expand Down Expand Up @@ -236,38 +228,39 @@ export default defineComponent({
...root.$route.params
}
}, () => {})
const containerManager = props.containerManager
if (containerManager !== undefined) {
// console.log(containerManager)
// containerManager.seekTab({
// tabNumber,
// currentTab
// }).then(() => {})
}

return tabNumber
}

const tabData = computed(() => {
return root.$store.getters.getTabData({
containerUuid: currentTabMetadata.value.uuid
})
})

// get records list
const recordsList = computed(() => {
const data = root.$store.getters['dataManager/getContainerData']({
containerUuid: props.containerUuid
})
if (data && data.recordsList) {
return data.recordsList
return tabData.value.recordsList
})

const isLoadedParentRecords = computed(() => {
return root.$store.getters.getTabData({
containerUuid: currentTabMetadata.value.firstTabUuid
}).isLoaded
})

const isReadyFromGetData = computed(() => {
if (props.isParentTabs) {
return !tabData.value.isLoaded
}
return []
// TODO: add is loaded context columns
return isLoadedParentRecords.value && !tabData.value.isLoaded
})

const getData = () => {
// TODO: Add support to load data in dependent childs
if (!props.isParentTabs) {
return
}
// TODO: Add store get data from tab
root.$store.dispatch('dataManager/getEntities', {
root.$store.dispatch('getEntities', {
parentUuid: props.parentUuid,
containerUuid: tabUuid.value,
...props.tabsList[currentTab.value]
containerUuid: tabUuid.value
}).then(responseData => {
if (!isCreateNew.value && !root.isEmptyValue(responseData)) {
let row
Expand Down Expand Up @@ -314,7 +307,17 @@ export default defineComponent({
})
}

getData()
if (props.isParentTabs) {
if (isReadyFromGetData.value) {
getData()
}
} else {
watch(isReadyFromGetData, (newValue, oldValue) => {
if (newValue) {
getData()
}
})
}

setTabNumber(currentTab.value)

Expand All @@ -324,7 +327,6 @@ export default defineComponent({
tableHeaders,
recordsList,
// computed
containerManagerTab,
isShowedTabs,
isShowedTableRecords,
tabStyle,
Expand Down
4 changes: 3 additions & 1 deletion src/store/modules/ADempiere/browserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ const browserControl = {
selectionsList
}) {
Vue.set(state.browserData[containerUuid], 'selectionsList', selectionsList)
},

console.log(state.browserData)
resetStateBrowserManager(state) {
state = initState
}
},

Expand Down
5 changes: 4 additions & 1 deletion src/store/modules/ADempiere/dictionary/browser/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

import router from '@/router'

// api request methods
import { requestBrowserMetadata } from '@/api/ADempiere/dictionary/smart-browser.js'
import { generatePanelAndFields } from '@/components/ADempiere/PanelDefinition/panelUtils'

// utils and helper methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
import { generatePanelAndFields } from '@/utils/ADempiere/dictionary/panel.js'
import { isDisplayedField, isMandatoryField } from '@/utils/ADempiere/dictionary/browser.js'

export default {
Expand Down
Loading