-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webui): navigation drawer for sort/filter
preliminary to #283
- Loading branch information
Showing
9 changed files
with
290 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<v-navigation-drawer | ||
v-model="display" | ||
right | ||
fixed | ||
temporary | ||
disable-route-watcher | ||
class="fill-height" | ||
> | ||
<slot></slot> | ||
|
||
<template v-if="$slots.filter"> | ||
<v-divider/> | ||
<v-subheader>FILTER</v-subheader> | ||
</template> | ||
<slot name="filter"></slot> | ||
|
||
<template v-if="$slots.sort"> | ||
<v-divider/> | ||
<v-subheader>SORT</v-subheader> | ||
</template> | ||
<slot name="sort"></slot> | ||
|
||
</v-navigation-drawer> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
name: 'FilterDrawer', | ||
data: () => { | ||
return { | ||
display: false, | ||
} | ||
}, | ||
props: { | ||
value: Boolean, | ||
}, | ||
watch: { | ||
value (val) { | ||
this.display = val | ||
}, | ||
display (val) { | ||
!val && this.$emit('input', false) | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<v-expansion-panels accordion multiple flat tile hover> | ||
<v-expansion-panel | ||
v-for="(f, key) in filtersOptions" | ||
:key="key" | ||
> | ||
<v-expansion-panel-header> | ||
<v-icon | ||
color="secondary" | ||
style="max-width: 24px" | ||
class="mr-2" | ||
@click.stop="clear(key)" | ||
>{{ groupActive(key) ? 'mdi-checkbox-marked' : '' }} | ||
</v-icon> | ||
{{ f.name }} | ||
</v-expansion-panel-header> | ||
<v-expansion-panel-content class="no-padding"> | ||
<v-list dense> | ||
<v-list-item v-for="v in f.values" | ||
:key="v" | ||
@click.stop="click(key, v)" | ||
> | ||
<v-list-item-icon> | ||
<v-icon v-if="filtersActive[key].includes(v)" color="secondary"> | ||
mdi-checkbox-marked | ||
</v-icon> | ||
<v-icon v-else> | ||
mdi-checkbox-blank-outline | ||
</v-icon> | ||
</v-list-item-icon> | ||
<v-list-item-title class="text-capitalize"> | ||
{{ v.toString().toLowerCase().replace('_', ' ') }} | ||
</v-list-item-title> | ||
</v-list-item> | ||
</v-list> | ||
</v-expansion-panel-content> | ||
</v-expansion-panel> | ||
</v-expansion-panels> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
name: 'FilterPanels', | ||
props: { | ||
filtersOptions: { | ||
type: Object as () => FiltersOptions, | ||
required: true, | ||
}, | ||
filtersActive: { | ||
type: Object as () => FiltersActive, | ||
required: true, | ||
}, | ||
}, | ||
methods: { | ||
clear (key: string) { | ||
let r = this.$_.cloneDeep(this.filtersActive) | ||
r[key] = [] | ||
this.$emit('update:filtersActive', r) | ||
}, | ||
groupActive (key: string): boolean { | ||
for (let v of this.filtersOptions[key].values) { | ||
if (this.filtersActive[key].includes(v)) { | ||
return true | ||
} | ||
} | ||
return false | ||
}, | ||
click (key: string, value: string) { | ||
let r = this.$_.cloneDeep(this.filtersActive) | ||
if (r[key].includes(value)) this.$_.pull(r[key], (value)) | ||
else r[key].push(value) | ||
this.$emit('update:filtersActive', r) | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style> | ||
.no-padding .v-expansion-panel-content__wrap { | ||
padding: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<v-list dense> | ||
<v-list-item v-for="(item, index) in sortOptions" | ||
:key="index" | ||
@click="setSort(item)" | ||
> | ||
<v-list-item-icon> | ||
<v-icon color="secondary" v-if="item.key === sortActive.key && sortActive.order === 'asc'"> | ||
mdi-chevron-up | ||
</v-icon> | ||
<v-icon color="secondary" v-if="item.key === sortActive.key && sortActive.order === 'desc'"> | ||
mdi-chevron-down | ||
</v-icon> | ||
</v-list-item-icon> | ||
<v-list-item-title>{{ item.name }}</v-list-item-title> | ||
</v-list-item> | ||
</v-list> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
export default Vue.extend({ | ||
name: 'SortList', | ||
props: { | ||
sortOptions: { | ||
type: Array, | ||
required: true, | ||
}, | ||
sortDefault: { | ||
type: Object, | ||
required: true, | ||
}, | ||
sortActive: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
methods: { | ||
setSort (sort: SortOption) { | ||
if (this.sortActive.key === sort.key) { | ||
if (this.sortActive.order === 'desc') { | ||
this.$emit('update:sortActive', { key: sort.key, order: 'asc' }) | ||
} else { | ||
this.$emit('update:sortActive', { key: sort.key, order: 'desc' }) | ||
} | ||
} else { | ||
this.$emit('update:sortActive', { key: sort.key, order: 'desc' }) | ||
} | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function sortOrFilterActive (sortActive: SortActive, sortDefault: SortActive, filters: FiltersActive): boolean { | ||
const sortCustom = sortActive.key !== sortDefault.key || sortActive.order !== sortDefault.order | ||
const filterCustom = Object.keys(filters).some(x => filters[x].length !== 0) | ||
return sortCustom || filterCustom | ||
} |
Oops, something went wrong.