Fixes total_items crashing trash tab on collection list. Closes #60.

This commit is contained in:
Mateus Machado Luna 2018-06-29 10:37:25 -03:00
parent eb3e6c3bbb
commit 1964576d36
4 changed files with 11 additions and 8 deletions

View File

@ -18,6 +18,7 @@ module.exports = {
'vue/require-default-prop': 'off', // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/require-default-prop.md
},
globals: {
'tainacan_plugin': true
'tainacan_plugin': true,
'_': true
}
}

View File

@ -63,7 +63,7 @@
<div class="th-wrap">{{ $i18n.get('label_created_by') }}</div>
</th>
<!-- Total Items -->
<th>
<th v-if="!isOnTrash">
<div class="th-wrap">{{ $i18n.get('label_total_items') }}</div>
</th>
<th class="actions-header">
@ -158,6 +158,7 @@
@click="goToCollectionPage(collection.id)"
class="column-small-width column-align-right"
:label="$i18n.get('label_total_items')"
v-if="collection.total_items != undefined"
:aria-label="$i18n.get('label_total_items') + ': ' + getTotalItems(collection.total_items)">
<p
v-tooltip="{

View File

@ -238,7 +238,6 @@
:key="index"
v-if="column.display && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop == 'title')"
@click="goToItemPage(item)"
class="metadata-title"
v-html="item.metadata != undefined ? renderMetadata(item.metadata, column) : ''" />
</div>
<!-- Actions -->

View File

@ -191,11 +191,13 @@ class REST_Collections_Controller extends REST_Controller {
}
$total_items = wp_count_posts( $item->get_db_identifier(), 'readable' );
$item_arr['total_items']['trash'] = $total_items->trash;
$item_arr['total_items']['publish'] = $total_items->publish;
$item_arr['total_items']['draft'] = $total_items->draft;
$item_arr['total_items']['private'] = $total_items->private;
if (isset($total_items->publish)) {
$item_arr['total_items']['trash'] = $total_items->trash;
$item_arr['total_items']['publish'] = $total_items->publish;
$item_arr['total_items']['draft'] = $total_items->draft;
$item_arr['total_items']['private'] = $total_items->private;
}
return $item_arr;
}