Project

General

Profile

1
/**
2
 * Created by stefanos on 19/5/2017.
3
 */
4
import { EventEmitter, Input, OnInit, Output, ViewChild, ViewRef } from "@angular/core";
5
import { MyFormDirective } from "./my-form.directive";
6
import { Description } from '../../../domain/oa-description';
7

    
8

    
9
export abstract class MyWrapper implements OnInit{
10

    
11
  @Input() public component : ViewRef;
12

    
13
  @Input() description : Description = null;
14

    
15
  @Input() viewRef : ViewRef;
16

    
17
  @Output() deleteNotifier : EventEmitter<ViewRef> = new EventEmitter();
18

    
19
  @ViewChild(MyFormDirective) private formComponents: MyFormDirective;
20

    
21
  public first = true;
22

    
23
  ngOnInit() {
24
    if (!this.formComponents) {
25
      console.log(this.formComponents);
26
      throw "Maybe you forgot [my-form] directive in the template";
27
    }
28
    this.formComponents.viewContainerRef.insert(this.component);
29
  }
30

    
31
  public remove(){
32
    this.deleteNotifier.emit(this.viewRef);
33
  };
34

    
35

    
36
  public get canDelete() {
37
    return !(this.description.mandatory == true && this.first == true);
38
  }
39

    
40
}
(5-5/5)