Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame^] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
| 5 | =================================================================== |
| 6 | |
| 7 | Unless otherwise specified, all software contained herein is licensed |
| 8 | under the Apache License, Version 2.0 (the License); |
| 9 | you may not use this software except in compliance with the License. |
| 10 | You may obtain a copy of the License at |
| 11 | |
| 12 | http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | |
| 14 | Unless required by applicable law or agreed to in writing, software |
| 15 | distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | See the License for the specific language governing permissions and |
| 18 | limitations under the License. |
| 19 | |
| 20 | ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 21 | ============LICENSE_END============================================ |
| 22 | */ |
| 23 | |
| 24 | import { Component, OnInit } from '@angular/core'; |
| 25 | import { Router } from '@angular/router'; |
| 26 | import * as _ from 'underscore'; |
| 27 | |
| 28 | @Component({ selector: 'app-build-design', templateUrl: './build-artifacts.component.html', styleUrls: ['./build-artifacts.component.css'] }) |
| 29 | export class BuildDesignComponent implements OnInit { |
| 30 | tabs: Array<Object> = []; |
| 31 | private allowOtherUpdates: boolean = true; |
| 32 | |
| 33 | constructor (private router: Router) { |
| 34 | } |
| 35 | |
| 36 | ngOnInit() { |
| 37 | this.tabs = [ |
| 38 | { |
| 39 | type: 'dropdown', |
| 40 | name: 'Reference Data', |
| 41 | url: 'references', |
| 42 | }, { |
| 43 | name: 'Template', |
| 44 | type: 'dropdown', |
| 45 | url: 'templates/myTemplates', |
| 46 | }, { |
| 47 | name: 'Parameter Definition', |
| 48 | type: 'dropdown', |
| 49 | url: 'parameterDefinitions/create' |
| 50 | } /*, { |
| 51 | name: "Test", |
| 52 | url: 'test', |
| 53 | }*/ |
| 54 | ]; |
| 55 | } |
| 56 | |
| 57 | public setAllowOtherUpdates(allowOtherUpdates: boolean) { |
| 58 | this.allowOtherUpdates = allowOtherUpdates; |
| 59 | } |
| 60 | |
| 61 | // Allow / block access to the update pages of GT and PD if no reference data present |
| 62 | public updateAccessUpdatePages(selectedAction, referenceList) { |
| 63 | // Disable/enable the menu items for update pages of GT and PD. |
| 64 | if (this.isReferenceFound(selectedAction, referenceList)) { |
| 65 | this.setAllowOtherUpdates(true); |
| 66 | } else { |
| 67 | //alert("false") |
| 68 | this.setAllowOtherUpdates(false); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | public isReferenceFound(selectedAction, referenceList) { |
| 73 | let selectedActioneObject = _.find(referenceList, function (obj) { |
| 74 | return obj['action'] == selectedAction; |
| 75 | }); |
| 76 | if (selectedActioneObject) { |
| 77 | return true; |
| 78 | } else { |
| 79 | return false; |
| 80 | } |
| 81 | } |
| 82 | } |