2 Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
24 } from "@angular/core";
25 import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
26 import { DashboardApiService } from "src/app/core/services/dashboard-api.service";
27 import { AdminService } from "src/app/core/services/admin.service";
28 import { Template } from "src/app/core/models/template.model";
29 import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
30 import {AlertComponent} from "../../../../core/alert/alert.component";
33 selector: 'app-edit-template-modal',
34 templateUrl: './edit-template-modal.component.html',
35 styleUrls: ['./edit-template-modal.component.css']
37 export class EditTemplateModalComponent implements OnInit {
38 @Input() edittemplate: Template;
39 @Input() selectedLangs;
40 templateInput: Template;
41 templatetypedata: Array<any> = [];
42 topicname: Array<any> = [];
43 @Output() passEntry: EventEmitter<any> = new EventEmitter();
45 @ViewChild("templatetype") templatetype: ElementRef;
46 @ViewChild("topic") topic: ElementRef;
49 public activeModal: NgbActiveModal,
50 public dashboardApiService: DashboardApiService,
51 private modalService: NgbModal,
54 inputtemplateName = null;
55 templateInputTitle = "";
59 this.getTemplateTypeName();
61 this.templateInput = new Template();
63 id:this.edittemplate.id,
64 name: this.edittemplate.name,
65 submitted: this.edittemplate.submitted,
66 body: this.edittemplate.body,
67 note: this.edittemplate.note,
68 topic: this.edittemplate.topic,
69 designType: this.edittemplate.designType
71 this.templateInput = feed;
72 this.templateInputTitle = ""+this.edittemplate.name;
73 console.log(this.templateInput,"this.templateInput")
76 this.dashboardApiService.getTopicName().subscribe(data => {
77 this.topicname = data;
81 getTemplateTypeName(){
82 this.dashboardApiService.getTemplateTypeName().subscribe(data => {
83 this.templatetypedata = data;
88 if(this.templateInput.name == '' || this.templateInput.name == undefined){
90 if (this.selectedLangs == "en-us") {
91 tips = "Name is required input."
92 } else if (this.selectedLangs == "zh-hans") {
94 } else if (this.selectedLangs == "zh-hant") {
99 this.edittemplate = this.templateInput;
100 this.edittemplate.designType = this.templatetype.nativeElement.value;
101 this.edittemplate.topic = this.topic.nativeElement.value;
102 this.passEntry.emit(this.edittemplate);