Skip to content

Commit

Permalink
feat: Add delete record (#1190)
Browse files Browse the repository at this point in the history
* feat: Add window support ReadOnly field.

* enable client validation.

* feat: Actions menu

* feat: Add delete record.

* remove deprecated getEntities

* change run actions
  • Loading branch information
EdwinBetanc0urt authored Sep 12, 2021
1 parent df00769 commit 16a4128
Show file tree
Hide file tree
Showing 18 changed files with 374 additions and 312 deletions.
61 changes: 3 additions & 58 deletions src/api/ADempiere/common/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ export function rollbackEntity({
})
}

// Get entity from table name and record id or record uuid
/**
* Get entity from table name and record id or record uuid
*/
export function getEntity({
tableName,
recordId,
Expand All @@ -159,60 +161,3 @@ export function getEntity({
return convertEntity(entityResponse)
})
}

/**
* Object List from window
* @param {string} tableName
* @param {string} query
* @param {string} whereClause
* @param {array} conditionsList
* @param {array} columnsList // TODO: Add support on adempiere-vue
* @param {string} orderByClause
* @param {string} pageToken
*/
export function getEntities({
tableName,
query,
whereClause,
conditionsList = [],
columnsList = [],
orderByClause,
limit,
pageToken,
pageSize
}) {
const filters = conditionsList.map(condition => {
const { value, operator, columnName, valueTo, values } = condition
return {
column_name: columnName,
value,
operator,
value_to: valueTo,
values
}
})

return request({
url: '/common/api/entites',
method: 'get',
params: {
table_name: tableName,
// DSL Query
filters,
columns: columnsList,
// Custom Query
query,
where_clause: whereClause,
order_by_clause: orderByClause,
limit,
// Page Data
pageToken,
pageSize
}
})
.then(entitiesListResponse => {
const { convertEntityList } = require('@/utils/ADempiere/apiConverts/persistence.js')

return convertEntityList(entitiesListResponse)
})
}
64 changes: 23 additions & 41 deletions src/components/ADempiere/ActionMenu/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
type="primary"
trigger="click"
class="menu-actions"
@command="clickRunAction"
@click="runAction(defaultActionToRun)"
@command="runAction"
@click="runDefaultAction"
>
{{ defaultActionName }}

Expand Down Expand Up @@ -135,15 +135,17 @@ export default defineComponent({
setup(props, { root }) {
const {
parentUuid,
containerUuid,
tableName
} = props.actionsManager
const actionsList = ref(
props.actionsManager.actionsList({ uuid: containerUuid, tableName })
props.actionsManager.getActionList()
)
const recordUuid = computed(() => {
// TODO: Change query name 'action'
const { action } = root.$route.query
return action
})
Expand Down Expand Up @@ -178,56 +180,36 @@ export default defineComponent({
return actionsList.value[0]
})
const clickRunAction = (action) => {
console.log('clickRunAction', action)
}
const runAction = (action) => {
console.log('runAction', action)
action.callBack()
/**
* Run default action with last parameters
*/
function runDefaultAction() {
runAction(defaultActionToRun.value)
} // end runAction
/**
* Get element-ui icon from action
* Run selected action
* @param {object} action
*/
const iconAction = ({ type, action }) => {
let icon = 'el-icon-setting'
if (type === 'dataAction') {
switch (action) {
case 'setDefaultValues':
icon = 'el-icon-circle-plus-outline'
break
case 'deleteEntity':
icon = 'el-icon-delete'
break
case 'undoModifyData':
icon = 'el-icon-refresh-left'
break
case 'lockRecord':
icon = 'el-icon-lock'
break
case 'unlockRecord':
icon = 'el-icon-unlock'
break
case 'recordAccess':
icon = 'el-icon-c-scale-to-original'
break
}
}
return icon
function runAction(action) {
const { actionName } = action
action[actionName]({
root,
parentUuid,
containerUuid,
tableName,
recordUuid: recordUuid.value,
uuid: action.uuid
})
}
return {
// size: pro,
actionsList,
// computeds
defaultActionName,
defaultActionToRun,
// methods
runAction,
clickRunAction,
iconAction
runDefaultAction
}
}
})
Expand Down
15 changes: 15 additions & 0 deletions src/lang/ADempiere/en/actionMenu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Edwin Betancourt [email protected] www.erpya.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

const actionMenu = {
// actions
Expand Down
22 changes: 22 additions & 0 deletions src/lang/ADempiere/en/recordManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Edwin Betancourt [email protected] www.erpya.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

const recordManager = {
deleteRecordSuccessful: 'Record deleted successfully',
deleteRecordError: 'Error deleting record'
}

export default recordManager
17 changes: 16 additions & 1 deletion src/lang/ADempiere/es/actionMenu.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Edwin Betancourt [email protected] www.erpya.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

const actionMenu = {
// actions
refreshRecords: 'Refrescar Registros',
deleteRecord: 'Eliminar Registro',
createNewRecord: 'Nuevo Registro',
shareLink: 'Compartir Enlace',
withoutActions: 'Sin Actions',
withoutActions: 'Sin Actiones',
// relations
relations: 'Relaciones',
withoutRelations: 'Sin Relaciones',
Expand Down
2 changes: 2 additions & 0 deletions src/lang/ADempiere/es/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

import actionMenu from './actionMenu'
import recordManager from './recordManager'

export default {
actionMenu,
recordManager,

language: 'Idioma',
route: {
Expand Down
22 changes: 22 additions & 0 deletions src/lang/ADempiere/es/recordManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
// Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A.
// Contributor(s): Edwin Betancourt [email protected] www.erpya.com
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

const recordManager = {
deleteRecordSuccessful: 'Registro eliminado exitosamente',
deleteRecordError: 'Error al eliminar el regitro'
}

export default recordManager
Loading

0 comments on commit 16a4128

Please sign in to comment.