<div class="row">
<div class="col-md-8">
- <mou-map (newactive)="sidebar.update($event)" #map></mou-map>
+ <mou-map (newactive)="sidebar.update($event)" (neworg)="sidebar.add($event)"#map></mou-map>
</div>
<div class="col-md-4">
<mou-sidebar #sidebar></mou-sidebar>
@Component({
selector: 'mou-map',
directives: [CORE_DIRECTIVES],
- events: ['newactive'],
+ events: ['newactive','neworg'],
templateUrl: './components/map/map.html'
})
uprunned: boolean;
constructor(http:Http) {
this.newactive = new EventEmitter();
- this.newOrg = new EventEmitter();
+ this.neworg = new EventEmitter();
this.map = new google.maps.Map(document.getElementById("map"),{center: {lat:0,lng:0}, zoom:12});
this.init();
this.http = http;
let lng = pos.lng()
let location= {lat: lat, lng: lng};
let event = {location,parent};
- this.newOrg.next(event);
+ this.neworg.next(event);
}
<div>
- <div *ng-if="activeOrgUnit">
+ <div [hidden]="!active">
<form *ng-if="editmode" (ng-submit)="onSubmit()" #of="form">
<h3>{{activeOrgUnit.id?"Update Organizational Unit":"Add new Organizational Unit"}}</h3>
<div class="form-group">
import {Component, NgFor, NgIf, NgModel, CORE_DIRECTIVES,FORM_DIRECTIVES} from 'angular2/angular2';
import {Http, Headers} from 'angular2/http';
+declare var zone: Zone;
@Component({
selector: 'mou-sidebar',
http:Http;
activeOrgUnit:Object;
editmode:boolean;
- submitted = false;
-
+ active: boolean;
constructor(http:Http) {
this.http = http;
this.editmode = false;
+ this.active = false;
+ this.activeOrgUnit = new Object();
}
update(orgunitId) {
+ this.active = true;
this.http.get(dhisAPI + "/api/organisationUnits/" + orgunitId)
.map(res => res.json())
.subscribe(res => this.activeOrgUnit = res)
.subscribe(res => console.log(res));
}
+
+
}
cancel(){
if(this.activeOrgUnit.id){
this.update(this.activeOrgUnit.id);
}else{
- this.activeOrgUnit = null;
+ this.activeOrgUnit = new Object();
}
}
+
+ addData(data){
+
+ this.active = true;
+ this.editmode = true;
+ console.log(data);
+ this.activeOrgUnit = new Object();
+ this.activeOrgUnit.name = "Erik";
+ console.log("faen");
+ zone.afterTask();
+ }
}