feat: Load basic data with tab (#951)
* feat: Load basic data into tab * change with clickpull/3759/head
							parent
							
								
									fb3ae87a3d
								
							
						
					
					
						commit
						1a51f6bce9
					
				| 
						 | 
				
			
			@ -244,8 +244,9 @@ export default {
 | 
			
		|||
        // TODO: Evaluate record uuid without route.action
 | 
			
		||||
        // edit mode is diferent to create new
 | 
			
		||||
        let isWithRecord = this.field.recordUuid !== 'create-new'
 | 
			
		||||
        // TODO: Remove false condition to production
 | 
			
		||||
        // evaluate context
 | 
			
		||||
        if ((this.preferenceClientId !== this.metadataField.clientId) && isWithRecord) {
 | 
			
		||||
        if ((this.preferenceClientId !== this.metadataField.clientId && 1 === 2) && isWithRecord) {
 | 
			
		||||
          return true
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -157,6 +157,8 @@ export default {
 | 
			
		|||
      }
 | 
			
		||||
    },
 | 
			
		||||
    actionKeyPerformed(value) {
 | 
			
		||||
      // TODO: Delete for production
 | 
			
		||||
      console.info('actionKeyPerformed ', value)
 | 
			
		||||
      if (this.metadata.handleActionKeyPerformed) {
 | 
			
		||||
        this.$store.dispatch('notifyActionKeyPerformed', {
 | 
			
		||||
          containerUuid: this.metadata.containerUuid,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@
 | 
			
		|||
        :windowuuid="windowUuid"
 | 
			
		||||
        :tabuuid="tabAttributes.uuid"
 | 
			
		||||
        :name="String(key)"
 | 
			
		||||
        :tabindex="String(key)"
 | 
			
		||||
        lazy
 | 
			
		||||
        :disabled="isDisabledTab(key)"
 | 
			
		||||
        :style="tabStyle"
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +54,7 @@
 | 
			
		|||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import { defineComponent, computed, ref, watch } from '@vue/composition-api'
 | 
			
		||||
import { defineComponent, computed, ref } from '@vue/composition-api'
 | 
			
		||||
 | 
			
		||||
import PanelDefinition from '@/components/ADempiere/PanelDefinition'
 | 
			
		||||
import LockRecord from '@/components/ADempiere/ContainerOptions/LockRecord'
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +83,10 @@ export default defineComponent({
 | 
			
		|||
  },
 | 
			
		||||
 | 
			
		||||
  setup(props, { root }) {
 | 
			
		||||
    const currentTab = ref(root.$route.query.tab)
 | 
			
		||||
    // if tabParent is present in path set this
 | 
			
		||||
    const tabNo = root.$route.query.tab || '0'
 | 
			
		||||
    const currentTab = ref(tabNo)
 | 
			
		||||
 | 
			
		||||
    const tabUuid = ref(props.tabsList[0].uuid)
 | 
			
		||||
 | 
			
		||||
    const tabStyle = computed(() => {
 | 
			
		||||
| 
						 | 
				
			
			@ -112,22 +116,23 @@ export default defineComponent({
 | 
			
		|||
     * @param {object} tabHTML DOM HTML the tab clicked
 | 
			
		||||
     */
 | 
			
		||||
    const handleClick = (tabHTML) => {
 | 
			
		||||
      tabUuid.value = tabHTML.$attrs.tabuuid
 | 
			
		||||
      setCurrentTab()
 | 
			
		||||
      setTabNumber(tabHTML.index)
 | 
			
		||||
      const { tabuuid, tabindex } = tabHTML.$attrs
 | 
			
		||||
      if (tabUuid.value !== tabuuid) {
 | 
			
		||||
        tabUuid.value = tabuuid
 | 
			
		||||
        setCurrentTab()
 | 
			
		||||
      }
 | 
			
		||||
      if (currentTab.value !== tabindex) {
 | 
			
		||||
        setTabNumber(tabindex)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // watch router query tab parent value
 | 
			
		||||
    watch(() => root.$route.query.tab, (newValue) => {
 | 
			
		||||
      if (root.isEmptyValue(newValue)) {
 | 
			
		||||
        setTabNumber('0')
 | 
			
		||||
        return
 | 
			
		||||
    const setTabNumber = (tabNumber = '0') => {
 | 
			
		||||
      if (root.isEmptyValue(tabNumber)) {
 | 
			
		||||
        tabNumber = '0'
 | 
			
		||||
      }
 | 
			
		||||
      if (tabNumber !== currentTab.value) {
 | 
			
		||||
        currentTab.value = tabNumber
 | 
			
		||||
      }
 | 
			
		||||
      setTabNumber(newValue)
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    const setTabNumber = (tabNumber) => {
 | 
			
		||||
      currentTab.value = tabNumber
 | 
			
		||||
 | 
			
		||||
      root.$router.push({
 | 
			
		||||
        query: {
 | 
			
		||||
| 
						 | 
				
			
			@ -141,8 +146,23 @@ export default defineComponent({
 | 
			
		|||
 | 
			
		||||
      // TODO: Delete this to production
 | 
			
		||||
      console.log('Click tab number ', tabNumber)
 | 
			
		||||
      return tabNumber
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const getData = () => {
 | 
			
		||||
      root.$store.dispatch('getDataListTab', {
 | 
			
		||||
        parentUuid: props.windowUuid,
 | 
			
		||||
        containerUuid: tabUuid.value
 | 
			
		||||
      })
 | 
			
		||||
        .catch(error => {
 | 
			
		||||
          console.warn(`Error getting data list tab. Message: ${error.message}, code ${error.code}.`)
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getData()
 | 
			
		||||
 | 
			
		||||
    setTabNumber(currentTab.value)
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
      currentTab,
 | 
			
		||||
      tabUuid,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -317,7 +317,7 @@ const window = {
 | 
			
		|||
        let isTabsChildren = false
 | 
			
		||||
        if (!isAdvancedQuery) {
 | 
			
		||||
          const window = getters.getWindow(parentUuid)
 | 
			
		||||
          if (window) {
 | 
			
		||||
          if (window && window.tabsListChildren) {
 | 
			
		||||
            isTabsChildren = Boolean(window.tabsListChildren.length)
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,6 @@ export default defineComponent({
 | 
			
		|||
  },
 | 
			
		||||
 | 
			
		||||
  setup(props, { root }) {
 | 
			
		||||
    const panelType = 'window'
 | 
			
		||||
    const isLoaded = ref(false)
 | 
			
		||||
    const windowMetadata = ref({})
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -77,27 +76,28 @@ export default defineComponent({
 | 
			
		|||
      isLoaded.value = true
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const getterWindow = computed(() => {
 | 
			
		||||
    const storedWindow = computed(() => {
 | 
			
		||||
      return root.$store.getters.getWindow(windowUuid)
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    // get window from vuex store or request from server
 | 
			
		||||
    const getWindow = () => {
 | 
			
		||||
      const window = storedWindow.value
 | 
			
		||||
      if (!root.isEmptyValue(window)) {
 | 
			
		||||
        generateWindow(window)
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // metadata props use for test
 | 
			
		||||
      if (!root.isEmptyValue(props.metadata)) {
 | 
			
		||||
        return new Promise(resolve => {
 | 
			
		||||
          const windowResponse = generateWindowRespose(props.metadata)
 | 
			
		||||
          root.$store.commit('addWindow', windowResponse)
 | 
			
		||||
          generateWindow(windowResponse)
 | 
			
		||||
          resolve(windowResponse)
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const window = getterWindow.value
 | 
			
		||||
      if (!root.isEmptyValue(window)) {
 | 
			
		||||
        generateWindow(window)
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      root.$store.dispatch('getWindowFromServer', {
 | 
			
		||||
        windowUuid,
 | 
			
		||||
        routeToDelete: root.$route
 | 
			
		||||
| 
						 | 
				
			
			@ -131,11 +131,9 @@ export default defineComponent({
 | 
			
		|||
    getWindow()
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
      panelType,
 | 
			
		||||
      windowUuid,
 | 
			
		||||
      windowMetadata,
 | 
			
		||||
      // computed
 | 
			
		||||
      getterWindow,
 | 
			
		||||
      renderWindowComponent,
 | 
			
		||||
      isLoaded
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue