Adds isOnTheme property to check if SearchControl and ItemsList should render or not certain parts.

This commit is contained in:
mateuswetah 2018-05-08 16:26:02 -03:00
parent ea77249da1
commit e75594ad43
5 changed files with 98 additions and 84 deletions

View File

@ -15,16 +15,16 @@
:data="items" :data="items"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
:checked-rows.sync="selectedItems" :checked-rows.sync="selectedItems"
checkable :checkable="!isOnTheme"
:loading="isLoading" :loading="isLoading"
hoverable hoverable
striped striped
selectable :selectable="!isOnTheme"
backend-sorting> backend-sorting>
<template slot-scope="props"> <template slot-scope="props">
<b-table-column <b-table-column
v-for="(column, index) in tableFields" v-for="(column, index) in tableFields"
v-if="column.field != 'row_actions' || (column.field == 'row_actions' && props.row.current_user_can_edit)" v-if="column.field != 'row_actions' || (column.field == 'row_actions' && props.row.current_user_can_edit && !isOnTheme)"
:key="index" :key="index"
:custom-key="column.slug" :custom-key="column.slug"
:label="column.name" :label="column.name"
@ -35,12 +35,16 @@
<template v-if="column.field != 'row_thumbnail' && column.field != 'row_actions' && column.field != 'row_creation'"> <template v-if="column.field != 'row_thumbnail' && column.field != 'row_actions' && column.field != 'row_creation'">
<span <span
class="clickable-row" class="clickable-row"
v-if="props.row.metadata[column.slug].value_as_html == props.row.metadata[column.slug].value_as_string" v-if="!isOnTheme && props.row.metadata[column.slug].value_as_html == props.row.metadata[column.slug].value_as_string"
@click.prevent="goToItemPage(props.row.id)" @click.prevent="goToItemPage(props.row.id)"
v-html="renderMetadata( props.row.metadata[column.slug] )" /> v-html="renderMetadata( props.row.metadata[column.slug] )" />
<span <span
class="clickable-row" class="clickable-row"
v-if="props.row.metadata[column.slug].value_as_html != props.row.metadata[column.slug].value_as_string" v-if="!isOnTheme && props.row.metadata[column.slug].value_as_html != props.row.metadata[column.slug].value_as_string"
v-html="renderMetadata( props.row.metadata[column.slug] )" />
<a
v-if="isOnTheme"
:href="getDecodedURI(props.row.url)"
v-html="renderMetadata( props.row.metadata[column.slug] )" /> v-html="renderMetadata( props.row.metadata[column.slug] )" />
</template> </template>
@ -101,7 +105,8 @@ export default {
collectionId: Number, collectionId: Number,
tableFields: Array, tableFields: Array,
items: Array, items: Array,
isLoading: false isLoading: false,
isOnTheme: false
}, },
methods: { methods: {
...mapActions('collection', [ ...mapActions('collection', [
@ -184,6 +189,9 @@ export default {
}, },
getCreationHtml(item) { getCreationHtml(item) {
return this.$i18n.get('info_created_by') + item['author_name'] + '<br>' + this.$i18n.get('info_date') + moment( item['creation_date'], 'YYYY-MM-DD').format('DD/MM/YYYY'); return this.$i18n.get('info_created_by') + item['author_name'] + '<br>' + this.$i18n.get('info_date') + moment( item['creation_date'], 'YYYY-MM-DD').format('DD/MM/YYYY');
},
getDecodedURI(url) {
return decodeURIComponent(url);
} }
} }
} }

View File

@ -2,7 +2,9 @@
<span> <span>
<div class="header-item"> <div class="header-item">
<b-dropdown id="item-creation-options-dropdown"> <b-dropdown
v-if="!isOnTheme"
id="item-creation-options-dropdown">
<button <button
class="button is-secondary" class="button is-secondary"
slot="trigger"> slot="trigger">
@ -88,7 +90,8 @@
props: { props: {
collectionId: Number, collectionId: Number,
isRepositoryLevel: false, isRepositoryLevel: false,
tableFields: Array tableFields: Array,
isOnTheme: false
}, },
computed: { computed: {
orderBy() { orderBy() {

View File

@ -82,7 +82,8 @@
:is-repository-level="isRepositoryLevel" :is-repository-level="isRepositoryLevel"
:collection-id="collectionId" :collection-id="collectionId"
:table-fields="tableFields" :table-fields="tableFields"
:pref-table-fields="prefTableFields"/> :pref-table-fields="prefTableFields"
:is-on-theme="isOnTheme"/>
</div> </div>
<div <div
:items="items" :items="items"
@ -97,7 +98,8 @@
:collection-id="collectionId" :collection-id="collectionId"
:table-fields="tableFields" :table-fields="tableFields"
:items="items" :items="items"
:is-loading="isLoading"/> :is-loading="isLoading"
:is-on-theme="isOnTheme"/>
<section <section
v-if="!isLoadingItems && items.length <= 0" v-if="!isLoadingItems && items.length <= 0"
class="section"> class="section">
@ -147,6 +149,7 @@
hasFiltered: false, hasFiltered: false,
isFiltersMenuCompressed: false, isFiltersMenuCompressed: false,
collapseAll: false, collapseAll: false,
isOnTheme: false
} }
}, },
props: { props: {
@ -206,6 +209,8 @@
themeList.appendChild(e); themeList.appendChild(e);
}); */ }); */
this.isOnTheme = (this.$route.name == null);
this.isRepositoryLevel = (this.collectionId == undefined); this.isRepositoryLevel = (this.collectionId == undefined);
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => { this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => {

View File

@ -11,7 +11,6 @@
<script> <script>
import TainacanSubheader from '../../components/navigation/tainacan-subheader.vue'; import TainacanSubheader from '../../components/navigation/tainacan-subheader.vue';
import {mapActions} from 'vuex';
export default { export default {
name: 'CollectionPage', name: 'CollectionPage',

View File

@ -3,11 +3,11 @@
<b-loading <b-loading
:active.sync="isLoading" :active.sync="isLoading"
:can-cancel="false"/> :can-cancel="false"/>
<div class="card"> <tainacan-title />
<div class="card-content"> <div class="content">
<router-link <router-link
class="card-footer-item" class="button is-secondary"
:to="{ path: $routerHelper.getItemEditPath(collectionId, itemId)}"> :to="{ path: $routerHelper.getItemEditPath(collectionId, itemId)}">
{{ $i18n.get('edit') + ' ' + $i18n.get('item') }} {{ $i18n.get('edit') + ' ' + $i18n.get('item') }}
</router-link> </router-link>
@ -80,7 +80,6 @@
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>