Skip to content
Open
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
1 change: 1 addition & 0 deletions web/src/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export default {
title: 'Title *',
description: 'Description',
required: 'Required',
search: 'Search',
key: '{expr}',
surveyVariables: 'Survey Variables',
addVariable: 'Add variable',
Expand Down
1 change: 1 addition & 0 deletions web/src/lang/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default {
title: 'Título *',
description: 'Descripción',
required: 'Requerido',
search: 'Buscar',
key: '{expr}',
surveyVariables: 'Variables de Encuesta',
addVariable: 'Agregar variable',
Expand Down
47 changes: 46 additions & 1 deletion web/src/views/project/Templates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@
</v-toolbar-title>
<v-spacer></v-spacer>

<v-text-field
v-model="search"
:label="$t('search')"
prepend-inner-icon="mdi-magnify"
clearable
hide-details
dense
outlined
single-line
class="templates-search mr-3"
/>

<v-menu
offset-y
>
Expand Down Expand Up @@ -136,7 +148,7 @@
single-expand
show-expand
:headers="filteredHeaders"
:items="items"
:items="searchedItems"
:items-per-page="Number.MAX_VALUE"
:expanded.sync="openedItems"
:style="{
Expand Down Expand Up @@ -257,6 +269,10 @@
padding-right: 0 !important;
}

.templates-search {
max-width: 260px;
}

@media #{map-get($display-breakpoints, 'sm-and-down')} {
.templates-table .v-data-table__mobile-row:first-child {
display: none !important;
Expand Down Expand Up @@ -311,6 +327,7 @@ export default {
viewTab: null,
apps: null,
itemApp: '',
search: '',
};
},

Expand Down Expand Up @@ -338,6 +355,15 @@ export default {
&& this.views
&& this.isAppsLoaded;
},

searchedItems() {
const search = (this.search || '').trim().toLowerCase();
if (!search) {
return this.items;
}

return (this.items || []).filter((item) => this.getTemplateSearchText(item).includes(search));
},
},
watch: {
async viewId() {
Expand Down Expand Up @@ -479,6 +505,25 @@ export default {
this.newTaskDialog = true;
},

getTemplateSearchText(item) {
const inventory = this.inventory?.find((x) => x.id === item.inventory_id)?.name || '';
const repository = this.repositories?.find((x) => x.id === item.repository_id)?.name || '';
const environments = Array.isArray(item.environment_ids)
? item.environment_ids
.map((id) => this.environment?.find((x) => x.id === id)?.name || '')
.join(' ')
: '';

return [
item.name,
item.playbook,
item.description,
inventory,
repository,
environments,
].filter(Boolean).join(' ').toLowerCase();
},

getHeaders() {
return [
{
Expand Down
Loading