<template>
  <ParentPage
    :link-types="linksTypes"
    :table-options="{ onRowClick, pagination, itemsPerPage }"
  />
</template>

<script>
import ParentPage from '@inside-ged/components/pages/GedPage'

export default {
  name: 'GedPage',
  components: { ParentPage },
  data() {
    return {
      linksTypes: {
        contents: ['articles'],
        filters: { status: 1, 'published_at:lte': 'now()' },
        fields: [
          'uuid',
          'title',
          'published_at',
          'updated_at',
          'slug',
          'content_type',
          'admin',
          'slug'
        ]
      },
      pagination: 'bar',
      itemsPerPage: 50
    }
  },
  methods: {
    onRowClick(data, { methods }) {
      const { content_type: contentType, uuid } = data
      const { selectFolder, clickOnDocument } = methods
      if (contentType === 'articles') {
        this.triggerModal(
          'articles',
          'static',
          { item: data, content: 'articles' },
          {
            layout: 'right',
            size: 'l',
            transition: 'fadeInLeft',
            useUrlParams: true
          }
        )
      } else if (contentType === 'folders') {
        selectFolder(uuid)
      } else if (contentType === 'documents') {
        clickOnDocument(data)
      }
    }
  }
}
</script>
