Commit 7113eeee by chamath

View career user Invitation tab completed.

parent 781dee2a
......@@ -6,7 +6,7 @@
View User
</div>
<div class="ui-toolbar-group-right">
<button pButton type="button" label="Save" icon="ui-icon-save" (click)="saveUser(false)"></button>
<button pButton type="button" label="Save" icon="ui-icon-save" (click)="saveUser(true)"></button>
</div>
<div class="ui-toolbar-group-right">
<button pButton type="button" icon="ui-icon-cancel" label="Cancel" [routerLink]="['/my-career/my-career-users']"
......@@ -58,11 +58,11 @@
<p-tabPanel header="Invitations" [selected]="true">
<div class="ui-g-12 ui-md-12">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-details" role="tabpanel" aria-labelledby="v-pills-details-tab">
<h2 class="tab-header">Invitations</h2>
<div class="tab-pane show active" id="v-pills-details" role="tabpanel" aria-labelledby="v-pills-details-tab">
<h3 class="tab-header">Invitations</h3>
<h4>Successful Invites</h4><br/>
<button pButton type="button" label="Add" (click)="addSuccessfulInvites()" style="text-align: center; "></button>
<p-table #successfulInvitesTable [columns]="successfulInvitesCols" [value]="successfulInvites" [paginator]="false" >
<button pButton type="button" label="Add" (click)="addSuccessfulInvites()" style="text-align: center; "></button>
<p-table #successfulInvitesTable [columns]="successfulInvitesCols" [value]="invitees" [paginator]="false" >
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of columns" [style.width]="col.width">
......@@ -79,16 +79,17 @@
<ng-template pTemplate="body" let-rowData let-rowIndex="rowIndex">
<tr>
<td>
{{rowData.Email}}
<input pInputText *ngIf="rowData.IsNew" type="text" class="form-control" [(ngModel)]="rowData.Email" name="Email{{rowIndex}}" style="height: 30px;">
{{rowData.IsNew ? "" : rowData?.Email}}
</td>
<td>
{{rowData.Name}}
{{rowData?.Name}}
</td>
<td>
{{rowData.JoinedDate}}
{{rowData?.JoinedDate | oneitdate : 'dd-MMM-yyyy'}}
</td>
<td>
<button pButton type="button" icon="ui-icon-edit" title="Edit" (click)="onRowSelect(rowData)"></button>
<td style="text-align: center;">
<button *ngIf="rowData.IsNew" pButton type="button" icon="ui-icon-delete" title="Remove" (click)="deleteRow(rowData)"></button>
</td>
</tr>
</ng-template>
......@@ -216,5 +217,6 @@
</p-tabPanel>
</p-tabView>
</div>
<p-confirmDialog header="Confirmation" icon="pi pi-exclamation-triangle" appendTo="body"></p-confirmDialog>
<p-progressSpinner *ngIf="showLoader"></p-progressSpinner>
</form>
\ No newline at end of file
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { ConfirmationService } from 'primeng/api';
import { Subscription } from 'rxjs/Subscription';
import { AppService } from '../../../app.service';
import { SaveService } from '../../../oneit/services/save.service';
import { UtilsService } from '../../../oneit/services/utils.service';
import { ViewCareerUserService } from './view-career-user.service';
......@@ -14,12 +15,13 @@ import { ViewCareerUserService } from './view-career-user.service';
export class ViewCareerUserComponent implements OnInit, OnDestroy {
subscriptions: Array<Subscription> = [];
@ViewChild('form') form: NgForm;
successfulInvitesCols = [
{ field: 'Email', header: 'Email', width: '32%', noSort: true, noFilter: true},
{ field: 'Name', header: 'Name', width: '32%', noSort: true, noFilter: true},
{ field: 'JoinedDate', header: 'Joined Date', width: '32%', noSort: true, noFilter: true},
{ field: '', header: '', width: '3%', noSort: true, noFilter: true}
{ field: 'Email', header: 'Email', width: '31%', noSort: true, noFilter: true},
{ field: 'Name', header: 'Name', width: '31%', noSort: true, noFilter: true},
{ field: 'JoinedDate', header: 'Joined Date', width: '31%', noSort: true, noFilter: true},
{ field: '', header: '', width: '7%', noSort: true, noFilter: true}
];
bosCols = [
......@@ -31,13 +33,14 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
careerUser: any;
showLoader: boolean = false;
invitees: any[] = [];
constructor(
private router: Router,
private activatedRoute: ActivatedRoute,
private utilsService: UtilsService,
private saveService: SaveService,
private appService: AppService,
private confirmationService: ConfirmationService,
private viewUserService: ViewCareerUserService
){
......@@ -59,12 +62,21 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
getCareerUserByID(id: string) {
this.showLoader = true;
let assocs = ['Candidate', 'Candidate.User', 'Candidate.ReferredBy'];
let assocs = ['Candidate', 'Candidate.User', 'Candidate.ReferredBy', 'Candidate.Invitees', 'Candidate.Invitees.User'];
this.subscriptions.push(this.viewUserService.getCareerUserByID(id, assocs)
.subscribe(
data => {
this.careerUser = data;
this.invitees = [];
if (this.careerUser.Candidate && this.careerUser.Candidate.Invitees) {
for (let invitee of this.careerUser.Candidate.Invitees) {
this.invitees.push({Email: invitee.User.Email, Name: invitee.User.Name, JoinedDate: invitee.ObjectCreated, IsNew: false});
}
}
this.careerUser.Candidate.NewInvitationEmails = [];
this.showLoader = false;
},
error => {
......@@ -75,6 +87,45 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
);
}
saveUser(reload: boolean) {
this.utilsService.clearErrorMessages();
if (this.form.invalid) {
this.utilsService.showAllErrorMessages();
} else {
this.showLoader = true;
let updatedObjs = {};
this.careerUser.Candidate.NewInvitationEmails = [];
for (let invitee of this.invitees) {
if (invitee.IsNew) {
this.careerUser.Candidate.NewInvitationEmails.push(invitee.Email);
}
}
this.utilsService.addObjsToJSONByObjectID(updatedObjs, [this.careerUser.Candidate]);
this.subscriptions.push(this.saveService.saveObjectsWithDefaultSvc({}, updatedObjs, {})
.subscribe(
data => {
this.utilsService.handleSuccess();
if (reload) {
let idToNavigate = this.careerUser.ObjectID;
this.getCareerUserByID(idToNavigate);
}
else {
this.router.navigate(["/my-career/my-career-users"]);
}
this.showLoader = false;
},
error => {
this.showLoader = false;
this.utilsService.handleError(error);
}
)
);
}
}
removeReferredBy() {
this.showLoader = true;
const params = {
......@@ -82,18 +133,33 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
};
this.utilsService.processObjects('RemoveReferredBy', params).subscribe(
() => {
this.getCareerUserByID(this.careerUser.ObjectID);
this.showLoader = false;
},
err => {
this.utilsService.handleError(err);
this.showLoader = false;
}
);
() => {
this.getCareerUserByID(this.careerUser.ObjectID);
this.showLoader = false;
},
err => {
this.utilsService.handleError(err);
this.showLoader = false;
}
);
}
addSuccessfulInvites(){
addSuccessfulInvites() {
this.invitees.push({Email: '', IsNew: true});
}
deleteRow(invitee: any) {
this.utilsService.clearErrorMessages();
this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?',
header: 'Delete Confirmation',
icon: 'fa fa-trash',
accept: () => {
const index = this.invitees.indexOf(invitee);
this.invitees.splice(index, 1);
}
});
}
ngOnDestroy(){
......
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