<script>
import SearchActions from '@inside-searches/displays/SearchActions'

export default {
  name: 'search-actions',
  extends: SearchActions,
  mounted() {
    this.actions.news = item => this.redirectTo(item, 'NewsPage')
    this.actions.groups = item => this.redirectAction(item)
    this.actions.entities = item => this.redirectAction(item)
    this.actions.groups_documents = item => this.downloadFile(item)
    this.actions.groups_folders = item => this.foldersAction(item)
    this.actions.manager_spaces_documents = item => this.downloadFile(item)
    this.actions.manager_spaces_events = item => this.redirectAction(item)
    this.actions.manager_spaces_folders = item => this.foldersAction(item)
    this.actions.movements = item => this.redirectTo(item, 'NominationPage')
    this.actions.offers = item => this.redirectTo(item, 'OfferPage')
  },
  methods: {
    redirectToLink(item) {
      if (item.uri) window.open(item.uri, '_blank')
    },
    redirectTo(item, routeName) {
      this.$router.push({
        name: routeName,
        params: { slug: item.slug[0] }
      })
    }
  }
}
</script>
