Update template.component.ts

This commit is contained in:
piotrpekala7 2020-09-09 16:38:51 +02:00
parent c7db04ce3b
commit cf725931f9

View File

@ -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) {