{"version":3,"file":"PodcastList-B20GtO2V.mjs","names":[],"sources":["../src/components/display/playlist/PodcastList.vue","../src/components/display/playlist/PodcastList.vue"],"sourcesContent":["<!--\n  Component displaying a list of podcasts IN A PLAYLIST\n  Do not confuse this with PodcastList from podcasts\n-->\n<template>\n  <div>\n    <h3 class=\"mb-3 align-self-baseline\">\n      {{ titleList }}\n    </h3>\n\n    <ClassicSearch\n      v-if=\"!loading && notEmptyPlaylist\"\n      v-model:text-init=\"searchPattern\"\n      class=\"align-self-baseline mb-2\"\n      id-search=\"podcast-list-search\"\n      :label=\"t('Search')\"\n    />\n\n    <ListPaginate\n      id=\"podcastPlaylistListPaginate\"\n      v-model:first=\"dfirst\"\n      v-model:rows-per-page=\"dsize\"\n      v-model:is-mobile=\"isMobile\"\n      :text-count=\"\n        podcasts.length > 1\n          ? `${t('Number podcasts', { nb: podcasts.length })}`\n          : undefined\n      \"\n      :total-count=\"podcasts.length\"\n      :loading=\"loading\"\n      :loading-text=\"loading ? t('Loading podcasts ...') : undefined\"\n      :error-text=\"\n        !loading && !podcasts.length && notEmptyPlaylist\n          ? t(`No podcast match your query`)\n          : undefined\n      \"\n      :player-responsive=\"true\"\n      :force-update-parameters=\"true\"\n    >\n      <template #list>\n        <div class=\"octopus-element-list\">\n          <ClassicLazy\n            v-for=\"p in podcastsDisplay\"\n            :key=\"p.podcastId\"\n            :min-height=\"410\"\n          >\n            <PodcastItem\n              v-if=\"0 !== p.podcastId\"\n              :podcast=\"p\"\n            />\n\n            <template #preview>\n              <router-link\n                :to=\"{\n                  name: 'podcast',\n                  params: { podcastId: p.podcastId },\n                }\"\n                :title=\"t('Episode name page', { name: p.title })\"\n              >\n                {{ p.title }}\n              </router-link>\n            </template>\n          </ClassicLazy>\n        </div>\n      </template>\n    </ListPaginate>\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport ListPaginate from \"../list/ListPaginate.vue\";\nimport {useErrorHandler} from \"../../composable/useErrorHandler\";\nimport {useOrgaComputed} from \"../../composable/useOrgaComputed\";\nimport classicApi from \"../../../api/classicApi\";\nimport PodcastItem from \"../podcasts/PodcastItem.vue\";\nimport ClassicSearch from \"../../form/ClassicSearch.vue\";\nimport ClassicLazy from \"../../misc/ClassicLazy.vue\";\nimport { Podcast } from \"@/stores/class/general/podcast\";\nimport { Playlist } from \"@/stores/class/general/playlist\";\nimport { computed, onBeforeMount, Ref, ref, watch } from \"vue\";\nimport { AxiosError } from \"axios\";\nimport { useI18n } from \"vue-i18n\";\nimport { playlistApi } from \"../../../api/playlistApi\";\n\n//Props \nconst props = defineProps({\n  playlist: { default: () => ({}), type: Object as () => Playlist },\n  first: { default: 0, type: Number },\n  size: { default: 30, type: Number },\n  query: { default: undefined, type: String },\n})\n\n//Emits\nconst emit = defineEmits([\"update:query\"]);\n\n//Data \nconst loading = ref(true);\nconst podcasts: Ref<Array<Podcast>> = ref([]);\nconst podcastsQuery: Ref<Array<Podcast>> = ref([]);\nconst dfirst = ref(props.first);\nconst dsize = ref(props.size);\nconst searchPattern = ref(\"\");\nconst isMobile = ref(false);\n\n//Composables\nconst { t } = useI18n();\nconst {handle403} = useErrorHandler();\nconst { isEditRights } = useOrgaComputed();\n\n//Computed\nconst titleList = computed(() => notEmptyPlaylist.value? t(\"Podcasts in the playlist\"): t(\"No podcasts in the playlist\"));\nconst notEmptyPlaylist = computed(() => 0 !== Object.keys(props.playlist.samplingViews ?? []).length);\nconst podcastsDisplay = computed(() => {\n  if (isMobile.value) {\n    return podcastsQuery.value.slice(\n      0,\n      Math.min(dfirst.value + dsize.value, podcasts.value.length),\n    );\n  }\n  return podcastsQuery.value.slice(\n    dfirst.value,\n    Math.min(dfirst.value + dsize.value, podcasts.value.length),\n  );\n});\nconst editRight = computed(() =>isEditRights(props.playlist.organisation?.id));\n\n//Watch\nwatch(searchPattern,() => {\n  emit('update:query', searchPattern.value);\n  if (\"\" !== searchPattern.value) {\n    podcastsQuery.value = podcasts.value.filter((el: Podcast) => {\n      return el.title\n        .toLowerCase()\n        .includes(searchPattern.value.toLowerCase());\n    });\n  } else {\n    podcastsQuery.value = podcasts.value;\n  }\n});\n\nonBeforeMount(fetchContent);\n\n\n//Methods\nasync function fetchContent(): Promise<void> {\n  if (notEmptyPlaylist.value) {\n    podcasts.value.length = 0;\n    loading.value = true;\n    try {\n      podcasts.value = await playlistApi.getContentFull(props.playlist.playlistId);\n      if (!editRight.value) {\n        podcasts.value = podcasts.value.filter((p: Podcast | null) => {\n          return (\n            null !== p &&\n            (!p.availability || true === p.availability.visibility)\n          );\n        });\n      }\n      podcastsQuery.value = podcasts.value;\n      searchPattern.value = props.query ?? \"\";\n    } catch (error) {\n      handle403(error as AxiosError);\n    }\n  }\n  loading.value = false;\n}\n</script>\n\n","<!--\n  Component displaying a list of podcasts IN A PLAYLIST\n  Do not confuse this with PodcastList from podcasts\n-->\n<template>\n  <div>\n    <h3 class=\"mb-3 align-self-baseline\">\n      {{ titleList }}\n    </h3>\n\n    <ClassicSearch\n      v-if=\"!loading && notEmptyPlaylist\"\n      v-model:text-init=\"searchPattern\"\n      class=\"align-self-baseline mb-2\"\n      id-search=\"podcast-list-search\"\n      :label=\"t('Search')\"\n    />\n\n    <ListPaginate\n      id=\"podcastPlaylistListPaginate\"\n      v-model:first=\"dfirst\"\n      v-model:rows-per-page=\"dsize\"\n      v-model:is-mobile=\"isMobile\"\n      :text-count=\"\n        podcasts.length > 1\n          ? `${t('Number podcasts', { nb: podcasts.length })}`\n          : undefined\n      \"\n      :total-count=\"podcasts.length\"\n      :loading=\"loading\"\n      :loading-text=\"loading ? t('Loading podcasts ...') : undefined\"\n      :error-text=\"\n        !loading && !podcasts.length && notEmptyPlaylist\n          ? t(`No podcast match your query`)\n          : undefined\n      \"\n      :player-responsive=\"true\"\n      :force-update-parameters=\"true\"\n    >\n      <template #list>\n        <div class=\"octopus-element-list\">\n          <ClassicLazy\n            v-for=\"p in podcastsDisplay\"\n            :key=\"p.podcastId\"\n            :min-height=\"410\"\n          >\n            <PodcastItem\n              v-if=\"0 !== p.podcastId\"\n              :podcast=\"p\"\n            />\n\n            <template #preview>\n              <router-link\n                :to=\"{\n                  name: 'podcast',\n                  params: { podcastId: p.podcastId },\n                }\"\n                :title=\"t('Episode name page', { name: p.title })\"\n              >\n                {{ p.title }}\n              </router-link>\n            </template>\n          </ClassicLazy>\n        </div>\n      </template>\n    </ListPaginate>\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport ListPaginate from \"../list/ListPaginate.vue\";\nimport {useErrorHandler} from \"../../composable/useErrorHandler\";\nimport {useOrgaComputed} from \"../../composable/useOrgaComputed\";\nimport classicApi from \"../../../api/classicApi\";\nimport PodcastItem from \"../podcasts/PodcastItem.vue\";\nimport ClassicSearch from \"../../form/ClassicSearch.vue\";\nimport ClassicLazy from \"../../misc/ClassicLazy.vue\";\nimport { Podcast } from \"@/stores/class/general/podcast\";\nimport { Playlist } from \"@/stores/class/general/playlist\";\nimport { computed, onBeforeMount, Ref, ref, watch } from \"vue\";\nimport { AxiosError } from \"axios\";\nimport { useI18n } from \"vue-i18n\";\nimport { playlistApi } from \"../../../api/playlistApi\";\n\n//Props \nconst props = defineProps({\n  playlist: { default: () => ({}), type: Object as () => Playlist },\n  first: { default: 0, type: Number },\n  size: { default: 30, type: Number },\n  query: { default: undefined, type: String },\n})\n\n//Emits\nconst emit = defineEmits([\"update:query\"]);\n\n//Data \nconst loading = ref(true);\nconst podcasts: Ref<Array<Podcast>> = ref([]);\nconst podcastsQuery: Ref<Array<Podcast>> = ref([]);\nconst dfirst = ref(props.first);\nconst dsize = ref(props.size);\nconst searchPattern = ref(\"\");\nconst isMobile = ref(false);\n\n//Composables\nconst { t } = useI18n();\nconst {handle403} = useErrorHandler();\nconst { isEditRights } = useOrgaComputed();\n\n//Computed\nconst titleList = computed(() => notEmptyPlaylist.value? t(\"Podcasts in the playlist\"): t(\"No podcasts in the playlist\"));\nconst notEmptyPlaylist = computed(() => 0 !== Object.keys(props.playlist.samplingViews ?? []).length);\nconst podcastsDisplay = computed(() => {\n  if (isMobile.value) {\n    return podcastsQuery.value.slice(\n      0,\n      Math.min(dfirst.value + dsize.value, podcasts.value.length),\n    );\n  }\n  return podcastsQuery.value.slice(\n    dfirst.value,\n    Math.min(dfirst.value + dsize.value, podcasts.value.length),\n  );\n});\nconst editRight = computed(() =>isEditRights(props.playlist.organisation?.id));\n\n//Watch\nwatch(searchPattern,() => {\n  emit('update:query', searchPattern.value);\n  if (\"\" !== searchPattern.value) {\n    podcastsQuery.value = podcasts.value.filter((el: Podcast) => {\n      return el.title\n        .toLowerCase()\n        .includes(searchPattern.value.toLowerCase());\n    });\n  } else {\n    podcastsQuery.value = podcasts.value;\n  }\n});\n\nonBeforeMount(fetchContent);\n\n\n//Methods\nasync function fetchContent(): Promise<void> {\n  if (notEmptyPlaylist.value) {\n    podcasts.value.length = 0;\n    loading.value = true;\n    try {\n      podcasts.value = await playlistApi.getContentFull(props.playlist.playlistId);\n      if (!editRight.value) {\n        podcasts.value = podcasts.value.filter((p: Podcast | null) => {\n          return (\n            null !== p &&\n            (!p.availability || true === p.availability.visibility)\n          );\n        });\n      }\n      podcastsQuery.value = podcasts.value;\n      searchPattern.value = props.query ?? \"\";\n    } catch (error) {\n      handle403(error as AxiosError);\n    }\n  }\n  loading.value = false;\n}\n</script>\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqFA,MAAM,QAAQ;EAQd,MAAM,OAAO;EAGb,MAAM,UAAU,IAAI,IAAI;EACxB,MAAM,WAAgC,IAAI,CAAC,CAAC;EAC5C,MAAM,gBAAqC,IAAI,CAAC,CAAC;EACjD,MAAM,SAAS,IAAI,MAAM,KAAK;EAC9B,MAAM,QAAQ,IAAI,MAAM,IAAI;EAC5B,MAAM,gBAAgB,IAAI,EAAE;EAC5B,MAAM,WAAW,IAAI,KAAK;EAG1B,MAAM,EAAE,MAAM,QAAQ;EACtB,MAAM,EAAC,cAAa,gBAAgB;EACpC,MAAM,EAAE,iBAAiB,gBAAg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