-
+
+
+
-
+
+
+
+
+
+
import { defineComponent, computed, ref } from '@vue/composition-api'
-
-import ContextMenu from '@/components/ADempiere/ContextMenu'
+import { generateWindow as generateWindowRespose } from './windowUtils'
export default defineComponent({
name: 'WindowView',
- components: {
- ContextMenu
+ props: {
+ // implement by test view
+ uuid: {
+ type: String,
+ default: ''
+ },
+ metadata: {
+ type: Object,
+ default: () => {}
+ }
},
setup(props, { root }) {
const panelType = 'window'
- const windowUuid = root.$route.meta.uuid
const isLoaded = ref(false)
const windowMetadata = ref({})
+ let windowUuid = root.$route.meta.uuid
+ // set uuid from test
+ if (!root.isEmptyValue(props.uuid)) {
+ windowUuid = props.uuid
+ }
+
const generateWindow = (window) => {
windowMetadata.value = window
isLoaded.value = true
@@ -72,11 +83,21 @@ export default defineComponent({
// get window from vuex store or request from server
const getWindow = () => {
+ // metadata props use for test
+ if (!root.isEmptyValue(props.metadata)) {
+ return new Promise(resolve => {
+ const windowResponse = generateWindowRespose(props.metadata)
+ generateWindow(windowResponse)
+ resolve(windowResponse)
+ })
+ }
+
const window = getterWindow.value
if (!root.isEmptyValue(window)) {
generateWindow(window)
return
}
+
root.$store.dispatch('getWindowFromServer', {
windowUuid,
routeToDelete: root.$route
@@ -113,6 +134,7 @@ export default defineComponent({
panelType,
windowUuid,
windowMetadata,
+ // computed
getterWindow,
renderWindowComponent,
isLoaded
diff --git a/src/views/ADempiere/WindowView/windowUtils.js b/src/views/ADempiere/WindowView/windowUtils.js
new file mode 100644
index 00000000..8a182384
--- /dev/null
+++ b/src/views/ADempiere/WindowView/windowUtils.js
@@ -0,0 +1,81 @@
+
+import { convertWindow } from '@/utils/ADempiere/apiConverts/dictionary.js'
+
+export function generateWindow(windowResponse) {
+ const responseWindow = convertWindow(windowResponse)
+
+ const {
+ tabsList, tabsListParent,
+ firstTab, firstTabUuid
+ } = generateTabs({
+ tabs: responseWindow.tabs,
+ windowUuid: responseWindow.uuid
+ })
+
+ const newWindow = {
+ ...responseWindow,
+ tabsList,
+ currentTab: tabsListParent[0],
+ tabsListParent,
+ // app attributes
+ currentTabUuid: tabsListParent[0].uuid,
+ firstTab,
+ firstTabUuid,
+ // App properties
+ isShowedTabsChildren: false,
+ isShowedRecordNavigation: undefined,
+ isShowedAdvancedQuery: false
+ }
+
+ return newWindow
+}
+
+export function generateTabs({
+ tabs,
+ windowUuid
+}) {
+ const firstTabTableName = tabs[0].tableName
+ const firstTabUuid = tabs[0].uuid
+ const tabsListParent = []
+
+ // indexes related to visualization
+ let tabParentIndex = 0
+
+ const tabsList = tabs.filter((itemTab) => {
+ return !(
+ itemTab.isTranslationTab || itemTab.isSortTab ||
+ itemTab.isAdvancedTab || itemTab.isHasTree
+ )
+ }).map((tabItem, index) => {
+ // let tab = tabItem
+ const tab = {
+ ...tabItem,
+ containerUuid: tabItem.uuid,
+ parentUuid: windowUuid,
+ windowUuid,
+ tabGroup: tabItem.fieldGroup,
+ firstTabUuid,
+ // relations
+ isParentTab: Boolean(firstTabTableName === tabItem.tableName),
+ // app properties
+ isShowedRecordNavigation: !(tabItem.isSingleRow),
+ isLoadFieldsList: false,
+ index // this index is not related to the index in which the tabs are displayed
+ }
+
+ if (tab.isParentTab) {
+ tab.tabParentIndex = tabParentIndex
+ tabParentIndex++
+ tabsListParent.push(tab)
+ return tab
+ }
+ return tab
+ })
+
+ return {
+ firstTabUuid,
+ firstTab: tabsList[0],
+ tabsListParent,
+ tabsList
+ }
+}