<template>
  <Page
    :items-per-page="9"
    :extra-fields="[{ subsidiaries: ['uuid', 'title'] }]"
    :filters="filters"
    component="minimal"
    filters-input="selectbox"
    class="news-listing-page"
  >
    <template #default="{ item }">
      <Minimal v-bind="item" :key="item.uuid" />
    </template>
  </Page>
</template>

<script>
import Page from '@inside-news/components/pages/ListingPage'

import Minimal from '../../inside-customs/components/news/MinimalNews'

export default {
  name: 'NewsListingPage',
  $_i18nRootPath: 'news.LISTING_PAGE',
  components: { Page, Minimal },
  computed: {
    filters() {
      return [
        {
          id: 'newsCategories',
          type: 'selectbox',
          modelName: 'category',
          fetch: true,
          reference: 'news_categories',
          fields: ['uuid', 'title'],
          filters: { 'status:eq': 1, sort: 'title:asc' },
          objectLabelKey: 'title',
          objectValueKey: 'uuid',
          label: this.$_tr('filters.categories')
        },
        {
          id: 'subsidiaries',
          type: 'selectbox',
          modelName: 'subsidiaries',
          fetch: true,
          reference: 'subsidiaries',
          fields: ['uuid', 'title'],
          filters: { 'status:eq': 1, sort: 'title:asc' },
          objectLabelKey: 'title',
          objectValueKey: 'uuid',
          label: this.$_tr('filters.subsidiaries')
        }
      ]
    }
  }
}
</script>
