Skip to content

Commit

Permalink
Merge pull request #283 from syedameenabrar/release-3.0.1
Browse files Browse the repository at this point in the history
matrix report and save questioner while navigate back
  • Loading branch information
5Amogh authored Jan 30, 2025
2 parents 8b0e6e5 + 677cb8e commit a03dee3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 97 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
"authentication_frontend_library": "^1.0.2",
"chart.js": "^4.4.3",
"chartjs-plugin-datalabels": "^2.2.0",
"elevate-dynamic-form": "^0.0.13",
"elevate-dynamic-form": "^0.0.15",
"ionicons": "^7.0.0",
"jwt-decode": "^4.0.0",
"network-service": "^0.0.1",
"project-player": "^1.1.7",
"questionnaire-webcomponent": "^4.0.17",
"questionnaire-webcomponent": "^4.0.20",
"rxjs": "~7.8.0",
"swiper": "^11.1.1",
"tslib": "^2.6.3",
Expand Down
2 changes: 1 addition & 1 deletion src/app/observation/observation.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-buttons slot="start">
<ion-icon name="arrow-back-outline" (click)="canPageLeave($event)" class="back-button"></ion-icon>
<ion-icon name="arrow-back-outline" (click)="canPageLeave()" class="back-button"></ion-icon>
</ion-buttons>
</ion-toolbar>
</ion-header>
Expand Down
109 changes: 23 additions & 86 deletions src/app/observation/observation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ export class ObservationComponent implements isDeactivatable {
isDirty: boolean = false;
saveQuestioner: boolean = false;
showDetails = false;
isOnline:any;
isOnline: any;
onlineStatus: boolean = true;
hasSessionList: boolean = false;

constructor(private navCtrl: NavController, private profileService: ProfileService,
private utils: UtilService, private toast:ToastService,
private alertService: AlertService) {}
private utils: UtilService, private toast: ToastService,
private alertService: AlertService) { }

ionViewWillEnter(){
ionViewWillEnter() {
this.toast.dismissToast();
this.getOnlineStatus();
this.windowEventListner();
Expand All @@ -38,60 +39,10 @@ export class ObservationComponent implements isDeactivatable {
}
}

async canPageLeave(event?: any): Promise<boolean> {
if (this.alertService.alert) {
this.alertService.dismissAlert();
}
if (this.isDirty && !this.saveQuestioner) {
await this.alertService.presentAlert(
'SAVE_DATA',
'EXIT_CONFIRMATION_MSG',
[
{
text: "DON'T_SAVE",
cssClass: 'secondary-button',
role: 'exit',
handler: () => {
if (event) {
this.isDirty = false;
this.navCtrl.back();
}
return true;
}
},
{
text: 'SAVE',
cssClass: 'primary-button',
role: 'exit',
handler: () => {
this.saveQuestioner = true;
this.windowEventListnerConfirmation((confirmation:any) => {
if (confirmation) {
this.navCtrl.back();
}else{
this.windowEventListner();
}
});
return true;
}
}
]
);

let data = await this.alertService.alert.onDidDismiss();
if (data.role == 'exit') {
return true;
}
return false;
}
else {
if (event) {
this.navCtrl.back();
return false;
} else {
return true;
}
}
async canPageLeave(): Promise<boolean> {
this.isDirty = false;
this.navCtrl.back();
return true;
}

getProfileDetails() {
Expand All @@ -102,9 +53,9 @@ export class ObservationComponent implements isDeactivatable {
this.profileService.getProfileAndEntityConfigData().subscribe((mappedIds) => {
if (mappedIds) {
const mappedIdsString = JSON.stringify(mappedIds) || "";
localStorage.setItem("profileData", mappedIdsString);
let storedProfileData:any = localStorage.getItem('profileData');
this.apiConfig['profileData'] = JSON.parse(storedProfileData);;
localStorage.setItem("profileData", mappedIdsString);
let storedProfileData: any = localStorage.getItem('profileData');
this.apiConfig['profileData'] = JSON.parse(storedProfileData);;
this.apiConfig['baseURL'] = environment.surveyBaseURL ?? environment.baseURL;
this.apiConfig['userAuthToken'] = localStorage.getItem('accToken');
this.apiConfig['solutionType'] = "observation";
Expand All @@ -114,38 +65,24 @@ export class ObservationComponent implements isDeactivatable {
});
}

getOnlineStatus(){
getOnlineStatus() {
const onlineEvent = fromEvent(window, 'online').pipe(map(() => true));
const offlineEvent = fromEvent(window, 'offline').pipe(map(() => false));
merge(onlineEvent, offlineEvent).pipe(startWith(navigator.onLine)).subscribe((isOnline:any) => {
this.onlineStatus = isOnline;
if (!this.onlineStatus) {
this.showDetails = true;
}else{
this.getProfileDetails()
}
});
const offlineEvent = fromEvent(window, 'offline').pipe(map(() => false));
merge(onlineEvent, offlineEvent).pipe(startWith(navigator.onLine)).subscribe((isOnline: any) => {
this.onlineStatus = isOnline;
if (!this.onlineStatus) {
this.showDetails = true;
} else {
this.getProfileDetails()
}
});
}

windowEventListner(){
windowEventListner() {
window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'formDirty') {
this.isDirty = event.data.isDirty;
}

if (event.data && event.data.type === 'saveQuestionerToggle') {
this.saveQuestioner = event.data.toggle;
}
});
}

windowEventListnerConfirmation(callback:any) {
const handleMessage = (event:any) => {
if (event.data && event.data.type === 'saveQuestionerConfirmation') {
callback(event.data.confirmation);
window.removeEventListener('message', handleMessage);
}
};
window.addEventListener('message', handleMessage);
}
}

0 comments on commit a03dee3

Please sign in to comment.