SubscriptionsList.vue 3.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<template>
  <main class="main pusher" v-title="labels.title">
    <section class="ui head vertical stripe segment container">
      <h1 class="ui with-actions header">
        {{ labels.title }}
        <div class="actions">
          <a @click.stop.prevent="showSubscribeModal = true">
            <i class="plus icon"></i>
            <translate translate-context="Content/Profile/Button">Add new</translate>
          </a>
        </div>
      </h1>
      <modal class="tiny" :show.sync="showSubscribeModal" :fullscreen="false">
        <h2 class="header">
          <translate translate-context="*/*/*/Noun">Subscription</translate>
        </h2>
        <div class="scrolling content" ref="modalContent">
          <remote-search-form
19
            type="both"
20
21
22
            :show-submit="false"
            :standalone="false"
            @subscribed="showSubscribeModal = false; reloadWidget()"
23
            :redirect="true"></remote-search-form>
24
25
        </div>
        <div class="actions">
26
          <button class="ui basic deny button">
27
            <translate translate-context="*/*/Button.Label/Verb">Cancel</translate>
28
          </button>
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
          <button form="remote-search" type="submit" class="ui primary button">
            <i class="bookmark icon"></i>
            <translate translate-context="*/*/*/Verb">Subscribe</translate>
          </button>
        </div>
      </modal>



      <inline-search-bar v-model="query" @search="reloadWidget" :placeholder="labels.searchPlaceholder"></inline-search-bar>
      <channels-widget
        :key="widgetKey"
        :limit="50"
        :show-modification-date="true"
        :filters="{q: query, subscribed: 'true', ordering: '-modification_date'}"></channels-widget>
    </section>
  </main>
</template>

<script>
import axios from "axios"
import Modal from '@/components/semantic/Modal'

import ChannelsWidget from "@/components/audio/ChannelsWidget"
import RemoteSearchForm from "@/components/RemoteSearchForm"

export default {
  props: ["defaultQuery"],
  components: {
    ChannelsWidget,
    RemoteSearchForm,
    Modal,
  },
  data() {
    return {
      query: this.defaultQuery || '',
      channels: [],
      count: 0,
      isLoading: false,
      errors: null,
      previousPage: null,
      nextPage: null,
      widgetKey: String(new Date()),
      showSubscribeModal: false,
    }
  },
  created () {
    this.fetchData()
  },
  computed: {
    labels () {
      return {
        title: this.$pgettext("Content/Subscriptions/Header", "Subscribed Channels"),
        searchPlaceholder: this.$pgettext("Content/Subscriptions/Form.Placeholder", "Filter by name…"),
      }
    },
  },
  methods: {
    fetchData() {
      var self = this
      this.isLoading = true
      axios.get('channels/', {params: {subscribed: "true", q: this.query}}).then(response => {
        self.previousPage = response.data.previous
        self.nextPage = response.data.next
        self.isLoading = false
        self.channels = [...self.channels, ...response.data.results]
        self.count = response.data.count
      })
    },
    reloadWidget () {
      this.widgetKey = String(new Date())
    }
  },
}
</script>