Commit 32edaadd authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

autocomplete prefix (progress 70%)

parent 720ef70a
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Prefix } from 'src/app/models/prefix.model';
import { PrefixService } from 'src/app/services/prefix.service';
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
@Component({
selector: 'app-prefix-details',
......@@ -24,6 +27,9 @@ export class PrefixDetailsComponent implements OnInit {
objects = [];
logic_con = [];
public static id: any [] = [];
private readonly notifier: NotifierService;
//for the moment only one prefix can showed/updates
currentprefix: Prefix = {
prefix: "",
......@@ -37,7 +43,8 @@ export class PrefixDetailsComponent implements OnInit {
message = '';
constructor(private prefixService: PrefixService) {
constructor(private prefixService: PrefixService,private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) { this.notifier = notifierService;
this.simpleprefixfilteredOptions = this.simpleprefixControl.valueChanges.pipe(
startWith(""),
map(value => this._filter(this.simpleprefix, value))
......@@ -48,31 +55,44 @@ export class PrefixDetailsComponent implements OnInit {
);
}
ngOnInit(): void { this.getchoices(); }
ngOnInit(): void {
this.getchoices();
for (let i=0; i<PrefixDetailsComponent.id.length; i++)
{
this.getPrefix(this.route.snapshot.params.id, PrefixDetailsComponent.id[i]);
};
}
private _filter(data:string[], value: string): string[] {
const filterValue = value.toLowerCase();
this.currentprefix.prefix = this.simpleprefixControl.value;
this.currentprefix.system_fun_item = this.subjectsControl.value;
return data.filter(option => option.toLowerCase().indexOf(filterValue) === 0);
}
getPrefix(prefix: any, id: string): void {
//PrefixDetailsComponent.id = id;
this.prefixService.get(prefix, id)
.subscribe(
data => {
this.currentprefix = data;
console.log(data);
console.log(data)
this.simpleprefixControl.setValue(this.currentprefix.prefix);
//make it null need solution
//this.subjectsControl.setValue(this.currentprefix.system_fun_item);
},
error => {
console.log(error);
});
}
// to be done
updateBoilerplate(): void {
//this.simpleprefix =
/*this.prefixService.update()
updatePrefix(): void {
for (let i=0; i<PrefixDetailsComponent.id.length; i++){
this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix)
.subscribe(
response => {
console.log(response);
......@@ -80,7 +100,8 @@ export class PrefixDetailsComponent implements OnInit {
},
error => {
console.log(error);
});*/
this.notifier.notify("warning",(JSON.stringify(error["error"])));
});}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment