diff --git a/src/app/components/template/template.component.ts b/src/app/components/template/template.component.ts index e71ef850..5323a42a 100644 --- a/src/app/components/template/template.component.ts +++ b/src/app/components/template/template.component.ts @@ -48,11 +48,16 @@ export class TemplateComponent implements OnInit, OnDestroy { this.templateService.list(this.server).subscribe((listOfTemplates: Template[]) => { this.filteredTemplates = listOfTemplates; + this.sortTemplates(); this.templates = listOfTemplates; }); this.symbolService.list(this.server); } + sortTemplates() { + this.filteredTemplates = this.filteredTemplates.sort((a, b) => (a.name < b.name ? -1 : 1)); + } + filterTemplates(event) { let temporaryTemplates = this.templates.filter(item => { return item.name.toLowerCase().includes(this.searchText.toLowerCase()); @@ -63,6 +68,7 @@ export class TemplateComponent implements OnInit, OnDestroy { } else { this.filteredTemplates = temporaryTemplates.filter(t => t.template_type === this.selectedType); } + this.sortTemplates(); } dragStart(ev) {