Skip to content

Commit 839f01b

Browse files
authored
fix(ui): fix tag selection on scenarios list (#137)
1 parent 2030e62 commit 839f01b

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

chutney/ui/src/app/modules/scenarios/components/search-list/scenarios.component.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class ScenariosComponent implements OnInit, OnDestroy {
229229

230230
private initFilters() {
231231
const allTagsInScenario: string[] = this.findAllTags();
232-
this.tags = this.getTagsForComboModel(allTagsInScenario);
232+
this.tags = allTagsInScenario.map(tag => this.toSelectOption(tag,tag));
233233
this.status = [...new Set(this.scenarios.map(scenario => scenario.status))].map(status => this.toSelectOption(status, this.translateService.instant(ExecutionStatus.toString(status))));
234234
}
235235

@@ -256,7 +256,7 @@ export class ScenariosComponent implements OnInit, OnDestroy {
256256
private setSelectedTags() {
257257
const savedTags = this.stateService.getTags();
258258
if (savedTags != null) {
259-
this.selectedTags = this.getTagsForComboModel(savedTags);
259+
this.selectedTags = this.tags.filter(tag => savedTags.includes(tag.id));
260260
}
261261
}
262262

@@ -277,7 +277,7 @@ export class ScenariosComponent implements OnInit, OnDestroy {
277277
}
278278
if (params['tags']) {
279279
const uriTag = params['tags'].split(',');
280-
this.selectedTags = this.getTagsForComboModel(uriTag);
280+
this.selectedTags = this.tags.filter(tag => uriTag.includes(tag.id));
281281
}
282282
this.applyFilters();
283283
this.urlParams?.unsubscribe()
@@ -354,16 +354,7 @@ export class ScenariosComponent implements OnInit, OnDestroy {
354354
}
355355
}
356356

357-
358357
private getSelectedTags() {
359358
return this.selectedTags.map((i) => i.text);
360359
}
361-
362-
private getTagsForComboModel(tags: String[]) {
363-
let index = 0;
364-
return tags.map((t) => {
365-
index++;
366-
return {'id': index, 'text': t};
367-
});
368-
}
369360
}

0 commit comments

Comments
 (0)