Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to organize filters by group #1190

Merged
merged 2 commits into from
Sep 18, 2023
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
14 changes: 0 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1169,20 +1169,6 @@ textarea.input:focus {
max-width: 95%;
}

.query-list .tag {
margin-right: 1em;
margin-bottom: 0.2em;
border: 1px solid transparent;
}

.query-list .tag .delete {
transform: rotate(45deg) scale(0.7);
}

.query-list .tag:hover {
transform: scale(1.1);
}

.fixed-page {
position: fixed;
left: 0;
Expand Down
128 changes: 128 additions & 0 deletions src/components/modals/EditSearchFilterGroupModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<template>
<div
:class="{
modal: true,
'is-active': active
}"
>
<div class="modal-background" @click="$emit('cancel')"></div>

<div class="modal-content">
<div class="box">
<h1 class="title" v-if="groupToEdit.id">
{{ $t('main.filter_group_edit') }} "{{ groupToEdit.name }}"
</h1>
<h1 class="title" v-else>
{{ $t('main.filter_group_add') }}
</h1>

<form v-on:submit.prevent>
<text-field
ref="nameField"
:label="$t('assets.fields.name')"
v-model.trim="form.name"
@enter="runConfirmation"
v-focus
/>
<color-field
ref="colorField"
:label="$t('main.color')"
v-model="form.color"
/>
</form>

<modal-footer
:error-text="$t('main.filter_group_error')"
:is-error="isError"
:is-loading="isLoading"
@confirm="runConfirmation"
@cancel="$emit('cancel')"
/>
</div>
</div>
</div>
</template>

<script>
/*
* Modal used to edit filter group information.
*/
import { modalMixin } from '@/components/modals/base_modal'
import ModalFooter from '@/components/modals/ModalFooter'
import ColorField from '@/components/widgets/ColorField'
import TextField from '@/components/widgets/TextField'

export default {
name: 'edit-search-filter-group-modal',
mixins: [modalMixin],
components: {
ColorField,
ModalFooter,
TextField
},

props: {
active: {
type: Boolean,
default: false
},
isError: {
type: Boolean,
default: false
},
isLoading: {
type: Boolean,
default: false
},
groupToEdit: {
type: Object,
default: () => {}
}
},

data() {
return {
form: {
color: '',
name: ''
}
}
},

methods: {
runConfirmation(event) {
if (!this.form.name.length) {
this.$refs.nameField.focus()
return
}

if (!event || event.keyCode === 13 || !event.keyCode) {
this.$emit('confirm', this.form)
}
}
},

watch: {
groupToEdit() {
const {
id,
color = '',
name = ''
} = this.groupToEdit?.id ? this.groupToEdit : {}
this.form = {
id,
color,
name
}
},

active() {
if (this.active) {
setTimeout(() => {
this.$refs.nameField.focus()
}, 100)
}
}
}
}
</script>
64 changes: 39 additions & 25 deletions src/components/modals/EditSearchFilterModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@
<text-field
ref="nameField"
:label="$t('assets.fields.name')"
v-model="form.name"
v-model.trim="form.name"
@enter="runConfirmation"
v-focus
/>

<text-field
ref="nameField"
:label="$t('main.search_query')"
v-model="form.search_query"
v-model.trim="form.search_query"
@enter="runConfirmation"
v-focus
/>

<combobox
:label="$t('main.filter_group')"
:options="groupOptions"
v-model="form.search_filter_group_id"
v-if="isGroupEnabled"
/>
</form>

Expand All @@ -49,14 +54,16 @@
filter label when it's too complex to read or too long.
*/
import { modalMixin } from '@/components/modals/base_modal'
import ModalFooter from '@/components/modals/ModalFooter'

import Combobox from '@/components/widgets/Combobox'
import TextField from '@/components/widgets/TextField'
import ModalFooter from '@/components/modals/ModalFooter'

export default {
name: 'edit-search-filter-modal',
mixins: [modalMixin],
components: {
Combobox,
ModalFooter,
TextField
},
Expand All @@ -70,38 +77,43 @@ export default {
type: Boolean,
default: false
},
isGroupEnabled: {
type: Boolean,
default: false
},
isLoading: {
type: Boolean,
default: false
},
searchQueryToEdit: {
type: Object,
default: () => {}
},
groupOptions: {
type: Array,
default: () => []
}
},

