diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-07-07 19:23:03 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-07-08 16:13:43 +0300 |
commit | f792671ae247a931f34d902e9276202b5016ef9a (patch) | |
tree | 6104971e8074c9a3d720836276ff18619719ec02 /vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts | |
parent | fc62274e8d15964d63c62bf0e2f4abc040252ee9 (diff) |
Merge from ecomp 718fd196 - Modern UI
Issue-ID: VID-378
Change-Id: I2736b98426e324ec3aa233b034229ba84d99839f
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts b/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts new file mode 100644 index 000000000..211f59337 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts @@ -0,0 +1,91 @@ +import {Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core'; +import {DialogComponent, DialogService} from "ng2-bootstrap-modal"; +import {IframeService} from "../../utils/iframe.service"; +import {AaiService} from "../../services/aaiService/aai.service"; +import {VnfGroupModel} from "../../models/vnfGroupModel"; +import {ElementsTableService} from "./members-table/elements-table.service"; +import {Level1Instance} from "../../models/level1Instance"; +import {ModalInformation} from "./members-table/element-table-row.model"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../store/reducers"; +import {FormGroup} from "@angular/forms"; +import * as _ from "lodash"; +import {clearAllGenericModalhelper} from "../../storeUtil/utils/global/global.actions"; +@Component({ + selector: 'search-members-modal', + templateUrl: 'search-elements-modal.component.html', + styleUrls: ['search-elements-modal.component.scss'] +}) + +export class SearchElementsModalComponent extends DialogComponent<{ modalInformation: ModalInformation }, boolean> implements OnInit, OnDestroy { + modalInformation: ModalInformation; + parentElementClassName = 'content'; + elementsData: Level1Instance[]; + vnfGroupModel: VnfGroupModel; + disableSetElements: boolean = true; + disableSearchByNetworkRole: boolean = false; + dynamicFormGroup: FormGroup = null; + + constructor(dialogService: DialogService, + private _iframeService: IframeService, + private _aaiService: AaiService, + private _membersTableService: ElementsTableService, + private _store: NgRedux<AppState>) { + super(dialogService); + ElementsTableService.changeFnTableDataTrigger.subscribe((triggerRes) => { + this._membersTableService.resetAll(this.modalInformation.uniqObjectField, this.modalInformation.maxSelectRow); + this.elementsData = triggerRes; + }); + + ElementsTableService.changeModalInformationDataTrigger.subscribe(({modalInformation, selectedRowsIds}) => { + this.disableSetElements = true; + this.modalInformation = modalInformation; + this.ngOnInit(selectedRowsIds); + }) + } + + @ViewChild('ElementsTableComponent') membersTable; + + ngOnInit(selectedRowsIds?: string[]): void { + const genericModalHelper = this._store.getState().global.genericModalHelper; + if(!_.isNil(genericModalHelper) && !_.isNil(genericModalHelper[`${this.modalInformation.type}_TABLE_DATA`]) && !_.isNil(genericModalHelper[`selected${this.modalInformation.type}`])){ + this.elementsData = this._store.getState().global.genericModalHelper[`${this.modalInformation.type}_TABLE_DATA`]; + } else { + this.modalInformation.getElements() + .subscribe((result) => { + this.elementsData = result; + }); + } + }; + + closeDialog(): void { + this._iframeService.removeFullScreen(); + this._iframeService.removeClassCloseModal(this.parentElementClassName); + this.dialogService.removeDialog(this); + setTimeout(() => { + window.parent.postMessage("closeIframe", "*"); + }, 15); + } + + selectedMembersAmountChange(selectedMembersAmount: number): void { + this.disableSetElements = selectedMembersAmount == 0; + } + + doneAction(): void { + this.modalInformation.topButton.action.call(this, this); + } + + searchByCriteriaAction(): void { + this.modalInformation.searchButton.action.call(this, this); + } + + backAction(): void { + if (this.modalInformation.backAction) { + this.modalInformation.backAction.call(this, this); + } else { + this.closeDialog(); + } + } +} + + |