1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-11 13:39:48 +08:00

fix: #277 Context menu relations. (#278)

This commit is contained in:
EdwinBetanc0urt 2020-01-29 10:17:48 -04:00 committed by GitHub
parent 182c4c2303
commit d7aaa4fc00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 245 additions and 167 deletions

View File

@ -2,12 +2,12 @@
<div class="container-submenu container-context-menu"> <div class="container-submenu container-context-menu">
<el-menu v-shortkey="{f2: ['f2'], f3: ['f3'], f5: ['f5'], f3:['ctrl', 'd']}" :default-active="activeMenu" :router="false" class="el-menu-demo" mode="horizontal" menu-trigger="hover" unique-opened @select="typeFormat" @shortkey.native="actionContextMenu"> <el-menu v-shortkey="{f2: ['f2'], f3: ['f3'], f5: ['f5'], f3:['ctrl', 'd']}" :default-active="activeMenu" :router="false" class="el-menu-demo" mode="horizontal" menu-trigger="hover" unique-opened @select="typeFormat" @shortkey.native="actionContextMenu">
<template> <template>
<el-submenu v-if="relations !== undefined && relations.length" class="el-menu-item" index="1"> <el-submenu v-if="relationsList !== undefined && relationsList.length" class="el-menu-item" index="1">
<template slot="title"> <template slot="title">
{{ $t('components.contextMenuRelations') }} {{ $t('components.contextMenuRelations') }}
</template> </template>
<el-scrollbar wrap-class="scroll"> <el-scrollbar wrap-class="scroll">
<item v-for="(relation, index) in relations" :key="index" :item="relation" /> <item v-for="(relation, index) in relationsList" :key="index" :item="relation" />
</el-scrollbar> </el-scrollbar>
</el-submenu> </el-submenu>
<el-menu-item v-else disabled index="1"> <el-menu-item v-else disabled index="1">

View File

