diff options
Diffstat (limited to 'ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table')
2 files changed, 47 insertions, 13 deletions
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.html 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.html index a0e2b01b..f2ff001b 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.html +++ 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.html @@ -49,6 +49,7 @@ <div [ngSwitch]="column.type"> <div *ngSwitchCase="'text'" class="groupItem"> <label class="item-label">{{column.dispalyTitle | titlecase}}:</label><br> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-input-editor (changedColumnValue)="columnDataChanged($event, column.title)" rowdata="{{selectedRowData}}" columntitle="{{column.title}}" @@ -57,6 +58,7 @@ </rdp-input-editor> </div> <div *ngSwitchCase="'dropdown'" class="groupItem"> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-select-editor (changedColumnValue)="columnDataChanged($event, column.title)" rowdata="{{selectedRowData}}" [data]="column.listData" @@ -64,14 +66,17 @@ </div> <div *ngSwitchCase="'textarea'" class="groupItem"> <label class="item-label">{{column.dispalyTitle | titlecase}}:</label><br> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-textarea-editor rowdata="{{selectedRowData}}" columntitle="{{column.title}}"></rdp-textarea-editor> </div> <div *ngSwitchCase="'checkbox'" class="groupItem"> <label class="item-label">{{column.dispalyTitle | titlecase}}:</label><br> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-checkbox-editor rowdata="{{selectedRowData}}" columntitle="{{column.title}}"></rdp-checkbox-editor> </div> <div *ngSwitchCase="'radio'" class="groupItem"> <label class="item-label">{{column.dispalyTitle | titlecase}}:</label><br> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-radio-editor (changedColumnValue)="columnDataChanged($event, column.title)" [data]="column.listData" rowdata="{{selectedRowData}}" @@ -79,10 +84,12 @@ </div> <div *ngSwitchCase="'datepicker'" class="groupItem"> <label class="item-label">{{column.dispalyTitle | titlecase}}:</label><br> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-datepicker-editor rowdata="{{selectedRowData}}" columntitle="{{column.title}}"></rdp-datepicker-editor> </div> <div *ngSwitchDefault class="groupItem"> <label class="item-label">{{column.dispalyTitle | titlecase}}:</label><br> + <span *ngIf="column.isMandatory" style="color: red;">*</span> <rdp-input-editor (changedColumnValue)="columnDataChanged($event, column.title)" rowdata="{{selectedRowData}}" columntitle="{{column.title}}"></rdp-input-editor> </div> 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) { |