data() {
if (this.searchQueryToEdit && this.searchQueryToEdit.id) {
return {
form: {
text: this.searchQueryToEdit.text,
task_status_id: this.searchQueryToEdit.task_status_id
}
}
} else {
return {
form: {
text: '',
task_status_id: null
}
return {
form: {
id: null,
name: '',
search_filter_group_id: null,
search_query: '',
task_status_id: null
}
}
},

computed: {},

methods: {
runConfirmation(event) {
if (!this.form.name.length) {
this.$refs.nameField.focus()
return
}

if (!event || event.keyCode === 13 || !event.keyCode) {
this.$emit('confirm', {
id: this.searchQueryToEdit.id,
Expand All @@ -113,15 +125,19 @@ export default {

watch: {
searchQueryToEdit() {
if (this.searchQueryToEdit && this.searchQueryToEdit.id) {
if (this.searchQueryToEdit?.id) {
this.form.id = this.searchQueryToEdit.id
this.form.name = this.searchQueryToEdit.name
this.form.search_filter_group_id =
this.searchQueryToEdit.search_filter_group_id
this.form.search_query = this.searchQueryToEdit.search_query
} else {
this.form = {
id: '',
id: null,
name: '',
search_query: ''
search_filter_group_id: null,
search_query: '',
task_status_id: null
}
}
},
Expand All @@ -136,5 +152,3 @@ export default {
}
}
</script>

<style lang="scss" scoped></style>
20 changes: 10 additions & 10 deletions src/components/pages/Assets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
</div>
<div class="query-list">
<search-query-list
:groups="assetSearchFilterGroups"
:is-group-enabled="true"
:queries="assetSearchQueries"
type="asset"
@change-search="changeSearch"
@remove-search="removeSearchQuery"
v-if="!isAssetsLoading && !initialLoading"
Expand Down Expand Up @@ -423,6 +426,7 @@ export default {
'assetListScrollPosition',
'assetsCsvFormData',
'assetSearchText',
'assetSearchFilterGroups',
'assetSearchQueries',
'assetTypes',
'assetValidationColumns',
Expand Down Expand Up @@ -812,19 +816,15 @@ export default {
},

saveSearchQuery(searchQuery) {
this.saveAssetSearch(searchQuery)
.then(() => {})
.catch(err => {
if (err) console.error(err)
})
this.saveAssetSearch(searchQuery).catch(err => {
if (err) console.error(err)
})
},

removeSearchQuery(searchQuery) {
this.removeAssetSearch(searchQuery)
.then(() => {})
.catch(err => {
if (err) console.error(err)
})
this.removeAssetSearch(searchQuery).catch(err => {
if (err) console.error(err)
})
},

saveScrollPosition(scrollPosition) {
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/Edits.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<div class="query-list">
<search-query-list
:queries="editSearchQueries"
type="edit"
@change-search="changeSearch"
@remove-search="removeSearchQuery"
v-if="!isEditsLoading && !initialLoading"
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/Episodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<div class="query-list mt1">
<search-query-list
:queries="episodeSearchQueries"
type="episode"
@change-search="changeSearch"
@remove-search="removeSearchQuery"
v-if="!isEpisodesLoading && !initialLoading"
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/People.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<div class="query-list">
<search-query-list
:queries="peopleSearchQueries"
type="people"
@change-search="changeSearch"
@remove-search="removeSearchQuery"
v-if="!isPeopleLoading"
Expand Down
17 changes: 7 additions & 10 deletions src/components/pages/Person.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
>
<search-query-list
:queries="personTaskSearchQueries"
type="person"
@change-search="changeSearch"
@remove-search="removeSearchQuery"
/>
Expand Down Expand Up @@ -577,19 +578,15 @@ export default {
},

saveSearchQuery(searchQuery) {
this.savePersonTasksSearch(searchQuery)
.then(() => {})
.catch(err => {
if (err) console.error(err)
})
this.savePersonTasksSearch(searchQuery).catch(err => {
if (err) console.error(err)
})
},

removeSearchQuery(searchQuery) {
this.removePersonTasksSearch(searchQuery)
.then(() => {})
.catch(err => {
if (err) console.error(err)
})
this.removePersonTasksSearch(searchQuery).catch(err => {
if (err) console.error(err)
})
},

updateActiveTab() {
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/SequenceStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<div class="query-list mt1">
<search-query-list
:queries="sequenceSearchQueries"
type="sequenceStat"
@change-search="changeSearch"
@remove-search="removeSearchQuery"
/>
Expand Down
Loading