Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Delete selected records (#215)
Browse files Browse the repository at this point in the history
* Delete selected records

* Update window.js

Co-authored-by: Edwin Betancourt <[email protected]>
  • Loading branch information
elsiosanchez and EdwinBetanc0urt authored Jun 29, 2022
1 parent aeb5ffd commit c42a7d9
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions src/utils/ADempiere/dictionary/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,33 @@ export const deleteRecord = {
name: language.t('actionMenu.deleteRecord'),
enabled: ({ parentUuid, containerUuid }) => {
const tab = store.getters.getStoredTab(parentUuid, containerUuid)
// TODO: Verify index Parent Tab
if (tab.isParentTab && tab.index > 0) {
return false
}
if (tab.isDeleteable && !tab.isReadOnly) {
const recordUuid = store.getters.getUuidOfContainer(containerUuid)
if (!isEmptyValue(recordUuid) && recordUuid !== 'create-new') {
// client id value of record
const clientIdRecord = store.getters.getValueOfField({
parentUuid,
containerUuid,
columnName: CLIENT
const preferenceClientId = store.getters.getSessionContextClientId
if (tab.isShowedTableRecords) {
const selectionsRecords = store.getters.getTabSelectionsList({
containerUuid
})
// evaluate client id context with record
const preferenceClientId = store.getters.getSessionContextClientId
return clientIdRecord === preferenceClientId
if (isEmptyValue(selectionsRecords)) {
return false
}
const isOtherClient = selectionsRecords.some(record => record[CLIENT] !== preferenceClientId)
return !isOtherClient
} else {
const recordUuid = store.getters.getUuidOfContainer(containerUuid)
if (!isEmptyValue(recordUuid) && recordUuid !== 'create-new') {
// client id value of record
const clientIdRecord = store.getters.getValueOfField({
parentUuid,
containerUuid,
columnName: CLIENT
})
// evaluate client id context with record
return clientIdRecord === preferenceClientId
}
}
}

Expand All @@ -215,6 +230,22 @@ export const deleteRecord = {
return false
}

// delete selection of records on table
if (tab.isShowedTableRecords) {
const selectionsRecords = store.getters.getTabSelectionsList({
containerUuid
})
if (isEmptyValue(selectionsRecords)) {
return false;
}
store.dispatch('deleteSelectedRecordsFromWindow', {
parentUuid,
containerUuid
})
return
}

// delete record on panel
store.dispatch('deleteEntity', {
parentUuid,
containerUuid,
Expand Down

0 comments on commit c42a7d9

Please sign in to comment.