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

fix: Multiple requests private access. #1299

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
29 changes: 26 additions & 3 deletions src/components/ADempiere/ContainerOptions/LockRecord/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export default defineComponent({
tableName: {
type: String,
required: true
},
isActiveTab: {
type: Boolean,
required: true
}
},

Expand Down Expand Up @@ -156,9 +160,17 @@ export default defineComponent({
}
}

const isGettingRecordAccess = ref(false)

const getPrivateAccess = () => {
const { recordId, recordUuid } = getRecordId()

if (root.isEmptyValue(recordId) && root.isEmptyValue(recordUuid)) {
return
}

isGettingRecordAccess.value = true

root.$store.dispatch('getPrivateAccessFromServer', {
tableName,
recordId,
Expand All @@ -171,11 +183,22 @@ export default defineComponent({
isLocked.value = false
}
})
.finally(() => {
isGettingRecordAccess.value = false
})
}

watch(() => root.$route.query.action, (newValue) => {
if (isValidUuid(newValue)) {
getPrivateAccess()
// timer to execute the request between times
const timeOut = ref(() => {})

watch(() => root.$route.query.action, (newValue, oldValue) => {
if (props.isActiveTab && isValidUuid(newValue) && !isGettingRecordAccess.value) {
clearTimeout(timeOut.value)

timeOut.value = setTimeout(() => {
// get records
getPrivateAccess()
}, 1000)
}
})

Expand Down
12 changes: 7 additions & 5 deletions src/components/ADempiere/TabManager/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
>
<lock-record
slot="label"
:is-active-tab="tabAttributes.uuid === tabUuid"
:tab-position="isParentTabs ? key : 1"
:tab-uuid="tabAttributes.uuid"
:table-name="tabAttributes.tableName"
Expand Down Expand Up @@ -100,11 +101,12 @@
<script>
import { defineComponent, computed, ref } from '@vue/composition-api'

import AuxiliaryPanel from '@/components/ADempiere/AuxiliaryPanel'
import DefaultTable from '@/components/ADempiere/DefaultTable'
import LockRecord from '@/components/ADempiere/ContainerOptions/LockRecord'
import PanelDefinition from '@/components/ADempiere/PanelDefinition'
import RecordNavigation from '@/components/ADempiere/RecordNavigation'
// components
import AuxiliaryPanel from '@/components/ADempiere/AuxiliaryPanel/index.vue'
import DefaultTable from '@/components/ADempiere/DefaultTable/index.vue'
import LockRecord from '@/components/ADempiere/ContainerOptions/LockRecord/index.vue'
import PanelDefinition from '@/components/ADempiere/PanelDefinition/index.vue'
import RecordNavigation from '@/components/ADempiere/RecordNavigation/index.vue'

export default defineComponent({
name: 'TabManager',
Expand Down