Skip to content

Commit

Permalink
Merge pull request #509 from rahulramakrishnan3/release-3.0.0
Browse files Browse the repository at this point in the history
Release 3.0.0
  • Loading branch information
Cafnanc authored Jul 2, 2024
2 parents 9276dfa + a0f7360 commit 7b02406
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/app/core/services/form/form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export class FormService {
allow_custom_entities: entity.allow_custom_entities,
allow_filtering: entity.allow_filtering
};
formData.validators = {
...formData.validators,
required: entity.required
}
}
});
return formData
Expand Down
21 changes: 21 additions & 0 deletions src/app/core/services/util/util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,26 @@ export class UtilService {
snakeToNormal(text: string): string {
return text.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
}

async profileUpdatePopup(msg){
let texts;
this.translate.get([msg.header, msg.message, msg.cancel]).subscribe(text => {
texts = text;
})
const alert = await this.alert.create({
cssClass: 'my-custom-class',
header: texts[msg.header],
message: texts[msg.message],
buttons: [
{
text: texts[msg.cancel],
role: 'cancel',
cssClass: 'alert-button-red'
},
],
backdropDismiss: false
});
await alert.present();
}

}
4 changes: 2 additions & 2 deletions src/app/modules/private/private.page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ion-split-pane contentId="main-content">
<ion-menu contentId="main-content" menuId="side-menu" type="overlay" swipeGesture="false" class="width-20">
<ion-header [translucent]="true" class="ion-no-border">
<ion-header [translucent]="true" class="ion-no-border" [ngClass]="{'disable-div': user?.profile_mandatory_fields.length}">
<div *ngIf="user" >
<div class="sub-menu-toolbar">
<div slot="start" class="img-mainDiv">
Expand All @@ -23,7 +23,7 @@
</div>
</div>
</ion-header>
<ion-content *ngIf="user" fullscreen>
<ion-content *ngIf="user" fullscreen [ngClass]="{'disable-div': user?.profile_mandatory_fields.length}">
<div class="menu-css">
<ion-list lines="none" class="sub-menu-list">
<ion-menu-toggle auto-hide="false" [class]="adminPage?.class" *ngIf="adminAccess">
Expand Down
5 changes: 5 additions & 0 deletions src/app/modules/private/private.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@
}
.user-role-labels{
padding-top: 3%;
}
.disable-div{
pointer-events: none; /* Disable all pointer events (clicks, hovers, etc.) */
opacity: 0.5; /* Make the header appear grayed out */
background-color: lightgray;
}
3 changes: 3 additions & 0 deletions src/app/modules/private/private.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ getUser() {
this.profile.profileDetails(false).then(profileDetails => {
this.adminAccess = profileDetails.permissions ? this.permissionService.hasAdminAcess(this.actionsArrays,profileDetails?.permissions) : false;
this.user = profileDetails;
if (profileDetails.profile_mandatory_fields && profileDetails.profile_mandatory_fields.length > 0 || !profileDetails.about) {
this.router.navigate([`/${CommonRoutes.EDIT_PROFILE}`], { replaceUrl: true });
}
this.isMentor = this.profile.isMentor;
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/edit-profile/edit-profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

<ion-footer class="ion-no-border footer-button" submitButton>
<ion-toolbar>
<ion-button expand="full" (click)="onSubmit()">{{'SUBMIT' | translate}}</ion-button>
<ion-button [disabled]="form1 && !form1.myForm.valid" expand="full" (click)="onSubmit()">{{'SUBMIT' | translate}}</ion-button>
</ion-toolbar>
</ion-footer>
43 changes: 34 additions & 9 deletions src/app/pages/edit-profile/edit-profile.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ import {
LoaderService,
LocalStorageService,
ToastService,
UtilService,
} from 'src/app/core/services';
import { localKeys } from 'src/app/core/constants/localStorage.keys';
import { urlConstants } from 'src/app/core/constants/urlConstants';
import { AlertController, Platform } from '@ionic/angular';
import { isDeactivatable } from 'src/app/core/guards/canDeactive/deactive.guard';
import { TranslateService } from '@ngx-translate/core';
import { map } from 'rxjs/operators';
import { Router } from '@angular/router';
import { CommonRoutes } from 'src/global.routes';

@Component({
selector: 'app-edit-profile',
Expand All @@ -34,10 +37,8 @@ export class EditProfilePage implements OnInit, isDeactivatable {
type: 'profile',
};
public headerConfig: any = {
// menu: true,
backButton: {
label: 'PROFILE_DETAILS',
},
backButton: true,
label: 'PROFILE_DETAILS',
notification: false,
};
path;
Expand All @@ -57,23 +58,37 @@ export class EditProfilePage implements OnInit, isDeactivatable {
private loaderService: LoaderService,
private alert: AlertController,
private translate: TranslateService,
private toast: ToastService
private toast: ToastService,
private utilService: UtilService,
private router: Router
) {
}
async ngOnInit() {
this.userDetails = await this.localStorage.getLocalData(localKeys.USER_DETAILS);
const response = await this.form.getForm(EDIT_PROFILE_FORM);
this.profileImageData.isUploaded = true;
this.formData = _.get(response, 'data.fields');
this.entityNames = await this.form.getEntityNames(this.formData)
this.entityList = await this.form.getEntities(this.entityNames, 'PROFILE')
const entityNames = await this.form.getEntityNames(this.formData);
this.entityNames = await this.updateEntityArray(this.userDetails?.profile_mandatory_fields, entityNames);
this.entityList = await this.form.getEntities(this.entityNames, 'PROFILE');
this.formData = await this.form.populateEntity(this.formData, this.entityList)
this.changeDetRef.detectChanges();
this.userDetails = await this.localStorage.getLocalData(localKeys.USER_DETAILS);
if (this.userDetails) {
this.profileImageData.image = this.userDetails.image;
this.profileService.prefillData(this.userDetails, this.entityNames, this.formData);
this.showForm = true;
}
if(this.userDetails?.profile_mandatory_fields?.length){
this.headerConfig.backButton = false;
let msg = {
header: 'SETUP_PROFILE',
message: 'SETUP_PROFILE_MESSAGE',
cancel: "CONTINUE"
}
this.utilService.profileUpdatePopup(msg)
}else{
this.headerConfig.backButton = true;
}
}

async canPageLeave() {
Expand Down Expand Up @@ -125,7 +140,8 @@ export class EditProfilePage implements OnInit, isDeactivatable {
form[entityKey] = control.multiple ? _.map(form[entityKey], 'value') : form[entityKey]
});
this.form1.myForm.markAsPristine();
this.profileService.profileUpdate(form);
const updated = this.profileService.profileUpdate(form);
if(updated){ this.router.navigate([`${CommonRoutes.TABS}/${CommonRoutes.HOME}`], { replaceUrl: true })}
}
} else {
this.toast.showToast('Please fill all the mandatory fields', 'danger');
Expand Down Expand Up @@ -168,4 +184,13 @@ export class EditProfilePage implements OnInit, isDeactivatable {
let data: any = await this.api.get(config);
return this.upload(file, data.result).subscribe()
}

updateEntityArray(arr1: string[], arr2: string[]) {
arr1.forEach(value => {
if (!arr2.includes(value)) {
arr2.push(value);
}
});
return arr2
}
}
4 changes: 3 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,7 @@
"NO_SESSIONS_AVAILABLE":"No sessions available",
"SESSSION_SEARCH_RESULT": "Session search result for",
"SEARCH_RESULT": "Search results found",
"MENTOR_SEARCH_RESULT": "Mentors search result for"
"MENTOR_SEARCH_RESULT": "Mentors search result for",
"SETUP_PROFILE": "Setup profile",
"SETUP_PROFILE_MESSAGE": "Finish setting up your profile to get started"
}

0 comments on commit 7b02406

Please sign in to comment.