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

Disables tag recommendations in TagFilterAutoComplete UI component #3357

Merged
merged 3 commits into from
May 4, 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
5 changes: 4 additions & 1 deletion src/dispatch/static/dispatch/src/tag/DeleteDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</v-card-title>
<v-card-text>
<v-container grid-list-md>
<v-layout wrap> Are you sure you would like to delete this tag? </v-layout>
<v-layout wrap> Are you sure you want to delete this tag? </v-layout>
</v-container>
</v-card-text>
<v-card-actions>
Expand All @@ -21,11 +21,14 @@
<script>
import { mapActions } from "vuex"
import { mapFields } from "vuex-map-fields"

export default {
name: "TagDeleteDialog",

data() {
return {}
},

computed: {
...mapFields("tag", ["dialogs.showRemove"]),
},
Expand Down
3 changes: 2 additions & 1 deletion src/dispatch/static/dispatch/src/tag/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<v-divider />
<v-list>
<v-list-group prepend-icon="label" no-action color="info">
<template v-slot:activator>
<template #activator>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Tags ({{ items.length }})</v-list-item-title>
Expand All @@ -29,6 +29,7 @@
import { mapActions } from "vuex"

import NewEditSheet from "@/tag/NewEditSheet.vue"

export default {
name: "TagList",

Expand Down
7 changes: 4 additions & 3 deletions src/dispatch/static/dispatch/src/tag/NewEditSheet.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<ValidationObserver v-slot="{ invalid, validated }">
<v-navigation-drawer v-model="showCreateEdit" app clipped right width="500">
<template v-slot:prepend>
<template #prepend>
<v-list-item two-line>
<v-list-item-content>
<v-list-item-title v-if="id" class="title"> Edit </v-list-item-title>
Expand Down Expand Up @@ -117,10 +117,11 @@
</template>

<script>
import { mapFields } from "vuex-map-fields"
import { mapActions } from "vuex"
import { ValidationObserver, ValidationProvider, extend } from "vee-validate"
import { mapActions } from "vuex"
import { mapFields } from "vuex-map-fields"
import { required } from "vee-validate/dist/rules"

import TagTypeSelect from "@/tag_type/TagTypeSelect.vue"

extend("required", {
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/static/dispatch/src/tag/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</template>
<template v-slot:item.data-table-actions="{ item }">
<v-menu bottom left>
<template v-slot:activator="{ on }">
<template #activator="{ on }">
<v-btn icon v-on="on">
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
Expand All @@ -70,9 +70,9 @@
import { mapFields } from "vuex-map-fields"
import { mapActions } from "vuex"

import SettingsBreadcrumbs from "@/components/SettingsBreadcrumbs.vue"
import DeleteDialog from "@/tag/DeleteDialog.vue"
import NewEditSheet from "@/tag/NewEditSheet.vue"
import SettingsBreadcrumbs from "@/components/SettingsBreadcrumbs.vue"

export default {
name: "TagTable",
Expand Down
63 changes: 36 additions & 27 deletions src/dispatch/static/dispatch/src/tag/TagFilterAutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
no-filter
v-model="tags"
>
<template v-slot:no-data>
<template #no-data>
<v-list-item>
<v-list-item-content>
<v-list-item-title>
Expand Down Expand Up @@ -47,7 +47,7 @@
</v-list-item-subtitle>
</v-list-item-content>
</template>
<template v-slot:append-item>
<template #append-item>
<v-list-item v-if="more" @click="loadMore()">
<v-list-item-content>
<v-list-item-subtitle> Load More </v-list-item-subtitle>
Expand All @@ -65,6 +65,7 @@ import TagApi from "@/tag/api"

export default {
name: "TagAutoComplete",

props: {
value: {
type: Array,
Expand All @@ -89,6 +90,7 @@ export default {
default: null,
},
},

data() {
return {
loading: false,
Expand Down Expand Up @@ -136,47 +138,54 @@ export default {
this.error = null
this.loading = "error"

// fetch recommendations model and ID are provided
if (!this.search) {
if (this.model && this.modelId) {
TagApi.getRecommendations(this.model, this.modelId).then((response) => {
this.items = response.data.items
this.total = response.data.total
// we don't support more for suggestions (limited)
this.more = false
this.loading = false
})
return
}
}
// NOTE: Disabled until loading more is supported
//
// Fetch recommendations model and ID are provided
// if (!this.search) {
// if (this.model && this.modelId) {
// TagApi.getRecommendations(this.model, this.modelId).then((response) => {
// this.items = response.data.items
// this.total = response.data.total
// // we don't support more for suggestions (limited)
// this.more = false
// this.loading = false
// })
// return
// }
// }

let filterOptions = {
q: this.search,
itemsPerPage: this.numItems,
sortBy: ["tag_type.name"],
descending: [false],
}

let filters = {}

if (this.project) {
filterOptions = {
...filterOptions,
filters: {
project: [this.project],
},
}
// we add a project filter
filters["project"] = [this.project]
}

let tagTypeFilter = {}
// we add a filter to only retrun discoverable tags
filters["tagFilter"] = [{ model: "Tag", field: "discoverable", op: "==", value: "true" }]
mvilanova marked this conversation as resolved.
Show resolved Hide resolved

if (filterOptions.q) {
if (filterOptions.q.indexOf("/") != -1) {
// we modify the query and add a tag type filter
let [tagType, query] = filterOptions.q.split("/")
filterOptions.q = query
tagTypeFilter = [{ model: "TagType", field: "name", op: "==", value: tagType }]
filters["tagTypeFilter"] = [{ model: "TagType", field: "name", op: "==", value: tagType }]
}
}

filterOptions = SearchUtils.createParametersFromTableOptions(
{ ...filterOptions },
tagTypeFilter
)
filterOptions = {
...filterOptions,
filters: filters,
}

filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })

TagApi.getAll(filterOptions).then((response) => {
this.items = response.data.items
Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/static/dispatch/src/tag/TagSummaryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
<script>
import { mapActions } from "vuex"
import NewEditSheet from "@/tag/NewEditSheet.vue"

export default {
name: "TagSummaryTable",

components: {
NewEditSheet,
},

data() {
return {
headers: [
Expand Down