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

autocomplete prefix (progress 70%)

parent 720ef70a
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Prefix } from 'src/app/models/prefix.model'; import { Prefix } from 'src/app/models/prefix.model';
import { PrefixService } from 'src/app/services/prefix.service'; import { PrefixService } from 'src/app/services/prefix.service';
import {FormControl} from '@angular/forms'; import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators'; import {map, startWith} from 'rxjs/operators';
import { NotifierService } from "angular-notifier";
@Component({ @Component({
selector: 'app-prefix-details', selector: 'app-prefix-details',
...@@ -24,6 +27,9 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -24,6 +27,9 @@ export class PrefixDetailsComponent implements OnInit {
objects = []; objects = [];
logic_con = []; logic_con = [];
public static id: any [] = [];
private readonly notifier: NotifierService;
//for the moment only one prefix can showed/updates //for the moment only one prefix can showed/updates
currentprefix: Prefix = { currentprefix: Prefix = {
prefix: "", prefix: "",
...@@ -37,7 +43,8 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -37,7 +43,8 @@ export class PrefixDetailsComponent implements OnInit {
message = ''; 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( this.simpleprefixfilteredOptions = this.simpleprefixControl.valueChanges.pipe(
startWith(""), startWith(""),
map(value => this._filter(this.simpleprefix, value)) map(value => this._filter(this.simpleprefix, value))
...@@ -48,31 +55,44 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -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[] { private _filter(data:string[], value: string): string[] {
const filterValue = value.toLowerCase(); 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); return data.filter(option => option.toLowerCase().indexOf(filterValue) === 0);
} }
getPrefix(prefix: any, id: string): void { getPrefix(prefix: any, id: string): void {
//PrefixDetailsComponent.id = id;
this.prefixService.get(prefix, id) this.prefixService.get(prefix, id)
.subscribe( .subscribe(
data => { data => {
this.currentprefix = 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 => { error => {
console.log(error); console.log(error);
}); });
} }
// to be done
updateBoilerplate(): void { updatePrefix(): void {
//this.simpleprefix = for (let i=0; i<PrefixDetailsComponent.id.length; i++){
/*this.prefixService.update() this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix)
.subscribe( .subscribe(
response => { response => {
console.log(response); console.log(response);
...@@ -80,7 +100,8 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -80,7 +100,8 @@ export class PrefixDetailsComponent implements OnInit {
}, },
error => { error => {
console.log(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