|
|
@@ -0,0 +1,221 @@
|
|
|
+<template>
|
|
|
+ <div class="filters">
|
|
|
+ <div class="main-filters">
|
|
|
+ <div class="unitCategories">
|
|
|
+ <q-btn v-if="unitCategories?.list?.length > 0"
|
|
|
+ flat
|
|
|
+ class="filter-btn unitCategory filter-btn__selected">
|
|
|
+ <div class="filter-btn-title">
|
|
|
+ همه
|
|
|
+ </div>
|
|
|
+ </q-btn>
|
|
|
+ <q-btn v-for="(unitCategory, unitCategoryIndex) in unitCategories.list"
|
|
|
+ :key="unitCategoryIndex"
|
|
|
+ flat
|
|
|
+ :to="{name: showCategoryRouteName, params: {category_id: unitCategory.id}}"
|
|
|
+ class="filter-btn unitCategory">
|
|
|
+ <div class="filter-btn-title">
|
|
|
+ {{ unitCategory.title }}
|
|
|
+ </div>
|
|
|
+ </q-btn>
|
|
|
+ </div>
|
|
|
+ <div class="unitCategories">
|
|
|
+ <q-btn v-if="units?.list?.length > 0"
|
|
|
+ flat
|
|
|
+ class="filter-btn unitCategory filter-btn__selected">
|
|
|
+ <div class="filter-btn-title">
|
|
|
+ همه
|
|
|
+ </div>
|
|
|
+ </q-btn>
|
|
|
+ <q-btn v-for="(unit, unitIndex) in units.list"
|
|
|
+ :key="unitIndex"
|
|
|
+ flat
|
|
|
+ :to="{name: showCategoryRouteName, params: {category_id: unit.id}}"
|
|
|
+ class="filter-btn unitCategory">
|
|
|
+ <div class="filter-btn-title">
|
|
|
+ {{ unit.title }}
|
|
|
+ </div>
|
|
|
+ </q-btn>
|
|
|
+ </div>
|
|
|
+ <div class="content-type-filters" />
|
|
|
+ </div>
|
|
|
+ <div class="sub-filters">
|
|
|
+ <q-expansion-item v-model="subFilterExpanded"
|
|
|
+ :header-style="'display: none;'">
|
|
|
+ <q-card class="sub-filters-card">
|
|
|
+ <div class="media-types">
|
|
|
+ <q-btn v-for="(mediaType, mediaTypeIndex) in mediaTypes"
|
|
|
+ :key="mediaTypeIndex"
|
|
|
+ flat
|
|
|
+ class="filter-btn unitCategory"
|
|
|
+ :class="{'filter-btn__selected': selectedMediaType === mediaType.value}"
|
|
|
+ @click="filterMediaType(mediaType.value)">
|
|
|
+ <div class="filter-btn-title">
|
|
|
+ {{ mediaType.label }}
|
|
|
+ </div>
|
|
|
+ </q-btn>
|
|
|
+ </div>
|
|
|
+ <div class="search-input">
|
|
|
+ <q-input v-model="searchText"
|
|
|
+ debounce="500">
|
|
|
+ <template #prepend>
|
|
|
+ <q-icon name="search" />
|
|
|
+ </template>
|
|
|
+ </q-input>
|
|
|
+ </div>
|
|
|
+ </q-card>
|
|
|
+ </q-expansion-item>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { Media } from 'src/models/Media.js'
|
|
|
+import { UnitCategory, UnitCategoryList } from 'src/models/UnitCategory'
|
|
|
+import { UnitList } from 'src/models/Unit'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'UnitCategoryItem',
|
|
|
+ props: {
|
|
|
+ unitCategories: {
|
|
|
+ type: UnitCategoryList,
|
|
|
+ default: new UnitCategoryList()
|
|
|
+ },
|
|
|
+ units: {
|
|
|
+ type: UnitList,
|
|
|
+ default: new UnitList()
|
|
|
+ },
|
|
|
+ unitCategory: {
|
|
|
+ type: UnitCategory,
|
|
|
+ default: new UnitCategory()
|
|
|
+ },
|
|
|
+ showCategoryRouteName: {
|
|
|
+ type: String,
|
|
|
+ default: 'Public.UnitCategory.Show'
|
|
|
+ },
|
|
|
+ listType: {
|
|
|
+ type: String,
|
|
|
+ default: 'category_parent_parent'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ emits: ['filter'],
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ media: new Media(),
|
|
|
+ searchText: null,
|
|
|
+ selectedMediaType: null,
|
|
|
+ subFilterExpanded: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ mediaTypes () {
|
|
|
+ return [{
|
|
|
+ label: 'همه',
|
|
|
+ value: null
|
|
|
+ }].concat(this.media.typeEnums)
|
|
|
+ },
|
|
|
+ screenGtMd () {
|
|
|
+ if (typeof window === 'undefined') {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return this.$q.screen.gt.md
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ searchText () {
|
|
|
+ this.emitFilters()
|
|
|
+ },
|
|
|
+ screenGtMd: {
|
|
|
+ handler (newValue) {
|
|
|
+ if (!newValue) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.subFilterExpanded = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ filterMediaType (mediaType) {
|
|
|
+ this.selectedMediaType = mediaType
|
|
|
+ this.emitFilters()
|
|
|
+ },
|
|
|
+ emitFilters () {
|
|
|
+ this.$emit('filter', this.getFilterObject())
|
|
|
+ },
|
|
|
+ getFilterObject () {
|
|
|
+ return {
|
|
|
+ medias__type: this.selectedMediaType,
|
|
|
+ search: this.searchText
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.filters {
|
|
|
+ .main-filters {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 8px;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ justify-content: space-between;
|
|
|
+
|
|
|
+ .unitCategories {
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ overflow-y: auto;
|
|
|
+ justify-content: flex-start;
|
|
|
+ scrollbar-width: none; // فایرفاکس
|
|
|
+ -ms-overflow-style: none; // IE و Edge قدیمی
|
|
|
+ }
|
|
|
+ .content-type-filters {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .sub-filters {
|
|
|
+ .sub-filters-card {
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding-top: 12px;
|
|
|
+ .media-types {
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ justify-content: flex-start;
|
|
|
+ height: 42.63px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .filter-btn {
|
|
|
+ border: 1px solid #000000;
|
|
|
+ border-radius: 20px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ background: #FFFFFF;
|
|
|
+ height: 43px;
|
|
|
+ padding: 0 8px;
|
|
|
+ white-space: nowrap;
|
|
|
+ .filter-btn-title {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #212121;
|
|
|
+ }
|
|
|
+ &.filter-btn__selected {
|
|
|
+ background: #444444;
|
|
|
+ .filter-btn-title {
|
|
|
+ color: white;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.unitCategories::-webkit-scrollbar {
|
|
|
+ display: none; // کروم و سافاری
|
|
|
+}
|
|
|
+</style>
|