Commit 7d62bdb9 authored by Rajkumar-D's avatar Rajkumar-D
Browse files

DAC changes

parent a86c68f2
<div class="mat-h3 mat-tittle">Contact Details</div>
<form (ngSubmit)="doAction()" #cf="ngForm">
<div *ngIf="action!='Delete' && action!='Success' && action!='Error'">
<mat-checkbox matInput name="mainContact" [(ngModel)]="contactObj.mainContact">Is Primary Contact</mat-checkbox>
<mat-checkbox matInput name="consortiumContact" [(ngModel)]="contactObj.consortiumContact"
style="padding-left: 20px;">Is Consortium Contact</mat-checkbox>
<ng-container *ngIf="!isDac">
<mat-checkbox matInput name="mainContact" [(ngModel)]="contactObj.mainContact">Is Primary Contact
</mat-checkbox>
<mat-checkbox matInput name="consortiumContact" [(ngModel)]="contactObj.consortiumContact"
style="padding-left: 20px;">Is Consortium Contact</mat-checkbox>
</ng-container>
<input type="hidden" name="submissionAccountId" [(ngModel)]="contactObj.submissionAccountId" />
<mat-form-field>
......@@ -20,25 +22,41 @@
<mat-error *ngIf="cf.controls['emailAddress']?.errors?.required || cf.controls['emailAddress']?.invalid">
Please enter a valid email address
</mat-error>
</mat-form-field>
<div *ngIf="!contactObj.consortiumContact">
<ng-container *ngIf="!isDac">
<div *ngIf="!contactObj.consortiumContact && !isDac">
<mat-form-field>
<input matInput name="firstName" [(ngModel)]="contactObj.firstName" placeholder="First Name"
required>
</mat-form-field>
<mat-form-field>
<input matInput name="middleInitials" [(ngModel)]="contactObj.middleInitials"
placeholder="Middle Name">
</mat-form-field>
<mat-form-field>
<input matInput name="surname" [(ngModel)]="contactObj.surname" placeholder="Surame" required>
</mat-form-field>
</div>
<div *ngIf="contactObj.consortiumContact">
<mat-form-field>
<input matInput name="consortium" [(ngModel)]="contactObj.consortium" placeholder="Consortium Name"
required>
</mat-form-field>
</div>
</ng-container>
<ng-container *ngIf="isDac">
<mat-form-field>
<input matInput name="firstName" [(ngModel)]="contactObj.firstName" placeholder="First Name" required>
<input matInput name="name" [(ngModel)]="contactObj.name" placeholder="Name" required>
</mat-form-field>
<mat-form-field>
<input matInput name="middleInitials" [(ngModel)]="contactObj.middleInitials" placeholder="Middle Name">
</mat-form-field>
<mat-form-field>
<input matInput name="surname" [(ngModel)]="contactObj.surname" placeholder="Surame" required>
<input matInput name="telephone" [(ngModel)]="contactObj.telephone" placeholder="Telephone number"
required>
</mat-form-field>
</div>
<div *ngIf="contactObj.consortiumContact">
<mat-form-field>
<input matInput name="consortium" [(ngModel)]="contactObj.consortium" placeholder="Consortium Name"
<input matInput name="organization" [(ngModel)]="contactObj.organization" placeholder="Organization"
required>
</mat-form-field>
</div>
</ng-container>
</div>
<div class="mat-body" *ngIf="action==='Delete'">
......
......@@ -23,12 +23,14 @@ export class ContactDialogModalComponent implements OnInit {
contactObj = {};
isDac: boolean;
constructor(
public dialogRef: MatDialogRef<ContactDialogModalComponent>,
@Optional() @Inject(MAT_DIALOG_DATA) public data: any,
private util: UtilService) {
this.action = data.action;
console.log(data)
this.isDac = data.isDac || false;
this.emails = data.emailList;
if (this.action != "Error") {
this.copyObjectValue(data.contactObj, this.contactObj)
......@@ -45,7 +47,10 @@ export class ContactDialogModalComponent implements OnInit {
if (this.action === "Add") {
this.contactObj["id"] = this.util.getId();
}
let contact = this.updateName(this.contactObj);
let contact = this.contactObj;
if (!this.isDac) {
contact = this.updateName(this.contactObj);
}
this.dialogRef.close({ event: this.action, data: contact });
}
......@@ -83,6 +88,11 @@ export class ContactDialogModalComponent implements OnInit {
to.consortiumContact = from.consortiumContact;
to.name = from.name;
to.submissionAccountId = from.submissionAccountId;
// Fields for DAC
to.telephone = from.telephone;
to.organization = from.organization;
}
......
......@@ -27,4 +27,8 @@ mat-card{
mat-form-field.mat-form-field {
font-size: 14px;
font-family: Roboto;
}
mat-icon {
cursor: pointer;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
<mat-divider></mat-divider>
<div class="container">
<mat-card>
<mat-card-subtitle>DAC Details</mat-card-subtitle>
<div style="width: 100%;">
<mat-form-field class="app-field-padding">
<textarea rows="3" matInput placeholder="Short descriptive title for the DAC" required
......@@ -12,5 +13,55 @@
</mat-form-field>
</div>
</mat-card>
<mat-card>
<mat-card-subtitle>Contact Information</mat-card-subtitle>
<a (click)="openDialog('Add', { submissionAccountId: id })">Add At Least One Contact
<mat-icon>add_circle</mat-icon>
</a>
<table mat-table *ngIf="dataSource" #table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="emailAddress">
<th mat-header-cell *matHeaderCellDef>Email</th>
<td mat-cell *matCellDef="let element">{{ element.emailAddress }}</td>
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let element">
{{ element.name }}
</td>
</ng-container>
<ng-container matColumnDef="telephone">
<th mat-header-cell *matHeaderCellDef>Telephone</th>
<td mat-cell *matCellDef="let element">
{{ element.telephone }}
</td>
</ng-container>
<ng-container matColumnDef="organization">
<th mat-header-cell *matHeaderCellDef>Organization</th>
<td mat-cell *matCellDef="let element">
{{ element.organization }}
</td>
</ng-container>
<ng-container matColumnDef="edit">
<th mat-header-cell *matHeaderCellDef>Edit</th>
<td mat-cell *matCellDef="let element">
<mat-icon (click)="openDialog('Update', element)">edit</mat-icon>
</td>
</ng-container>
<ng-container matColumnDef="remove">
<th mat-header-cell *matHeaderCellDef>Remove</th>
<td mat-cell *matCellDef="let element">
<mat-icon (click)="openDialog('Delete', element)">delete</mat-icon>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
</mat-card>
</div>
</div>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { MatDialog, MatTableDataSource } from '@angular/material';
import { ContactDialogModalComponent } from '../contact-dialog-modal/contact-dialog-modal.component';
@Component({
selector: 'app-dac-management',
......@@ -7,9 +9,98 @@ import { Component, OnInit } from '@angular/core';
})
export class DacManagementComponent implements OnInit {
constructor() { }
editMode = false;
/* Used for storing added emails, this will be used for validation */
emails = [];
contactArray = [];
deletedContacts = [];
dataSource: MatTableDataSource<any>;
displayedColumns: string[] = [
"emailAddress",
"name",
"telephone",
"organization",
"edit",
"remove",
];
constructor(public dialog: MatDialog,) { }
ngOnInit() {
}
openDialog(action, obj): void {
const dialogRef = this.dialog.open(ContactDialogModalComponent, {
width: "500px",
backdropClass: "custom-dialog-backdrop-class",
panelClass: "custom-dialog-panel-class",
data: { action: action, emailList: this.emails, contactObj: obj, isDac: true },
});
dialogRef.afterClosed().subscribe((result) => {
if (result.event != "close") {
let contactObj = result.data;
if (result.event === "Add") {
this.addContactRow(contactObj);
if (this.editMode) {
// this.newContacts.push(contactObj);
}
}
if (result.event === "Update") {
this.updateContactRow(contactObj);
}
if (result.event === "Delete") {
this.deleteContactRow(contactObj);
}
if (result.event === "CloseSuccess") {
if (!this.editMode) {
// this._router.navigateByUrl("");
} else {
// this._router.navigateByUrl("/accountInfo");
}
}
if (typeof contactObj != "undefined") {
this.dataSource = new MatTableDataSource<any>(this.contactArray);
}
this.updateEmailsArray();
}
});
}
addContactRow(contact) {
this.contactArray.push(contact);
}
updateContactRow(contact) {
var index = this.contactArray
.map(function (item) {
return item.id;
})
.indexOf(contact.id);
this.contactArray[index].emailAddress = contact.emailAddress;
this.contactArray[index].name = contact.name;
this.contactArray[index].telephone = contact.telephone;
this.contactArray[index].organization = contact.organization;
}
updateEmailsArray() {
this.emails = [];
for (var i in this.contactArray) {
this.emails.push(this.contactArray[i].emailAddress);
}
}
deleteContactRow(contact) {
var index = this.contactArray
.map(function (item) {
return item.id;
})
.indexOf(contact.id);
this.deletedContacts.push(this.contactArray[index]);
this.contactArray.splice(index, 1);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment