67eb8822b49b6fc3dab0bc8aff805f1d27518100
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import {Component, ViewChild, ElementRef, Input} from '@angular/core';
22 import {UiElementBase, UiElementBaseInterface} from "../ui-element-base.component";
23 import {ButtonsModelMap, ButtonModel} from "app/models";
24 import { PopoverContentComponent } from "app/ng2/components/popover/popover-content.component"
25 import { PopoverComponent } from "app/ng2/components/popover/popover.component"
26
27 @Component({
28     selector: 'ui-element-popover-input',
29     templateUrl: './ui-element-popover-input.component.html',
30     styleUrls: ['./ui-element-popover-input.component.less']
31 })
32 export class UiElementPopoverInputComponent extends UiElementBase implements UiElementBaseInterface {
33     @ViewChild('textArea') textArea: ElementRef;
34     @ViewChild('popoverForm') popoverContentComponent: PopoverContentComponent;
35
36     saveButton: ButtonModel;
37     buttonsArray: ButtonsModelMap;
38
39     onSave = ():void => {
40         if (!this.control.invalid){
41             this.baseEmitter.emit(this.value);
42             this.popoverContentComponent.hide();
43         }
44     }
45
46     constructor() {
47         super();
48         // Create Save button and insert to buttons map
49         this.saveButton = new ButtonModel('save', 'blue', this.onSave);
50         this.buttonsArray = { 'test': this.saveButton };
51
52         // Define the regex pattern for this controller
53         this.pattern = this.validation.validationPatterns.comment;
54
55         // Disable / Enable button according to validation
56         //this.control.valueChanges.subscribe(data => this.saveButton.disabled = this.control.invalid);
57     }
58 }