Remove bad implementation for dashboard (#206)

pull/3759/head
Yamel Senih 2019-12-12 18:42:21 -04:00 committed by GitHub
parent 9a74271d2a
commit 739f658fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 119 additions and 33 deletions

View File

@ -34,6 +34,8 @@
</template>
<script>
import { getFavoritesFromServer } from '@/api/ADempiere'
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
export default {
name: 'Favorites',
data() {
@ -59,18 +61,33 @@ export default {
},
methods: {
getFavoritesList() {
this.$store.dispatch('getFavoritesFromServer')
.then(response => {
this.favorites = response
this.isLoaded = false
}).catch(error => {
console.log(error)
})
const userUuid = this.$store.getters['user/getUserUuid']
return new Promise((resolve, reject) => {
getFavoritesFromServer(userUuid)
.then(response => {
const favorites = response.getFavoritesList().map(favorite => {
const actionConverted = convertAction(favorite.getAction())
return {
uuid: favorite.getMenuuuid(),
name: favorite.getMenuname(),
description: favorite.getMenudescription(),
referenceUuid: favorite.getReferenceuuid(),
action: actionConverted.name,
icon: actionConverted.icon
}
})
this.favorites = favorites
resolve(favorites)
})
.catch(error => {
reject(error)
})
})
},
subscribeChanges() {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'setFavorites') {
this.recentItems = this.getterFavoritesList
if (mutation.type === 'notifyDashboardRefresh') {
this.getFavoritesList()
}
})
},

View File

@ -32,6 +32,7 @@
</template>
<script>
import { getPendingDocumentsFromServer } from '@/api/ADempiere'
export default {
name: 'PendingDocuments',
data() {
@ -42,9 +43,6 @@ export default {
}
},
computed: {
getterPendingDocuments() {
return this.$store.getters.getPendingDocuments
},
cachedViews() {
return this.$store.getters.cachedViews
},
@ -58,17 +56,44 @@ export default {
},
methods: {
getPendingDocuments() {
this.$store.dispatch('getPendingDocumentsFromServer')
.then(response => {
this.documents = response
}).catch(error => {
console.log(error)
})
const userUuid = this.$store.getters['user/getUserUuid']
const roleUuid = this.$store.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()
}
})
this.documents = documentsList
resolve(documentsList)
})
.catch(error => {
reject(error)
})
})
},
subscribeChanges() {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'setPendingDocuments') {
this.recentItems = this.getterPendingDocuments
if (mutation.type === 'notifyDashboardRefresh') {
this.getPendingDocuments()
}
})
},

View File

@ -36,7 +36,8 @@
</template>
<script>
import { getRecentItems as getRecentItemsFromServer } from '@/api/ADempiere'
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
export default {
name: 'RecentItems',
data() {
@ -65,19 +66,34 @@ export default {
return this.cachedViews.includes(uuid)
},
getRecentItems() {
var items = this.getterRecentItems
if (items === undefined || items.length < 1) {
this.$store.dispatch('getRecentItemsFromServer')
return new Promise((resolve, reject) => {
getRecentItemsFromServer()
.then(response => {
this.recentItems = response
const recentItems = response.getRecentitemsList().map(item => {
const actionConverted = convertAction(item.getAction())
return {
action: actionConverted.name,
icon: actionConverted.icon,
displayName: item.getDisplayname(),
menuUuid: item.getMenuuuid(),
menuName: item.getMenuname(),
windowUuid: item.getWindowuuid(),
tableId: item.getTableid(),
recordId: item.getRecordid(),
uuidRecord: item.getRecorduuid(),
tabUuid: item.getTabuuid(),
updated: new Date(item.getUpdated()),
description: item.getMenudescription()
}
})
this.recentItems = recentItems
this.isLoaded = false
}).catch(error => {
console.log(error)
resolve(recentItems)
})
} else {
this.recentItems = items
this.isLoaded = false
}
.catch(error => {
reject(error)
})
})
},
handleClick(row) {
if (!this.isEmptyValue(row.uuidRecord)) {
@ -88,8 +104,8 @@ export default {
},
subscribeChanges() {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'setRecentItems') {
this.recentItems = this.getterRecentItems
if (mutation.type === 'notifyDashboardRefresh') {
this.getRecentItems()
}
})
},

View File

@ -0,0 +1,28 @@
// Default store for handle dashboard refresh and other functionalities
const dashboard = {
state: {
dashboard: []
},
mutations: {
addDashboard(state, payload) {
state.dashboard.push(payload)
},
notifyDashboardRefresh: (state, payload) => {
}
},
actions: {
refreshDashboard({ commit, getters }, parameters) {
commit('notifyDashboardRefresh', parameters)
}
},
getters: {
getDashboard: (state) => (dashboardUuid) => {
return state.dashboard.find(
item => item.uuid === dashboardUuid
)
}
}
}
export default dashboard