Skip to content

Commit

Permalink
Reset Data
Browse files Browse the repository at this point in the history
  • Loading branch information
vikas.m committed Feb 18, 2024
1 parent 31041e2 commit 57966eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/surveys/list-surveys/list-surveys.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="header">
<div class="header" (click)="resetData()">
<h1>Survey</h1>
</div>
<div class="survey-container">
Expand Down
24 changes: 24 additions & 0 deletions src/app/surveys/list-surveys/list-surveys.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Survey } from 'src/app/model/survey';
import { ConfirmationDialogComponent } from 'src/app/shared/confirmation-dialog/confirmation-dialog.component';
import { SurveyFormComponent } from '../survey-form/survey-form.component';
import { SurveyService } from '../survey.service';

Expand All @@ -23,4 +24,27 @@ export class ListSurveysComponent implements OnInit {
openSurveyForm() {
const dialogRef = this._dialog.open(SurveyFormComponent);
}

count = 0;
resetData() {
this.count++;
if (this.count == 3) {
const dialogRef = this._dialog.open(ConfirmationDialogComponent, {
data: {
title: 'Reset Data',
body: 'All the Surevy and their responses will be Reset.',
highlight: 'Are you sure ?',
secondaryActionText: 'No, Cancel',
primaryActionText: 'Yes, Reset Data',
primaryColor: 'warn',
},
});
dialogRef.afterClosed().subscribe((isReset) => {
if (isReset) {
this.service.resetData();
}
});
this.count = 0;
}
}
}
5 changes: 5 additions & 0 deletions src/app/surveys/survey.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@ export class SurveyService {

return false;
}

resetData() {
localStorage.clear();
window.location.reload();
}
}

0 comments on commit 57966eb

Please sign in to comment.