]> git.uio.no Git - u/erikhf/frm.git/commitdiff
[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 1be1056b61ab80b541d3b322a84ed7428f914242..c79e1f5d1b8a6a88820f73e9ca955876db022cfd 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 d1a37a2f4d37629723fc0f43644bcf9e13387800..97ea4c18f3a4657aa7dfbc86aa11cece557696af 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 f5fd079e32eac42a063f166690322d874a76fbf2..1a0efa4abf02798a194ce9930cee26165be94e21 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 b513341b27918898c8fa5b902c75c027153477e3..b79a400738045f7960cc21836d95d60a9ad1650c 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();
+    }
 }