Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/app/manage-learn/core/services/utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,4 +781,8 @@ return data;
];
return tabs;
}

checkDateofTask(template){
return template.tasks.find(task => task.endDate && (template.endDate && task.endDate >= template.endDate || template.startDate && task.endDate < template.startDate))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Subscription } from 'rxjs';
import { Location } from '@angular/common';
import { DbService } from '../../core/services/db.service';
import { TranslateService } from '@ngx-translate/core';
import { NetworkService, ProjectService, statusType, ToastService } from '../../core';
import { NetworkService, ProjectService, projectStatus, statusType, ToastService, UtilsService } from '../../core';
import { RouterLinks } from '../../../../app/app.constant';
import cloneDeep from 'lodash/cloneDeep';

Expand Down Expand Up @@ -39,7 +39,7 @@ export class ProjectOperationPage {
private backButtonFunc: Subscription;
projectEndDateModalOpen : boolean = false;
projecStartDateModalOpen : boolean = false;

dateChangeForTask: boolean = false;
headerConfig = {
showHeader: true,
showBurgerMenu: false,
Expand All @@ -59,6 +59,7 @@ export class ProjectOperationPage {
private networkService: NetworkService,
private toast: ToastService,
private projectServ: ProjectService,
private utils : UtilsService
) {
this.routerparam.params.subscribe(data => {
this.projectId = data.id;
Expand Down Expand Up @@ -336,7 +337,17 @@ export class ProjectOperationPage {
if (this.button == 'FRMELEMNTS_LBL_VIEW_PROJECT') {
this.newProjectCreate();
} else {
this.update();
let showPopup;
if(this.template.tasks && this.template.tasks.length){
showPopup = this.utils.checkDateofTask(this.template);
if(showPopup){
this.showConfirmationPopup();
}else{
this.update();
}
} else{
this.update();
}
}
}

Expand All @@ -357,4 +368,59 @@ export class ProjectOperationPage {
setStartDate(isOpen: boolean) {
this.projecStartDateModalOpen = isOpen;
}
async showConfirmationPopup() {
let text;
this.translate
.get([
'FRMELEMNTS_LBL_PROJECT_END_DATE',
'FRMELEMNTS_LBL_PROJECT_START_DATE',
'FRMELEMNTS_MSG_PROJECT_END_DATE',
'YES',
'NO',
])
.subscribe((data) => {
text = data;
});
this.viewProjectAlert = await this.alertController.create({
cssClass: 'dark-background central-alert',
header: this.template.startDate && !this.template.endDate ? text['FRMELEMNTS_LBL_PROJECT_START_DATE'] : text['FRMELEMNTS_LBL_PROJECT_END_DATE'],
subHeader: text['FRMELEMNTS_MSG_PROJECT_END_DATE'],
backdropDismiss: false,
buttons: [
{
text: text['NO'],
cssClass: 'secondary',
handler: (blah) => {

}
},
{
text: text['YES'],
cssClass: 'secondary',
handler: (blah) => {
this.dateMapping();
}
}
]
});
await this.viewProjectAlert.present();
}
dateMapping() {
let taskCount = 0;
this.template.tasks.forEach(task => {
taskCount++;
if (task.endDate && ( this.template.startDate && task.endDate < this.template.startDate || this.template.endDate && task.endDate > this.template.endDate)) {
if(!this.template.endDate && this.template.startDate && task.endDate < this.template.startDate){
task.endDate = this.template.startDate;
}else if(!this.template.startDate && this.template.endDate && task.endDate < this.template.endDate){
task.endDate = this.template.endDate;
}else if(this.template.startDate && this.template.endDate &&( task.endDate < this.template.startDate || task.endDate > this.template.endDate)){
task.endDate = this.template.endDate;
}
}
});
if (this.template.tasks.length === taskCount) {
this.update();
}
}
}
2 changes: 1 addition & 1 deletion src/app/manage-learn/project/task-view/task-view.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h4 *ngIf="editField != 'name'">{{task?.name}}</h4>
<ion-popover [isOpen]="taskDateModalOpen" (ionPopoverWillDismiss)="setOpen(false)">
<ng-template>
<ion-datetime presentation="date" id="taskEndDate" #dateTime value="{{task?.endDate}}" display-timezone="utc"
min="{{currentYear - 2}}" max="{{currentYear + 5}}" display-timezone="utc" [(ngModel)]="task.endDate" (ngModelChange)="setOpen(false,'update')">
min="{{project?.startDate ? project?.startDate : currentYear - 2 }}" max="{{project?.endDate ? project?.endDate : currentYear + 5}}" display-timezone="utc" [(ngModel)]="task.endDate" (ngModelChange)="setOpen(false,'update')">
</ion-datetime>
</ng-template>
</ion-popover>
Expand Down
5 changes: 4 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1404,5 +1404,8 @@
"FRMELEMNTS_MSG_NOT_LOGGEDIN_USER":"Please login with HT & Officials to access this content",
"FRMELEMENTS_MSG_YOU_MUST_LOGIN_TO_ACCESS":"You must login to access {{%s}}",
"FRMELEMENTS_MSG_ONLY_REGISTERED_USERS_CAN_ACCESS": "Only registered users can take {{%s}}",
"FRMELEMNTS_LBL_TASKS_COMPLETED": "tasks completed"
"FRMELEMNTS_LBL_TASKS_COMPLETED": "tasks completed",
"FRMELEMNTS_LBL_PROJECT_END_DATE":"Project end date",
"FRMELEMNTS_LBL_PROJECT_START_DATE":"Project start date",
"FRMELEMNTS_MSG_PROJECT_END_DATE":"Are you sure? Task end date will also be changed to this if it is later"
}