fix: Not resend request when hidden document status. (#339)

* fix: Not resend request when hidden document status.

* Validate store data to get documents actions.
pull/3759/head
Edwin Betancourt 2020-02-22 23:46:17 -04:00 committed by GitHub
parent 4c507aa82a
commit 6ce282c65d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 227 additions and 208 deletions

View File

@ -345,12 +345,12 @@ export const contextMixin = {
} }
this.actions = this.metadataMenu.actions this.actions = this.metadataMenu.actions
if (this.panelType === 'window') { if (this.panelType === 'window') {
var processAction = this.actions.find(item => { const processAction = this.actions.find(item => {
if (item.name === 'Procesar Orden' || (item.name === 'Process Order')) { if (item.name === 'Procesar Orden' || (item.name === 'Process Order')) {
return item return item
} }
}) })
this.$store.dispatch('setOrden', processAction) this.$store.dispatch('setOrder', processAction)
} }
if (this.actions && this.actions.length) { if (this.actions && this.actions.length) {

View File

@ -1,7 +1,6 @@
<template> <template>
<span> <span v-if="isContextInfo">
<el-popover <el-popover
v-if="(fieldAttributes.contextInfo && fieldAttributes.contextInfo.isActive) || fieldAttributes.reference.zoomWindowList.length"
ref="contextInfoField" ref="contextInfoField"
placement="top" placement="top"
width="300" width="300"
@ -15,9 +14,7 @@
<span class="custom-tittle-popover"> <span class="custom-tittle-popover">
{{ fieldAttributes.name }} {{ fieldAttributes.name }}
</span> </span>
<template v-if="!isEmptyValue(fieldAttributes.help)"> {{ fieldAttributes.help }}
: {{ fieldAttributes.help }}
</template>
</div> </div>
<template v-for="(zoomItem, index) in fieldAttributes.reference.zoomWindowList"> <template v-for="(zoomItem, index) in fieldAttributes.reference.zoomWindowList">
<el-button <el-button
@ -58,6 +55,9 @@ export default {
} }
}, },
computed: { computed: {
isContextInfo() {
return (this.fieldAttributes.contextInfo && this.fieldAttributes.contextInfo.isActive) || this.fieldAttributes.reference.zoomWindowList.length
},
permissionRoutes() { permissionRoutes() {
return this.$store.getters.permission_routes return this.$store.getters.permission_routes
} }

View File

@ -0,0 +1,141 @@
<template>
<el-popover
v-if="(field.columnName === 'DocStatus') && (!isEmptyValue(processOrderUuid))"
placement="right"
width="400"
trigger="click"
:disabled="withoutRecord"
>
<el-select
v-model="valueActionDocument"
@change="documentActionChange"
@visible-change="listActionDocument"
>
<el-option
v-for="(item, key) in listDocumentActions"
:key="key"
:label="item.name"
:value="item.value"
/>
</el-select>
<el-tag
v-if="isEmptyValue(valueActionDocument)"
:type="tagStatus(field.value)"
>
{{ field.displayColumn }}
</el-tag>
<el-tag
v-else
:type="tagStatus(valueActionDocument)"
>
{{ labelDocumentActions }}
</el-tag>
<p v-if="isEmptyValue(valueActionDocument)"> {{ field.description }} </p>
<p v-else> {{ descriptionDocumentActions }} </p>
<el-button
slot="reference"
type="text"
icon="el-icon-set-up"
/>
</el-popover>
</template>
<script>
export default {
name: 'FieldDocumentStatus',
props: {
field: {
type: Object,
required: true
}
},
data() {
return {
valueActionDocument: ''
}
},
computed: {
withoutRecord() {
// TODO: Validate with record attribute
if (this.isEmptyValue(this.$route.query.action) ||
['create-new', 'reference', 'advancedQuery', 'criteria'].includes(this.$route.query.action)) {
return true
}
return false
},
documentActions() {
return this.$store.getters.getListDocumentActions
},
listDocumentActions() {
return this.documentActions.documentActionsList
},
labelDocumentActions() {
const found = this.listDocumentActions.find(element => {
if (element.value === this.valueActionDocument) {
return element
}
})
if (this.isEmptyValue(found)) {
return this.valueActionDocument
}
return found.name
},
descriptionDocumentActions() {
const found = this.listDocumentActions.find(element => {
if (element.value === this.valueActionDocument) {
return element
}
})
if (this.isEmptyValue(found)) {
return this.valueActionDocument
}
return found.description
},
processOrderUuid() {
return this.$store.getters.getOrders
}
},
methods: {
listActionDocument(isShowList) {
if (isShowList) {
if (!this.withoutRecord && this.$route.query.action !== this.documentActions.recordUuid) {
this.$store.dispatch('listDocumentActionStatus', {
recordUuid: this.$route.query.action,
recordId: this.$route.params.recordId
})
}
}
},
documentActionChange(value) {
this.$store.dispatch('notifyFieldChange', {
parentUuid: this.parentUuid,
containerUuid: this.containerUuid,
columnName: 'DocAction',
isSendToServer: true,
newValue: value
})
const actionProcess = this.$store.getters.getOrders
this.$store.dispatch('startProcess', {
action: {
uuid: actionProcess.uuid,
id: actionProcess.id,
name: actionProcess.name
}, // process metadata
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId,
recordUuid: this.$route.query.action,
parametersList: [{
columnName: 'DocStatus',
value: this.valueActionDocument
}],
isActionDocument: true,
parentUuid: this.parentUuid,
panelType: this.panelType,
containerUuid: this.containerUuid// determinate if get table name and record id (window) or selection (browser)
})
this.valueActionDocument = ''
}
}
}
</script>

View File

@ -25,7 +25,7 @@
:field-value="field.value" :field-value="field.value"
/> />
<field-context-info <field-context-info
v-else-if="(field.contextInfo && field.contextInfo.isActive) || field.reference.zoomWindowList.length" v-else-if="isContextInfo"
key="is-field-context-info" key="is-field-context-info"
:field-attributes="fieldAttributes" :field-attributes="fieldAttributes"
:field-value="field.value" :field-value="field.value"
@ -33,39 +33,12 @@
<span v-else key="is-field-name"> <span v-else key="is-field-name">
{{ isFieldOnly() }} {{ isFieldOnly() }}
</span> </span>
<el-popover
v-if="(field.columnName === 'DocStatus') && (!isEmptyValue(processOrdenUuid))" <field-document-status
placement="right" v-if="isDocuemntStatus"
width="400" :field="fieldAttributes"
trigger="click" />
>
<el-select
v-model="valueActionDocument"
@change="documentActionChange"
>
<el-option
v-for="(item, key) in listDocumentActions"
:key="key"
:label="item.name"
:value="item.value"
/>
</el-select>
<el-tag
v-if="isEmptyValue(valueActionDocument)"
:type="tagStatus(field.value)"
>
{{ field.displayColumn }}
</el-tag>
<el-tag
v-else
:type="tagStatus(valueActionDocument)"
>
{{ labelDocumentActions }}
</el-tag>
<p v-if="isEmptyValue(valueActionDocument)"> {{ field.description }} </p>
<p v-else> {{ descriptionDocumentActions }} </p>
<el-button slot="reference" type="text" icon="el-icon-set-up" @click="listActionDocument" />
</el-popover>
<field-translated <field-translated
v-if="field.isTranslated && !isAdvancedQuery" v-if="field.isTranslated && !isAdvancedQuery"
:field-attributes="fieldAttributes" :field-attributes="fieldAttributes"
@ -92,13 +65,12 @@
<script> <script>
import FieldContextInfo from '@/components/ADempiere/Field/fieldPopovers/fieldContextInfo' import FieldContextInfo from '@/components/ADempiere/Field/fieldPopovers/fieldContextInfo'
import FieldDocumentStatus from '@/components/ADempiere/Field/fieldPopovers/fieldDocumentStatus'
import FieldOperatorComparison from '@/components/ADempiere/Field/fieldPopovers/fieldOperatorComparison' import FieldOperatorComparison from '@/components/ADempiere/Field/fieldPopovers/fieldOperatorComparison'
import FieldTranslated from '@/components/ADempiere/Field/fieldPopovers/fieldTranslated' import FieldTranslated from '@/components/ADempiere/Field/fieldPopovers/fieldTranslated'
import { FIELD_ONLY } from '@/components/ADempiere/Field/references' import { FIELD_ONLY } from '@/components/ADempiere/Field/references'
import { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize' import { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
import { fieldIsDisplayed } from '@/utils/ADempiere' import { fieldIsDisplayed } from '@/utils/ADempiere'
import { showMessage } from '@/utils/ADempiere/notification'
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
/** /**
* This is the base component for linking the components according to the * This is the base component for linking the components according to the
@ -108,6 +80,7 @@ export default {
name: 'FieldDefinition', name: 'FieldDefinition',
components: { components: {
FieldContextInfo, FieldContextInfo,
FieldDocumentStatus,
FieldOperatorComparison, FieldOperatorComparison,
FieldTranslated FieldTranslated
}, },
@ -148,8 +121,7 @@ export default {
}, },
data() { data() {
return { return {
field: {}, field: {}
valueActionDocument: ''
} }
}, },
computed: { computed: {
@ -267,36 +239,22 @@ export default {
} }
return false return false
}, },
listDocumentActions() { processOrderUuid() {
return this.$store.getters.getListDocumentActions.documentActionsList return this.$store.getters.getOrders
}, },
defaultDocumentActions() { isDocuemntStatus() {
return this.$store.getters.getListDocumentActions.defaultDocumentAction if (this.panelType === 'window') {
}, if (this.field.columnName === 'DocStatus' && !this.isEmptyValue(this.processOrderUuid)) {
labelDocumentActions() { return true
const found = this.listDocumentActions.find(element => {
if (element.value === this.valueActionDocument) {
return element
} }
})
if (this.isEmptyValue(found)) {
return this.valueActionDocument
} }
return found.name return false
}, },
descriptionDocumentActions() { isContextInfo() {
const found = this.listDocumentActions.find(element => { if (!this.isAdvancedQuery) {
if (element.value === this.valueActionDocument) { return (this.field.contextInfo && this.field.contextInfo.isActive) || this.field.reference.zoomWindowList.length
return element
}
})
if (this.isEmptyValue(found)) {
return this.valueActionDocument
} }
return found.description return false
},
processOrdenUuid() {
return this.$store.getters.getOrden
} }
}, },
watch: { watch: {
@ -309,42 +267,6 @@ export default {
this.field = this.metadataField this.field = this.metadataField
}, },
methods: { methods: {
showMessage,
listActionDocument() {
this.$store.dispatch('listDocumentActionStatus', {
tableName: 'C_Order',
recordUuid: this.$route.query.action
})
},
documentActionChange(value) {
var actionProcess = this.$store.getters.getOrden
this.$store.dispatch('notifyFieldChange', {
parentUuid: this.parentUuid,
containerUuid: this.containerUuid,
columnName: 'DocAction',
isSendToServer: true,
newValue: value
})
this.$store.dispatch('startProcess', {
action: {
uuid: actionProcess.uuid,
id: actionProcess.id,
name: actionProcess.name
}, // process metadata
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId,
recordUuid: this.$route.query.action,
parametersList: [{
columnName: 'DocStatus',
value: this.valueActionDocument
}],
isActionDocument: true,
parentUuid: this.parentUuid,
panelType: this.panelType,
containerUuid: this.containerUuid// determinate if get table name and record id (window) or selection (browser)
})
this.valueActionDocument = ''
},
isDisplayed() { isDisplayed() {
if (this.isAdvancedQuery) { if (this.isAdvancedQuery) {
return this.field.isShowedFromUser return this.field.isShowedFromUser
@ -424,30 +346,6 @@ export default {
if (this.isDisplayed() && this.isMandatory() && !this.isReadOnly()) { if (this.isDisplayed() && this.isMandatory() && !this.isReadOnly()) {
this.$refs[this.field.columnName].activeFocus() this.$refs[this.field.columnName].activeFocus()
} }
},
redirect({ window, columnName, value }) {
const viewSearch = recursiveTreeSearch({
treeData: this.permissionRoutes,
attributeValue: window.uuid,
attributeName: 'meta',
secondAttribute: 'uuid',
attributeChilds: 'children'
})
if (viewSearch) {
this.$router.push({
name: viewSearch.name,
query: {
action: 'advancedQuery',
tabParent: 0,
[columnName]: value
}
})
} else {
this.showMessage({
type: 'error',
message: this.$t('notifications.noRoleAccess')
})
}
} }
} }
} }

View File

@ -17,7 +17,12 @@ import { requestListDocumentActions } from '@/api/ADempiere/data'
const contextMenu = { const contextMenu = {
state: { state: {
contextMenu: [], contextMenu: [],
listDocumentAction: [] listDocumentAction: {
defaultDocumentAction: undefined,
documentActionsList: [],
recordId: undefined,
recordUuid: undefined
}
}, },
mutations: { mutations: {
setContextMenu(state, payload) { setContextMenu(state, payload) {
@ -34,21 +39,37 @@ const contextMenu = {
setContextMenu({ commit }, payload) { setContextMenu({ commit }, payload) {
commit('setContextMenu', payload) commit('setContextMenu', payload)
}, },
listDocumentActionStatus({ commit }, params) { /**
const tableName = params.tableName * TODO: Verify tableName params to change in constant
const recordId = params.recordId * @param {number} recordId
const recordUuid = params.recordUuid * @param {string} recordUuid
const documentStatus = params.DocStatus */
const documentAction = params.DocAction listDocumentActionStatus({ commit }, {
const pageSize = 0 tableName = 'C_Order',
const pageToken = '' recordId,
requestListDocumentActions({ tableName, recordId, recordUuid, documentStatus, documentAction, pageSize, pageToken }) recordUuid,
.then(response => { documentAction,
var documentAction = { documentStatus
defaultDocumentAction: response.defaultDocumentAction, }) {
documentActionsList: response.documentActionsList requestListDocumentActions({
tableName,
recordId,
recordUuid,
documentAction,
documentStatus,
pageSize: 0,
pageToken: ''
})
.then(responseDocumentActios => {
const documentAction = {
defaultDocumentAction: responseDocumentActios.defaultDocumentAction,
documentActionsList: responseDocumentActios.documentActionsList,
recordId,
recordUuid
} }
commit('listDocumentAction', documentAction) commit('listDocumentAction', documentAction)
return documentAction
}) })
.catch(error => { .catch(error => {
console.warn(error) console.warn(error)
@ -79,6 +100,9 @@ const contextMenu = {
}, },
getListDocumentActions: (state) => { getListDocumentActions: (state) => {
return state.listDocumentAction return state.listDocumentAction
},
getListDocumentActionByUuid: (state) => (recordUuid) => {
return state.listDocumentAction.find(itemDocumentAction => itemDocumentAction.recordUuid === recordUuid)
} }
} }
} }

View File

@ -58,7 +58,7 @@ const utils = {
setProcessTable(state, recordTable) { setProcessTable(state, recordTable) {
state.recordTable = recordTable state.recordTable = recordTable
}, },
setOrden(state, payload) { setOrder(state, payload) {
state.documentAction = payload state.documentAction = payload
}, },
setChatText(state, payload) { setChatText(state, payload) {
@ -146,8 +146,8 @@ const utils = {
setReportTypeToShareLink({ commit }, value) { setReportTypeToShareLink({ commit }, value) {
commit('setReportTypeToShareLink', value) commit('setReportTypeToShareLink', value)
}, },
setOrden({ commit }, params) { setOrder({ commit }, params) {
commit('setOrden', params) commit('setOrder', params)
} }
}, },
getters: { getters: {
@ -209,7 +209,7 @@ const utils = {
getIsReadedOpenRoute: (state) => { getIsReadedOpenRoute: (state) => {
return state.openRoute.isReaded return state.openRoute.isReaded
}, },
getOrden: (state) => { getOrders: (state) => {
return state.documentAction return state.documentAction
}, },
getChatTextLong: (state) => { getChatTextLong: (state) => {

View File

@ -22,7 +22,7 @@
circle circle
style="margin-left: 10px;" style="margin-left: 10px;"
class="el-button-window" class="el-button-window"
@click="handleChangeShowedRecordNavigation(isShowedRecordNavigation)" @click="handleChangeShowedRecordNavigation(false)"
/> />
<el-button <el-button
v-show="!isPanel" v-show="!isPanel"
@ -50,18 +50,12 @@
</div> </div>
</div> </div>
</div> </div>
<i
v-if="isMobile"
class="el-icon-close"
style="position: fixed; padding-top: 15px; color: #000000; font-size: 121%; font-weight: 615 !important; padding-left: 9px;"
@click="handleChangeShowedRecordNavigation(isShowedRecordNavigation)"
/>
</el-aside> </el-aside>
</div> </div>
</template> </template>
<template slot="paneR"> <template slot="paneR">
<el-container style="height: 86vh;"> <el-container style="height: 86vh;">
<Split v-shortkey="['f8']" direction="vertical" @onDrag="onDrag" @shortkey.native="handleChangeShowedRecordNavigation(isShowedRecordNavigation)"> <Split v-shortkey="['f8']" direction="vertical" @onDrag="onDrag" @shortkey.native="handleChangeShowedRecordNavigation(!isShowedRecordNavigation)">
<SplitArea :size="sizeAreaStyle" :style="splitAreaStyle"> <SplitArea :size="sizeAreaStyle" :style="splitAreaStyle">
<el-header style="height: 39px;"> <el-header style="height: 39px;">
<context-menu <context-menu
@ -113,7 +107,7 @@
class="open-navegation" class="open-navegation"
circle circle
type="primary" type="primary"
@click="handleChangeShowedRecordNavigation(isShowedRecordNavigation)" @click="handleChangeShowedRecordNavigation(true)"
/> />
</div> </div>
</div> </div>
@ -255,10 +249,6 @@ export default {
isPanel: false, isPanel: false,
activeInfo: 'listChatEntries', activeInfo: 'listChatEntries',
show: false, show: false,
chatNote: '',
typeAction: 0,
isLoadingFromServer: false,
currentKey: 100,
// TODO: Manage attribute with store // TODO: Manage attribute with store
isShowedRecordPanel: false isShowedRecordPanel: false
} }
@ -386,45 +376,26 @@ export default {
return true return true
}, },
getIsWorkflowLog() { getIsWorkflowLog() {
if (this.isEmptyValue(this.gettersListWorkflow)) { if (this.isEmptyValue(this.$store.getters.getWorkflow)) {
return false return false
} }
return true return true
}, },
getIsChat() {
return this.$store.getters.getIsNote
},
isNote() {
return this.$store.getters.getIsNote
},
gettersListWorkflow() {
return this.$store.getters.getWorkflow
},
getterShowContainerInfo() { getterShowContainerInfo() {
return this.$store.getters.getShowContainerInfo return this.$store.getters.getShowContainerInfo
} }
}, },
watch: { watch: {
$route(value) { $route(value) {
if (value.query.action === 'create-new') { this.$store.dispatch(this.activeInfo, {
this.$store.dispatch(this.activeInfo, { tableName: this.$route.params.tableName,
tableName: this.$route.params.tableName, recordId: this.$route.params.recordId
recordId: this.$route.params.recordId })
}) .then(response => {
.then((response) => { if (value.query.action === 'create-new') {
this.$store.dispatch('isNote', false) this.$store.dispatch('isNote', false)
}) }
} else {
this.$store.dispatch(this.activeInfo, {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
}) })
}
},
'this.$route.params'(newValue, oldValue) {
if (!this.isEmptyValue(newValue)) {
this.getIsRecordLocked()
}
} }
}, },
created() { created() {
@ -449,12 +420,6 @@ export default {
recordId: this.$route.params.recordId recordId: this.$route.params.recordId
}) })
}, },
refres(tabInfo) {
this.$store.dispatch(tabInfo, {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
},
// callback new size // callback new size
onDrag(size) { onDrag(size) {
this.$store.dispatch('setSplitHeightTop', { this.$store.dispatch('setSplitHeightTop', {
@ -468,7 +433,6 @@ export default {
getWindow() { getWindow() {
if (this.getterWindow) { if (this.getterWindow) {
this.generateWindow() this.generateWindow()
this.isLoadingFromServer = true
return return
} }
this.$store.dispatch('getWindowFromServer', { this.$store.dispatch('getWindowFromServer', {
@ -477,7 +441,6 @@ export default {
}) })
.then(response => { .then(response => {
this.generateWindow() this.generateWindow()
this.isLoadingFromServer = true
}) })
}, },
generateWindow() { generateWindow() {
@ -485,23 +448,22 @@ export default {
let isShowRecords = this.isShowedRecordNavigation let isShowRecords = this.isShowedRecordNavigation
if (isShowRecords === undefined) { if (isShowRecords === undefined) {
if (['M', 'Q'].includes(this.windowMetadata.windowType) && this.getterRecordList >= 10) { if ((['M', 'Q'].includes(this.windowMetadata.windowType) && this.getterRecordList >= 10) ||
this.$route.query.action === 'advancedQuery') {
isShowRecords = true isShowRecords = true
} else if (this.windowMetadata.windowType === 'T') { } else if (this.windowMetadata.windowType === 'T') {
isShowRecords = false isShowRecords = false
} else if (this.$route.query.action === 'advancedQuery') {
isShowRecords = true
} }
this.handleChangeShowedRecordNavigation(!isShowRecords)
} }
this.handleChangeShowedRecordNavigation(!isShowRecords)
this.isLoaded = true this.isLoaded = true
}, },
handleChangeShowedRecordNavigation(value) { handleChangeShowedRecordNavigation(valueToChange) {
this.$store.dispatch('changeWindowAttribute', { this.$store.dispatch('changeWindowAttribute', {
parentUuid: this.windowUuid, // act as parentUuid parentUuid: this.windowUuid, // act as parentUuid
attributeName: 'isShowedRecordNavigation', attributeName: 'isShowedRecordNavigation',
attributeValue: !value attributeValue: valueToChange
}) })
}, },
handleChangeShowedPanel(value) { handleChangeShowedPanel(value) {
@ -514,12 +476,6 @@ export default {
attributeName: 'isShowedTabsChildren', attributeName: 'isShowedTabsChildren',
attributeValue: !this.isShowedTabsChildren attributeValue: !this.isShowedTabsChildren
}) })
},
getIsRecordLocked() {
if (this.$store.getters.getRecordPrivateAccess(this.$route.params.tableName, this.$route.params.recordId)) {
return true
}
return false
} }
} }
} }