fix: Delete record with contextual menu in data table. (#329)
parent
ed74a67ea7
commit
be0e3d8eec
|
@ -61,10 +61,10 @@
|
|||
</a>
|
||||
</el-menu-item>
|
||||
<el-submenu
|
||||
v-if="['browser', 'window'].includes(panelType)"
|
||||
v-if="isManageDataRecords"
|
||||
:disabled="isDisabledExportRecord"
|
||||
index="exportRecord"
|
||||
@click.native="exportRecord('xlsx')"
|
||||
@click.native="exportRecord(defaultFromatExport)"
|
||||
>
|
||||
<template slot="title">
|
||||
{{ $t('data.exportRecord') }}
|
||||
|
@ -76,7 +76,7 @@
|
|||
<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">
|
||||
<el-menu-item v-if="isManageDataRecords" index="refreshData" @click="refreshData">
|
||||
{{ $t('components.contextMenuRefresh') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item index="shareLink" @click="setShareLink">
|
||||
|
|
|
@ -43,6 +43,10 @@ export const contextMixin = {
|
|||
isInsertRecord: {
|
||||
type: Boolean,
|
||||
default: undefined
|
||||
},
|
||||
defaultFromatExport: {
|
||||
type: String,
|
||||
default: 'xlsx'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -172,6 +176,9 @@ export const contextMixin = {
|
|||
},
|
||||
isPersonalLock() {
|
||||
return this.$store.getters['user/getIsPersonalLock']
|
||||
},
|
||||
isManageDataRecords() {
|
||||
return ['browser', 'window'].includes(this.panelType)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -226,9 +233,7 @@ export const contextMixin = {
|
|||
this.$store.dispatch('deleteEntity', {
|
||||
parentUuid: this.parentUuid,
|
||||
containerUuid: this.containerUuid,
|
||||
recordUuid: this.recordUuid,
|
||||
panelType: 'window',
|
||||
isNewRecord: false
|
||||
recordUuid: this.recordUuid
|
||||
})
|
||||
break
|
||||
case 'f5':
|
||||
|
@ -411,18 +416,20 @@ export const contextMixin = {
|
|||
href: window.location.href
|
||||
})
|
||||
}
|
||||
|
||||
let reportFormat = action.reportExportType
|
||||
if (this.isEmptyValue(reportFormat)) {
|
||||
if (!this.isEmptyValue(this.$route.query.reportType)) {
|
||||
reportFormat = this.$route.query.reportType
|
||||
} else if (!this.isEmptyValue(this.$route.meta.reportFormat)) {
|
||||
reportFormat = this.$route.query.reportType
|
||||
if (this.isEmptyValue(reportFormat)) {
|
||||
reportFormat = this.$route.meta.reportFormat
|
||||
} else {
|
||||
reportFormat = 'html'
|
||||
if (this.isEmptyValue(reportFormat)) {
|
||||
reportFormat = 'html'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.$store.dispatch(action.action, {
|
||||
action: action,
|
||||
action,
|
||||
parentUuid: this.containerUuid,
|
||||
containerUuid: containerParams, // EVALUATE IF IS action.uuid
|
||||
panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser)
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</a>
|
||||
</el-menu-item>
|
||||
<el-submenu
|
||||
v-if="['browser', 'window'].includes(panelType)"
|
||||
v-if="isManageDataRecords"
|
||||
:disabled="isDisabledExportRecord"
|
||||
index="exportRecord"
|
||||
>
|
||||
|
@ -82,7 +82,7 @@
|
|||
<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">
|
||||
<el-menu-item v-if="isManageDataRecords" index="refreshData" @click="refreshData">
|
||||
{{ $t('components.contextMenuRefresh') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item index="shareLink" @click="setShareLink">
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
:default-active="menuTable"
|
||||
:class="classTableMenu + ' menu-table-container'"
|
||||
mode="horizontal"
|
||||
@select="exporRecordTable"
|
||||
>
|
||||
<el-submenu index="2">
|
||||
<template slot="title">
|
||||
|
@ -41,15 +40,19 @@
|
|||
<el-submenu
|
||||
:disabled="Boolean(getDataSelection.length < 1)"
|
||||
index="xlsx"
|
||||
@click.native="exporRecordTable(defaultFromatExport)"
|
||||
>
|
||||
<template slot="title">
|
||||
{{ $t('table.dataTable.exportRecordTable') }}
|
||||
</template>
|
||||
<template v-for="(format, index) in supportedTypes">
|
||||
<el-menu-item :key="index" :index="index">
|
||||
{{ format }}
|
||||
</el-menu-item>
|
||||
</template>
|
||||
<el-menu-item
|
||||
v-for="(format, keyFormat) in supportedTypes"
|
||||
:key="keyFormat"
|
||||
:index="keyFormat"
|
||||
@click.native="exporRecordTable(keyFormat)"
|
||||
>
|
||||
{{ format }}
|
||||
</el-menu-item>
|
||||
</el-submenu>
|
||||
<el-menu-item index="optional" @click="showOptionalColums()">
|
||||
{{ $t('components.filterableItems') }}
|
||||
|
@ -61,13 +64,17 @@
|
|||
{{ $t('table.dataTable.showAllAvailableColumns') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item
|
||||
v-if="['browser', 'window'].includes(panelType)"
|
||||
:disabled="isFieldsQuantity"
|
||||
@click="showTotals()"
|
||||
>
|
||||
{{ panelMetadata.isShowedTotals ? $t('table.dataTable.hiddenTotal') : $t('table.dataTable.showTotal') }}
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="!isPanelWindow" :disabled="Boolean(getDataSelection.length < 1)" index="zoom-record" @click="zoomRecord()">
|
||||
<el-menu-item
|
||||
v-if="!isPanelWindow"
|
||||
:disabled="Boolean(getDataSelection.length < 1)"
|
||||
index="zoom-record"
|
||||
@click="zoomRecord()"
|
||||
>
|
||||
{{ $t('table.ProcessActivity.zoomIn') }}
|
||||
</el-menu-item>
|
||||
</el-submenu>
|
||||
|
|
|
@ -40,6 +40,10 @@ export const menuTableMixin = {
|
|||
panelMetadata: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
defaultFromatExport: {
|
||||
type: String,
|
||||
default: 'xlsx'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -232,11 +236,12 @@ export const menuTableMixin = {
|
|||
this.$store.dispatch('deleteSelectionDataList', {
|
||||
parentUuid: this.parentUuid,
|
||||
containerUuid: this.containerUuid
|
||||
})
|
||||
this.$store.dispatch('setRecordSelection', {
|
||||
parentUuid: this.parentUuid,
|
||||
containerUuid: this.containerUuid,
|
||||
panelType: this.panelType
|
||||
}).then(() => {
|
||||
this.$store.dispatch('setRecordSelection', {
|
||||
parentUuid: this.parentUuid,
|
||||
containerUuid: this.containerUuid,
|
||||
panelType: this.panelType
|
||||
})
|
||||
})
|
||||
},
|
||||
addNewRow() {
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
<template>
|
||||
<el-menu
|
||||
:collapse="isCollapse"
|
||||
class="el-menu-demo"
|
||||
@select="exporRecordTable"
|
||||
>
|
||||
<el-submenu
|
||||
index="xlsx"
|
||||
@click.native="exportRecord(defaultFromatExport)"
|
||||
>
|
||||
<template
|
||||
slot="title"
|
||||
>
|
||||
<template slot="title">
|
||||
{{ $t('data.exportRecord') }}
|
||||
</template>
|
||||
<template v-for="(format, index) in supportedTypes">
|
||||
<el-menu-item
|
||||
:key="index"
|
||||
:index="index"
|
||||
>
|
||||
{{ format }}
|
||||
</el-menu-item>
|
||||
</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-if="panelType === 'window'"
|
||||
index="delete"
|
||||
@click="deleteRecord()"
|
||||
>
|
||||
{{ $t('window.deleteRecord') }}
|
||||
</el-menu-item>
|
||||
|
||||
<!-- process associated -->
|
||||
<el-menu-item
|
||||
v-for="(process, key) in processMenu"
|
||||
:key="key"
|
||||
index="process"
|
||||
:index="'process' + key"
|
||||
@click="showModalTable(process)"
|
||||
>
|
||||
{{ process.name }}
|
||||
|
@ -48,6 +48,15 @@ export default {
|
|||
return {
|
||||
menuType: 'tableContextMenu'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteRecord() {
|
||||
this.$store.dispatch('deleteEntity', {
|
||||
parentUuid: this.parentUuid,
|
||||
containerUuid: this.containerUuid,
|
||||
row: this.currentRow
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -408,42 +408,55 @@ const windowControl = {
|
|||
})
|
||||
})
|
||||
},
|
||||
deleteEntity({ dispatch, rootGetters }, parameters) {
|
||||
deleteEntity({ dispatch, rootGetters }, {
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
recordUuid,
|
||||
recordId,
|
||||
row
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
const panel = rootGetters.getPanel(parameters.containerUuid)
|
||||
const panel = rootGetters.getPanel(containerUuid)
|
||||
if (!isEmptyValue(row)) {
|
||||
recordUuid = row.UUID
|
||||
recordId = row[`${panel.tableName}_ID`]
|
||||
}
|
||||
|
||||
deleteEntity({
|
||||
tableName: panel.tableName,
|
||||
recordUuid: parameters.recordUuid
|
||||
recordUuid,
|
||||
recordId
|
||||
})
|
||||
.then(responseDeleteEntity => {
|
||||
// refresh record list
|
||||
dispatch('getDataListTab', {
|
||||
parentUuid: parameters.parentUuid,
|
||||
containerUuid: parameters.containerUuid
|
||||
parentUuid,
|
||||
containerUuid
|
||||
})
|
||||
.then(responseDataList => {
|
||||
// if response is void, go to new record
|
||||
if (responseDataList.length <= 0) {
|
||||
dispatch('resetPanelToNew', {
|
||||
parentUuid: parameters.parentUuid,
|
||||
containerUuid: parameters.containerUuid,
|
||||
panelType: 'window',
|
||||
isNewRecord: true
|
||||
})
|
||||
} else {
|
||||
const oldRoute = router.app._route
|
||||
// else display first record of table in panel
|
||||
router.push({
|
||||
name: oldRoute.name,
|
||||
params: {
|
||||
...oldRoute.params
|
||||
},
|
||||
query: {
|
||||
...oldRoute.query,
|
||||
action: responseDataList[0].UUID
|
||||
}
|
||||
})
|
||||
if (panel.isParentTab) {
|
||||
// if response is void, go to new record
|
||||
if (responseDataList.length <= 0) {
|
||||
dispatch('resetPanelToNew', {
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType: 'window',
|
||||
isNewRecord: true
|
||||
})
|
||||
} else {
|
||||
const oldRoute = router.app._route
|
||||
// else display first record of table in panel
|
||||
router.push({
|
||||
name: oldRoute.name,
|
||||
params: {
|
||||
...oldRoute.params
|
||||
},
|
||||
query: {
|
||||
...oldRoute.query,
|
||||
action: responseDataList[0].UUID
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
showMessage({
|
||||
|
@ -451,13 +464,17 @@ const windowControl = {
|
|||
type: 'success'
|
||||
})
|
||||
|
||||
if (isEmptyValue(recordId)) {
|
||||
// TODO: Verify performance with tableName_ID
|
||||
const fieldId = panel.fieldList.find(itemField => itemField.isKey)
|
||||
recordId = fieldId.value
|
||||
}
|
||||
// set data log to undo action
|
||||
const fieldId = panel.fieldList.find(itemField => itemField.isKey)
|
||||
dispatch('setDataLog', {
|
||||
containerUuid: parameters.containerUuid,
|
||||
containerUuid,
|
||||
tableName: panel.tableName,
|
||||
recordId: fieldId.value, // TODO: Verify performance with tableName_ID
|
||||
recordUuid: parameters.recordUuid,
|
||||
recordId,
|
||||
recordUuid,
|
||||
eventType: 'DELETE'
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue