Skip to content

Commit

Permalink
Issue #ED-1629 merge : Merge pull request #3512 from shikshalokam/rel…
Browse files Browse the repository at this point in the history
…ease-7.0.0

Issue #ED-1629 feat : Task end date restriction
  • Loading branch information
swayangjit authored Nov 30, 2023
2 parents 225abf2 + 30c7dc6 commit b5c7bfc
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 27 deletions.
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))
}
}
5 changes: 5 additions & 0 deletions src/app/manage-learn/project/add-file/add-file.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ <h5 class="page-header-content">{{ description | translate }}

<div *ngFor="let attachment of attachments; let i = index" class="attachments-list">
<div class="attachment-label" *ngIf="attachment?.type != 'link'">
<span *ngIf="!attachment?.uploadFailed; else showAlertIcon" class="m-0">
<ion-icon name="image" slot="start" *ngIf="attachment?.type == 'image/jpeg'"></ion-icon>
<ion-icon name="document" slot="start" *ngIf="attachment?.type == 'application/pdf'"></ion-icon>
<ion-icon name="videocam" slot="start" *ngIf="attachment?.type == 'video/mp4'"></ion-icon>
</span>
<ng-template #showAlertIcon>
<ion-icon name="alert" slot="start" *ngIf="attachment?.uploadFailed" class="alert-icon"></ion-icon>
</ng-template>
<span>{{attachment?.name || attachment?.url}} </span>
</div>
<div class="attachment-label" *ngIf="attachment?.type == 'link'">
Expand Down
6 changes: 6 additions & 0 deletions src/app/manage-learn/project/add-file/add-file.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions src/app/manage-learn/project/add-file/add-file.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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);
Expand Down
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();
}
}
}
14 changes: 13 additions & 1 deletion src/app/manage-learn/project/sync/sync.page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ion-content>
<div class="container">
<ion-card class="innerContainer">
<ion-card class="innerContainer" *ngIf="!cloudUploadFailed; else showError">
<ion-card-header>
<ion-card-title>{{"FRMELEMNTS_LBL_SYNCING_PROJECT" | translate}}</ion-card-title>
</ion-card-header>
Expand All @@ -22,6 +22,18 @@


</ion-card>

<ng-template #showError>
<ion-card class="innerContainer">
<ion-card-title class="error-heading">{{"FRMELEMNTS_LBL_FILE_UPLOAD_ERROR" | translate}}</ion-card-title>
<div>{{"FRMELEMNTS_MSG_FILE_UPLOAD_ERROR_MSG" | translate}}</div>
<div class="d-flex flex-jc-flex-end">
<ion-button class="custom-btn-txt-transform-none view-button" (click)="goToAttachmentsList()">
{{"VIEW" | translate}}
</ion-button>
</div>
</ion-card>
</ng-template>
</div>

</ion-content>
10 changes: 10 additions & 0 deletions src/app/manage-learn/project/sync/sync.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@
}
.flexBox {
display: flex;
}

.view-button{
width: 6rem;
margin-top: 15px;
}

.error-heading{
font-weight: 700;
margin-bottom: 15px;
}
44 changes: 36 additions & 8 deletions src/app/manage-learn/project/sync/sync.page.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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: {
Expand Down Expand Up @@ -39,6 +40,8 @@ export class SyncPage implements OnDestroy {
syncCompletedProjects = [];
isSubmission;
retryCount: number = 0;
cloudUploadFailed= false
fileUploadCount = 0;

constructor(
private routerparam: ActivatedRoute,
Expand All @@ -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([
Expand Down Expand Up @@ -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];
}
Expand All @@ -246,6 +250,7 @@ export class SyncPage implements OnDestroy {
resetImageUploadVariables() {
this.imageUploadIndex = 0;
this.attachments = [];
this.fileUploadCount = 0;
}

cloudUpload(imageDetails) {
Expand All @@ -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]);
}
Expand All @@ -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 })
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
</ion-col>
<ion-col size="6" class="img-wrapper" *ngFor="let attachment of data.attachments| slice:0:limit; let i=index;">
<ion-card>
<div class="d-flex flex-jc-flex-end">
<ion-icon class="close-icon" *ngIf="!viewOnly" name="close-circle" (click)="delete(attachment,i)"></ion-icon>
</div>
<ion-card-content>
<div >
<ion-icon class="close-icon" *ngIf="!viewOnly" name="close-circle" (click)="delete(attachment,i)"></ion-icon>
</div>
<div class="relative">
<img [src]="getImgContent(attachment?.localUrl)"
*ngIf="attachment.type.includes('image') && !attachment.url" alt=""/>
<img [src]="attachment?.url" *ngIf="attachment.type.includes('image') && attachment.url" alt=""/>
<div class="error-overlay" *ngIf="attachment?.uploadFailed">
<ion-icon name="alert" class="alert-icon"></ion-icon>
<div>{{ "FRMELEMNTS_LBL_FILE_CORRUPTED" | translate }}</div>
</div>
</div>
</ion-card-content>
</ion-card>
</ion-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Loading

0 comments on commit b5c7bfc

Please sign in to comment.