Support to private access feature (#174)
* add feature for go to print format setup window from report viewer * change translation * add feature for field condition in table records * add private access feature * some changes * redefine * add notification for lock and unlock records * bugfix syntax * bugfix lock and unlock recordspull/3759/head
parent
73b375ca74
commit
2c35e3f978
|
@ -319,6 +319,18 @@ export function getContextInfoValueFromServer({ uuid, query }) {
|
|||
return Instance.call(this).getContextInfoValue({ uuid: uuid, query: query })
|
||||
}
|
||||
|
||||
export function getPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid }) {
|
||||
return Instance.call(this).getPrivateAccess({ tableName: tableName, recordId: recordId, userUuid: userUuid })
|
||||
}
|
||||
|
||||
export function lockPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid }) {
|
||||
return Instance.call(this).lockPrivateAccess({ tableName: tableName, recordId: recordId, userUuid: userUuid })
|
||||
}
|
||||
|
||||
export function unlockPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid }) {
|
||||
return Instance.call(this).unlockPrivateAccess({ tableName: tableName, recordId: recordId, userUuid: userUuid })
|
||||
}
|
||||
|
||||
export function getFavoritesFromServer(userUuid) {
|
||||
return Instance.call(this).requestFavorites(userUuid)
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ export function getInfo(token) {
|
|||
const user = session.getUserinfo()
|
||||
|
||||
const response = {
|
||||
id: user.getId(),
|
||||
uuid: user.getUuid(),
|
||||
name: user.getName(),
|
||||
comments: user.getComments(),
|
||||
description: user.getDescription(),
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
{{ child.name }}
|
||||
</el-menu-item>
|
||||
</el-submenu>
|
||||
<el-menu-item v-else :key="index" :index="action.name" :disabled="action.disabled" @click="runAction(action)">
|
||||
<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>
|
||||
|
|
|
@ -275,6 +275,15 @@ export const contextMixin = {
|
|||
},
|
||||
generateContextMenu() {
|
||||
this.metadataMenu = this.getterContextMenu
|
||||
this.$store.dispatch('getPrivateAccessFromServer', {
|
||||
tableName: this.$route.params.tableName,
|
||||
recordId: this.$route.params.recordId
|
||||
})
|
||||
.then(response => {
|
||||
this.$nextTick(() => {
|
||||
this.validatePrivateAccess(response)
|
||||
})
|
||||
})
|
||||
this.actions = this.metadataMenu.actions
|
||||
|
||||
if (this.actions && this.actions.length) {
|
||||
|
@ -401,8 +410,15 @@ export const contextMixin = {
|
|||
containerUuid: this.containerUuid,
|
||||
recordUuid: this.recordUuid,
|
||||
panelType: this.panelType,
|
||||
isNewRecord: action.action === 'resetPanelToNew'
|
||||
isNewRecord: action.action === 'resetPanelToNew',
|
||||
tableName: action.tableName,
|
||||
recordId: action.recordId
|
||||
})
|
||||
.then(response => {
|
||||
if (response && response.isPrivateAccess) {
|
||||
this.validatePrivateAccess(response)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (action.type === 'reference') {
|
||||
this.$store.dispatch('getWindowByUuid', { routes: this.permissionRoutes, windowUuid: action.windowUuid })
|
||||
|
@ -483,6 +499,19 @@ export const contextMixin = {
|
|||
type: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
},
|
||||
validatePrivateAccess(response) {
|
||||
if (response.isLocked) {
|
||||
this.actions.find(item => item.action === 'unlockRecord').hidden = false
|
||||
this.actions.find(item => item.action === 'unlockRecord').tableName = response.tableName
|
||||
this.actions.find(item => item.action === 'unlockRecord').recordId = response.recordId
|
||||
this.actions.find(item => item.action === 'lockRecord').hidden = true
|
||||
} else {
|
||||
this.actions.find(item => item.action === 'lockRecord').hidden = false
|
||||
this.actions.find(item => item.action === 'lockRecord').tableName = response.tableName
|
||||
this.actions.find(item => item.action === 'lockRecord').recordId = response.recordId
|
||||
this.actions.find(item => item.action === 'unlockRecord').hidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -903,6 +903,10 @@ export default {
|
|||
query: {
|
||||
...this.$route.query,
|
||||
action: row.UUID
|
||||
},
|
||||
params: {
|
||||
tableName: this.getterPanel.tableName,
|
||||
recordId: row[`${this.getterPanel.tableName}_ID`]
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
|
|
@ -488,6 +488,10 @@ export default {
|
|||
name: this.$route.name,
|
||||
query: {
|
||||
...this.$route.query
|
||||
},
|
||||
params: {
|
||||
tableName: this.metadata.tableName,
|
||||
recordId: this.dataRecords[`${this.metadata.tableName}_ID`]
|
||||
}
|
||||
})
|
||||
this.$store.dispatch('notifyPanelChange', {
|
||||
|
@ -501,12 +505,13 @@ export default {
|
|||
})
|
||||
} else {
|
||||
this.$router.push({
|
||||
name: this.$route.name,
|
||||
query: {
|
||||
...this.$route.query,
|
||||
action: this.dataRecords.UUID
|
||||
}
|
||||
})
|
||||
this.$route.params['tableName'] = this.metadata.tableName
|
||||
this.$route.params['recordId'] = this.dataRecords[`${this.metadata.tableName}_ID`]
|
||||
this.$store.dispatch('notifyPanelChange', {
|
||||
parentUuid: this.parentUuid,
|
||||
containerUuid: this.containerUuid,
|
||||
|
|
|
@ -38,7 +38,9 @@ export default {
|
|||
copyUnsuccessful: 'Error, unable to copy',
|
||||
mandatoryFieldMissing: 'Missing fill in the fields ',
|
||||
updateFields: 'The record is updated with the field ',
|
||||
invalidEmailFormat: 'Invalid email format'
|
||||
invalidEmailFormat: 'Invalid email format',
|
||||
recordLocked: 'This record has been locked',
|
||||
recordUnlocked: 'This record has been unlocked'
|
||||
},
|
||||
navbar: {
|
||||
badge: {
|
||||
|
@ -269,6 +271,8 @@ export default {
|
|||
deleteRecordSuccessful: 'Record deleted successfully',
|
||||
deleteRecordError: 'Error deleting record',
|
||||
selectionRequired: 'You must select a record',
|
||||
undo: 'Undo'
|
||||
undo: 'Undo',
|
||||
lockRecord: 'Lock Record',
|
||||
unlockRecord: 'Unlock Record'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ export default {
|
|||
copyUnsuccessful: 'Error, no se puede copiar',
|
||||
mandatoryFieldMissing: 'Falta completar los campos ',
|
||||
updateFields: 'Se actualiza el registro con el campo ',
|
||||
invalidEmailFormat: 'Formato de correo electronico invalido'
|
||||
invalidEmailFormat: 'Formato de correo electronico invalido',
|
||||
recordLocked: 'Este registro ha sido bloqueado',
|
||||
recordUnlocked: 'Este registro ha sido desbloqueado'
|
||||
},
|
||||
navbar: {
|
||||
badge: {
|
||||
|
@ -244,6 +246,8 @@ export default {
|
|||
deleteRecordSuccessful: 'Registro eliminado exitosamente',
|
||||
deleteRecordError: 'Error al eliminar el regitro',
|
||||
selectionRequired: 'Debe seleccionar un registro',
|
||||
undo: 'Deshacer'
|
||||
undo: 'Deshacer',
|
||||
lockRecord: 'Bloquear Registro',
|
||||
unlockRecord: 'Desbloquear Registro'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import {
|
|||
getDefaultValueFromServer,
|
||||
convertValueFromGRPC,
|
||||
getContextInfoValueFromServer,
|
||||
getPrivateAccessFromServer,
|
||||
lockPrivateAccessFromServer,
|
||||
unlockPrivateAccessFromServer,
|
||||
getFavoritesFromServer,
|
||||
getPendingDocumentsFromServer,
|
||||
requestPrintFormats
|
||||
|
@ -22,6 +25,7 @@ const data = {
|
|||
pendingDocuments: [],
|
||||
inGetting: [],
|
||||
contextInfoField: [],
|
||||
recordPrivateAccess: {},
|
||||
printFormatList: []
|
||||
},
|
||||
mutations: {
|
||||
|
@ -102,6 +106,9 @@ const data = {
|
|||
setContextInfoField(state, payload) {
|
||||
state.contextInfoField.push(payload)
|
||||
},
|
||||
setPrivateAccess(state, payload) {
|
||||
state.recordPrivateAccess = payload
|
||||
},
|
||||
setPrintFormatList(state, payload) {
|
||||
state.printFormatList.push(payload)
|
||||
}
|
||||
|
@ -836,6 +843,92 @@ const data = {
|
|||
console.warn(`Error ${error.code} getting context info value for field ${error.message}`)
|
||||
})
|
||||
},
|
||||
getPrivateAccessFromServer({ commit, rootGetters }, parameters) {
|
||||
const { tableName, recordId } = parameters
|
||||
const userUuid = rootGetters['user/getUserUuid']
|
||||
return getPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid })
|
||||
.then(privateAccess => {
|
||||
if (privateAccess.getRecordid()) {
|
||||
var recordPrivateAccess = {
|
||||
isLocked: true,
|
||||
tableName: privateAccess.getTablename(),
|
||||
recordId: privateAccess.getRecordid(),
|
||||
userUuid: privateAccess.getUseruuid()
|
||||
}
|
||||
} else {
|
||||
recordPrivateAccess = {
|
||||
isLocked: false,
|
||||
tableName: parameters.tableName,
|
||||
recordId: parameters.recordId,
|
||||
userUuid: rootGetters['user/getUserUuid']
|
||||
}
|
||||
}
|
||||
return recordPrivateAccess
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
})
|
||||
},
|
||||
lockRecord({ commit, rootGetters }, parameters) {
|
||||
const { tableName, recordId } = parameters
|
||||
const userUuid = rootGetters['user/getUserUuid']
|
||||
return lockPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid })
|
||||
.then(response => {
|
||||
if (response.getRecordid()) {
|
||||
const recordLocked = {
|
||||
isPrivateAccess: true,
|
||||
isLocked: true,
|
||||
tableName: response.getTablename(),
|
||||
recordId: response.getRecordid(),
|
||||
userUuid: response.getUseruuid()
|
||||
}
|
||||
showMessage({
|
||||
title: language.t('notifications.succesful'),
|
||||
message: language.t('notifications.recordLocked'),
|
||||
type: 'success'
|
||||
})
|
||||
return recordLocked
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage({
|
||||
title: language.t('notifications.error'),
|
||||
message: language.t('login.unexpectedError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
},
|
||||
unlockRecord({ commit, rootGetters, state }, parameters) {
|
||||
const { tableName, recordId } = parameters
|
||||
const userUuid = rootGetters['user/getUserUuid']
|
||||
return unlockPrivateAccessFromServer({ tableName: tableName, recordId: recordId, userUuid: userUuid })
|
||||
.then(response => {
|
||||
if (response.getRecordid()) {
|
||||
const recordUnlocked = {
|
||||
isPrivateAccess: true,
|
||||
isLocked: false,
|
||||
tableName: response.getTablename(),
|
||||
recordId: response.getRecordid(),
|
||||
userUuid: response.getUseruuid()
|
||||
}
|
||||
showMessage({
|
||||
title: language.t('notifications.succesful'),
|
||||
message: language.t('notifications.recordUnlocked'),
|
||||
type: 'success'
|
||||
})
|
||||
return recordUnlocked
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage({
|
||||
title: language.t('notifications.error'),
|
||||
message: language.t('login.unexpectedError'),
|
||||
type: 'error'
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
},
|
||||
requestPrintFormats({ commit }, parameters) {
|
||||
return requestPrintFormats({ processUuid: parameters.processUuid })
|
||||
.then(response => {
|
||||
|
@ -988,6 +1081,14 @@ const data = {
|
|||
info.sqlStatement === sqlStatement
|
||||
)
|
||||
},
|
||||
getRecordPrivateAccess: (state) => (tableName, recordId) => {
|
||||
if (!isEmptyValue(tableName) && !isEmptyValue(recordId)) {
|
||||
if (state.recordPrivateAccess.tableName === tableName && state.recordPrivateAccess.recordId === recordId) {
|
||||
return state.recordPrivateAccess
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
},
|
||||
getPrintFormatList: (state) => (containerUuid) => {
|
||||
var printFormatList = state.printFormatList.find(list => list.containerUuid === containerUuid)
|
||||
if (printFormatList) {
|
||||
|
|
|
@ -322,7 +322,8 @@ const panel = {
|
|||
newValues: defaultAttributes,
|
||||
isSendToServer: false,
|
||||
// if isNewRecord active callouts, if window is closed no send callout
|
||||
isSendCallout: isNewRecord
|
||||
isSendCallout: isNewRecord,
|
||||
isPrivateAccess: false
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
@ -333,7 +334,7 @@ const panel = {
|
|||
* @param {object} newValues, values to set in panel
|
||||
* @param {boolean} isSendToServer, indicate if changes send to server
|
||||
*/
|
||||
notifyPanelChange({ dispatch, getters }, parameters) {
|
||||
notifyPanelChange({ dispatch, getters, rootGetters }, parameters) {
|
||||
const {
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
|
@ -343,7 +344,8 @@ const panel = {
|
|||
panelType = 'window',
|
||||
withOutColumnNames = [],
|
||||
isSendCallout = true,
|
||||
isAdvancedQuery = false
|
||||
isAdvancedQuery = false,
|
||||
isPrivateAccess = true
|
||||
} = parameters
|
||||
var { fieldList = [] } = parameters
|
||||
|
||||
|
@ -394,6 +396,14 @@ const panel = {
|
|||
dispatch('setIsloadContext', {
|
||||
containerUuid: containerUuid
|
||||
})
|
||||
if (isPrivateAccess) {
|
||||
var tableName = rootGetters.getTableNameFromTab(parentUuid, containerUuid)
|
||||
dispatch('getPrivateAccessFromServer', {
|
||||
tableName: tableName,
|
||||
recordId: newValues[`${tableName}_ID`],
|
||||
userUuid: rootGetters['user/getUserUuid']
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -243,6 +243,7 @@ const processControl = {
|
|||
if (reportType !== 'pdf' && reportType !== 'html') {
|
||||
link.click()
|
||||
}
|
||||
|
||||
// Report views List to context menu
|
||||
var reportViewList = {
|
||||
name: language.t('views.reportView'),
|
||||
|
|
|
@ -134,6 +134,26 @@ const window = {
|
|||
action: 'undoModifyData',
|
||||
uuidParent: newWindow.uuid,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
name: language.t('data.lockRecord'),
|
||||
processName: language.t('data.lockRecord'),
|
||||
type: 'dataAction',
|
||||
action: 'lockRecord',
|
||||
disabled: false,
|
||||
hidden: true,
|
||||
tableName: '',
|
||||
recordId: null
|
||||
},
|
||||
{
|
||||
name: language.t('data.unlockRecord'),
|
||||
processName: language.t('data.unlockRecord'),
|
||||
type: 'dataAction',
|
||||
action: 'unlockRecord',
|
||||
disabled: false,
|
||||
hidden: true,
|
||||
tableName: '',
|
||||
recordId: null
|
||||
})
|
||||
const processList = tabItem.getProcessesList().map(processItem => {
|
||||
return {
|
||||
|
|
|
@ -7,6 +7,7 @@ import { showMessage, convertMapToArrayPairs } from '@/utils/ADempiere'
|
|||
const state = {
|
||||
token: getToken(),
|
||||
name: '',
|
||||
userUuid: '',
|
||||
avatar: '',
|
||||
introduction: '',
|
||||
rol: {}, // info current rol
|
||||
|
@ -38,6 +39,9 @@ const mutations = {
|
|||
SET_ROL: (state, rol) => {
|
||||
state.rol = rol
|
||||
},
|
||||
SET_USER_UUID: (state, payload) => {
|
||||
state.userUuid = payload
|
||||
},
|
||||
setIsSession(state, payload) {
|
||||
state.isSession = payload
|
||||
},
|
||||
|
@ -91,6 +95,7 @@ const actions = {
|
|||
const userInfo = response.getUserinfo()
|
||||
commit('SET_NAME', userInfo.getName())
|
||||
commit('SET_INTRODUCTION', userInfo.getDescription())
|
||||
commit('SET_USER_UUID', userInfo.getUuid())
|
||||
|
||||
var defaultContext = convertMapToArrayPairs({
|
||||
toConvert: response.getDefaultcontextMap()
|
||||
|
@ -267,6 +272,9 @@ const getters = {
|
|||
},
|
||||
getIsSession: (state) => {
|
||||
return state.isSession
|
||||
},
|
||||
getUserUuid: (state) => {
|
||||
return state.userUuid
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -280,6 +280,13 @@ export default {
|
|||
return false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'this.$route.params'(newValue, oldValue) {
|
||||
if (!this.isEmptyValue(newValue)) {
|
||||
this.getIsRecordLocked()
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getWindow()
|
||||
},
|
||||
|
@ -353,6 +360,12 @@ export default {
|
|||
containerUuid: this.windowUuid, // act as parentUuid
|
||||
isShowedDetail: this.isShowedTabChildren
|
||||
})
|
||||
},
|
||||
getIsRecordLocked() {
|
||||
if (this.$store.getters.getRecordPrivateAccess(this.$route.params.tableName, this.$route.params.recordId)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue