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
ISSUE #ED-3837, ED-3824 fix : OCI issue fix, sync loader and evidence…
… listing
  • Loading branch information
Vishwanath committed Mar 25, 2024
commit c2b52bc1ddb19bc7a0dfe1c5dc33e6ce73340974
91 changes: 55 additions & 36 deletions src/app/manage-learn/project/add-file/add-file.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class AddFilePage implements OnInit {
this.description = params.taskId ? actions.TASK_FILE_DESCRIPTION.label : actions.PROJECT_FILE_DESCRIPTION.label;
this.taskId = params.taskId;
})
this.updateRemarks = _.debounce(this.updateRemarks,1500)
this.updateRemarks = _.debounce(this.updateRemarks,1500);
}

ngOnInit() { }
Expand All @@ -76,7 +76,14 @@ export class AddFilePage implements OnInit {
}

handleHeaderEvents($event) {
this.location.back()
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()
}
}
}
getProject() {
this.db.query({ _id: this.projectId }).then(
Expand Down Expand Up @@ -104,7 +111,6 @@ export class AddFilePage implements OnInit {
} else {
this.project.remarks = this.remarks
}
this.update('save')
}

setHeaderConfig() {
Expand Down Expand Up @@ -159,24 +165,20 @@ export class AddFilePage implements OnInit {

delete(index) {
this.attachments.splice(index, 1);
this.update('save');
this.taskId ? this.task.isEdit = true :'';
this.task.isEdit = true;
this.update('delete');
}

async onAction(event) {
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(async(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((data: any) => {
if (data.isClicked) {
if(data.isChecked){
if (event == 'openLink') {
this.toggleLinkModal();
return;
}
await this.attachmentService.openAttachmentSource(event, this.attachments);
setTimeout(() => {
this.update('save')
}, 1000);

this.attachmentService.openAttachmentSource(event, this.attachments);
}else{
this.toast.showMessage('FRMELEMNTS_MSG_EVIDENCES_CONTENT_POLICY_REJECT', 'danger');
}
Expand All @@ -187,10 +189,7 @@ export class AddFilePage implements OnInit {
this.toggleLinkModal();
return;
}
await this.attachmentService.openAttachmentSource(event, this.attachments);
setTimeout(() => {
this.update('save')
}, 1000);
this.attachmentService.openAttachmentSource(event, this.attachments);
}
}

Expand All @@ -199,11 +198,13 @@ export class AddFilePage implements OnInit {
if (this.taskId) {
this.task.attachments = this.attachments;
this.task.remarks = this.remarks;
this.location.back();
if (JSON.stringify(this.projectCopy.tasks[this.taskIndex]) !== JSON.stringify(this.task)) {
this.task.isEdit = true;
this.project.isEdit = true;
this.taskId ? this.update(): this.update('submit');
this.toast.showMessage('FRMELEMNTS_LBL_FILES_ATTACHED', 'success')
} else {
this.location.back();
}
} else {
if (this.network.isNetworkAvailable) {
Expand All @@ -218,14 +219,11 @@ export class AddFilePage implements OnInit {
if (event) {
this.attachments = this.attachments.concat(this.projectService.getLinks(event));
if (this.taskId) {
this.task.isEdit = true;
this.task.attachments = this.task?.attachments.concat(this.projectService.getLinks(event));
} else {
this.project.isEdit = true;
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 @@ -235,23 +233,16 @@ export class AddFilePage implements OnInit {
}

update(type?) {
if (this.taskId) {
this.task.attachments = this.attachments;
this.task.remarks = this.remarks;
if (JSON.stringify(this.projectCopy.tasks[this.taskIndex]) !== JSON.stringify(this.task)) {
this.task.isEdit = true;
this.project.isEdit = true;
this.toast.showMessage('FRMELEMNTS_LBL_FILES_ATTACHED', 'success')
}
}
this.project.isEdit = true;
this.db
.update(this.project)
.then((success) => {
this.project._rev = success.rev;
this.projectCopy = JSON.parse(JSON.stringify(this.project));
if(type !== 'save'){
this.location.back()
if (type == 'submit') {
this.attachments = [];
this.doSyncAction(type === 'submit');
}else{
this.location.back();
}
})
}
Expand All @@ -265,6 +256,35 @@ export class AddFilePage implements OnInit {
}
}

async pageExitConfirm() {
let data;
this.translate.get(["FRMELEMNTS_MSG_ATTACHMENT_PAGE_EXIT_CONFIRM", "FRMELEMNTS_BTN_EXIT_PAGE", "FRMELEMNTS_BTN_YES_PAGE", "FRMELEMNTS_LBL_YES", "NO"]).subscribe((text) => {
data = text;
});
const alert = await this.alert.create({
cssClass: 'central-alert',
header: data['FRMELEMNTS_BTN_EXIT_PAGE'],
message: data['FRMELEMNTS_MSG_ATTACHMENT_PAGE_EXIT_CONFIRM'],
buttons: [
{
text: this.taskId ? data["FRMELEMNTS_BTN_YES_PAGE"] : data["FRMELEMNTS_LBL_YES"],
handler: () => { },
}, {
text: data["NO"],
role: "cancel",
cssClass: "secondary",
handler: (blah) => {
},
},
],
});
await alert.present();
let resp = await alert.onDidDismiss();
if (resp.role !== 'cancel') {
this.location.back();
}
}

async submitProjectConfirmation() {
let data;
this.translate.get(["FRMELEMNTS_MSG_SUBMIT_PROJECT", "FRMELEMNTS_LBL_SUBMIT_IMPROVEMENT", "CANCEL", "FRMELEMNTS_BTN_SUBMIT"]).subscribe((text) => {
Expand Down Expand Up @@ -296,10 +316,9 @@ export class AddFilePage implements OnInit {
setTimeout(() => {
this.project.attachments = this.attachments;
this.project.remarks = this.remarks;
this.project.status = statusType.submitted;
this.attachments = [];
this.update();
this.doSyncAction(true);
// this.project.status = statusType.submitted;
this.update('submit');
}, 0)
this.location.back()
}
}