From 13758cf841eda6ab5c2c7b7ffa204ee42f298644 Mon Sep 17 00:00:00 2001 From: Rachitha Ramappa Date: Fri, 27 Mar 2020 10:55:45 +0530 Subject: Menu mandatory field, add/update fixes Change-Id: I238d9ba1ae20210bd305461ebc2fd6180ee9940d Issue-ID: PORTAL-864 Signed-off-by: rachitha.ramappa@att.com --- .../rdp-data-table-edit.component.ts | 53 ++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table-edit/rdp-data-table-edit.component.ts') diff --git a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table-edit/rdp-data-table-edit.component.ts b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table-edit/rdp-data-table-edit.component.ts index d92ce320..5437c174 100644 --- a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table-edit/rdp-data-table-edit.component.ts +++ b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table-edit/rdp-data-table-edit.component.ts @@ -1,6 +1,8 @@ import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { RdpDataTableService } from '../../shared/rdp-data-table.service'; +import { RdpModalService } from '../../services/rdp-modal.service'; +import { RdpInformationModelComponent } from '../../rdp-information-model/rdp-information-model.component'; @Component({ selector: 'rdp-rdp-data-table-edit', @@ -18,7 +20,10 @@ export class RdpDataTableEditComponent implements OnInit { selectedRowData: any; public columnsInfoList = []; - constructor(public activeModal: NgbActiveModal, public rdpDataTableService: RdpDataTableService) { } + constructor( + public activeModal: NgbActiveModal, + public rdpDataTableService: RdpDataTableService, + private rdpModal: RdpModalService) { } ngOnInit() { this.modalPopupTitle = "Edit"; @@ -36,19 +41,41 @@ export class RdpDataTableEditComponent implements OnInit { } saveChanges() { - this.applicationService.update(this.rowdata); - this.applicationService.statusResponse.subscribe(responseData => { - if (responseData == "200") { - console.log("Success") - this.applicationService.get(); - this.applicationService.updatedData.subscribe(val => { - if (val) { - this.passEntry.emit(val); - } - }) + let validationResult = this.validateRowData(this.rowdata); + if (validationResult) { + console.log("Validation is complete") + this.applicationService.update(this.rowdata); + this.applicationService.statusResponse.subscribe(responseData => { + if (responseData == "200") { + console.log("Success") + this.applicationService.get(); + this.applicationService.updatedData.subscribe(val => { + if (val) { + this.passEntry.emit(val); + } + }) + } + }) + this.activeModal.close(); + } + } + + validateRowData(rowData): any { + let columnData = this.settings.columns; + let validate: boolean = true; + for (let column of columnData) { + if (column.isMandatory) { + if (rowData[column.title] == undefined || rowData[column.title] == null + || rowData[column.title] == "") { + const modelRef = this.rdpModal.open(RdpInformationModelComponent, { size: 'lg' }); + modelRef.componentInstance.title = 'Missing Mandatory Field'; + modelRef.componentInstance.message = "Please fill mandatory field " + column.dispalyTitle; + validate = false; + break; + } } - }) - this.activeModal.close(); + } + return validate; } columnDataChanged($event, columnTitle) { -- cgit 1.2.3-korg