director-view.ts 3.4 KB
Newer Older
Open Source Developer's avatar
Open Source Developer committed
1 2 3 4 5 6
import { Component, OnInit, OnDestroy,ElementRef, ViewChild} from "@angular/core";
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http';
Open Source Developer's avatar
tran  
Open Source Developer committed
7
import { NgRedux, select } from 'ng2-redux';
Open Source Developer's avatar
Open Source Developer committed
8 9 10
import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
Open Source Developer's avatar
transf  
Open Source Developer committed
11
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
Open Source Developer's avatar
trans  
Open Source Developer committed
12 13 14 15 16 17 18
import {
    FormBuilder,
    FormGroup,
    FormControl,
    FormArray,
    Validators,
} from '@angular/forms';
Open Source Developer's avatar
Open Source Developer committed
19 20 21
@Component({
    selector: 'director-view',
    template: `
Open Source Developer's avatar
transf  
Open Source Developer committed
22

Open Source Developer's avatar
trans  
Open Source Developer committed
23
    <form [formGroup]="formGroup">
Open Source Developer's avatar
transf  
Open Source Developer committed
24
            <div class="form-group" >
Open Source Developer's avatar
trans  
Open Source Developer committed
25
              <label for="name">Τάξη</label><br/>
Open Source Developer's avatar
trans  
Open Source Developer committed
26
                    <select #txoption [(ngModel)]="taxi" [ngModelOptions]="{standalone: true}" (change)="verifyclass(txoption)" >
Open Source Developer's avatar
transf  
Open Source Developer committed
27 28 29
                        <option value="1" >Α' Λυκείου</option>
                        <option value="2" >Β' Λυκείου</option>
                        <option value="3" >Γ' Λυκείου</option>
Open Source Developer's avatar
trans  
Open Source Developer committed
30 31
                    </select>

Open Source Developer's avatar
transf  
Open Source Developer committed
32
            <div>
Open Source Developer's avatar
trans  
Open Source Developer committed
33
            <div class="form-group" *ngIf="(StudentSelected$ != {}) && (bclassenabled === true)">
Open Source Developer's avatar
transf  
Open Source Developer committed
34
                    <label for="tomeas">Τομέας</label><br/>
Open Source Developer's avatar
trans  
Open Source Developer committed
35
                     <select #tmop [(ngModel)]="tomeas" [ngModelOptions]="{standalone: true}"  >
Open Source Developer's avatar
transf  
Open Source Developer committed
36
                      <option *ngFor="let SectorSelection$  of StudentSelected$ | async" [ngValue]="SectorSelection$.id">{{SectorSelection$.sector_id}}</option>
Open Source Developer's avatar
tran  
Open Source Developer committed
37
                    </select>
Open Source Developer's avatar
transf  
Open Source Developer committed
38 39
             <div>
              
Open Source Developer's avatar
Open Source Developer committed
40 41 42 43 44
   `
})

@Injectable() export default class DirectorView implements OnInit , OnDestroy{

Open Source Developer's avatar
trans  
Open Source Developer committed
45
    public formGroup: FormGroup;
Open Source Developer's avatar
Open Source Developer committed
46 47
    private StudentSelected$: BehaviorSubject<any>;
    private StudentSelectedSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
48
    public bClassEnabled: boolean;
Open Source Developer's avatar
transf  
Open Source Developer committed
49 50 51
    public gClassEnabled: boolean;
    private SchoolId = 12 ;
    
Open Source Developer's avatar
trans  
Open Source Developer committed
52 53 54

    constructor(private fb: FormBuilder,
                private _hds: HelperDataService, 
Open Source Developer's avatar
Open Source Developer committed
55 56 57 58
                private activatedRoute: ActivatedRoute,
                private router: Router )
    {
       this.StudentSelected$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
trans  
Open Source Developer committed
59
       this.formGroup = this.fb.group({
Open Source Developer's avatar
transf  
Open Source Developer committed
60
                taxi:[],
Open Source Developer's avatar
trans  
Open Source Developer committed
61
                tomeas: []
Open Source Developer's avatar
trans  
Open Source Developer committed
62
                 });
Open Source Developer's avatar
Open Source Developer committed
63 64 65 66 67 68 69 70
    }

    ngOnDestroy()
    {
        if (this.StudentSelectedSub)
            this.StudentSelectedSub.unsubscribe();

    }
Open Source Developer's avatar
tran  
Open Source Developer committed
71
 
Open Source Developer's avatar
Open Source Developer committed
72 73
    ngOnInit() {
     
Open Source Developer's avatar
transf  
Open Source Developer committed
74 75 76 77
       this.bClassEnabled = false;    
       this.gClassEnabled = false;   
       this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);    
       console.log(this.StudentSelected$);        
Open Source Developer's avatar
Open Source Developer committed
78 79 80 81

    }


Open Source Developer's avatar
trans  
Open Source Developer committed
82
    verifyclass(txop)
Open Source Developer's avatar
trans  
Open Source Developer committed
83
    {
Open Source Developer's avatar
trans  
Open Source Developer committed
84 85
            console.log(txop.value);
            if (txop.value === "1")
Open Source Developer's avatar
transf  
Open Source Developer committed
86 87 88
            {     this.bClassEnabled = false;
                  this.gClassEnabled = false;
            }
Open Source Developer's avatar
trans  
Open Source Developer committed
89
            else if (txop.value === "2")
Open Source Developer's avatar
transf  
Open Source Developer committed
90
            {
Open Source Developer's avatar
trans  
Open Source Developer committed
91
                console.log(txop.value,"aaaaaa");
Open Source Developer's avatar
transf  
Open Source Developer committed
92 93 94
                this.bClassEnabled = true;
                this.gClassEnabled = false;
            }
Open Source Developer's avatar
trans  
Open Source Developer committed
95
            else if (txop.value === "3")
Open Source Developer's avatar
transf  
Open Source Developer committed
96 97 98
            {   this.bClassEnabled = true;
                this.gClassEnabled = true;
            }            
Open Source Developer's avatar
trans  
Open Source Developer committed
99 100
    }

Open Source Developer's avatar
Open Source Developer committed
101 102

}