diff --git a/src/app/manage-learn/core/services/utils.service.ts b/src/app/manage-learn/core/services/utils.service.ts index 60fdf3b023..de4042bb99 100644 --- a/src/app/manage-learn/core/services/utils.service.ts +++ b/src/app/manage-learn/core/services/utils.service.ts @@ -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)) + } } \ No newline at end of file diff --git a/src/app/manage-learn/project/add-file/add-file.page.html b/src/app/manage-learn/project/add-file/add-file.page.html index e12909ee23..f6202afb4f 100644 --- a/src/app/manage-learn/project/add-file/add-file.page.html +++ b/src/app/manage-learn/project/add-file/add-file.page.html @@ -20,9 +20,14 @@
{{ description | translate }}
+ + + + + {{attachment?.name || attachment?.url}}
diff --git a/src/app/manage-learn/project/add-file/add-file.page.scss b/src/app/manage-learn/project/add-file/add-file.page.scss index 893cdd26af..d13a65f4d7 100644 --- a/src/app/manage-learn/project/add-file/add-file.page.scss +++ b/src/app/manage-learn/project/add-file/add-file.page.scss @@ -47,6 +47,12 @@ font-size: 1.25rem; color: $black-color !important; } + + .alert-icon{ + color: $white-color !important; + background-color: red; + border-radius: 50%; + } } .text-transform-none { text-transform: none !important; diff --git a/src/app/manage-learn/project/add-file/add-file.page.ts b/src/app/manage-learn/project/add-file/add-file.page.ts index efeac2c896..f9ccd8e30b 100644 --- a/src/app/manage-learn/project/add-file/add-file.page.ts +++ b/src/app/manage-learn/project/add-file/add-file.page.ts @@ -250,16 +250,13 @@ export class AddFilePage implements OnInit { .then((success) => { this.project._rev = success.rev; this.projectCopy = JSON.parse(JSON.stringify(this.project)); - if(type !== 'save'){ - this.location.back() - } }) } doSyncAction(isSubmission:boolean = false) { if (this.network.isNetworkAvailable) { this.project.isNew ? this.projectServ.createNewProject(this.project) - : this.router.navigate([`${RouterLinks.PROJECT}/${RouterLinks.SYNC}`], { queryParams: { projectId: this.projectId,isSubmission: isSubmission } }); + : this.router.navigate([`${RouterLinks.PROJECT}/${RouterLinks.SYNC}`], { queryParams: { projectId: this.projectId,isSubmission: isSubmission },replaceUrl:true }); } else { this.toast.showMessage('FRMELEMNTS_MSG_PLEASE_GO_ONLINE', 'danger'); } @@ -296,7 +293,6 @@ 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); diff --git a/src/app/manage-learn/project/project-operation/project-operation.page.ts b/src/app/manage-learn/project/project-operation/project-operation.page.ts index 2ef8d93bac..89536af9d5 100644 --- a/src/app/manage-learn/project/project-operation/project-operation.page.ts +++ b/src/app/manage-learn/project/project-operation/project-operation.page.ts @@ -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'; @@ -39,7 +39,7 @@ export class ProjectOperationPage { private backButtonFunc: Subscription; projectEndDateModalOpen : boolean = false; projecStartDateModalOpen : boolean = false; - + dateChangeForTask: boolean = false; headerConfig = { showHeader: true, showBurgerMenu: false, @@ -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; @@ -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(); + } } } @@ -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(); + } + } } diff --git a/src/app/manage-learn/project/sync/sync.page.html b/src/app/manage-learn/project/sync/sync.page.html index 668bac71fc..59c00cb82a 100644 --- a/src/app/manage-learn/project/sync/sync.page.html +++ b/src/app/manage-learn/project/sync/sync.page.html @@ -1,6 +1,6 @@
- + {{"FRMELEMNTS_LBL_SYNCING_PROJECT" | translate}} @@ -22,6 +22,18 @@ + + + + {{"FRMELEMNTS_LBL_FILE_UPLOAD_ERROR" | translate}} +
{{"FRMELEMNTS_MSG_FILE_UPLOAD_ERROR_MSG" | translate}}
+
+ + {{"VIEW" | translate}} + +
+
+
\ No newline at end of file diff --git a/src/app/manage-learn/project/sync/sync.page.scss b/src/app/manage-learn/project/sync/sync.page.scss index 6abeb6e16c..a7987a539e 100644 --- a/src/app/manage-learn/project/sync/sync.page.scss +++ b/src/app/manage-learn/project/sync/sync.page.scss @@ -22,4 +22,14 @@ } .flexBox { display: flex; +} + +.view-button{ + width: 6rem; + margin-top: 15px; +} + +.error-heading{ + font-weight: 700; + margin-bottom: 15px; } \ No newline at end of file diff --git a/src/app/manage-learn/project/sync/sync.page.ts b/src/app/manage-learn/project/sync/sync.page.ts index a3bc62f261..e021a14888 100644 --- a/src/app/manage-learn/project/sync/sync.page.ts +++ b/src/app/manage-learn/project/sync/sync.page.ts @@ -1,6 +1,6 @@ import { Location } from '@angular/common'; import { Component, OnDestroy } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import * as _ from 'underscore'; import { TranslateService } from '@ngx-translate/core'; import { SyncService } from '../../core/services/sync.service'; @@ -9,6 +9,7 @@ import { statusType, ToastService } from '../../core'; import { DbService } from '../../core/services/db.service'; import { urlConstants } from '../../core/constants/urlConstants'; import { SharingFeatureService } from '../../core/services/sharing-feature.service'; +import { RouterLinks } from '../../../../app/app.constant'; var environment = { db: { @@ -39,6 +40,8 @@ export class SyncPage implements OnDestroy { syncCompletedProjects = []; isSubmission; retryCount: number = 0; + cloudUploadFailed= false + fileUploadCount = 0; constructor( private routerparam: ActivatedRoute, @@ -48,7 +51,7 @@ export class SyncPage implements OnDestroy { private translate: TranslateService, private db: DbService, private network: NetworkService, - private share: SharingFeatureService) { + private share: SharingFeatureService, private router: Router) { this.db.createPouchDB(environment.db.projects); this.translate .get([ @@ -235,6 +238,7 @@ export class SyncPage implements OnDestroy { for (let i = 0; i < this.attachments.length; i++) { this.attachments[i].uploadUrl = imageInfo[i].url; this.attachments[i].cloudStorage = imageInfo[i].cloudStorage; + this.attachments[i].url = imageInfo[i].url.split('?')[0] for (const key of Object.keys(imageInfo[i].payload)) { this.attachments[i][key] = imageInfo[i].payload[key]; } @@ -246,6 +250,7 @@ export class SyncPage implements OnDestroy { resetImageUploadVariables() { this.imageUploadIndex = 0; this.attachments = []; + this.fileUploadCount = 0; } cloudUpload(imageDetails) { @@ -254,19 +259,32 @@ export class SyncPage implements OnDestroy { delete this.attachments[this.imageUploadIndex].cloudStorage; delete this.attachments[this.imageUploadIndex].uploadUrl; delete this.attachments[this.imageUploadIndex].isUploaded; + delete this.attachments[this.imageUploadIndex].uploadFailed if (this.imageUploadIndex + 1 < this.attachments.length) { this.imageUploadIndex++; + this.fileUploadCount++ this.cloudUpload(this.attachments[this.imageUploadIndex]) } else { - this.doSyncCall(); + if(this.imageUploadIndex == this.fileUploadCount){ + this.doSyncCall() + }else{ + this.cloudUploadFailed = true + this.updateDataToDb() + } } }).catch(error => { this.retryCount++; if (this.retryCount > 3) { - this.translate.get('FRMELEMNTS_MSG_EVIDENCE_UPLOAD_FAILED').subscribe((translations) => { - this.toast.showMessage(translations,'danger'); - }); - this.location.back(); + this.attachments[this.imageUploadIndex]['uploadFailed'] = true + delete this.attachments[this.imageUploadIndex].sourcePath + this.attachments[this.imageUploadIndex].url = '' + if(this.imageUploadIndex + 1 < this.attachments.length){ + this.imageUploadIndex++ + this.cloudUpload(this.attachments[this.imageUploadIndex]) + }else{ + this.cloudUploadFailed = true + this.updateDataToDb() + } } else { this.cloudUpload(this.attachments[this.imageUploadIndex]); } @@ -283,4 +301,14 @@ export class SyncPage implements OnDestroy { }; this.share.getFileUrl(config, fileName); } -} + + updateDataToDb(){ + this.db.update(this.allProjects[this.syncIndex]).then(success => { + this.resetImageUploadVariables() + }) + } + + goToAttachmentsList(){ + this.router.navigate([`${RouterLinks.ATTACHMENTS_LIST}`, this.projectId],{ replaceUrl:true }) + } +} \ No newline at end of file diff --git a/src/app/manage-learn/project/task-view/task-view.page.html b/src/app/manage-learn/project/task-view/task-view.page.html index 408e417ba0..728f27fdd2 100644 --- a/src/app/manage-learn/project/task-view/task-view.page.html +++ b/src/app/manage-learn/project/task-view/task-view.page.html @@ -14,7 +14,7 @@

{{task?.name}}

+ min="{{project?.startDate ? project?.startDate : currentYear - 2 }}" max="{{project?.endDate ? project?.endDate : currentYear + 5}}" display-timezone="utc" [(ngModel)]="task.endDate" (ngModelChange)="setOpen(false,'update')"> diff --git a/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.html b/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.html index f3b4212d1d..5db962a573 100644 --- a/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.html +++ b/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.html @@ -9,13 +9,19 @@ +
+ +
-
- -
+
+
+ +
{{ "FRMELEMNTS_LBL_FILE_CORRUPTED" | translate }}
+
+
diff --git a/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.scss b/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.scss index 24541840e8..0c049d081c 100644 --- a/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.scss +++ b/src/app/manage-learn/shared/components/attachment-card/attachment-card.component.scss @@ -33,11 +33,32 @@ img{ .close-icon{ font-size: 1.25rem; - float: right; - margin: 5px; + margin: 10px 5px 0px 0px; color: black; - margin-right: -10px; } .img-wrapper{ margin-top: 4px; + } + + .error-overlay{ + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + color: $white-color; + background-color: rgba(0,0,0,0.5); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + font-size: 12px; + } + + .alert-icon{ + font-size: 16px; + background-color: red; + border-radius: 50%; + margin-bottom: 5px; + } \ No newline at end of file diff --git a/src/app/manage-learn/shared/components/attachment-lists/attachment-lists.component.html b/src/app/manage-learn/shared/components/attachment-lists/attachment-lists.component.html index 394be869c3..1f5c4a54f1 100644 --- a/src/app/manage-learn/shared/components/attachment-lists/attachment-lists.component.html +++ b/src/app/manage-learn/shared/components/attachment-lists/attachment-lists.component.html @@ -6,10 +6,12 @@
- + - + {{attachment.name}}