Remove bad implementation for dashboard (#206)
parent
9a74271d2a
commit
739f658fea
|
@ -34,6 +34,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { getFavoritesFromServer } from '@/api/ADempiere'
|
||||||
|
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
export default {
|
export default {
|
||||||
name: 'Favorites',
|
name: 'Favorites',
|
||||||
data() {
|
data() {
|
||||||
|
@ -59,18 +61,33 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFavoritesList() {
|
getFavoritesList() {
|
||||||
this.$store.dispatch('getFavoritesFromServer')
|
const userUuid = this.$store.getters['user/getUserUuid']
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
getFavoritesFromServer(userUuid)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.favorites = response
|
const favorites = response.getFavoritesList().map(favorite => {
|
||||||
this.isLoaded = false
|
const actionConverted = convertAction(favorite.getAction())
|
||||||
}).catch(error => {
|
return {
|
||||||
console.log(error)
|
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() {
|
subscribeChanges() {
|
||||||
this.$store.subscribe((mutation, state) => {
|
this.$store.subscribe((mutation, state) => {
|
||||||
if (mutation.type === 'setFavorites') {
|
if (mutation.type === 'notifyDashboardRefresh') {
|
||||||
this.recentItems = this.getterFavoritesList
|
this.getFavoritesList()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { getPendingDocumentsFromServer } from '@/api/ADempiere'
|
||||||
export default {
|
export default {
|
||||||
name: 'PendingDocuments',
|
name: 'PendingDocuments',
|
||||||
data() {
|
data() {
|
||||||
|
@ -42,9 +43,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getterPendingDocuments() {
|
|
||||||
return this.$store.getters.getPendingDocuments
|
|
||||||
},
|
|
||||||
cachedViews() {
|
cachedViews() {
|
||||||
return this.$store.getters.cachedViews
|
return this.$store.getters.cachedViews
|
||||||
},
|
},
|
||||||
|
@ -58,17 +56,44 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getPendingDocuments() {
|
getPendingDocuments() {
|
||||||
this.$store.dispatch('getPendingDocumentsFromServer')
|
const userUuid = this.$store.getters['user/getUserUuid']
|
||||||
|
const roleUuid = this.$store.getters.getRoleUuid
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
getPendingDocumentsFromServer(userUuid, roleUuid)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.documents = response
|
const documentsList = response.getPendingdocumentsList().map(document => {
|
||||||
}).catch(error => {
|
return {
|
||||||
console.log(error)
|
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() {
|
subscribeChanges() {
|
||||||
this.$store.subscribe((mutation, state) => {
|
this.$store.subscribe((mutation, state) => {
|
||||||
if (mutation.type === 'setPendingDocuments') {
|
if (mutation.type === 'notifyDashboardRefresh') {
|
||||||
this.recentItems = this.getterPendingDocuments
|
this.getPendingDocuments()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { getRecentItems as getRecentItemsFromServer } from '@/api/ADempiere'
|
||||||
|
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
export default {
|
export default {
|
||||||
name: 'RecentItems',
|
name: 'RecentItems',
|
||||||
data() {
|
data() {
|
||||||
|
@ -65,19 +66,34 @@ export default {
|
||||||
return this.cachedViews.includes(uuid)
|
return this.cachedViews.includes(uuid)
|
||||||
},
|
},
|
||||||
getRecentItems() {
|
getRecentItems() {
|
||||||
var items = this.getterRecentItems
|
return new Promise((resolve, reject) => {
|
||||||
if (items === undefined || items.length < 1) {
|
getRecentItemsFromServer()
|
||||||
this.$store.dispatch('getRecentItemsFromServer')
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.recentItems = response
|
const recentItems = response.getRecentitemsList().map(item => {
|
||||||
this.isLoaded = false
|
const actionConverted = convertAction(item.getAction())
|
||||||
}).catch(error => {
|
return {
|
||||||
console.log(error)
|
action: actionConverted.name,
|
||||||
})
|
icon: actionConverted.icon,
|
||||||
} else {
|
displayName: item.getDisplayname(),
|
||||||
this.recentItems = items
|
menuUuid: item.getMenuuuid(),
|
||||||
this.isLoaded = false
|
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
|
||||||
|
resolve(recentItems)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleClick(row) {
|
handleClick(row) {
|
||||||
if (!this.isEmptyValue(row.uuidRecord)) {
|
if (!this.isEmptyValue(row.uuidRecord)) {
|
||||||
|
@ -88,8 +104,8 @@ export default {
|
||||||
},
|
},
|
||||||
subscribeChanges() {
|
subscribeChanges() {
|
||||||
this.$store.subscribe((mutation, state) => {
|
this.$store.subscribe((mutation, state) => {
|
||||||
if (mutation.type === 'setRecentItems') {
|
if (mutation.type === 'notifyDashboardRefresh') {
|
||||||
this.recentItems = this.getterRecentItems
|
this.getRecentItems()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue