Commit 7113eeee by chamath

View career user Invitation tab completed.

parent 781dee2a
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
View User View User
</div> </div>
<div class="ui-toolbar-group-right"> <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>
<div class="ui-toolbar-group-right"> <div class="ui-toolbar-group-right">
<button pButton type="button" icon="ui-icon-cancel" label="Cancel" [routerLink]="['/my-career/my-career-users']" <button pButton type="button" icon="ui-icon-cancel" label="Cancel" [routerLink]="['/my-career/my-career-users']"
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
<p-tabPanel header="Invitations" [selected]="true"> <p-tabPanel header="Invitations" [selected]="true">
<div class="ui-g-12 ui-md-12"> <div class="ui-g-12 ui-md-12">
<div class="tab-content" id="v-pills-tabContent"> <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"> <div class="tab-pane show active" id="v-pills-details" role="tabpanel" aria-labelledby="v-pills-details-tab">
<h2 class="tab-header">Invitations</h2> <h3 class="tab-header">Invitations</h3>
<h4>Successful Invites</h4><br/> <h4>Successful Invites</h4><br/>
<button pButton type="button" label="Add" (click)="addSuccessfulInvites()" style="text-align: center; "></button> <button pButton type="button" label="Add" (click)="addSuccessfulInvites()" style="text-align: center; "></button>
<p-table #successfulInvitesTable [columns]="successfulInvitesCols" [value]="successfulInvites" [paginator]="false" > <p-table #successfulInvitesTable [columns]="successfulInvitesCols" [value]="invitees" [paginator]="false" >
<ng-template pTemplate="colgroup" let-columns> <ng-template pTemplate="colgroup" let-columns>
<colgroup> <colgroup>
<col *ngFor="let col of columns" [style.width]="col.width"> <col *ngFor="let col of columns" [style.width]="col.width">
...@@ -79,16 +79,17 @@ ...@@ -79,16 +79,17 @@
<ng-template pTemplate="body" let-rowData let-rowIndex="rowIndex"> <ng-template pTemplate="body" let-rowData let-rowIndex="rowIndex">
<tr> <tr>
<td> <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>
<td> <td>
{{rowData.Name}} {{rowData?.Name}}
</td> </td>
<td> <td>
{{rowData.JoinedDate}} {{rowData?.JoinedDate | oneitdate : 'dd-MMM-yyyy'}}
</td> </td>
<td> <td style="text-align: center;">
<button pButton type="button" icon="ui-icon-edit" title="Edit" (click)="onRowSelect(rowData)"></button> <button *ngIf="rowData.IsNew" pButton type="button" icon="ui-icon-delete" title="Remove" (click)="deleteRow(rowData)"></button>
</td> </td>
</tr> </tr>
</ng-template> </ng-template>
...@@ -216,5 +217,6 @@ ...@@ -216,5 +217,6 @@
</p-tabPanel> </p-tabPanel>
</p-tabView> </p-tabView>
</div> </div>
<p-confirmDialog header="Confirmation" icon="pi pi-exclamation-triangle" appendTo="body"></p-confirmDialog>
<p-progressSpinner *ngIf="showLoader"></p-progressSpinner> <p-progressSpinner *ngIf="showLoader"></p-progressSpinner>
</form> </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 { ActivatedRoute, Params, Router } from '@angular/router';
import { ConfirmationService } from 'primeng/api';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { AppService } from '../../../app.service';
import { SaveService } from '../../../oneit/services/save.service'; import { SaveService } from '../../../oneit/services/save.service';
import { UtilsService } from '../../../oneit/services/utils.service'; import { UtilsService } from '../../../oneit/services/utils.service';
import { ViewCareerUserService } from './view-career-user.service'; import { ViewCareerUserService } from './view-career-user.service';
...@@ -14,12 +15,13 @@ import { ViewCareerUserService } from './view-career-user.service'; ...@@ -14,12 +15,13 @@ import { ViewCareerUserService } from './view-career-user.service';
export class ViewCareerUserComponent implements OnInit, OnDestroy { export class ViewCareerUserComponent implements OnInit, OnDestroy {
subscriptions: Array<Subscription> = []; subscriptions: Array<Subscription> = [];
@ViewChild('form') form: NgForm;
successfulInvitesCols = [ successfulInvitesCols = [
{ field: 'Email', header: 'Email', width: '32%', noSort: true, noFilter: true}, { field: 'Email', header: 'Email', width: '31%', noSort: true, noFilter: true},
{ field: 'Name', header: 'Name', width: '32%', noSort: true, noFilter: true}, { field: 'Name', header: 'Name', width: '31%', noSort: true, noFilter: true},
{ field: 'JoinedDate', header: 'Joined Date', width: '32%', noSort: true, noFilter: true}, { field: 'JoinedDate', header: 'Joined Date', width: '31%', noSort: true, noFilter: true},
{ field: '', header: '', width: '3%', noSort: true, noFilter: true} { field: '', header: '', width: '7%', noSort: true, noFilter: true}
]; ];
bosCols = [ bosCols = [
...@@ -31,13 +33,14 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy { ...@@ -31,13 +33,14 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
careerUser: any; careerUser: any;
showLoader: boolean = false; showLoader: boolean = false;
invitees: any[] = [];
constructor( constructor(
private router: Router, private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private utilsService: UtilsService, private utilsService: UtilsService,
private saveService: SaveService, private saveService: SaveService,
private appService: AppService, private confirmationService: ConfirmationService,
private viewUserService: ViewCareerUserService private viewUserService: ViewCareerUserService
){ ){
...@@ -59,12 +62,21 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy { ...@@ -59,12 +62,21 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
getCareerUserByID(id: string) { getCareerUserByID(id: string) {
this.showLoader = true; 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) this.subscriptions.push(this.viewUserService.getCareerUserByID(id, assocs)
.subscribe( .subscribe(
data => { data => {
this.careerUser = 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; this.showLoader = false;
}, },
error => { error => {
...@@ -75,6 +87,45 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy { ...@@ -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() { removeReferredBy() {
this.showLoader = true; this.showLoader = true;
const params = { const params = {
...@@ -82,18 +133,33 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy { ...@@ -82,18 +133,33 @@ export class ViewCareerUserComponent implements OnInit, OnDestroy {
}; };
this.utilsService.processObjects('RemoveReferredBy', params).subscribe( this.utilsService.processObjects('RemoveReferredBy', params).subscribe(
() => { () => {
this.getCareerUserByID(this.careerUser.ObjectID); this.getCareerUserByID(this.careerUser.ObjectID);
this.showLoader = false; this.showLoader = false;
}, },
err => { err => {
this.utilsService.handleError(err); this.utilsService.handleError(err);
this.showLoader = false; 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(){ 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