/* * ============LICENSE_START========================================== * ONAP Portal SDK * =================================================================== * Copyright © 2019 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * * https://creativecommons.org/licenses/by/4.0/ * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============LICENSE_END============================================ * * */ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { AdminService } from '../../admin.service'; import { SidebarComponent } from 'src/app/layout/components/sidebar/sidebar.component'; import { Router } from '@angular/router'; import { SidebarService } from 'src/app/shared/services'; import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; import { CookieService } from 'ngx-cookie-service'; @Component({ selector: 'app-new-menu', templateUrl: './new-menu.component.html', styleUrls: ['./new-menu.component.scss'] }) export class NewMenuComponent implements OnInit { menu = { action: null, active: false, activeAsString: "false", auditTrail: null, auditUserId: null, childMenus: [], created: null, createdId: null, externalUrl: null, functionCd: null, id: null, imageSrc: null, label: null, menuLevel: null, menuSetCode: null, modified: null, modifiedId: null, parentId: null, parentIdAsString: null, parentMenu: null, queryString: null, rowNum: null, separator: false, separatorAsString: false, servlet: null, sortOrder: null, target: null } showSpinner: boolean; result: any; //menu: any; @Input() selectedMenu: any; @Input() isEditMode: boolean; @Output() passEntry: EventEmitter = new EventEmitter(); statusOptions = [ {index: 0, value: 'true', title: 'Y'}, {index: 1, value: 'false', title: 'N'} ]; selectedValue = this.statusOptions[0]; separator = { availableOptions:[ {value: 'true', name: 'Y'}, {value: 'false', name: 'N'} ], selectedOption: {value: 'true', name: 'Y'} } activeStatusOptions = [ {index: 0, value: 'true', title: 'Y'}, {index: 1, value: 'false', title: 'N'} ]; activeSelectedValue = this.activeStatusOptions[0]; separatorStatusOptions = [ {index: 0, value: 'true', title: 'Y'}, {index: 1, value: 'false', title: 'N'} ]; separatorSelectedValue = this.separatorStatusOptions[1]; active = { availableOptions:[ {value: 'true', name: 'Y'}, {value: 'false', name: 'N'} ], selectedOption: {value: 'true', name: 'Y'} }; functionCDselectData = []; parentListSelectData = []; childListSelectData = []; constructor(public adminService: AdminService, public activeModal: NgbActiveModal, public ngmodel: NgbModal, public router: Router, public sidebarService: SidebarService,public cookieService:CookieService) { } ngOnInit() { if(this.selectedMenu){ this.menu = this.selectedMenu; }else{ this.menu.menuSetCode='APP'; } //console.log("selected menu >>>>",this.menu); this.getFunctionCDselectData(); this.getParentData(); } getParentData(){ this.showSpinner = true; this.adminService.getParentData() .subscribe( _data => { //console.log("getParentData :: _data ",_data); this.result = _data; if(_data){ this.parentListSelectData= _data; // data from server let menuItems = this.parentListSelectData; var heirarchicalMenuItems = []; var children = []; for ( var i=0; i { this.showSpinner = false; console.log(error); }); } sortItems(prop){ return function(a, b) { if (a[prop] > b[prop]) { return 1; } else if (a[prop] < b[prop]) { return -1; } return 0; } } getParentLabel(parentId, parentListSelectData){ var element; element = parentListSelectData[0]; for (var i=0; i>>>>>",postData); this.adminService.updateFnMenuItem(postData) .subscribe( _data => { this.result = _data; this.passEntry.emit(this.result); this.ngmodel.dismissAll(); }, error => { this.showSpinner = false; console.log(error); this.openConfirmationModal("Error",error); }); this.getLeftMenuItems(); } } getLeftMenuItems(){ //console.log("getLeftMenuItems called after update menu"); let sidebarComponent = new SidebarComponent(this.router, this.sidebarService,this.cookieService); sidebarComponent.ngOnInit(); } getFunctionCDselectData = function(){ this.adminService.getFunctionCdList() .subscribe( _data => { this.result = _data; if(_data){ this.functionCDselectData = _data; } }, error => { this.showSpinner = false; console.log(error); this.openConfirmationModal("","Function Code Data not available !"); }); } openConfirmationModal(_title: string, _message: string) { const modalInfoRef = this.ngmodel.open(ConfirmationModalComponent); modalInfoRef.componentInstance.title = _title; modalInfoRef.componentInstance.message = _message; } }