Skip to content
Merged
Changes from all 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
35 changes: 21 additions & 14 deletions src/app/manage-learn/project/add-file/add-file.page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { AppHeaderService } from '../../../../services/app-header.service';
import { AlertController } from '@ionic/angular';
import { AlertController, Platform } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs';
import { AttachmentService, DbService, NetworkService, ProjectService, statusType, ToastService, UtilsService } from '../../core';
Expand All @@ -17,6 +17,7 @@ import { GenericPopUpService } from '../../shared/generic.popup';
styleUrls: ['./add-file.page.scss'],
})
export class AddFilePage implements OnInit {
private backButtonFunc: Subscription;
description: string;
parameters;
isLinkModalOpen: boolean = false;
Expand Down Expand Up @@ -55,6 +56,7 @@ export class AddFilePage implements OnInit {
private projectServ: ProjectService,
private toast: ToastService,
private popupService: GenericPopUpService,
private platform : Platform

) {
routerParams.params.subscribe(urlParams => {
Expand All @@ -73,18 +75,22 @@ export class AddFilePage implements OnInit {
this._appHeaderSubscription = this.headerService.headerEventEmitted$.subscribe(eventName => {
this.handleHeaderEvents(eventName);
});
this.handleBackButton();
}

handleHeaderEvents($event) {
if ($event.name == 'back') {
if (JSON.stringify(this.projectCopy) !== JSON.stringify(this.project) ||
JSON.stringify(this.projectCopy.tasks[this.taskIndex]) !== JSON.stringify(this.task)) {
this.pageExitConfirm();
} else {
this.location.back()
}
this.update('save');
this.location.back();
}
}
public handleBackButton() {
this.backButtonFunc = this.platform.backButton.subscribeWithPriority(10, () => {
this.location.back();
this.update('save');
this.backButtonFunc.unsubscribe();
});
}
getProject() {
this.db.query({ _id: this.projectId }).then(
(success) => {
Expand All @@ -111,6 +117,7 @@ export class AddFilePage implements OnInit {
} else {
this.project.remarks = this.remarks
}
this.update('save');
}

setHeaderConfig() {
Expand Down Expand Up @@ -169,16 +176,16 @@ export class AddFilePage implements OnInit {
this.update('delete');
}

onAction(event) {
async onAction(event) {
if(!this.taskId){
this.popupService.showPPPForProjectPopUp('FRMELEMNTS_LBL_EVIDENCES_CONTENT_POLICY', 'FRMELEMNTS_LBL_EVIDENCES_CONTENT_POLICY_TEXT', 'FRMELEMNTS_LBL_EVIDENCES_CONTENT_POLICY_LABEL', 'FRMELEMNTS_LBL_UPLOAD_EVIDENCES', 'https://diksha.gov.in/term-of-use.html', 'contentPolicy').then((data: any) => {
this.popupService.showPPPForProjectPopUp('FRMELEMNTS_LBL_EVIDENCES_CONTENT_POLICY', 'FRMELEMNTS_LBL_EVIDENCES_CONTENT_POLICY_TEXT', 'FRMELEMNTS_LBL_EVIDENCES_CONTENT_POLICY_LABEL', 'FRMELEMNTS_LBL_UPLOAD_EVIDENCES', 'https://diksha.gov.in/term-of-use.html', 'contentPolicy').then(async (data: any) => {
if (data.isClicked) {
if(data.isChecked){
if (event == 'openLink') {
this.toggleLinkModal();
return;
}
this.attachmentService.openAttachmentSource(event, this.attachments);
await this.attachmentService.openAttachmentSource(event, this.attachments);
}else{
this.toast.showMessage('FRMELEMNTS_MSG_EVIDENCES_CONTENT_POLICY_REJECT', 'danger');
}
Expand Down Expand Up @@ -224,6 +231,7 @@ export class AddFilePage implements OnInit {
this.project.attachments = this.project?.attachments.concat(this.projectService.getLinks(event));
}
this.toast.showMessage('FRMELEMNTS_MSG_SUCCESSFULLY_ATTACHED', 'success');
this.update('save')
  }
this.toggleLinkModal();
}
Expand All @@ -242,9 +250,9 @@ export class AddFilePage implements OnInit {
if (type == 'submit') {
this.attachments = [];
this.doSyncAction(type === 'submit');
}else{
this.location.back();
}
}else if(type !== 'save'){
this.location.back()
}
})
}
doSyncAction(isSubmission:boolean = false) {
Expand Down Expand Up @@ -322,6 +330,5 @@ export class AddFilePage implements OnInit {
this.doSyncAction(true);
// this.project.status = statusType.submitted;
}, 0)
this.location.back()
}
}