Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

feat(default-theme): slugify filter type filename #1387

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/default-theme/src/components/listing/NoFilterFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,37 @@
<span class="sf-alert__message">
{{ $t("Filter") }}
<b>
{{ filter.label }}
{{ filterLabel }}
</b>
{{ $t("is not implemented! Please add new filter to") }}
`src/components/listing/types/{{ filter.label }}.vue`
`src/components/listing/types/{{ filterCode }}.vue`
</span>
</template>
</SfAlert>
</template>

<script>
import { SfAlert } from "@storefront-ui/vue"
import { simplifyString } from "@/helpers"

export default {
components: {
SfAlert,
},
name: "NoFilterFound",
data() {
return {}
},
props: {
filter: {
type: Object,
default: () => ({}),
},
},
computed: {
filterLabel() {
return this.filter.label
},
filterCode() {
return simplifyString(this.filter.label)
},
},
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script>
import { SfFilter } from "@storefront-ui/vue"
import NoFilterFound from "@/components/listing/NoFilterFound.vue"
import { simplifyString } from "@/helpers"

export default {
name: "SwProductListingFilter",
Expand Down Expand Up @@ -43,16 +44,16 @@ export default {
getComponent() {
try {
return () => ({
component: import(
"@/components/listing/types/" +
this.filter.label.toLowerCase(".vue")
),
component: import(`@/components/listing/types/${this.filterCode}`),
error: NoFilterFound,
})
} catch (e) {
console.error("SwProductListingFilter:getComponent", e)
}
},
filterCode() {
return simplifyString(this.filter.label.toLowerCase(".vue"))
},
selectedValues() {
return this.selectedFilters || []
},
Expand Down