1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-10-02 12:24:53 +08:00
EdwinBetanc0urt fd6096b565 redefine API to provide business data (#214)
* Change of main functions of api from the application to the grpc library

* Create entity.
* Update entity.
* Delete entity.
* Request entity.
* Request entities list.
* Rollback entity.
* Run process.
* Browser search.

* Convert API functions to get values.

* migrate CRUD and Browser Search.

* migrate process control and callout control.

* migrate print formats.

* migrate recent items, references, context info value, private access

* migrate pending documents, favorites, language and translations.

* migrate lookups.

* fix: Drill table empty name.

* Change report output.

* Refactor dashboard and language.

* Fix dashboard component.

* Fix dashboards unsupported, and refactor and remove getting values
2020-01-14 15:42:09 -04:00

141 lines
3.8 KiB
Vue

<template>
<el-collapse v-model="activeFavorites" accordion>
<el-collapse-item name="favorites">
<template slot="title">
<i class="el-icon-time" style="margin-right: 4px;margin-left: 10px;" />
{{ $t('profile.favorites') }}
</template>
<el-card class="box-card" :body-style="{ padding: '0px' }" shadow="never">
<div class="recent-items">
<el-table :data="search.length ? filterResult(search) : favorites" max-height="455" @row-click="handleClick">
<el-table-column width="40">
<template slot-scope="{row}">
<svg-icon :icon-class="row.icon" class="icon-window" />
</template>
</el-table-column>
<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>
<el-tag class="action-tag">{{ $t(`views.${row.action}`) }}</el-tag>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
</el-collapse-item>
</el-collapse>
</template>
<script>
import { getFavoritesFromServer } from '@/api/ADempiere/data'
import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
export default {
name: 'Favorites',
data() {
return {
activeFavorites: 'favorites',
favorites: [],
isLoaded: true,
search: '',
accentRegexp: /[\u0300-\u036f]/g
}
},
computed: {
cachedViews() {
return this.$store.getters.cachedViews
}
},
mounted() {
this.getFavoritesList()
this.subscribeChanges()
},
methods: {
getFavoritesList() {
const userUuid = this.$store.getters['user/getUserUuid']
return new Promise((resolve, reject) => {
getFavoritesFromServer(userUuid)
.then(response => {
const favorites = response.favoritesList.map(favoriteElement => {
const actionConverted = convertAction(favoriteElement.action)
return {
...favoriteElement,
uuid: favoriteElement.menuUuid,
name: favoriteElement.menuName,
description: favoriteElement.menuDescription,
action: actionConverted.name,
icon: actionConverted.icon
}
})
this.favorites = favorites
resolve(favorites)
})
.catch(error => {
console.warn(`Error getting favorites: ${error.message}. Code: ${error.code}.`)
})
})
},
subscribeChanges() {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'notifyDashboardRefresh') {
this.getFavoritesList()
}
})
},
handleClick(row) {
this.$router.push({ name: row.uuid })
},
filterResult(search) {
return this.favorites.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, '')
},
translateDate(value) {
return this.$d(new Date(value), 'long', this.language)
}
}
}
</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>