From fc18c76efddf0e47e351cf2c31e4514eb2ea9feb Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Mon, 21 Aug 2023 11:44:01 +0200 Subject: [PATCH] Fix filtering of template tags [SCI-8422] --- .../label_template/insert_field_dropdown.vue | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/app/javascript/vue/label_template/insert_field_dropdown.vue b/app/javascript/vue/label_template/insert_field_dropdown.vue index 64a6a0e8f..4d54048fa 100644 --- a/app/javascript/vue/label_template/insert_field_dropdown.vue +++ b/app/javascript/vue/label_template/insert_field_dropdown.vue @@ -43,11 +43,11 @@ {{ field.key }} - +
{{ i18n.t('label_templates.show.insert_dropdown.nothing_found') }}
@@ -107,28 +107,22 @@ ` }, filteredFields() { - let result = {}; - if (this.searchValue.length == 0) { - result = this.fields; - } else { - let filteredRepositories = this.filterArray(this.fields.repositories, 'repository_name'); - filteredRepositories = filteredRepositories.map((repo) => { - repo.tags = this.filterArray(repo.tags, 'key'); - return repo; - }); - - result = { - default: this.filterArray(this.fields.default, 'key'), - common: this.filterArray(this.fields.common, 'key'), - repositories: filteredRepositories, - }; - } - this.$nextTick(() => { $('.tooltip').remove(); $('[data-toggle="tooltip"]').tooltip(); }); - return result; + + if (this.searchValue.length == 0) { + return this.fields; + } else { + return { + default: this.filterArray(this.fields.default, 'key'), + common: this.filterArray(this.fields.common, 'key'), + repositories: this.filterArray(this.fields.repositories, 'repository_name').map((repo) => { + return { ...repo, tags: this.filterArray(repo.tags, 'key') }; + }) + }; + } }, noResults() { return this.filteredFields.default.concat(this.filteredFields.common, this.filteredFields.repositories).length === 0;