add support to dashboard collapsible and open by default (#265)

* add support to dashboard collapsible and open by default

* change component definition of dynamic dashboard
pull/3759/head
Leonel Matos 2020-01-24 16:26:07 -04:00 committed by Yamel Senih
parent c6c23f31fb
commit 44940dee0e
6 changed files with 148 additions and 134 deletions

View File

@ -1,10 +1,4 @@
<template> <template>
<el-collapse v-model="activeCalendar" accordion>
<el-collapse-item name="calendar">
<template slot="title">
<i class="el-icon-date" style="margin-right: 4px;margin-left: 10px;" />
{{ $t('route.calendar') }}
</template>
<el-calendar> <el-calendar>
<!-- Use 2.5 slot syntax. If you use Vue 2.6, please use new slot syntax--> <!-- Use 2.5 slot syntax. If you use Vue 2.6, please use new slot syntax-->
<template <template
@ -16,16 +10,19 @@
</p> </p>
</template> </template>
</el-calendar> </el-calendar>
</el-collapse-item>
</el-collapse>
</template> </template>
<script> <script>
export default { export default {
name: 'Calendar', name: 'Calendar',
props: {
metadata: {
type: Object,
required: true
}
},
data() { data() {
return { return {
activeCalendar: 'calendar',
value: new Date() value: new Date()
} }
} }

View File

@ -1,10 +1,4 @@
<template> <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"> <el-card class="box-card" :body-style="{ padding: '0px' }" shadow="never">
<div class="recent-items"> <div class="recent-items">
<el-table :data="search.length ? filterResult(search) : documents" max-height="455" @row-click="handleClick"> <el-table :data="search.length ? filterResult(search) : documents" max-height="455" @row-click="handleClick">
@ -28,8 +22,6 @@
</el-table> </el-table>
</div> </div>
</el-card> </el-card>
</el-collapse-item>
</el-collapse>
</template> </template>
<script> <script>
@ -37,9 +29,14 @@ import { getPendingDocumentsFromServer } from '@/api/ADempiere/data'
export default { export default {
name: 'PendingDocuments', name: 'PendingDocuments',
props: {
metadata: {
type: Object,
required: true
}
},
data() { data() {
return { return {
activeDocuments: 'documents',
documents: [], documents: [],
search: '' search: ''
} }

View File

@ -1,10 +1,4 @@
<template> <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"> <el-card class="box-card" :body-style="{ padding: '0px' }" shadow="never">
<div class="recent-items"> <div class="recent-items">
<el-table :data="search.length ? filterResult(search) : favorites" max-height="455" @row-click="handleClick"> <el-table :data="search.length ? filterResult(search) : favorites" max-height="455" @row-click="handleClick">
@ -30,8 +24,6 @@
</el-table> </el-table>
</div> </div>
</el-card> </el-card>
</el-collapse-item>
</el-collapse>
</template> </template>
<script> <script>
@ -40,9 +32,14 @@ import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
export default { export default {
name: 'Favorites', name: 'Favorites',
props: {
metadata: {
type: Object,
required: true
}
},
data() { data() {
return { return {
activeFavorites: 'favorites',
favorites: [], favorites: [],
isLoaded: true, isLoaded: true,
search: '', search: '',

View File

@ -1,9 +1,24 @@
<template> <template>
<el-collapse
v-if="!unsupportedDashboards.includes(dashboard.fileName)"
v-model="activeDashboard"
accordion
>
<el-collapse-item
:name="dashboard.dashboardName"
:disabled="!dashboard.isCollapsible"
class="custom-collapse-item"
>
<template slot="title">
<span class="custom-title"> {{ dashboard.dashboardName }}</span>
</template>
<component <component
:is="renderDashboard" :is="renderDashboard"
:ref="dashboard.dashboardName" :ref="dashboard.dashboardName"
:metadata="dashboard" :metadata="dashboard"
/> />
</el-collapse-item>
</el-collapse>
</template> </template>
<script> <script>
@ -18,15 +33,16 @@ export default {
}, },
data() { data() {
return { return {
dashboard: this.metadata dashboard: this.metadata,
unsupportedDashboards: ['activities', 'views', 'performance'],
activeDashboard: this.metadata.isOpenByDefault ? this.metadata.dashboardName : undefined
} }
}, },
computed: { computed: {
// load the component that is indicated in the attributes of received property // load the component that is indicated in the attributes of received property
renderDashboard() { renderDashboard() {
// TODO: Add support to this list of currently unsupported dashboards // TODO: Add support to this list of currently unsupported dashboards
const unsupportedDashboards = ['activities', 'views', 'performance'] if (this.unsupportedDashboards.includes(this.metadata.fileName)) {
if (unsupportedDashboards.includes(this.metadata.fileName)) {
return return
} }
if (this.metadata.fileName === 'userfavorites') { if (this.metadata.fileName === 'userfavorites') {
@ -39,6 +55,9 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.custom-title {
padding: 10px;
}
.dashboard-editor-container { .dashboard-editor-container {
padding: 32px; padding: 32px;
background-color: rgb(240, 242, 245); background-color: rgb(240, 242, 245);
@ -57,4 +76,9 @@ export default {
margin-bottom: 32px; margin-bottom: 32px;
} }
} }
.custom-collapse-item.is-disabled {
.custom-title {
color: #303133;
}
}
</style> </style>

View File

@ -1,10 +1,4 @@
<template> <template>
<el-collapse v-model="activeRecentItems" accordion>
<el-collapse-item name="recentItems">
<template slot="title">
<i class="el-icon-time" style="margin-right: 4px;margin-left: 10px;" />
{{ $t('profile.recentItems') }}
</template>
<el-card class="box-card" :body-style="{ padding: '0px' }" shadow="never"> <el-card class="box-card" :body-style="{ padding: '0px' }" shadow="never">
<div class="recent-items"> <div class="recent-items">
<el-table :data="search.length ? filterResult(search) : recentItems" max-height="455" @row-click="handleClick"> <el-table :data="search.length ? filterResult(search) : recentItems" max-height="455" @row-click="handleClick">
@ -32,8 +26,6 @@
</el-table> </el-table>
</div> </div>
</el-card> </el-card>
</el-collapse-item>
</el-collapse>
</template> </template>
<script> <script>
@ -41,9 +33,14 @@ import { getRecentItems as getRecentItemsFromServer } from '@/api/ADempiere'
import { convertAction } from '@/utils/ADempiere/dictionaryUtils' import { convertAction } from '@/utils/ADempiere/dictionaryUtils'
export default { export default {
name: 'RecentItems', name: 'RecentItems',
props: {
metadata: {
type: Object,
required: true
}
},
data() { data() {
return { return {
activeRecentItems: 'recentItems',
recentItems: [], recentItems: [],
isLoaded: true, isLoaded: true,
search: '', search: '',

View File

@ -131,12 +131,14 @@ export default {
height: 100%; height: 100%;
font-size: 13px; font-size: 13px;
} }
.collapse-item {
.el-collapse-item__header { .el-collapse-item__header {
height: 60px; height: 60px;
font-weight: bold; font-weight: bold;
font-size: 16px; font-size: 16px;
text-align: center; text-align: center;
} }
}
.three-dots{ .three-dots{
margin-top: 0 !important; margin-top: 0 !important;
overflow: hidden; overflow: hidden;