fix: Export record in table, and mobile support to Smart Browser. (#325)

* fix: Export record in table, and mobile support to Smart Browser.

* Change comparison disabled export record action.

* Closed fotmat exports list in export record action menu.
pull/3759/head
Edwin Betancourt 2020-02-11 17:52:23 -04:00 committed by GitHub
parent ac4b0df91c
commit 252cc43679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 192 additions and 187 deletions

View File

@ -1,6 +1,7 @@
<template>
<div class="container-submenu container-context-menu">
<el-menu
ref="contextMenu"
v-shortkey="{ f2: ['f2'], f3: ['f3'], f5: ['f5'], f3:['ctrl', 'd'] }"
:default-active="activeMenu"
:router="false"
@ -8,120 +9,104 @@
mode="horizontal"
menu-trigger="hover"
unique-opened
@select="typeFormat"
@shortkey.native="actionContextMenu"
>
<template>
<el-submenu v-if="!isEmptyValue(relationsList)" class="el-menu-item" index="1">
<template slot="title">
{{ $t('components.contextMenuRelations') }}
</template>
<el-scrollbar wrap-class="scroll">
<item v-for="(relation, index) in relationsList" :key="index" :item="relation" />
</el-scrollbar>
</el-submenu>
<el-menu-item v-else disabled index="1">
<el-submenu v-if="!isEmptyValue(relationsList)" class="el-menu-item" index="1">
<template slot="title">
{{ $t('components.contextMenuRelations') }}
</el-menu-item>
<el-submenu v-if="actions !== undefined && actions.length" class="el-menu-item" index="2" @click.native="runAction(actions[0])">
<template slot="title">
{{ $t('components.contextMenuActions') }}
</template>
<template v-for="(action, index) in actions">
<el-submenu v-if="action.childs" :key="index" :index="action.name" :disabled="action.disabled">
<template slot="title">
{{ action.name }}
</template>
<el-scrollbar wrap-class="scroll-child">
<el-menu-item
v-for="(child, key) in action.childs"
:key="key"
:index="child.uuid"
@click="runAction(child)"
>
{{ child.name }}
</el-menu-item>
</el-scrollbar>
</el-submenu>
<el-menu-item
v-else
v-show="!action.hidden"
:key="index"
:index="action.name"
:disabled="action.disabled"
@click="runAction(action)"
>
{{ action.name }}
</el-menu-item>
</template>
<el-menu-item v-show="isReport" index="4">
<a :href="downloads" :download="file">
{{ $t('components.contextMenuDownload') }}
</a>
</el-menu-item>
<el-submenu
v-if="getDataSelection.length > 0 && panelType === 'browser'"
:disabled="Boolean(getDataSelection.length < 1)"
index="xlsx"
@click.native="exporBrowser('xlsx')"
>
<template slot="title">
{{ $t('components.contextMennuWindowReport') }}
</template>
<template v-for="(format, index) in option">
<el-menu-item :key="index" :index="index">
{{ format }}
</el-menu-item>
</template>
</el-submenu>
<el-submenu
v-if="panelType === 'window'"
index="xlsx"
@click.native="exporWindow('xlsx')"
>
<template slot="title">
{{ $t('components.contextMennuWindowReport') }}
</template>
<template v-for="(format, index) in option">
<el-menu-item :key="index" :index="index">
{{ format }}
</el-menu-item>
</template>
</el-submenu>
<el-menu-item v-show="$route.name === 'Report Viewer'" index="9" @click="redirect">
{{ $t('components.contextMenuPrintFormatSetup') }}
</el-menu-item>
<el-menu-item v-if="panelType !== 'process'" index="8" @click="refreshData">
{{ $t('components.contextMenuRefresh') }}
</el-menu-item>
<el-menu-item index="5" @click="setShareLink">
{{ $t('components.contextMenuShareLink') }}
</el-menu-item>
</el-submenu>
<el-menu-item v-else disabled index="2">
</template>
<el-scrollbar wrap-class="scroll">
<item v-for="(relation, index) in relationsList" :key="index" :item="relation" />
</el-scrollbar>
</el-submenu>
<el-menu-item v-else disabled index="relations">
{{ $t('components.contextMenuRelations') }}
</el-menu-item>
<el-submenu v-if="actions !== undefined && actions.length" class="el-menu-item" index="actions" @click.native="runAction(actions[0])">
<template slot="title">
{{ $t('components.contextMenuActions') }}
</el-menu-item>
<el-submenu :disabled="!(isReferecesContent && isLoadedReferences)" class="el-menu-item" index="3">
<template slot="title">
{{ $t('components.contextMenuReferences') }}
</template>
<template v-if="references && !isEmptyValue(references.referencesList)">
</template>
<template v-for="(action, index) in actions">
<el-submenu v-if="action.childs" :key="index" :index="action.name" :disabled="action.disabled">
<template slot="title">
{{ action.name }}
</template>
<el-scrollbar wrap-class="scroll-child">
<el-menu-item
v-for="(reference, index) in references.referencesList"
:key="index"
:index="reference.displayName"
@click="runAction(reference)"
v-for="(child, key) in action.childs"
:key="key"
:index="child.uuid"
@click="runAction(child)"
>
{{ reference.displayName }}
{{ child.name }}
</el-menu-item>
</el-scrollbar>
</el-submenu>
<el-menu-item
v-else
v-show="!action.hidden"
:key="index"
:index="action.name"
:disabled="action.disabled"
@click="runAction(action)"
>
{{ action.name }}
</el-menu-item>
</template>
<!-- other actions -->
<el-menu-item v-show="isReport" index="downloadReport">
<a :href="downloads" :download="file">
{{ $t('components.contextMenuDownload') }}
</a>
</el-menu-item>
<el-submenu
v-if="['browser', 'window'].includes(panelType)"
:disabled="isDisabledExportRecord"
index="exportRecord"
@click.native="exportRecord('xlsx')"
>
<template slot="title">
{{ $t('data.exportRecord') }}
</template>
<el-menu-item v-else index="not-references" disabled>
{{ $t('components.withOutReferences') }}
<el-menu-item v-for="(format, keyFormat) in supportedTypes" :key="keyFormat" :index="keyFormat" @click.native="exportRecord(keyFormat)">
{{ format }}
</el-menu-item>
</el-submenu>
</template>
<el-menu-item v-show="$route.name === 'Report Viewer'" index="printFormat" @click="redirect">
{{ $t('components.contextMenuPrintFormatSetup') }}
</el-menu-item>
<el-menu-item v-if="panelType !== 'process'" index="refreshData" @click="refreshData">
{{ $t('components.contextMenuRefresh') }}
</el-menu-item>
<el-menu-item index="shareLink" @click="setShareLink">
{{ $t('components.contextMenuShareLink') }}
</el-menu-item>
</el-submenu>
<el-menu-item v-else disabled index="actionsDisabled">
{{ $t('components.contextMenuActions') }}
</el-menu-item>
<el-submenu :disabled="!(isReferecesContent && isLoadedReferences)" class="el-menu-item" index="references">
<template slot="title">
{{ $t('components.contextMenuReferences') }}
</template>
<template v-if="references && !isEmptyValue(references.referencesList)">
<el-scrollbar wrap-class="scroll-child">
<el-menu-item
v-for="(reference, index) in references.referencesList"
:key="index"
:index="reference.displayName"
@click="runAction(reference)"
>
{{ reference.displayName }}
</el-menu-item>
</el-scrollbar>
</template>
<el-menu-item v-else index="not-references" disabled>
{{ $t('components.withOutReferences') }}
</el-menu-item>
</el-submenu>
</el-menu>
</div>
</template>

View File

@ -48,7 +48,7 @@ export const contextMixin = {
data() {
return {
actions: [],
option: supportedTypes,
supportedTypes: supportedTypes,
references: [],
file: this.$store.getters.getProcessResult.download,
downloads: this.$store.getters.getProcessResult.url,
@ -68,9 +68,6 @@ export const contextMixin = {
}
return path
},
getDataSelection() {
return this.$store.getters.getDataRecordSelection(this.containerUuid)
},
getterContextMenu() {
return this.$store.getters.getContextMenu(this.containerUuid)
},
@ -133,11 +130,20 @@ export const contextMixin = {
}
})
},
isDisabledExportRecord() {
if (this.panelType === 'browser') {
return this.getDataSelection.length < 1
}
return false
},
getterDataRecordsAll() {
return this.$store.getters.getDataRecordAndSelection(this.containerUuid).record
return this.$store.getters.getDataRecordAndSelection(this.containerUuid)
},
getDataSelection() {
return this.getterDataRecordsAll.selection
},
getDataRecord() {
return this.getterDataRecordsAll.filter(fieldItem => {
return this.getterDataRecordsAll.record.filter(fieldItem => {
if (this.recordUuid === fieldItem.UUID) {
return fieldItem
}
@ -186,6 +192,14 @@ export const contextMixin = {
if (this.panelType === 'window' && newValue !== oldValue) {
this.generateContextMenu()
}
},
isDisabledExportRecord(isDisabled) {
if (isDisabled) {
this.$nextTick(() => {
// close childs items in exportRecord menu
this.$refs.contextMenu.close('exportRecord')
})
}
}
},
created() {
@ -276,37 +290,22 @@ export const contextMixin = {
this.isLoadedReferences = false
}
},
typeFormat(key) {
Object.keys(supportedTypes).forEach(type => {
if (type === key && (this.panelType === 'window')) {
this.exporWindow(key)
} else if (type === key && (this.panelType === 'browser')) {
this.exporBrowser(key)
}
})
},
exporBrowser(key) {
exportRecord(fotmatToExport) {
const tHeader = this.getterFieldListHeader
const filterVal = this.getterFieldListValue
const list = this.getDataSelection
let list = []
if (this.panelType === 'window') {
list = this.getDataRecord
} else if (this.panelType === 'browser') {
// TODO: Check usage as the selection is exported with the table menu
list = this.getDataSelection
}
const data = this.formatJson(filterVal, list)
exportFileFromJson({
header: tHeader,
data,
filename: '',
exportType: key
})
},
exporWindow(key) {
const tHeader = this.getterFieldListHeader
const filterVal = this.getterFieldListValue
const list = this.getDataRecord
const data = this.formatJson(filterVal, list)
exportFileFromJson({
header: tHeader,
data,
filename: '',
exportType: key
exportType: fotmatToExport
})
},
formatJson(filterVal, jsonData) {

View File

@ -2,6 +2,7 @@
<div class="container-submenu-mobile container-context-menu">
<right-menu>
<el-menu
ref="contextMenu"
v-shortkey="{ f2: ['f2'], f3: ['f3'], f5: ['f5'], f3:['ctrl', 'd'] }"
:default-active="activeMenu"
:router="false"
@ -11,7 +12,7 @@
unique-opened
style="width: 258px; float: right;"
>
<el-submenu index="1">
<el-submenu index="relations">
<template slot="title">
<svg-icon icon-class="tree" />
{{ $t('components.contextMenuRelations') }}
@ -22,7 +23,8 @@
</el-scrollbar>
</el-menu-item-group>
</el-submenu>
<el-submenu index="2">
<el-submenu index="actions">
<template slot="title">
<svg-icon icon-class="link" />
{{ $t('components.contextMenuActions') }}
@ -59,21 +61,38 @@
{{ action.name }}
</el-menu-item>
</template>
<el-menu-item v-show="isReport" index="4">
<!-- other actions -->
<el-menu-item v-show="isReport" index="downloadReport">
<a :href="downloads" :download="file">
{{ $t('components.contextMenuDownload') }}
</a>
</el-menu-item>
<el-menu-item index="5" @click="setShareLink">
{{ $t('components.contextMenuShareLink') }}
<el-submenu
v-if="['browser', 'window'].includes(panelType)"
:disabled="isDisabledExportRecord"
index="exportRecord"
>
<template slot="title">
{{ $t('data.exportRecord') }}
</template>
<el-menu-item v-for="(format, keyFormat) in supportedTypes" :key="keyFormat" :index="keyFormat" @click.native="exportRecord(keyFormat)">
{{ format }}
</el-menu-item>
</el-submenu>
<el-menu-item v-show="$route.name === 'Report Viewer'" index="printFormat" @click="redirect">
{{ $t('components.contextMenuPrintFormatSetup') }}
</el-menu-item>
<el-menu-item index="6" @click="refreshData">
<el-menu-item v-if="panelType !== 'process'" index="refreshData" @click="refreshData">
{{ $t('components.contextMenuRefresh') }}
</el-menu-item>
<el-menu-item index="shareLink" @click="setShareLink">
{{ $t('components.contextMenuShareLink') }}
</el-menu-item>
</el-scrollbar>
</el-menu-item-group>
</el-submenu>
<el-submenu :disabled="!(isReferecesContent && isLoadedReferences)" class="el-menu-item" index="3">
<el-submenu :disabled="!(isReferecesContent && isLoadedReferences)" class="el-menu-item" index="references">
<template slot="title">
{{ $t('components.contextMenuReferences') }}
</template>

View File

@ -22,7 +22,7 @@
</el-collapse>
<div>
<div v-if="!isMobile">
<table-menu
<table-main-menu
:container-uuid="containerUuid"
:parent-uuid="parentUuid"
:panel-type="panelType"
@ -120,14 +120,14 @@
</div>
</el-header>
<el-main style="padding: 0px !important; overflow: hidden;">
<context-menu
<table-context-menu
v-show="isParent ? getShowContextMenuTable : getShowContextMenuTabChildren"
:style="{ left: left + 'px', top: top + 'px' }"
class="contextmenu"
:container-uuid="containerUuid"
:parent-uuid="parentUuid"
:panel-type="panelType"
:is-option="isOption"
:current-row="currentRowMenu"
:is-panel-window="isPanelWindow"
:process-menu="getterContextMenu"
:is-mobile="isMobile"
@ -247,8 +247,8 @@ import FieldDefinition from '@/components/ADempiere/Field'
import Sortable from 'sortablejs'
import FilterColumns from '@/components/ADempiere/DataTable/filterColumns'
import FixedColumns from '@/components/ADempiere/DataTable/fixedColumns'
import ContextMenu from '@/components/ADempiere/DataTable/menu/contextMenu'
import TableMenu from '@/components/ADempiere/DataTable/menu'
import TableContextMenu from '@/components/ADempiere/DataTable/menu/tableContextMenu'
import TableMainMenu from '@/components/ADempiere/DataTable/menu'
import IconElement from '@/components/ADempiere/IconElement'
import { formatDate } from '@/filters/ADempiere'
import MainPanel from '@/components/ADempiere/Panel'
@ -263,10 +263,10 @@ export default {
FieldDefinition,
FilterColumns,
FixedColumns,
ContextMenu,
IconElement,
MainPanel,
TableMenu
TableContextMenu,
TableMainMenu
},
props: {
parentUuid: {
@ -311,7 +311,7 @@ export default {
return {
top: 0,
left: 0,
isOption: {},
currentRowMenu: {},
currentRow: null,
currentTable: 0,
visible: this.getShowContextMenuTable,
@ -585,7 +585,7 @@ export default {
this.top = event.clientY - 100
}
this.isOption = row
this.currentRowMenu = row
this.visible = true
this.$store.dispatch('showMenuTable', {
isShowedTable: this.isParent

View File

@ -3,7 +3,7 @@
:default-active="menuTable"
:class="classTableMenu + ' menu-table-container'"
mode="horizontal"
@select="typeFormat"
@select="exporRecordTable"
>
<el-submenu index="2">
<template slot="title">
@ -75,11 +75,16 @@
</template>
<script>
import { menuTableMixin } from '@/components/ADempiere/DataTable/menu/mixinMenu'
import { menuTableMixin } from '@/components/ADempiere/DataTable/menu/menuTableMixin'
export default {
name: 'TableMenu',
mixins: [menuTableMixin]
name: 'TableMainMenu',
mixins: [menuTableMixin],
data() {
return {
menuType: 'tableMainMenu'
}
}
}
</script>

View File

@ -17,7 +17,7 @@ export const menuTableMixin = {
type: String,
default: 'window'
},
isOption: {
currentRow: {
type: Object,
default: () => {}
},
@ -53,8 +53,6 @@ export const menuTableMixin = {
classTableMenu() {
if (this.isMobile) {
return 'menu-table-mobile'
} else if (this.$store.state.app.sidebar.opened) {
return 'menu-table'
}
return 'menu-table'
},
@ -78,9 +76,13 @@ export const menuTableMixin = {
},
fieldList() {
if (this.panelMetadata && this.panelMetadata.fieldList) {
let sortAttribute = 'sequence'
if (this.panelType === 'browser') {
sortAttribute = 'seqNoGrid'
}
return this.sortFields(
this.panelMetadata.fieldList,
this.panelType !== 'browser' ? 'seqNoGrid' : 'sequence'
sortAttribute
)
}
return []
@ -159,6 +161,7 @@ export const menuTableMixin = {
methods: {
showNotification,
closeMenu() {
// TODO: Validate to dispatch one action
this.$store.dispatch('showMenuTable', {
isShowedTable: false
})
@ -168,7 +171,7 @@ export const menuTableMixin = {
},
showModalTable(process) {
const processData = this.$store.getters.getProcess(process.uuid)
if (!this.isOption) {
if (!this.currentRow) {
this.$store.dispatch('setProcessSelect', {
selection: this.getDataSelection,
processTablaSelection: true,
@ -176,7 +179,7 @@ export const menuTableMixin = {
})
} else {
let valueProcess
const selection = this.isOption
const selection = this.currentRow
for (const element in selection) {
if (element === this.panelMetadata.keyColumn) {
valueProcess = selection[element]
@ -261,20 +264,15 @@ export const menuTableMixin = {
attributeName: 'isShowedTableOptionalColumns'
})
},
typeFormat(key, keyPath) {
Object.keys(supportedTypes).forEach(type => {
if (type === key) {
this.exporRecordTable(key)
}
})
this.closeMenu()
},
exporRecordTable(key) {
/**
* @param {string} formatToExport
*/
exporRecordTable(formatToExport) {
const header = this.getterFieldListHeader
const filterVal = this.getterFieldListValue
let list = this.getDataSelection
if (this.isOption) {
list = this.gettersRecrdContextMenu
if (this.menuType === 'tableContextMenu') {
list = [this.currentRow]
}
const data = this.formatJson(filterVal, list)
@ -282,8 +280,9 @@ export const menuTableMixin = {
header,
data,
filename: '',
exportType: key
exportType: formatToExport
})
this.closeMenu()
},
exporZipRecordTable() {
const header = this.getterFieldListHeader

View File

@ -2,7 +2,7 @@
<el-menu
:collapse="isCollapse"
class="el-menu-demo"
@select="typeFormat"
@select="exporRecordTable"
>
<el-submenu
index="xlsx"
@ -10,7 +10,7 @@
<template
slot="title"
>
{{ $t('components.contextMennuWindowReport') }}
{{ $t('data.exportRecord') }}
</template>
<template v-for="(format, index) in supportedTypes">
<el-menu-item
@ -22,7 +22,7 @@
</template>
</el-submenu>
<el-menu-item
index="eliminar"
index="delete"
@click="deleteRecord()"
>
{{ $t('window.deleteRecord') }}
@ -39,10 +39,15 @@
</template>
<script>
import { menuTableMixin } from '@/components/ADempiere/DataTable/menu/mixinMenu'
import { menuTableMixin } from '@/components/ADempiere/DataTable/menu/menuTableMixin'
export default {
name: 'ContextMenu',
mixins: [menuTableMixin]
name: 'TableContextMenu',
mixins: [menuTableMixin],
data() {
return {
menuType: 'tableContextMenu'
}
}
}
</script>

View File

@ -131,7 +131,6 @@ export default {
contextMenuShareLink: 'Share Link',
contextMenuRefresh: 'Refresh',
contextMennuExport: 'Export Smart Browser',
contextMennuWindowReport: 'Export Records',
contextMenuPrintFormatSetup: 'Print Format Setup',
dateStartPlaceholder: 'Start date',
dateEndPlaceholder: 'End date',
@ -192,7 +191,6 @@ export default {
},
dataTable: {
search: 'Search',
records: 'Records',
selected: 'Selected',
deleteSelection: 'Delete Selected Records',
advancedQuery: 'Advanced Query',
@ -285,16 +283,15 @@ export default {
}
},
data: {
emtpyTableName: 'Error: Table Name is not defined',
errorGetData: 'Error getting data records',
createRecordSuccessful: 'New record created successfully',
createNewRecord: 'Mode New record',
createRecordError: 'Error creating new record',
deleteRecordSuccessful: 'Record deleted successfully',
deleteRecordError: 'Error deleting record',
exportRecord: 'Export Record',
lockRecord: 'Lock Record',
selectionRequired: 'You must select a record',
undo: 'Undo',
lockRecord: 'Lock Record',
unlockRecord: 'Unlock Record'
},
sequence: {

View File

@ -127,7 +127,6 @@ export default {
contextMenuShareLink: 'Compartir Link',
contextMenuRefresh: 'Actualizar',
contextMennuExport: 'Exportar Smart Browser',
contextMennuWindowReport: 'Exportar Registro',
contextMenuPrintFormatSetup: 'Configurar Formato de Impresión',
RunProcess: 'Ejecutar',
ChangeParameters: 'Cambiar Parametros',
@ -192,7 +191,6 @@ export default {
},
dataTable: {
search: 'Buscar',
records: 'Registros',
selected: 'Seleccionados',
deleteSelection: 'Eliminar Registros Seleccionados',
advancedQuery: 'Consulta Avanzada',
@ -260,16 +258,15 @@ export default {
}
},
data: {
emtpyTableName: 'Error: El nombre de la tabla no esta definida',
errorGetData: 'Error obteniendo los datos de registro',
createRecordSuccessful: 'Nuevo registro creado con exito',
createNewRecord: 'Modo nuevo registro',
createRecordError: 'Error al crear nuevo registro',
deleteRecordSuccessful: 'Registro eliminado exitosamente',
deleteRecordError: 'Error al eliminar el regitro',
exportRecord: 'Exportar Registro',
lockRecord: 'Bloquear Registro',
selectionRequired: 'Debe seleccionar un registro',
undo: 'Deshacer',
lockRecord: 'Bloquear Registro',
unlockRecord: 'Desbloquear Registro'
},
sequence: {

View File

@ -205,7 +205,6 @@ const actions = {
query: route.query,
title: route.meta.title
}
console.log(selectedTag)
if (isCloseAllViews) {
dispatch('tagsView/delAllViews', selectedTag, { root: true })
} else {