Support Documents Pendings (#189)

* Support Documents Pendings

* Bugfix syntax

* route getters according to the role

* add send criteria from list of documents pendings

* change translations
pull/3759/head
elsiosanchez 2019-12-03 15:04:33 -04:00 committed by Yamel Senih
parent 929301579c
commit 73b375ca74
12 changed files with 221 additions and 9 deletions

View File

@ -322,6 +322,9 @@ export function getContextInfoValueFromServer({ uuid, query }) {
export function getFavoritesFromServer(userUuid) {
return Instance.call(this).requestFavorites(userUuid)
}
export function getPendingDocumentsFromServer(userUuid, roleUuid) {
return Instance.call(this).requestPendingDocuments(userUuid, roleUuid)
}
export function requestReportViews({ tableName, processUuid }) {
return Instance.call(this).requestReportViews({ tableName: tableName, processUuid: processUuid })

View File

@ -365,7 +365,8 @@ export default {
isLoadAllRecords: true,
isReference: false,
isNewRecord: false,
isWindow: true
isWindow: true,
criteria: {}
}
if (this.isPanelWindow) {
// TODO: use action notifyPanelChange with isShowedField in true
@ -399,7 +400,14 @@ export default {
parameters.referenceWhereClause = referenceInfo.whereClause
} else if (route.query.action && route.query.action === 'create-new') {
parameters.isNewRecord = true
} else if (route.query.action && route.query.action !== 'create-new' && route.query.action !== 'reference' && route.query.action !== 'advancedQuery') {
} else if (route.query.action && route.query.action === 'criteria') {
route.params.isReadParameters = true
Object.keys(route.params).forEach(param => {
if (!this.isEmptyValue(route.params[param])) {
parameters.criteria[param] = route.params[param]
}
})
} else if (route.query.action && route.query.action !== 'create-new' && route.query.action !== 'reference' && route.query.action !== 'advancedQuery' && route.query.action !== 'criteria') {
parameters.isLoadAllRecords = false
parameters.value = route.query.action
parameters.tableName = this.metadata.tableName
@ -462,7 +470,8 @@ export default {
isReference: parameters.isReference,
referenceWhereClause: parameters.referenceWhereClause,
columnName: parameters.columnName,
value: parameters.value
value: parameters.value,
criteria: parameters.criteria
})
.then(response => {
if (response.length && !parameters.isNewRecord) {
@ -494,8 +503,8 @@ export default {
this.$router.push({
name: this.$route.name,
query: {
action: this.dataRecords.UUID,
...this.$route.query
...this.$route.query,
action: this.dataRecords.UUID
}
})
this.$store.dispatch('notifyPanelChange', {
@ -606,7 +615,7 @@ export default {
dataTransfer.setData('Text', '')
},
changePanelRecord(uuidRecord) {
if (uuidRecord !== 'create-new' && uuidRecord !== 'reference' && uuidRecord !== 'advancedQuery') {
if (uuidRecord !== 'create-new' && uuidRecord !== 'reference' && uuidRecord !== 'advancedQuery' && uuidRecord !== 'criteria') {
var recordSelected = this.$store.getters.getDataRecordsList(this.containerUuid).find(record => record.UUID === uuidRecord)
if (recordSelected) {
this.dataRecords = recordSelected

View File

@ -0,0 +1,130 @@
<template>
<el-collapse v-model="activeDocuments" accordion>
<el-collapse-item name="documents">
<template slot="title">
<i class="el-icon-document" style="margin-right: 4px;margin-left: 10px;" /> {{ $t('profile.PendingDocuments') }}
</template>
<el-card class="box-card" :body-style="{ padding: '0px' }" shadow="never">
<div class="recent-items">
<el-table :data="search.length ? filterResult(search) : documents" max-height="455" @row-click="handleClick">
<el-table-column
prop="recordCount"
width="60"
/>
<el-table-column>
<template slot="header" slot-scope="scope">
<el-input
v-model="search"
size="mini"
:metadata="scope"
:placeholder="$t('table.dataTable.search')"
/>
</template>
<template slot-scope="{row}">
<span>{{ row.name }}</span>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
</el-collapse-item>
</el-collapse>
</template>
<script>
export default {
name: 'PendingDocuments',
data() {
return {
activeDocuments: 'documents',
documents: [],
search: ''
}
},
computed: {
getterPendingDocuments() {
return this.$store.getters.getPendingDocuments
},
cachedViews() {
return this.$store.getters.cachedViews
},
permissionRoutes() {
return this.$store.getters.permission_routes
}
},
mounted() {
this.getPendingDocuments()
this.subscribeChanges()
},
methods: {
getPendingDocuments() {
this.$store.dispatch('getPendingDocumentsFromServer')
.then(response => {
this.documents = response
}).catch(error => {
console.log(error)
})
},
subscribeChanges() {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'setPendingDocuments') {
this.recentItems = this.getterPendingDocuments
}
})
},
handleClick(row) {
this.$store.dispatch('getWindowByUuid', { routes: this.permissionRoutes, windowUuid: row.windowUuid })
var windowRoute = this.$store.getters.getWindowRoute(row.windowUuid)
this.$router.push({
name: windowRoute.name,
params: {
...row.criteria
},
query: {
action: 'criteria'
}
})
// conditions for the registration amount (operador: row.criteria.whereClause)
},
filterResult(search) {
return this.documents.filter(item => this.ignoreAccent(item.name).toLowerCase().includes(this.ignoreAccent(search.toLowerCase())))
},
ignoreAccent(s) {
if (!s) { return '' }
return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
}
}
}
</script>
<style scoped>
.search_recent {
width: 50%!important;
float: right;
}
.header {
padding-bottom: 10px;
}
.recent-items {
height: 455px;
overflow: auto;
}
.time {
float: left;
font-size: 11px;
color: #999;
}
.card-box {
cursor: pointer;
}
.card-content {
font-size: 15px;
}
.icon-window {
font-size: x-large;
color: #36a3f7;
}
.action-tag {
float: right;
}
</style>

View File

@ -58,6 +58,9 @@ export default {
query: {
...this.$route.query,
tabParent: String(newValue)
},
params: {
...this.$route.params
}
})
this.$route.meta.tabUuid = this.tabUuid

View File

@ -37,7 +37,7 @@ export const tabMixin = {
// Current TabChildren
currentTabChild(newValue, oldValue) {
if (newValue !== oldValue) {
this.$router.push({ query: { ...this.$route.query, tabChild: String(newValue) }})
this.$router.push({ query: { ...this.$route.query, tabChild: String(newValue) }, params: { ...this.$route.params }})
}
},
// Load parent tab context

View File

@ -244,6 +244,7 @@ export default {
aboutMe: 'About Me',
recentItems: 'Recent Items',
favorites: 'Favorites',
PendingDocuments: 'Pending Documents',
recentItemsName: 'Name Recent Items',
role: 'Role',
availableRoles: 'Available roles',

View File

@ -219,6 +219,7 @@ export default {
aboutMe: 'Sobre Mi',
recentItems: 'Artículos Recientes',
favorites: 'Favoritos',
PendingDocuments: 'Documentos Pendientes',
recentItemsName: 'Nombre Ítems Recientes',
role: 'Rol',
availableRoles: 'Roles disponibles',

View File

@ -9,8 +9,10 @@ const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
router: state => state.permission.addRoutes,
introduction: state => state.user.introduction,
currentRole: state => state.user.currentRole,
getRoleUuid: state => state.user.rol.uuid,
roles: state => state.user.roles,
permission_routes: state => state.permission.routes,
errorLogs: state => state.errorLog.logs

View File

@ -7,6 +7,7 @@ import {
convertValueFromGRPC,
getContextInfoValueFromServer,
getFavoritesFromServer,
getPendingDocumentsFromServer,
requestPrintFormats
} from '@/api/ADempiere'
import { convertValuesMapToObject, isEmptyValue, showMessage, convertAction } from '@/utils/ADempiere'
@ -18,6 +19,7 @@ const data = {
recordDetail: [],
recentItems: [],
favorites: [],
pendingDocuments: [],
inGetting: [],
contextInfoField: [],
printFormatList: []
@ -67,6 +69,9 @@ const data = {
setFavorites(state, payload) {
state.favorites = payload
},
setPendingDocuments(state, payload) {
state.pendingDocuments = payload
},
setPageNumber(state, payload) {
payload.data.pageNumber = payload.pageNumber
},
@ -645,6 +650,41 @@ const data = {
})
})
},
getPendingDocumentsFromServer({ commit, getters, rootGetters }) {
const userUuid = rootGetters['user/getUserUuid']
const roleUuid = getters.getRoleUuid
return new Promise((resolve, reject) => {
getPendingDocumentsFromServer(userUuid, roleUuid)
.then(response => {
const documentsList = response.getPendingdocumentsList().map(document => {
return {
formUuid: document.getFormuuid(),
name: document.getDocumentname(),
description: document.getDocumentdescription(),
criteria: {
type: document.getCriteria().getConditionsList(),
limit: document.getCriteria().getLimit(),
orderbyclause: document.getCriteria().getOrderbyclause(),
orderbycolumnList: document.getCriteria().getOrderbycolumnList(),
query: document.getCriteria().getQuery(),
referenceUuid: document.getCriteria().getReferenceuuid(),
tableName: document.getCriteria().getTablename(),
valuesList: document.getCriteria().getValuesList(),
whereClause: document.getCriteria().getWhereclause()
},
recordCount: document.getRecordcount(),
sequence: document.getSequence(),
windowUuid: document.getWindowuuid()
}
})
commit('setPendingDocuments', documentsList)
resolve(documentsList)
})
.catch(error => {
reject(error)
})
})
},
/**
* TODO: Add support to tab children
* @param {object} objectParams
@ -934,6 +974,9 @@ const data = {
getFavoritesList: (state) => {
return state.favorites
},
getPendingDocuments: (state) => {
return state.pendingDocuments
},
getLanguageList: (state) => (roleUuid) => {
return state.recordSelection.find(
record => record.containerUuid === roleUuid

View File

@ -534,7 +534,8 @@ const windowControl = {
isReference = false,
referenceWhereClause = '',
columnName,
value
value,
criteria
} = parameters
const tab = rootGetters.getTab(parentUuid, containerUuid)
@ -564,6 +565,14 @@ const windowControl = {
}
}
if (!isEmptyValue(criteria)) {
if (!isEmptyValue(parsedWhereClause)) {
parsedWhereClause += ' AND ' + criteria.whereClause
} else {
parsedWhereClause += criteria.whereClause
}
}
var conditions = []
if (tab.isParentTab && !isEmptyValue(tab.tableName) && !isEmptyValue(value)) {
conditions.push({

View File

@ -16,6 +16,12 @@ const ROUTES = {
action: undefined,
tabParent: '0',
tabChild: undefined
},
DOCUMENTS_WINDOW: {
uuid: '8e50d7c8-fb40-11e8-a479-7a0060f0aa01',
action: undefined,
tabParent: '0',
tabChild: undefined
}
}

View File

@ -39,6 +39,9 @@
<el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
<box-card />
</el-col>
<el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
<pending-documents />
</el-col>
</el-row>
</div>
</template>
@ -55,6 +58,7 @@ import TodoList from './components/TodoList'
import BoxCard from './components/BoxCard'
import RecentItems from '@/components/ADempiere/RecentItems'
import Favorites from '@/components/ADempiere/Favorites'
import PendingDocuments from '@/components/ADempiere/PendingDocuments'
const lineChartData = {
newVisitis: {
@ -88,7 +92,8 @@ export default {
TodoList,
BoxCard,
RecentItems,
Favorites
Favorites,
PendingDocuments
},
data() {
return {