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 records
pull/3759/head
Leonel Matos 2019-12-03 15:18:16 -04:00 committed by Yamel Senih
parent 73b375ca74
commit 2c35e3f978
14 changed files with 223 additions and 10 deletions

View File

@ -319,6 +319,18 @@ export function getContextInfoValueFromServer({ uuid, query }) {
return Instance.call(this).getContextInfoValue({ uuid: uuid, query: 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) { export function getFavoritesFromServer(userUuid) {
return Instance.call(this).requestFavorites(userUuid) return Instance.call(this).requestFavorites(userUuid)
} }

View File

@ -51,6 +51,8 @@ export function getInfo(token) {
const user = session.getUserinfo() const user = session.getUserinfo()
const response = { const response = {
id: user.getId(),
uuid: user.getUuid(),
name: user.getName(), name: user.getName(),
comments: user.getComments(), comments: user.getComments(),
description: user.getDescription(), description: user.getDescription(),

View File

@ -26,7 +26,7 @@
{{ child.name }} {{ child.name }}
</el-menu-item> </el-menu-item>
</el-submenu> </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 }} {{ action.name }}
</el-menu-item> </el-menu-item>
</template> </template>

View File

@ -275,6 +275,15 @@ export const contextMixin = {
}, },
generateContextMenu() { generateContextMenu() {
this.metadataMenu = this.getterContextMenu 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 this.actions = this.metadataMenu.actions
if (this.actions && this.actions.length) { if (this.actions && this.actions.length) {
@ -401,7 +410,14 @@ export const contextMixin = {
containerUuid: this.containerUuid, containerUuid: this.containerUuid,
recordUuid: this.recordUuid, recordUuid: this.recordUuid,
panelType: this.panelType, 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') { } else if (action.type === 'reference') {
@ -483,6 +499,19 @@ export const contextMixin = {
type: 'success', type: 'success',
duration: 1500 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
}
} }
} }
} }

View File

@ -903,6 +903,10 @@ export default {
query: { query: {
...this.$route.query, ...this.$route.query,
action: row.UUID action: row.UUID
},
params: {
tableName: this.getterPanel.tableName,
recordId: row[`${this.getterPanel.tableName}_ID`]
} }
}) })
} else { } else {

View File

@ -488,6 +488,10 @@ export default {
name: this.$route.name, name: this.$route.name,
query: { query: {
...this.$route.query ...this.$route.query
},
params: {
tableName: this.metadata.tableName,
recordId: this.dataRecords[`${this.metadata.tableName}_ID`]
} }
}) })
this.$store.dispatch('notifyPanelChange', { this.$store.dispatch('notifyPanelChange', {
@ -501,12 +505,13 @@ export default {
}) })
} else { } else {
this.$router.push({ this.$router.push({
name: this.$route.name,
query: { query: {
...this.$route.query, ...this.$route.query,
action: this.dataRecords.UUID 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', { this.$store.dispatch('notifyPanelChange', {
parentUuid: this.parentUuid, parentUuid: this.parentUuid,
containerUuid: this.containerUuid, containerUuid: this.containerUuid,

View File

@ -38,7 +38,9 @@ export default {
copyUnsuccessful: 'Error, unable to copy', copyUnsuccessful: 'Error, unable to copy',
mandatoryFieldMissing: 'Missing fill in the fields ', mandatoryFieldMissing: 'Missing fill in the fields ',
updateFields: 'The record is updated with the field ', 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: { navbar: {
badge: { badge: {
@ -269,6 +271,8 @@ export default {
deleteRecordSuccessful: 'Record deleted successfully', deleteRecordSuccessful: 'Record deleted successfully',
deleteRecordError: 'Error deleting record', deleteRecordError: 'Error deleting record',
selectionRequired: 'You must select a record', selectionRequired: 'You must select a record',
undo: 'Undo' undo: 'Undo',
lockRecord: 'Lock Record',
unlockRecord: 'Unlock Record'
} }
} }

View File

@ -38,7 +38,9 @@ export default {
copyUnsuccessful: 'Error, no se puede copiar', copyUnsuccessful: 'Error, no se puede copiar',
mandatoryFieldMissing: 'Falta completar los campos ', mandatoryFieldMissing: 'Falta completar los campos ',
updateFields: 'Se actualiza el registro con el campo ', 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: { navbar: {
badge: { badge: {
@ -244,6 +246,8 @@ export default {
deleteRecordSuccessful: 'Registro eliminado exitosamente', deleteRecordSuccessful: 'Registro eliminado exitosamente',
deleteRecordError: 'Error al eliminar el regitro', deleteRecordError: 'Error al eliminar el regitro',
selectionRequired: 'Debe seleccionar un registro', selectionRequired: 'Debe seleccionar un registro',
undo: 'Deshacer' undo: 'Deshacer',
lockRecord: 'Bloquear Registro',
unlockRecord: 'Desbloquear Registro'
} }
} }

View File

@ -6,6 +6,9 @@ import {
getDefaultValueFromServer, getDefaultValueFromServer,
convertValueFromGRPC, convertValueFromGRPC,
getContextInfoValueFromServer, getContextInfoValueFromServer,
getPrivateAccessFromServer,
lockPrivateAccessFromServer,
unlockPrivateAccessFromServer,
getFavoritesFromServer, getFavoritesFromServer,
getPendingDocumentsFromServer, getPendingDocumentsFromServer,
requestPrintFormats requestPrintFormats
@ -22,6 +25,7 @@ const data = {
pendingDocuments: [], pendingDocuments: [],
inGetting: [], inGetting: [],
contextInfoField: [], contextInfoField: [],
recordPrivateAccess: {},
printFormatList: [] printFormatList: []
}, },
mutations: { mutations: {
@ -102,6 +106,9 @@ const data = {
setContextInfoField(state, payload) { setContextInfoField(state, payload) {
state.contextInfoField.push(payload) state.contextInfoField.push(payload)
}, },
setPrivateAccess(state, payload) {
state.recordPrivateAccess = payload
},
setPrintFormatList(state, payload) { setPrintFormatList(state, payload) {
state.printFormatList.push(payload) state.printFormatList.push(payload)
} }
@ -836,6 +843,92 @@ const data = {
console.warn(`Error ${error.code} getting context info value for field ${error.message}`) 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) { requestPrintFormats({ commit }, parameters) {
return requestPrintFormats({ processUuid: parameters.processUuid }) return requestPrintFormats({ processUuid: parameters.processUuid })
.then(response => { .then(response => {
@ -988,6 +1081,14 @@ const data = {
info.sqlStatement === sqlStatement 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) => { getPrintFormatList: (state) => (containerUuid) => {
var printFormatList = state.printFormatList.find(list => list.containerUuid === containerUuid) var printFormatList = state.printFormatList.find(list => list.containerUuid === containerUuid)
if (printFormatList) { if (printFormatList) {

View File

@ -322,7 +322,8 @@ const panel = {
newValues: defaultAttributes, newValues: defaultAttributes,
isSendToServer: false, isSendToServer: false,
// if isNewRecord active callouts, if window is closed no send callout // 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 {object} newValues, values to set in panel
* @param {boolean} isSendToServer, indicate if changes send to server * @param {boolean} isSendToServer, indicate if changes send to server
*/ */
notifyPanelChange({ dispatch, getters }, parameters) { notifyPanelChange({ dispatch, getters, rootGetters }, parameters) {
const { const {
parentUuid, parentUuid,
containerUuid, containerUuid,
@ -343,7 +344,8 @@ const panel = {
panelType = 'window', panelType = 'window',
withOutColumnNames = [], withOutColumnNames = [],
isSendCallout = true, isSendCallout = true,
isAdvancedQuery = false isAdvancedQuery = false,
isPrivateAccess = true
} = parameters } = parameters
var { fieldList = [] } = parameters var { fieldList = [] } = parameters
@ -394,6 +396,14 @@ const panel = {
dispatch('setIsloadContext', { dispatch('setIsloadContext', {
containerUuid: containerUuid containerUuid: containerUuid
}) })
if (isPrivateAccess) {
var tableName = rootGetters.getTableNameFromTab(parentUuid, containerUuid)
dispatch('getPrivateAccessFromServer', {
tableName: tableName,
recordId: newValues[`${tableName}_ID`],
userUuid: rootGetters['user/getUserUuid']
})
}
} }
}, },
/** /**

View File

@ -243,6 +243,7 @@ const processControl = {
if (reportType !== 'pdf' && reportType !== 'html') { if (reportType !== 'pdf' && reportType !== 'html') {
link.click() link.click()
} }
// Report views List to context menu // Report views List to context menu
var reportViewList = { var reportViewList = {
name: language.t('views.reportView'), name: language.t('views.reportView'),

View File

@ -134,6 +134,26 @@ const window = {
action: 'undoModifyData', action: 'undoModifyData',
uuidParent: newWindow.uuid, uuidParent: newWindow.uuid,
disabled: false 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 => { const processList = tabItem.getProcessesList().map(processItem => {
return { return {

View File

@ -7,6 +7,7 @@ import { showMessage, convertMapToArrayPairs } from '@/utils/ADempiere'
const state = { const state = {
token: getToken(), token: getToken(),
name: '', name: '',
userUuid: '',
avatar: '', avatar: '',
introduction: '', introduction: '',
rol: {}, // info current rol rol: {}, // info current rol
@ -38,6 +39,9 @@ const mutations = {
SET_ROL: (state, rol) => { SET_ROL: (state, rol) => {
state.rol = rol state.rol = rol
}, },
SET_USER_UUID: (state, payload) => {
state.userUuid = payload
},
setIsSession(state, payload) { setIsSession(state, payload) {
state.isSession = payload state.isSession = payload
}, },
@ -91,6 +95,7 @@ const actions = {
const userInfo = response.getUserinfo() const userInfo = response.getUserinfo()
commit('SET_NAME', userInfo.getName()) commit('SET_NAME', userInfo.getName())
commit('SET_INTRODUCTION', userInfo.getDescription()) commit('SET_INTRODUCTION', userInfo.getDescription())
commit('SET_USER_UUID', userInfo.getUuid())
var defaultContext = convertMapToArrayPairs({ var defaultContext = convertMapToArrayPairs({
toConvert: response.getDefaultcontextMap() toConvert: response.getDefaultcontextMap()
@ -267,6 +272,9 @@ const getters = {
}, },
getIsSession: (state) => { getIsSession: (state) => {
return state.isSession return state.isSession
},
getUserUuid: (state) => {
return state.userUuid
} }
} }

View File

@ -280,6 +280,13 @@ export default {
return false return false
} }
}, },
watch: {
'this.$route.params'(newValue, oldValue) {
if (!this.isEmptyValue(newValue)) {
this.getIsRecordLocked()
}
}
},
created() { created() {
this.getWindow() this.getWindow()
}, },
@ -353,6 +360,12 @@ export default {
containerUuid: this.windowUuid, // act as parentUuid containerUuid: this.windowUuid, // act as parentUuid
isShowedDetail: this.isShowedTabChildren isShowedDetail: this.isShowedTabChildren
}) })
},
getIsRecordLocked() {
if (this.$store.getters.getRecordPrivateAccess(this.$route.params.tableName, this.$route.params.recordId)) {
return true
}
return false
} }
} }
} }