@ -1,6 +1,6 @@
import { showNotification } from '@/utils/ADempiere/notification' import { showNotification } from '@/utils/ADempiere/notification'
import Item from './items' import Item from './items'
import { convertFieldListToShareLink } from '@/utils/ADempiere/valueUtils' import { convertFieldListToShareLink, recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil' import { supportedTypes, exportFileFromJson } from '@/utils/ADempiere/exportUtil'
import ROUTES from '@/utils/ADempiere/zoomWindow' import ROUTES from '@/utils/ADempiere/zoomWindow'
@ -71,17 +71,6 @@ export const contextMixin = {
getDataSelection() { getDataSelection() {
return this.$store.getters.getDataRecordSelection(this.containerUuid) return this.$store.getters.getDataRecordSelection(this.containerUuid)
}, },
relations() {
if (this.$route.params.menuParentUuid !== undefined) {
return this.$store.getters.getRelations(this.$route.params.menuParentUuid)
} else {
return this.$store.getters.getRelations(this.menuParentUuid).filter(relations => {
if (!relations.hidden) {
return relations
}
})
}
},
getterContextMenu() { getterContextMenu() {
return this.$store.getters.getContextMenu(this.containerUuid) return this.$store.getters.getContextMenu(this.containerUuid)
}, },
@ -97,6 +86,14 @@ export const contextMixin = {
} }
return [] return []
}, },
relationsList() {
let menuUuid = this.$route.params.menuParentUuid
if (this.isEmptyValue(menuUuid)) {
menuUuid = this.menuParentUuid
}
const relations = this.$store.getters.getRelations(menuUuid)
return relations.children
},
permissionRoutes() { permissionRoutes() {
return this.$store.getters.permission_routes return this.$store.getters.permission_routes
}, },
@ -111,7 +108,7 @@ export const contextMixin = {
return this.$store.getters.getFieldsListFromPanel(this.containerUuid) return this.$store.getters.getFieldsListFromPanel(this.containerUuid)
}, },
getterFieldListHeader() { getterFieldListHeader() {
var header = this.getterFieldList.filter(fieldItem => { const header = this.getterFieldList.filter(fieldItem => {
const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic
if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) { if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) {
return fieldItem.name return fieldItem.name
@ -122,7 +119,7 @@ export const contextMixin = {
}) })
}, },
getterFieldListValue() { getterFieldListValue() {
var value = this.getterFieldList.filter(fieldItem => { const value = this.getterFieldList.filter(fieldItem => {
const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic
if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) { if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) {
return fieldItem return fieldItem
@ -412,7 +409,7 @@ export const contextMixin = {
// run process or report // run process or report
const fieldNotReady = this.$store.getters.isNotReadyForSubmit(this.$route.meta.uuid) const fieldNotReady = this.$store.getters.isNotReadyForSubmit(this.$route.meta.uuid)
if (!fieldNotReady) { if (!fieldNotReady) {
var containerParams = this.$route.meta.uuid let containerParams = this.$route.meta.uuid
if (this.lastParameter !== undefined) { if (this.lastParameter !== undefined) {
containerParams = this.lastParameter containerParams = this.lastParameter
} }
@ -429,7 +426,7 @@ export const contextMixin = {
href: window.location.href href: window.location.href
}) })
} }
var reportFormat = action.reportExportType let reportFormat = action.reportExportType
if (this.isEmptyValue(reportFormat)) { if (this.isEmptyValue(reportFormat)) {
if (!this.isEmptyValue(this.$route.query.reportType)) { if (!this.isEmptyValue(this.$route.query.reportType)) {
reportFormat = this.$route.query.reportType reportFormat = this.$route.query.reportType
@ -445,7 +442,7 @@ export const contextMixin = {
containerUuid: containerParams, // EVALUATE IF IS action.uuid containerUuid: containerParams, // EVALUATE IF IS action.uuid
panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser)
reportFormat: reportFormat, // this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType, reportFormat: reportFormat, // this.$route.query.reportType ? this.$route.query.reportType : action.reportExportType,
menuParentUuid: parentMenu, // to load relations in context menu (report view) menuParentUuid: parentMenu, // to load relationsList in context menu (report view)
routeToDelete: this.$route routeToDelete: this.$route
}) })
.catch(error => { .catch(error => {
@ -493,14 +490,17 @@ export const contextMixin = {
}) })
} }
} else if (action.type === 'reference') { } else if (action.type === 'reference') {
this.$store.dispatch('getWindowByUuid', {
routes: this.permissionRoutes,
windowUuid: action.windowUuid
})
if (action.windowUuid && action.recordUuid) { if (action.windowUuid && action.recordUuid) {
var windowRoute = this.$store.getters.getWindowRoute(action.windowUuid) const viewSearch = recursiveTreeSearch({
treeData: this.permissionRoutes,
attributeValue: action.windowUuid,
attributeName: 'meta',
secondAttribute: 'uuid',
attributeChilds: 'children'
})
if (viewSearch) {
this.$router.push({ this.$router.push({
name: windowRoute.name, name: viewSearch.name,
query: { query: {
action: action.type, action: action.type,
referenceUuid: action.uuid, referenceUuid: action.uuid,
@ -510,6 +510,7 @@ export const contextMixin = {
} }
}) })
} }
}
} else if (action.type === 'updateReport') { } else if (action.type === 'updateReport') {
var updateReportParams = { var updateReportParams = {
instanceUuid: action.instanceUuid, instanceUuid: action.instanceUuid,
@ -532,12 +533,15 @@ export const contextMixin = {
this.$store.dispatch('getReportOutputFromServer', updateReportParams) this.$store.dispatch('getReportOutputFromServer', updateReportParams)
.then(response => { .then(response => {
if (!response.isError) { if (!response.isError) {
var link = { let link = {
href: undefined, href: undefined,
download: undefined download: undefined
} }
const blob = new Blob([response.outputStream], { type: response.mimeType }) const blob = new Blob(
[response.outputStream],
{ type: response.mimeType }
)
link = document.createElement('a') link = document.createElement('a')
link.href = window.URL.createObjectURL(blob) link.href = window.URL.createObjectURL(blob)
link.download = response.fileName link.download = response.fileName
@ -554,10 +558,10 @@ export const contextMixin = {
} }
}, },
setShareLink() { setShareLink() {
var shareLink = this.panelType === 'window' || window.location.href.includes('?') ? `${window.location.href}&` : `${window.location.href}?` let shareLink = this.panelType === 'window' || window.location.href.includes('?') ? `${window.location.href}&` : `${window.location.href}?`
if (this.$route.name === 'Report Viewer') { if (this.$route.name === 'Report Viewer') {
var processParameters = convertFieldListToShareLink(this.processParametersExecuted) const processParameters = convertFieldListToShareLink(this.processParametersExecuted)
var reportFormat = this.$store.getters.getReportType const reportFormat = this.$store.getters.getReportType
shareLink = this.$store.getters.getTempShareLink shareLink = this.$store.getters.getTempShareLink
if (String(processParameters).length) { if (String(processParameters).length) {
shareLink += '?' + processParameters shareLink += '?' + processParameters
@ -576,20 +580,17 @@ export const contextMixin = {
} }
}, },
fallbackCopyTextToClipboard(text) { fallbackCopyTextToClipboard(text) {
var textArea = document.createElement('textarea') const textArea = document.createElement('textarea')
textArea.value = text textArea.value = text
document.body.appendChild(textArea) document.body.appendChild(textArea)
textArea.focus() textArea.focus()
textArea.select() textArea.select()
try { try {
var successful = document.execCommand('copy') if (document.execCommand('copy')) {
if (successful) { this.clipboardMessage(this.$t('notifications.copySuccessful'))
var message = this.$t('notifications.copySuccessful')
this.clipboardMessage(message)
} }
} catch (err) { } catch (err) {
message = this.$t('notifications.copyUnsuccessful') this.clipboardMessage(this.$t('notifications.copyUnsuccessful'))
this.clipboardMessage(message)
} }
document.body.removeChild(textArea) document.body.removeChild(textArea)
}, },
@ -600,12 +601,10 @@ export const contextMixin = {
} }
navigator.clipboard.writeText(text) navigator.clipboard.writeText(text)
.then(() => { .then(() => {
var message = this.$t('notifications.copySuccessful') this.clipboardMessage(this.$t('notifications.copySuccessful'))
this.clipboardMessage(message)
}) })
.catch(() => { .catch(() => {
var message = this.$t('notifications.copyUnsuccessful') this.clipboardMessage(this.$t('notifications.copyUnsuccessful'))
this.clipboardMessage(message)
}) })
navigator.clipboard.writeText(text) navigator.clipboard.writeText(text)
}, },

View File

@ -8,7 +8,7 @@
</template> </template>
<el-menu-item-group> <el-menu-item-group>
<el-scrollbar wrap-class="scroll"> <el-scrollbar wrap-class="scroll">
<item v-for="(relation, index) in relations" :key="index" :item="relation" /> <item v-for="(relation, index) in relationsList" :key="index" :item="relation" />
</el-scrollbar> </el-scrollbar>
</el-menu-item-group> </el-menu-item-group>
</el-submenu> </el-submenu>

View File

@ -26,6 +26,7 @@
<script> <script>
import { getPendingDocumentsFromServer } from '@/api/ADempiere/data' import { getPendingDocumentsFromServer } from '@/api/ADempiere/data'
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
export default { export default {
name: 'PendingDocuments', name: 'PendingDocuments',
@ -83,10 +84,16 @@ export default {
}) })
}, },
handleClick(row) { handleClick(row) {
this.$store.dispatch('getWindowByUuid', { routes: this.permissionRoutes, windowUuid: row.windowUuid }) const viewSearch = recursiveTreeSearch({
var windowRoute = this.$store.getters.getWindowRoute(row.windowUuid) treeData: this.permissionRoutes,
attributeValue: row.windowUuid,
attributeName: 'meta',
secondAttribute: 'uuid',
attributeChilds: 'children'
})
if (viewSearch) {
this.$router.push({ this.$router.push({
name: windowRoute.name, name: viewSearch.name,
params: { params: {
...row.criteria ...row.criteria
}, },
@ -94,6 +101,7 @@ export default {
action: 'criteria' action: 'criteria'
} }
}) })
}
// conditions for the registration amount (operador: row.criteria.whereClause) // conditions for the registration amount (operador: row.criteria.whereClause)
}, },
filterResult(search) { filterResult(search) {

View File

@ -31,6 +31,7 @@
<script> <script>
import { getRecentItems as getRecentItemsFromServer } from '@/api/ADempiere' import { getRecentItems as getRecentItemsFromServer } from '@/api/ADempiere'
import { convertAction } from '@/utils/ADempiere/dictionaryUtils' import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
export default { export default {
name: 'RecentItems', name: 'RecentItems',
props: { props: {
@ -91,7 +92,13 @@ export default {
}, },
handleClick(row) { handleClick(row) {
if (!this.isEmptyValue(row.uuidRecord)) { if (!this.isEmptyValue(row.uuidRecord)) {
this.$router.push({ name: row.menuUuid, query: { action: row.uuidRecord, tabParent: 0 }}) this.$router.push({
name: row.menuUuid,
query: {
action: row.uuidRecord,
tabParent: 0
}
})
} else { } else {
this.$router.push({ name: row.menuUuid }) this.$router.push({ name: row.menuUuid })
} }

View File

@ -1,5 +1,6 @@
import { supportedTypes, exportFileFromJson, exportFileZip } from '@/utils/ADempiere/exportUtil' import { supportedTypes, exportFileFromJson, exportFileZip } from '@/utils/ADempiere/exportUtil'
import { showNotification } from '@/utils/ADempiere/notification' import { showNotification } from '@/utils/ADempiere/notification'
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
import { FIELDS_QUANTITY } from '@/components/ADempiere/Field/references' import { FIELDS_QUANTITY } from '@/components/ADempiere/Field/references'
export const menuTableMixin = { export const menuTableMixin = {
@ -324,23 +325,26 @@ export const menuTableMixin = {
}, },
zoomRecord() { zoomRecord() {
const browserMetadata = this.$store.getters.getBrowser(this.$route.meta.uuid) const browserMetadata = this.$store.getters.getBrowser(this.$route.meta.uuid)
const elementName = browserMetadata.fieldList.find(field => field.columnName === browserMetadata.keyColumn).elementName const { elementName } = browserMetadata.fieldList.find(field => field.columnName === browserMetadata.keyColumn)
const records = [] const records = []
this.getDataSelection.forEach(record => { this.getDataSelection.forEach(record => {
if (!isNaN(record[browserMetadata.keyColumn])) { if (isNaN(record[browserMetadata.keyColumn])) {
records.push(Number(record[browserMetadata.keyColumn]))
} else {
records.push(record[browserMetadata.keyColumn]) records.push(record[browserMetadata.keyColumn])
} else {
records.push(Number(record[browserMetadata.keyColumn]))
} }
}) })
this.$store.dispatch('getWindowByUuid', { const viewSearch = recursiveTreeSearch({
routes: this.permissionRoutes, treeData: this.permissionRoutes,
windowUuid: browserMetadata.window.uuid attributeValue: browserMetadata.window.uuid,
attributeName: 'meta',
secondAttribute: 'uuid',
attributeChilds: 'children'
}) })
const windowRoute = this.$store.getters.getWindowRoute(browserMetadata.window.uuid) if (viewSearch) {
this.$router.push({ this.$router.push({
name: windowRoute.name, name: viewSearch.name,
query: { query: {
action: 'advancedQuery', action: 'advancedQuery',
[elementName]: records [elementName]: records
@ -349,3 +353,4 @@ export const menuTableMixin = {
} }
} }
} }
}

View File

@ -104,6 +104,7 @@ 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 { 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
@ -340,14 +341,16 @@ export default {
} }
}, },
redirect({ window, columnName, value }) { redirect({ window, columnName, value }) {
this.$store.dispatch('getWindowByUuid', { const viewSearch = recursiveTreeSearch({
routes: this.permissionRoutes, treeData: this.permissionRoutes,
windowUuid: window.uuid attributeValue: window.uuid,
attributeName: 'meta',
secondAttribute: 'uuid',
attributeChilds: 'children'
}) })
const windowRoute = this.$store.getters.getWindowRoute(window.uuid) if (viewSearch) {
if (windowRoute) {
this.$router.push({ this.$router.push({
name: windowRoute.name, name: viewSearch.name,
query: { query: {
action: 'advancedQuery', action: 'advancedQuery',
tabParent: 0, tabParent: 0,

View File

@ -56,9 +56,10 @@ const staticRoutes = [
// Get Menu from server // Get Menu from server
export function loadMainMenu() { export function loadMainMenu() {
return getMenu(getToken()).then(menu => { return new Promise(resolve => {
getMenu(getToken()).then(menuResponse => {
const asyncRoutesMap = [] const asyncRoutesMap = []
menu.childsList.forEach(menu => { menuResponse.childsList.forEach(menu => {
const optionMenu = getRouteFromMenuItem(menu) const optionMenu = getRouteFromMenuItem(menu)
if (menu.isSummary) { if (menu.isSummary) {
menu.childsList.forEach(menu => { menu.childsList.forEach(menu => {
@ -76,9 +77,10 @@ export function loadMainMenu() {
} }
asyncRoutesMap.push(optionMenu) asyncRoutesMap.push(optionMenu)
}) })
return staticRoutes.concat(asyncRoutesMap) resolve(staticRoutes.concat(asyncRoutesMap))
}).catch(error => { }).catch(error => {
console.warn(`Error getting menu: ${error.message}. Code: ${error.code}`) console.warn(`Error getting menu: ${error.message}. Code: ${error.code}.`)
})
}) })
} }

View File

@ -1,3 +1,4 @@
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils.js'
// Store used for set all related to context menu // Store used for set all related to context menu
// for Window, Process, Smart Browser andother customized component // for Window, Process, Smart Browser andother customized component
// See structure: // See structure:
@ -32,23 +33,17 @@ const contextMenu = {
getContextMenu: (state) => (containerUuid) => { getContextMenu: (state) => (containerUuid) => {
return state.contextMenu.find(item => item.containerUuid === containerUuid) return state.contextMenu.find(item => item.containerUuid === containerUuid)
}, },
getRelations: (state, getters, rootState) => (containerUuid) => { getRelations: (state, getters, rootState, rootGetters) => (containerUuid) => {
var menuRelations const dataTree = rootGetters.permission_routes
rootState.permission.addRoutes.forEach(route => { return recursiveTreeSearch({
if (route.name === containerUuid) { treeData: dataTree,
menuRelations = route.children attributeName: 'name',
} else if (route.name !== containerUuid && route.children) { attributeValue: containerUuid,
route.children.forEach(child => { attributeChilds: 'children'
if (child.name === containerUuid) {
menuRelations = route.children
}
}) })
}
})
return menuRelations
}, },
getActions: (state) => (containerUuid) => { getActions: (state) => (containerUuid) => {
var menu = state.contextMenu.find( const menu = state.contextMenu.find(
item => item.containerUuid === containerUuid item => item.containerUuid === containerUuid
) )
if (menu === undefined) { if (menu === undefined) {

View File

@ -9,7 +9,6 @@ const windowControl = {
state: { state: {
inCreate: [], inCreate: [],
references: [], references: [],
windowRoute: {},
windowOldRoute: { windowOldRoute: {
path: '', path: '',
fullPath: '', fullPath: '',
@ -39,9 +38,6 @@ const windowControl = {
return true return true
}) })
}, },
addWindowRoute(state, payload) {
state.windowRoute = payload
},
setDataLog(state, payload) { setDataLog(state, payload) {
state.dataLog = payload state.dataLog = payload
}, },
@ -407,7 +403,7 @@ const windowControl = {
}) })
}, },
deleteEntity({ dispatch, rootGetters }, parameters) { deleteEntity({ dispatch, rootGetters }, parameters) {
return new Promise((resolve, reject) => { return new Promise(resolve => {
const panel = rootGetters.getPanel(parameters.containerUuid) const panel = rootGetters.getPanel(parameters.containerUuid)
deleteEntity({ deleteEntity({
@ -464,8 +460,7 @@ const windowControl = {
message: language.t('data.deleteRecordError'), message: language.t('data.deleteRecordError'),
type: 'error' type: 'error'
}) })
console.warn(`Delete Entity - Error ${error.message}, Code: ${error.code}`) console.warn(`Delete Entity - Error ${error.message}, Code: ${error.code}.`)
reject(error)
}) })
}) })
}, },
@ -547,7 +542,7 @@ const windowControl = {
message: error.message, message: error.message,
type: 'error' type: 'error'
}) })
console.warn(`Rollback Entity error: ${error.message}`) console.warn(`Rollback Entity error: ${error.message}. Code: ${error.code}.`)
}) })
}, },
setDataLog({ commit }, parameters) { setDataLog({ commit }, parameters) {
@ -597,7 +592,7 @@ const windowControl = {
if (isReference) { if (isReference) {
if (!isEmptyValue(parsedWhereClause)) { if (!isEmptyValue(parsedWhereClause)) {
parsedWhereClause += ' AND ' + referenceWhereClause parsedWhereClause += ` AND ${referenceWhereClause}`
} else { } else {
parsedWhereClause += referenceWhereClause parsedWhereClause += referenceWhereClause
} }
@ -605,7 +600,7 @@ const windowControl = {
if (!isEmptyValue(criteria)) { if (!isEmptyValue(criteria)) {
if (!isEmptyValue(parsedWhereClause)) { if (!isEmptyValue(parsedWhereClause)) {
parsedWhereClause += ' AND ' + criteria.whereClause parsedWhereClause += ` AND ${criteria.whereClause}`
} else { } else {
parsedWhereClause += criteria.whereClause parsedWhereClause += criteria.whereClause
} }
@ -744,15 +739,6 @@ const windowControl = {
}) })
}) })
}, },
getWindowByUuid({ dispatch, commit }, parameters) {
parameters.routes.forEach((routeItem) => {
if (routeItem.meta && routeItem.meta.uuid === parameters.windowUuid) {
commit('addWindowRoute', routeItem)
} else if (routeItem.meta && routeItem.meta.childs && routeItem.meta.childs.length > 0) {
dispatch('getWindowByUuid', { routes: routeItem.meta.childs, windowUuid: parameters.windowUuid })
}
})
},
setWindowOldRoute({ commit }, oldPath = { path: '', fullPath: '', query: {}}) { setWindowOldRoute({ commit }, oldPath = { path: '', fullPath: '', query: {}}) {
commit('setWindowOldRoute', oldPath) commit('setWindowOldRoute', oldPath)
}, },
@ -848,11 +834,6 @@ const windowControl = {
const references = getters.getReferencesList(windowUuid, recordUuid) const references = getters.getReferencesList(windowUuid, recordUuid)
return references.referencesList.find(item => item.uuid === referenceUuid) return references.referencesList.find(item => item.uuid === referenceUuid)
}, },
getWindowRoute: (state) => (windowUuid) => {
if (state.windowRoute && state.windowRoute.meta && state.windowRoute.meta.uuid === windowUuid) {
return state.windowRoute
}
},
getTabSequenceRecord: (state) => { getTabSequenceRecord: (state) => {
return state.tabSequenceRecord return state.tabSequenceRecord
}, },

View File

@ -16,10 +16,10 @@ const mutations = {
const actions = { const actions = {
generateRoutes({ commit }) { generateRoutes({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
return loadMainMenu().then(menu => { loadMainMenu().then(menuResponse => {
commit('SET_ROUTES', menu) commit('SET_ROUTES', menuResponse)
resolve(menu) resolve(menuResponse)
}).catch(err => console.log(err)) })
}) })
} }
} }

View File

@ -1,15 +1,9 @@
import { convertValueFromGRPC } from '@/api/ADempiere/data' import { convertValueFromGRPC } from '@/api/ADempiere/data'
// Decode a HTML text
export function decodeHtml(text) {
var processMetadata = document.createElement('div')
processMetadata.innerHTML = text
return processMetadata.childNodes[0].nodeValue
}
/** /**
* Checks if value is empty. Deep-checks arrays and objects * Checks if value is empty. Deep-checks arrays and objects
* Note: isEmpty([]) == true, isEmpty({}) == true, isEmpty([{0:false},"",0]) == true, isEmpty({0:1}) == false * Note: isEmpty([]) == true, isEmpty({}) == true,
* isEmpty([{0: false}, "", 0]) == true, isEmpty({0: 1}) == false
* @param {boolean|array|object|number|string} value * @param {boolean|array|object|number|string} value
* @returns {boolean} * @returns {boolean}
*/ */
@ -114,28 +108,30 @@ export function clientDateTime(date = null, type = '') {
* @param {object} objectToConvert, object to convert * @param {object} objectToConvert, object to convert
* @param {string} nameKey, name from key in pairs * @param {string} nameKey, name from key in pairs
* @param {string} nameValue, name from value in pairs * @param {string} nameValue, name from value in pairs
* @returns {array} [ { nameKe: key, nameValue: value } ] * @returns {array} [ { nameKey: key, nameValue: value } ]
*/ */
export function convertObjectToArrayPairs(objectToConvert, nameKey = 'columnName', nameValue = 'value') { export function convertObjectToArrayPairs(objectToConvert, nameKey = 'columnName', nameValue = 'value') {
var result = Object.keys(objectToConvert).map(key => { return Object.keys(objectToConvert).map(key => {
var returnPairs = {} const returnPairs = {}
returnPairs[nameKey] = key returnPairs[nameKey] = key
returnPairs[nameValue] = objectToConvert[key] returnPairs[nameValue] = objectToConvert[key]
return returnPairs return returnPairs
}) })
return result
} }
/** /**
* Convert array pairs of object to simple object { key:value } * Convert array pairs of object to simple object { key:value }
* @param {object} objectToConvert, object to convert * @param {array} arrayToConvert, object to convert
* @param {string} nameKey, name from key in pairs * @param {string} nameKey, name from key in pairs
* @param {string} nameValue, name from value in pairs * @param {string} nameValue, name from value in pairs
*/ */
export function convertArrayPairsToObject(arrayToConver, nameKey = 'columnName', nameValue = 'value') { export function convertArrayPairsToObject({
var result = {} arrayToConvert,
arrayToConver.forEach(element => { nameKey = 'columnName',
nameValue = 'value'
}) {
const result = {}
arrayToConvert.forEach(element => {
result[element[nameKey]] = element[nameValue] result[element[nameKey]] = element[nameValue]
}) })
@ -178,7 +174,7 @@ export function convertMapToArrayPairs({
} }
export function convertHasMapToObject(hasMapToConvert) { export function convertHasMapToObject(hasMapToConvert) {
var result = {} const result = {}
hasMapToConvert.forEach((value, key) => { hasMapToConvert.forEach((value, key) => {
result[key] = value result[key] = value
}) })
@ -294,3 +290,76 @@ export function parsedValueComponent({ fieldType, value, referenceType, isMandat
} }
return returnValue return returnValue
} }
/**
* Find element in an array recursively
* @param {object|array} treeData
* @param {string} attributeName, key to get value, default id
* @param {mixed} attributeValue, value to compare with search
* @param {string} attributeChilds, childs list into element
*/
export const recursiveTreeSearch = ({
treeData,
attributeValue,
attributeName = 'id',
secondAttribute = false,
attributeChilds = 'childsList',
isParent = false
}) => {
if (Array.isArray(treeData)) {
let index = 0
const length = treeData.length
while (index < length) {
// ESTA MIERDA NO SIRVE PORQUE LOS ATRIBTO
let value = treeData[index]
if (!isEmptyValue(value) && value.hasOwnProperty(attributeName)) {
value = value[attributeName]
}
if (!isEmptyValue(value) && secondAttribute && value.hasOwnProperty(secondAttribute)) {
value = value[secondAttribute]
}
// compare item to search
if (value === attributeValue) {
return treeData[index]
}
if (treeData[index] && treeData[index][attributeChilds]) {
const found = recursiveTreeSearch({
treeData: treeData[index][attributeChilds],
attributeValue,
attributeName,
secondAttribute,
attributeChilds,
isParent
})
if (found) {
return found
}
}
index++
}
} else {
let value = treeData
if (!isEmptyValue(value) && value.hasOwnProperty(attributeName)) {
value = value[attributeName]
}
if (!isEmptyValue(value) && secondAttribute && value.hasOwnProperty(secondAttribute)) {
value = value[secondAttribute]
}
// compare item to search
if (value === attributeValue) {
return treeData
}
const found = recursiveTreeSearch({
treeData: treeData[attributeChilds],
attributeValue,
attributeName,
secondAttribute,
attributeChilds
})
return found
}
}

View File

@ -117,6 +117,8 @@
</template> </template>
<script> <script>
import { recursiveTreeSearch } from '@/utils/ADempiere/valueUtils'
export default { export default {
name: 'ProcessActivity', name: 'ProcessActivity',
data() { data() {
@ -203,11 +205,16 @@ export default {
} }
}) })
} else if (activity.command === 'zoomIn') { } else if (activity.command === 'zoomIn') {
this.$store.dispatch('getWindowByUuid', { routes: this.permissionRoutes, windowUuid: activity.uuid }) const viewSearch = recursiveTreeSearch({
const processRoute = this.$store.getters.getWindowRoute(activity.uuid) treeData: this.permissionRoutes,
if (!this.isEmptyValue(processRoute)) { attributeValue: activity.uuid,
attributeName: 'meta',
secondAttribute: 'uuid',
attributeChilds: 'children'
})
if (viewSearch) {
this.$router.push({ this.$router.push({
name: processRoute.name, name: viewSearch.name,
query: { query: {
...this.$route.query, ...this.$route.query,
...activity.parametersList ...activity.parametersList

View File

@ -353,6 +353,9 @@ export default {
this.$store.dispatch('setWindowOldRoute', { this.$store.dispatch('setWindowOldRoute', {
path: from.path, path: from.path,
fullPath: from.fullPath, fullPath: from.fullPath,
params: {
...from.params
},
query: { query: {
...from.query ...from.query
} }
@ -361,7 +364,6 @@ export default {
}, },
computed: { computed: {
defaultPorcentSplitPane() { defaultPorcentSplitPane() {
// isShowedRecordPanel ? (isShowedRecordNavigation ? 100 : 50) : (isShowedRecordNavigation ? 50 : -1)
if (this.isShowedRecordPanel) { if (this.isShowedRecordPanel) {
if (this.isShowedRecordNavigation) { if (this.isShowedRecordNavigation) {
return 100 return 100