[sidebar] Working on adding object
authorErik Haider Forsén <erik@forsen.not>
Tue, 1 Dec 2015 21:33:32 +0000 (22:33 +0100)
committerErik Haider Forsén <erik@forsen.not>
Tue, 1 Dec 2015 21:33:32 +0000 (22:33 +0100)
src/components/app.html
src/components/map/map.ts
src/components/sidebar/sidebar.html
src/components/sidebar/sidebar.ts

index 1be1056..c79e1f5 100644 (file)
@@ -3,7 +3,7 @@
 
     <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>
index d1a37a2..97ea4c1 100644 (file)
@@ -5,7 +5,7 @@ import {Headers, Http} from 'angular2/http';
 @Component({
     selector: 'mou-map',
     directives: [CORE_DIRECTIVES],
-    events: ['newactive'],
+    events: ['newactive','neworg'],
     templateUrl: './components/map/map.html'
 })
 
@@ -21,7 +21,7 @@ export class Map {
     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;
@@ -284,7 +284,7 @@ export class Map {
         let lng = pos.lng()
         let location= {lat: lat, lng: lng};
         let event =  {location,parent};
-        this.newOrg.next(event);
+        this.neworg.next(event);
 
     }
 
index f5fd079..1a0efa4 100644 (file)
@@ -1,5 +1,5 @@
 <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">
index b513341..b79a400 100644 (file)
@@ -1,6 +1,7 @@
 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',
@@ -19,14 +20,16 @@ export class 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)
@@ -47,6 +50,8 @@ export class Sidebar {
                 .subscribe(res => console.log(res));
         }
 
+
+
     }
 
     cancel(){
@@ -54,8 +59,19 @@ export class Sidebar {
         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();
+    }
 }